@abacus-ai/cli 2.2.4 → 2.2.5
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.mjs +91 -91
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -85535,7 +85535,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
85535
85535
|
`:`
|
|
85536
85536
|
`)+n,i=r+1,r=e.indexOf(`
|
|
85537
85537
|
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:QA,stderr:$A}=YA,ej=Symbol(`GENERATOR`),tj=Symbol(`STYLER`),nj=Symbol(`IS_EMPTY`),rj=[`ansi`,`ansi`,`ansi256`,`ansi16m`],ij=Object.create(null),aj=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=QA?QA.level:0;e.level=t.level===void 0?n:t.level},oj=e=>{let t=(...e)=>e.join(` `);return aj(t,e),Object.setPrototypeOf(t,sj.prototype),t};function sj(e){return oj(e)}Object.setPrototypeOf(sj.prototype,Function.prototype);for(let[e,t]of Object.entries(VA))ij[e]={get(){let n=dj(this,uj(t.open,t.close,this[tj]),this[nj]);return Object.defineProperty(this,e,{value:n}),n}};ij.visible={get(){let e=dj(this,this[tj],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const cj=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?VA[n].ansi16m(...r):t===`ansi256`?VA[n].ansi256(VA.rgbToAnsi256(...r)):VA[n].ansi(VA.rgbToAnsi(...r)):e===`hex`?cj(`rgb`,t,n,...VA.hexToRgb(...r)):VA[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){ij[e]={get(){let{level:t}=this;return function(...n){let r=uj(cj(e,rj[t],`color`,...n),VA.color.close,this[tj]);return dj(this,r,this[nj])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);ij[t]={get(){let{level:t}=this;return function(...n){let r=uj(cj(e,rj[t],`bgColor`,...n),VA.bgColor.close,this[tj]);return dj(this,r,this[nj])}}}}const lj=Object.defineProperties(()=>{},{...ij,level:{enumerable:!0,get(){return this[ej].level},set(e){this[ej].level=e}}}),uj=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},dj=(e,t,n)=>{let r=(...e)=>fj(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,lj),r[ej]=e,r[tj]=t,r[nj]=n,r},fj=(e,t)=>{if(e.level<=0||!t)return e[nj]?``:t;let n=e[tj];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=XA(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
85538
|
-
`);return a!==-1&&(t=ZA(t,i,r,a)),r+t+i};Object.defineProperties(sj.prototype,ij);const pj=sj();sj({level:$A?$A.level:0});var mj=H(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.2.
|
|
85538
|
+
`);return a!==-1&&(t=ZA(t,i,r,a)),r+t+i};Object.defineProperties(sj.prototype,ij);const pj=sj();sj({level:$A?$A.level:0});var mj=H(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.2.5`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/product":`workspace:*`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`^10.42.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`^1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,chalk:`^5.6.2`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),hj=Oe(mj(),1);let gj=null;function _j(e){let t=(0,mA.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function vj(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function yj(){let e=`${Le.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=x(n)}catch{}let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function bj(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let t=process.argv[1]??``;return t.includes(`yarn`)?`yarn`:t.includes(`pnpm`)?`pnpm`:t.includes(`bun`)?`bun`:`npm`}async function xj(e){let t=Date.now();if(gj&&t-gj.timestamp<6e4)return gj.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return gj={tags:r,timestamp:t},r}async function Sj(e){let t=_j(e),n=bj(),r=vj(),i=(await xj(Re.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}function Cj(){return`${Le.binName} upgrade`}function wj(e){let t=`${Re.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function Tj(e){try{return d(wj(e),{stdio:`pipe`}),!0}catch{return!1}}function Ej(e,t){let n=wj(e).split(` `),r=n[0],i=n.slice(1);return new Promise(e=>{let n=f(r,i,{stdio:[`ignore`,`pipe`,`pipe`],shell:!1,env:{...process.env}}),a=[],o=e=>{let n=e.toString(`utf-8`);for(let e of n.split(`
|
|
85539
85539
|
`)){let n=e.trim();n&&(a.push(n),t(n))}};n.stdout?.on(`data`,o),n.stderr?.on(`data`,o);let s=null;n.on(`error`,t=>{e({ok:!1,output:t.message})}),n.on(`exit`,e=>{s=e}),n.on(`close`,()=>{e({ok:s===0,output:a.join(`
|
|
85540
85540
|
`)})})})}function Dj(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function Oj(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
85541
85541
|
`),process.exit(1)),t?Dj(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const kj=T.join(i(),Le.configDirName,Le.logsDirName),Aj=T.join(kj,`cli.log`);let jj=!1;function Mj(){if(!jj)try{v(kj)||y(kj,{recursive:!0}),jj=!0}catch{}}function Nj(e){return e.length===0?``:` `+e.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function Pj(e,t,n){Mj();let r=`[${new Date().toISOString()}] [${e}] ${t instanceof Error?`${t.message}${t.stack?`
|
|
@@ -85738,19 +85738,8 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
|
|
|
85738
85738
|
`),displayLineCount:i.length,totalLines:n,hasMore:n>r}},[e,r]),d=(0,X.useMemo)(()=>{if(!s)return s;let n=t?yJ(t):void 0;if(n===`mermaid`){let t=bJ(e);if(t!==null)return t}if(n&&(0,FU.supportsLanguage)(n))try{return(0,FU.highlight)(s,{language:n,theme:o})}catch{}return s},[s,t,e,o]);if(!s)return null;let f=(n+c-1).toString().length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[d.split(`
|
|
85739
85739
|
`).map((e,t)=>{let r=n+t;return(0,Y.jsxs)(Q,{dimColor:i,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[String(r).padStart(f,` `),` │ `]}),e]},t)}),l&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` ... `,c-u,` more lines`]})]})}function SJ(e,t,n){let r=yJ(t);if(r&&r!==`mermaid`&&(0,FU.supportsLanguage)(r))try{return(0,FU.highlight)(e,{language:r,...n?{theme:n}:{}}).split(`
|
|
85740
85740
|
`)}catch{}return e.split(`
|
|
85741
|
-
`)}function CJ(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>CJ(e));let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());t[e]=CJ(r)}return t}function wJ(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function TJ(e){if(typeof e!=`string`)return e;let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`y`].includes(t)?!0:[`false`,`0`,`no`,`n`].includes(t)?!1:e}const EJ=Jc(wJ,Ws()),DJ=Jc(wJ,Ws().optional()),OJ=Jc(TJ,Js()),kJ=Jc(TJ,Js().optional()),AJ=q({questions:sc(q({question:K(),header:K(),options:sc(q({label:K(),description:K()})),multiSelect:OJ})),answers:yc(K(),K()).optional()}),jJ={displayName:`AskUserQuestion`,getHeaderParams(e){return``},renderUI(e,t,n){let r=AJ.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.questions||[],o=n?.data.answers??i.answers??{};if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=Object.keys(o).length>0;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:e?`success`:`rejected`}),(0,Y.jsx)(_J,{color:e?`green`:`yellow`,children:e?`User answered ${Object.keys(o).length} question${Object.keys(o).length===1?``:`s`}`:n?.userNote?(0,Y.jsxs)(Y.Fragment,{children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):`User cancelled the questions`})]})}if(t===`pending`||t===`executing`)return(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`pending`,showSpinner:!0});let s=a.length,c=Object.keys(o).length;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`success`}),(0,Y.jsxs)(_J,{children:[`Answered `,s,` question`,s===1?``:`s`]}),c>0&&(0,Y.jsx)(vJ,{children:Object.entries(o).map(([e,t],n)=>{let r=parseInt(e.replace(`question_`,``),10),i=a[r];return(0,Y.jsxs)(Z,{flexDirection:`column`,marginBottom:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:i?.header||`Question ${r+1}`}),(0,Y.jsxs)(Q,{color:`cyan`,children:[`→ `,String(t)]})]},n)})})]})}},MJ={displayName:`EnterPlanMode`,getHeaderParams(e){return``},renderUI(e,t,n){return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):t===`pending`||t===`executing`?(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`pending`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`success`}),(0,Y.jsx)(_J,{children:`Entered plan mode`})]})}};let NJ=function(e){return e[e.Prompt=0]=`Prompt`,e[e.Help=1]=`Help`,e[e.Bash=2]=`Bash`,e[e.Command=3]=`Command`,e[e.Files=4]=`Files`,e}({});const PJ=(0,X.createContext)(null),FJ=()=>{let e=(0,X.use)(PJ);if(!e)throw Error(`${FJ.name} must be used within ${RJ.name}`);return e},IJ=[Sl.Normal,Sl.AcceptEdits,Sl.PlanMode];function LJ(e,t){switch(t.type){case`CYCLE`:{if(e.isWaitingForYoloConfirm)return{agentMode:Sl.Yolo,isWaitingForYoloConfirm:!1};if(e.agentMode===Sl.Yolo)return{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1};let t=IJ.indexOf(e.agentMode);return t===-1?{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1}:t===IJ.length-1?{agentMode:e.agentMode,isWaitingForYoloConfirm:!0}:{agentMode:IJ[t+1],isWaitingForYoloConfirm:!1}}case`SET`:return{agentMode:t.mode,isWaitingForYoloConfirm:!1};case`RESET`:return{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1};case`YOLO_TIMEOUT`:return{...e,isWaitingForYoloConfirm:!1}}}function RJ({children:e,initialMode:t}){let[{agentMode:n,isWaitingForYoloConfirm:r},i]=(0,X.useReducer)(LJ,{agentMode:t??Sl.Normal,isWaitingForYoloConfirm:!1});(0,X.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i({type:`YOLO_TIMEOUT`}),3e3);return()=>clearTimeout(e)},[r]);let a=(0,X.useMemo)(()=>({agentMode:n,setAgentMode:e=>i({type:`SET`,mode:e}),cycleAgentMode:()=>i({type:`CYCLE`}),isWaitingForYoloConfirm:r,resetToNormal:()=>i({type:`RESET`})}),[n,r]);return(0,Y.jsx)(PJ.Provider,{value:a,children:e})}const zJ=q({planFilePath:K()});function BJ({rawInput:e,status:t,parsedResult:n}){let{agentMode:r}=FJ(),i=zJ.safeParse(CJ(e)),a=(i.success?i.data.planFilePath:e?.planFilePath)||``;if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]});if(t===`pending`||t===`executing`)return(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`pending`,showSpinner:!0});let o=r===Sl.AcceptEdits?`Plan approved (auto-accept mode)`:`Plan approved`;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`success`}),(0,Y.jsxs)(_J,{children:[o,`: `,pJ(a)]})]})}const VJ={displayName:`ExitPlanMode`,getHeaderParams(e){return e?.planFilePath||``},renderUI(e,t,n){return(0,Y.jsx)(BJ,{rawInput:e,status:t,parsedResult:n})}},HJ={displayName:`HandOff`,getHeaderParams(e){return``},renderUI(e,t,n){return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`HandOff`,status:`success`}),(0,Y.jsx)(_J,{children:`Handed off to main agent`})]})}},UJ=q({agent:K(),task:K()}),WJ={displayName:`Subagent`,getHeaderParams(e){return e?.agent||``},renderUI(e,t,n){let r=UJ.safeParse(CJ(e)),i=r.success?r.data.agent:e?.agent||``;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Subagent`,params:i,status:`success`}),(0,Y.jsxs)(_J,{children:[`Switched to `,i,` agent`]})]})}},GJ=q({description:K(),prompt:K(),subagentType:K(),model:K().optional(),resume:K().optional()});function KJ({call:e,isFirst:t}){let n=q$[e.name],r=n?.displayName??e.name,i=n?n.getHeaderParams(e.input):``,a=i.length>80?i.slice(0,80)+`...`:i;return(0,Y.jsxs)(Z,{flexDirection:`column`,marginLeft:2,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{dimColor:!0,children:t?`⎿ `:` `}),(0,Y.jsx)(Q,{color:`cyan`,children:r}),a?(0,Y.jsxs)(Q,{dimColor:!0,children:[`(`,a,`)`]}):null]}),e.status===`executing`&&(0,Y.jsx)(Z,{marginLeft:5,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Running…`})})]})}const qJ={displayName:`Task`,getHeaderParams(e){let t=GJ.safeParse(CJ(e));return t.success?`${t.data.subagentType}: ${t.data.description}`:e?.description||e?.subagent_type||``},renderUI(e,t,n,r){let i=GJ.safeParse(CJ(e)),a=i.success?i.data.subagentType:e?.subagent_type||``,o=i.success?i.data.description:e?.description||``,s=t===`executing`||t===`pending`?`pending`:t===`error`||t===`rejected`||t===`interrupted`?`error`:`success`;if(!n?.data&&r?.nestedToolCalls){let e=r.nestedToolCalls,t=(r.toolCallCount??e.length)-e.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,showSpinner:!0}),t>0&&(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ +`,t,` more tool uses`]})}),e.map((e,n)=>(0,Y.jsx)(KJ,{call:e,isFirst:t===0&&n===0},e.id))]})}if(n?.data){let e=n.data;if(e.toolCalls&&e.toolCalls.length>0){let t=e.toolCalls.slice(-4),n=e.toolCalls.length-4;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,status:s}),n>0&&(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ +`,n,` more tool uses`]})}),t.map((e,t)=>(0,Y.jsx)(KJ,{call:{...e,status:`success`},isFirst:n<=0&&t===0},t)),e.error&&(0,Y.jsx)(_J,{children:(0,Y.jsxs)(Q,{color:`red`,children:[`Error: `,e.error]})})]})}return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,status:s}),e.error&&(0,Y.jsx)(_J,{children:(0,Y.jsxs)(Q,{color:`red`,children:[`Error: `,e.error]})})]})}return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,showSpinner:!0}),(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ Running `,a,` agent...`]})})]})}},JJ=(0,X.createContext)(!1),YJ=q({todos:Jc(e=>{if(e==null)return[];if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return Array.isArray(e)?e:[]},sc(q({content:K(),status:xc([`pending`,`in_progress`,`completed`,`cancelled`]),id:K().optional()})))});function XJ({rawInput:e,parsedResult:t}){if(!(0,X.useContext)(JJ))return(0,Y.jsx)(Y.Fragment,{});let n=YJ.safeParse(CJ(e)),r=n.success?n.data.todos:[],i=(0,X.useCallback)(e=>{switch(e){case`completed`:return`[x]`;case`in_progress`:return`[>]`;default:return`[ ]`}},[]),a=(0,X.useCallback)(e=>{switch(e){case`completed`:return`green`;case`in_progress`:return`blue`;default:return`gray`}},[]);return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`TodoWrite`,status:`success`}),t?.summary&&(0,Y.jsx)(_J,{children:t.summary}),r.length>0&&(0,Y.jsx)(vJ,{children:r.map((e,t)=>(0,Y.jsxs)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:[(0,Y.jsx)(Q,{color:a(e.status),children:i(e.status)}),(0,Y.jsx)(Q,{color:e.status===`completed`?`gray`:void 0,dimColor:e.status===`completed`,children:e.content})]},t))})]})}const ZJ={displayName:`TodoWrite`,getHeaderParams(e){return``},renderUI(e,t,n){return(0,Y.jsx)(XJ,{rawInput:e,parsedResult:n})}},QJ=q({id:EJ}),$J={displayName:`CloseTab`,getHeaderParams(e){let t=e;return`id: ${String(t.id??``)}`},renderUI(e,t,n){let r=QJ.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.id;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`pending`,showSpinner:!0}):n?t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error closing tab`})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`success`}),(0,Y.jsx)(_J,{children:`Closed`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`pending`})})}},eY=q({action:xc([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:_c([EJ,EJ]).optional(),startCoordinate:_c([EJ,EJ]).optional(),duration:DJ,text:K().optional(),scrollAmount:DJ,scrollDirection:xc([`up`,`down`,`left`,`right`]).optional()}),tY={displayName:`Computer`,getHeaderParams(e){return e?.action||`action`},renderUI(e,t,n){let r=eY.safeParse(CJ(e)),i=r.success?r.data.action:e?.action||`action`;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing computer action`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`success`}),(0,Y.jsxs)(_J,{children:[`Performed `,i]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`pending`})})}},nY=q({id:DJ}),rY={displayName:`GetElements`,getHeaderParams(e){let t=e;return t.id===void 0?``:`id: ${String(t.id)}`},renderUI(e,t,n){let r=nY.safeParse(CJ(e)),i=r.success&&r.data.id!==void 0?`id: ${r.data.id}`:void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error: Failed to get interactive elements`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Found elements`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`pending`})})}},iY=q({id:DJ}),aY={displayName:`GetContent`,getHeaderParams(e){let t=e;return t.id===void 0?``:`id: ${String(t.id)}`},renderUI(e,t,n){let r=iY.safeParse(CJ(e)),i=r.success&&r.data.id!==void 0?`id: ${r.data.id}`:void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error: Failed to get tab content`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Got content`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`pending`})})}},oY=q({url:K()}),sY={displayName:`Navigate`,getHeaderParams(e){let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t},renderUI(e,t,n){let r=oY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error navigating to URL`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:`Navigated`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`pending`})})}},cY=q({url:K().optional()}),lY={displayName:`NewTab`,getHeaderParams(e){let t=e?.url||``;return t.length>40?t.substring(0,37)+`...`:t},renderUI(e,t,n){let r=cY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=(i.length>40?i.substring(0,37)+`...`:i)||void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error opening new tab`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Opened tab`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`pending`})})}},uY=q({id:K(),action:xc([`click`,`type`,`hover`,`scroll`,`focus`,`select`]),text:K().optional(),scroll_direction:xc([`up`,`down`,`left`,`right`]).optional(),scroll_amount:DJ,held_keys:K().optional(),tab_id:DJ}),dY={displayName:`PerformAction`,getHeaderParams(e){return`id: ${(e.id||``).substring(0,20)}`},renderUI(e,t,n){let r=e,i=uY.safeParse(CJ(e)),a=i.success?i.data.action:r.action||`action`,o=`id: ${(r.id||``).substring(0,20)}`,s=a.charAt(0).toUpperCase()+a.slice(1);return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:s,params:o,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:s,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing action`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:s,params:o,status:`success`}),(0,Y.jsxs)(_J,{children:[`Performed `,a]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:s,params:o,status:`pending`})})}},fY={displayName:`Refresh`,getHeaderParams(e){return``},renderUI(e,t,n){return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Refresh`,status:`pending`,showSpinner:!0}):n?t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Refresh`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error refreshing tab`})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Refresh`,status:`success`}),(0,Y.jsx)(_J,{children:`Refreshed`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Refresh`,status:`pending`})})}},pY=q({id:EJ}),mY={displayName:`SwitchTab`,getHeaderParams(e){let t=e;return`id: ${String(t.id??``)}`},renderUI(e,t,n){let r=pY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.id;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error switching tab`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`success`}),(0,Y.jsxs)(_J,{children:[`Switched to tab `,i]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`pending`})})}},hY=q({targetFile:K(),explanation:K().optional()}),gY={displayName:`Delete`,getHeaderParams(e){try{return pJ(e?.targetFile||e?.target_file||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n){let r=hY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let{targetFile:i}=r.data,a=pJ(i);return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?n?.userNote?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`rejected`}),(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`rejected`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error deleting file`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:`Deleted`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`pending`})})}};function _Y(e,t){return aJ(e,t)}const vY=(0,X.memo)(({line:e,pairedLine:t,lineNumber:n,dimmed:r=!1})=>{let{colors:i}=bz();if(e.type===`separator`)return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[n,` `]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`⋮ `,e.skippedLines,` unchanged lines`]})]});if(e.type===`unchanged`)return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[n,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{dimColor:!0,wrap:`wrap`,children:e.highlightedContent??e.content})})]});if(e.type===`removed`){let a=t?.type===`added`?_Y(e.content,t.content):null;return(0,Y.jsxs)(Z,{flexDirection:`row`,backgroundColor:i.diffRemoved,children:[(0,Y.jsxs)(Q,{backgroundColor:i.diffRemoved,color:i.diffRemovedText,dimColor:r,children:[n,` -`,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{color:i.diffRemovedText,dimColor:r,wrap:`wrap`,children:a?a.map((e,t)=>e.removed?(0,Y.jsx)(Q,{backgroundColor:i.diffRemovedHighlight,dimColor:r,children:e.value},t):e.added?null:(0,Y.jsx)(Q,{backgroundColor:i.diffRemoved,dimColor:r,children:e.value},t)):(0,Y.jsx)(Q,{backgroundColor:i.diffRemoved,dimColor:r,children:e.highlightedContent??e.content})})})]})}if(e.type===`added`){let a=t?.type===`removed`?_Y(t.content,e.content):null;return(0,Y.jsxs)(Z,{flexDirection:`row`,backgroundColor:i.diffAdded,children:[(0,Y.jsxs)(Q,{backgroundColor:i.diffAdded,color:i.diffAddedText,dimColor:r,children:[n,` +`,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{color:i.diffAddedText,dimColor:r,wrap:`wrap`,children:a?a.map((e,t)=>e.added?(0,Y.jsx)(Q,{backgroundColor:i.diffAddedHighlight,dimColor:r,children:e.value},t):e.removed?null:(0,Y.jsx)(Q,{backgroundColor:i.diffAdded,dimColor:r,children:e.value},t)):(0,Y.jsx)(Q,{backgroundColor:i.diffAdded,dimColor:r,children:e.highlightedContent??e.content})})})]})}return null});vY.displayName=`DiffLineContent`;const yY=(0,X.memo)(({filePath:e,hunks:t})=>{let{colors:n}=bz(),r=t.reduce((e,t)=>e+t.lines.filter(e=>e.startsWith(`+`)).length,0),i=t.reduce((e,t)=>e+t.lines.filter(e=>e.startsWith(`-`)).length,0);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{bold:!0,children:e}),(r>0||i>0)&&(0,Y.jsxs)(Q,{dimColor:!0,children:[r>0&&(0,Y.jsxs)(Q,{color:n.diffAddedText,children:[`+`,r]}),r>0&&i>0&&(0,Y.jsx)(Q,{children:` `}),i>0&&(0,Y.jsxs)(Q,{color:n.diffRemovedText,children:[`-`,i]})]})]})});yY.displayName=`DiffPreviewTitle`;const bY=(0,X.memo)(({filePath:e,originalContent:t,newContent:n,dimmed:r=!1,...i})=>{let[a,o]=(0,X.useState)(n),s=a!==n;(0,X.useEffect)(()=>{if(a===n)return;let e=setTimeout(()=>o(n),0);return()=>clearTimeout(e)},[n,a]);let{colors:c}=bz(),l=(0,X.useMemo)(()=>LU(c),[c]),{diffLines:u,totalOriginalLines:d}=(0,X.useMemo)(()=>{let n=SJ(t,e,l),r=SJ(a,e,l),i=lJ(e,e,t,a,void 0,void 0,{context:1}),o=[],s=0;for(let e=0;e<i.hunks.length;e++){let t=i.hunks[e];if(!t)continue;let a=t.oldStart;if(e>0&&a>s+1){let e=a-s-1;e>0&&o.push({type:`separator`,content:``,skippedLines:e})}let c=t.oldStart,l=t.newStart;for(let e of t.lines){let t=e[0],i=e.slice(1);t!==`\\`&&(t===`+`?o.push({type:`added`,content:i,highlightedContent:r[l-1],newLineNumber:l++}):t===`-`?o.push({type:`removed`,content:i,highlightedContent:n[c-1],originalLineNumber:c++}):o.push({type:`unchanged`,content:i,highlightedContent:n[c-1],originalLineNumber:c++,newLineNumber:l++}))}s=c-1}return{diffLines:o,totalOriginalLines:t.split(`
|
|
85742
|
-
`).length}},[e,t,a,l]),f=(0,X.useMemo)(()=>{let e=new Map;for(let t=0;t<u.length;t++){let n=u[t];if(n&&n.type===`removed`){let r=u[t+1];r&&r.type===`added`&&(e.set(t,r),e.set(t+1,n))}}return e},[u]);if(u.length===0)return(0,Y.jsxs)(Z,{flexDirection:`column`,...i,children:[(0,Y.jsx)(Z,{borderStyle:`singleDouble`,width:`100%`,borderTop:!1,borderLeft:!1,borderRight:!1,borderBottom:!0}),(0,Y.jsx)(Q,{dimColor:!0,children:`No changes detected`}),(0,Y.jsx)(Z,{borderStyle:`singleDouble`,width:`100%`,borderTop:!1,borderLeft:!1,borderRight:!1,borderBottom:!0})]});let p=Math.max(d,...u.filter(e=>e.type!==`separator`).map(e=>e.originalLineNumber||e.newLineNumber||0)).toString().length;return(0,Y.jsxs)(Z,{flexDirection:`column`,...i,children:[s&&(0,Y.jsx)(Z,{marginBottom:0,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Processing diff...`})}),(0,Y.jsx)(Z,{flexDirection:`column`,children:u.map((e,t)=>{let n=f.get(t);if(e.type===`separator`)return(0,Y.jsx)(vY,{line:e,lineNumber:` `.repeat(p),dimmed:r},`sep-${t}`);let i=e.originalLineNumber||e.newLineNumber||``;return(0,Y.jsx)(vY,{line:e,pairedLine:n,lineNumber:String(i).padStart(p,` `),dimmed:r},t)})})]})});bY.displayName=`DiffPreview`;const xY=q({targetFile:K(),codeEdit:K(),overwriteFile:kJ,instructions:K().optional(),startLine:dc([Ws(),K(),$s(),Zs()]).optional().transform(e=>{if(e==null)return;let t=Number(e);return isNaN(t)?void 0:t}),endLine:dc([Ws(),K(),$s(),Zs()]).optional().transform(e=>{if(e==null)return;let t=Number(e);return isNaN(t)?void 0:t}),explanation:K().optional()});function SY({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let[i,a]=(0,X.useState)(!1),o=n!=null&&(t===`success`||n.phase===`skipped`),{isFocused:s}=UL({id:`edit-tool-${e?.targetFile||e?.target_file||`unknown`}`,isActive:o});HL((e,t)=>{s&&t.ctrl&&e===`o`&&a(e=>!e)},{isActive:s&&o});let c=xY.safeParse(CJ(e));if(!c.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let l=c.data,u=n?.data.targetFile??l.targetFile,d=!n&&(t===`executing`||t===`pending`),f=pJ(u),p=r?.isPlanFile??!1,m=n?.data.isNewFile??r?.isNewFile??!1,h=m?`Create`:`Update`;if(p&&t===`success`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`success`}),(0,Y.jsx)(_J,{children:`Updated plan`})]});if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`rejected`}),!p&&e&&t&&(0,Y.jsx)(vJ,{children:(0,Y.jsx)(bY,{filePath:u,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(d)return(0,Y.jsx)(gJ,{name:h,params:f,status:`pending`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:h,params:f,status:`pending`})});if(n.phase===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error executing tool`})]});let g=n.phase===`skipped`,_=n.summary??`Updated`,v=r?.originalContent,y=r?.finalContent??r?.newContent;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:g?`rejected`:`success`}),(0,Y.jsx)(_J,{color:g?`yellow`:void 0,children:_}),!g&&v!==void 0&&y!==void 0&&(0,Y.jsx)(vJ,{children:m?(0,Y.jsx)(xJ,{filePath:u,content:y,maxLines:i?100:15}):(0,Y.jsx)(bY,{filePath:u,originalContent:v,newContent:y})})]})}const CY={displayName:`Edit`,getHeaderParams(e){try{return pJ(e?.targetFile||e?.target_file||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,Y.jsx)(SY,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},wY=q({relativeWorkspacePath:K().optional(),explanation:K().optional()}),TY={displayName:`ListDir`,getHeaderParams(e){try{return pJ(e?.relativeWorkspacePath||e?.relative_workspace_path||`.`)}catch{return`[unknown]`}},renderUI(e,t,n){let r=wY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`LS`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=pJ(r.data.relativeWorkspacePath||`.`);return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`List`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error listing directory`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`pending`})})}},EY=q({notebookPath:K(),cellId:K().optional(),newSource:K(),cellType:xc([`code`,`markdown`]).optional(),editMode:xc([`replace`,`insert`,`delete`]).optional()});function DY(e,t,n){let r=e??`replace`;return r===`delete`?`Delete cell${t?` ${t}`:``}`:r===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${n??`code`})`:`Replace cell contents for cell ${t??`unknown`}`}function OY({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=EY.safeParse(CJ(e));if(!i.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let a=i.data,o=pJ(a.notebookPath),s=a.editMode??`replace`,c=DY(s,a.cellId,a.cellType);if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`rejected`}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,c]}),s!==`delete`&&e&&t&&(0,Y.jsx)(vJ,{children:(0,Y.jsx)(bY,{filePath:a.notebookPath,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error editing notebook`})]});if(!n&&(t===`executing`||t===`pending`))return(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`pending`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`pending`})});if(n.phase===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:n.errorMessage??`Error editing notebook`})]});let l=n.summary??`Notebook edited`,u=r?.originalContent,d=r?.newContent;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`success`}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,c]}),(0,Y.jsx)(_J,{children:l}),s!==`delete`&&u!==void 0&&d!==void 0&&(0,Y.jsx)(vJ,{children:s===`insert`||!u?(0,Y.jsx)(xJ,{filePath:a.notebookPath,content:d,maxLines:15}):(0,Y.jsx)(bY,{filePath:a.notebookPath,originalContent:u,newContent:d})})]})}const kY={displayName:`Edit notebook`,getHeaderParams(e){try{return pJ(e?.notebookPath||e?.notebook_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,Y.jsx)(OY,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},AY
|
|
85743
|
-
`).length;return(0,Y.jsx)(MY,{displayParams:f,content:p,filePath:a,startLine:m,lineCount:h})}};function MY({displayParams:e,content:t,filePath:n,startLine:r,lineCount:i}){let[a,o]=(0,X.useState)(!1),s=t.split(`
|
|
85744
|
-
`).length,c=a?100:4,l=s>4,{isFocused:u}=UL({id:`read-file-${n}`,isActive:l});return HL((e,t)=>{u&&t.ctrl&&e===`o`&&o(e=>!e)},{isActive:u&&l}),(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Read`,params:e,status:`success`}),(0,Y.jsxs)(_J,{children:[`Read `,i,` lines`]}),(0,Y.jsx)(vJ,{children:(0,Y.jsx)(xJ,{content:t,filePath:n,startLine:r,maxLines:c})})]})}const NY=q({uri:K().optional()}),PY={displayName:`GetDiagnostics`,getHeaderParams(e){let t=e?.uri;return t?`for ${t}`:`for all files`},renderUI(e,t,n){let r=NY.safeParse(CJ(e)),i=r.success?r.data.uri:void 0,a=i?`for ${i}`:`for all files`;return!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`pending`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error getting diagnostics`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`pending`})})}};function FY(e){return e[0]??{}}function IY(e){return Array.isArray(e)?e:e==null?[]:[e]}function LY(e){return typeof e.bytes==`function`?e.bytes():e.arrayBuffer()}const RY=`orpc`;var zY=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function BY(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}function VY(){return globalThis[`__@orpc/shared@1.13.6/otel/config__`]}function HY(e,t={},n){return(VY()?.tracer)?.startSpan(e,t,n)}function UY(e,t,n={}){if(!e)return;let r=WY(t);e.recordException(r),(!n.signal?.aborted||n.signal.reason!==t)&&e.setStatus({code:2,message:r.message})}function WY(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function GY({name:e,context:t,...n},r){let i=VY()?.tracer;if(!i)return r();let a=async e=>{try{return await r(e)}catch(t){throw UY(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,a):i.startActiveSpan(e,n,a)}async function KY(e,t){let n=VY();if(!e||!n)return t();let r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}var qY=class{openIds=new Set;queues=new Map;waiters=new Map;get length(){return this.openIds.size}get waiterIds(){return Array.from(this.waiters.keys())}hasBufferedItems(e){return!!this.queues.get(e)?.length}open(e){this.openIds.add(e)}isOpen(e){return this.openIds.has(e)}push(e,t){this.assertOpen(e);let n=this.waiters.get(e);if(n?.length)n.shift()[0](t),n.length===0&&this.waiters.delete(e);else{let n=this.queues.get(e);n?n.push(t):this.queues.set(e,[t])}}async pull(e){this.assertOpen(e);let t=this.queues.get(e);if(t?.length){let n=t.shift();return t.length===0&&this.queues.delete(e),n}return new Promise((t,n)=>{let r=this.waiters.get(e),i=[t,n];r?r.push(i):this.waiters.set(e,[i])})}close({id:e,reason:t}={}){if(e===void 0){this.waiters.forEach((e,n)=>{let r=t??new zY(`[AsyncIdQueue] Queue[${n}] was closed or aborted while waiting for pulling.`);e.forEach(([,e])=>e(r))}),this.waiters.clear(),this.openIds.clear(),this.queues.clear();return}let n=t??new zY(`[AsyncIdQueue] Queue[${e}] was closed or aborted while waiting for pulling.`);this.waiters.get(e)?.forEach(([,e])=>e(n)),this.waiters.delete(e),this.openIds.delete(e),this.queues.delete(e)}assertOpen(e){if(!this.isOpen(e))throw Error(`[AsyncIdQueue] Cannot access queue[${e}] because it is not open or aborted.`)}};function JY(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}const YY=Symbol.for(`asyncDispose`),XY=Symbol.asyncDispose??YY;var ZY=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=BY(async()=>{if(this.#e)return{done:!0,value:void 0};try{let t=await e();return t.done&&(this.#e=!0),t}catch(e){throw this.#e=!0,e}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n(`next`))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n(`return`)),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n(`throw`)),e}async[XY](){this.#e=!0,this.#t||(this.#t=!0,await this.#n(`dispose`))}[Symbol.asyncIterator](){return this}};function QY({name:e,...t},n){let r;return new ZY(async()=>{r??=HY(e);try{let e=await KY(r,()=>n.next());return r?.addEvent(e.done?`completed`:`yielded`),e}catch(e){throw UY(r,e,t),e}},async e=>{try{e!==`next`&&await KY(r,()=>n.return?.())}catch(e){throw UY(r,e,t),e}finally{r?.end()}})}var $Y=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function eX(e,t,n){let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function tX(e){if(e)return JSON.parse(e)}function nX(e){return JSON.stringify(e)}function rX(e){return aX(e)?Object.getPrototypeOf(e)?.constructor:null}function iX(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function aX(e){return!!e&&(typeof e==`object`||typeof e==`function`)}function oX(e){if(Array.isArray(e))return e.map(oX);if(iX(e)){let t={};for(let n in e)t[n]=oX(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=oX(e[n]);return t}return e}const sX=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function cX(e,...t){return typeof e==`function`?e(...t):e}function lX(e){return new Proxy(e,{get(e,t,n){let r=Reflect.get(e,t,n);return t!==`then`||typeof r!=`function`?r:new Proxy(r,{apply(t,n,r){if(r.length!==2||r.some(e=>!dX(e)))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,lX(new Proxy(e,{get:(e,t,n)=>{if(i&&t===`then`){i=!1;return}return Reflect.get(e,t,n)}})))}})}})}const uX=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;function dX(e){return typeof e==`function`&&uX.test(e.toString())}function fX(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){let i=r in t?t:cX(e),a=Reflect.get(i,r);return typeof a==`function`?a.bind(i):a},has(n,r){return Reflect.has(t,r)||Reflect.has(cX(e),r)}})}function pX(e){try{return decodeURIComponent(e)}catch{return e}}const mX={BAD_REQUEST:{status:400,message:`Bad Request`},UNAUTHORIZED:{status:401,message:`Unauthorized`},FORBIDDEN:{status:403,message:`Forbidden`},NOT_FOUND:{status:404,message:`Not Found`},METHOD_NOT_SUPPORTED:{status:405,message:`Method Not Supported`},NOT_ACCEPTABLE:{status:406,message:`Not Acceptable`},TIMEOUT:{status:408,message:`Request Timeout`},CONFLICT:{status:409,message:`Conflict`},PRECONDITION_FAILED:{status:412,message:`Precondition Failed`},PAYLOAD_TOO_LARGE:{status:413,message:`Payload Too Large`},UNSUPPORTED_MEDIA_TYPE:{status:415,message:`Unsupported Media Type`},UNPROCESSABLE_CONTENT:{status:422,message:`Unprocessable Content`},TOO_MANY_REQUESTS:{status:429,message:`Too Many Requests`},CLIENT_CLOSED_REQUEST:{status:499,message:`Client Closed Request`},INTERNAL_SERVER_ERROR:{status:500,message:`Internal Server Error`},NOT_IMPLEMENTED:{status:501,message:`Not Implemented`},BAD_GATEWAY:{status:502,message:`Bad Gateway`},SERVICE_UNAVAILABLE:{status:503,message:`Service Unavailable`},GATEWAY_TIMEOUT:{status:504,message:`Gateway Timeout`}};function hX(e,t){return t??mX[e]?.status??500}function gX(e,t){return t||mX[e]?.message||e}const _X=Symbol.for(`__@orpc/client@1.13.6/error/ORPC_ERROR_CONSTRUCTORS__`);globalThis[_X]??=new WeakSet;const vX=globalThis[_X];var yX=class extends Error{defined;code;status;data;constructor(e,...t){let n=FY(t);if(n.status!==void 0&&!xX(n.status))throw Error(`[ORPCError] Invalid error status code.`);let r=gX(e,n.message);super(r,n),this.code=e,this.status=hX(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(vX.has(this)){let t=rX(e);if(t&&vX.has(t))return!0}return super[Symbol.hasInstance](e)}};vX.add(yX);function bX(e){return e instanceof yX?e:new yX(`INTERNAL_SERVER_ERROR`,{message:`Internal server error`,cause:e})}function xX(e){return e<200||e>=400}function SX(e){if(!iX(e))return!1;let t=[`defined`,`code`,`status`,`message`,`data`];return Object.keys(e).some(e=>!t.includes(e))?!1:`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`status`in e&&typeof e.status==`number`&&xX(e.status)&&`message`in e&&typeof e.message==`string`}function CX(e,t={}){return new yX(e.code,{...t,...e})}var wX=class extends TypeError{},TX=class extends Error{data;constructor(e){super(e?.message??`An error event was received`,e),this.data=e?.data}};function EX(e){if(e.includes(`
|
|
85745
|
-
`))throw new wX(`Event's id must not contain a newline character`)}function DX(e){if(!Number.isInteger(e)||e<0)throw new wX(`Event's retry must be a integer and >= 0`)}function OX(e){if(e.includes(`
|
|
85746
|
-
`))throw new wX(`Event's comment must not contain a newline character`)}const kX=Symbol(`ORPC_EVENT_SOURCE_META`);function AX(e,t){if(t.id===void 0&&t.retry===void 0&&!t.comments?.length)return e;if(t.id!==void 0&&EX(t.id),t.retry!==void 0&&DX(t.retry),t.comments!==void 0)for(let e of t.comments)OX(e);return new Proxy(e,{get(e,n,r){return n===kX?t:Reflect.get(e,n,r)}})}function jX(e){return aX(e)?Reflect.get(e,kX):void 0}var MX=class extends ZY{hibernationCallback;constructor(e){super(async()=>{throw Error(`Cannot iterate over hibernating iterator directly`)},async e=>{if(e!==`next`)throw Error(`Cannot cleanup hibernating iterator directly`)}),this.hibernationCallback=e}};function NX(e){return`inline; filename="${e.replace(/"/g,`\\"`)}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function PX(e){let t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&typeof t[2]==`string`)return pX(t[2]);let n=e.match(/filename="((?:\\"|[^"])*)"/i);if(n&&typeof n[1]==`string`)return n[1].replace(/\\"/g,`"`)}function FX(e,t){let n={...e};for(let e in t)Array.isArray(t[e])?n[e]=[...IY(n[e]),...t[e]]:t[e]!==void 0&&(Array.isArray(n[e])?n[e]=[...n[e],t[e]]:n[e]===void 0?n[e]=t[e]:n[e]=[n[e],t[e]]);return n}function IX(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function LX(e){return!!(IX(e[`content-type`])?.startsWith(`text/event-stream`)&&IX(e[`content-disposition`])===void 0)}function RX(e,t){let n=async e=>{let n=await t.error(e);if(n!==e){let t=jX(e);t&&aX(n)&&(n=AX(n,t))}return n};return new ZY(async()=>{let{done:r,value:i}=await(async()=>{try{return await e.next()}catch(e){throw await n(e)}})(),a=await t.value(i,r);if(a!==i){let e=jX(i);e&&aX(a)&&(a=AX(a,e))}return{done:r,value:a}},async()=>{try{await e.return?.()}catch(e){throw await n(e)}})}function zX(e){return{...e,context:e.context??{}}}function BX(e,t={}){let n=t.path??[];return lX(new Proxy(async(...[t,r={}])=>await e.call(n,t,zX(r)),{get(r,i){return typeof i==`string`?BX(e,{...t,path:[...n,i]}):Reflect.get(r,i)}}))}var VX=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function HX(e,t){return{...e,...t}}async function UX(e,t){let{code:n,status:r,message:i,data:a,cause:o,defined:s}=t,c=e?.[t.code];if(!c||hX(t.code,c.status)!==t.status)return s?new yX(n,{defined:!1,status:r,message:i,data:a,cause:o}):t;if(!c.data)return s?t:new yX(n,{defined:!0,status:r,message:i,data:a,cause:o});let l=await c.data[`~standard`].validate(t.data);return l.issues?s?new yX(n,{defined:!1,status:r,message:i,data:a,cause:o}):t:new yX(n,{defined:!0,status:r,message:i,data:l.value,cause:o})}var WX=class{"~orpc";constructor(e){if(e.route?.successStatus&&xX(e.route.successStatus))throw Error(`[ContractProcedure] Invalid successStatus.`);if(Object.values(e.errorMap).some(e=>e&&e.status&&!xX(e.status)))throw Error(`[ContractProcedure] Invalid error status code.`);this[`~orpc`]=e}};function GX(e){return e instanceof WX?!0:(typeof e==`object`||typeof e==`function`)&&e!==null&&`~orpc`in e&&typeof e[`~orpc`]==`object`&&e[`~orpc`]!==null&&`errorMap`in e[`~orpc`]&&`route`in e[`~orpc`]&&`meta`in e[`~orpc`]}function KX(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]===void 0?t[n]=e:t[n]=[t[n],e]}),t}var qX=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(let t of this.plugins)t.init?.(e)}},JX=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new qX(n.plugins).init(n),this.interceptors=IY(n.interceptors),this.clientInterceptors=IY(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return GY({name:`${RY}.${e.join(`/`)}`,signal:n.signal},r=>(r?.setAttribute(`rpc.system`,RY),r?.setAttribute(`rpc.method`,e.join(`.`)),JY(t)&&(t=QY({name:`consume_event_iterator_input`,signal:n.signal},t)),eX(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=VY(),a,o=i?.trace.getActiveSpan()??r;o&&i&&(a=i?.trace.setSpan(i.context.active(),o));let s=await GY({name:`encode_request`,context:a},()=>this.codec.encode(e,t,n)),c=await eX(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>GY({name:`send_request`,signal:r.signal,context:a},()=>this.sender.call(n,r,t,e))),l=await GY({name:`decode_response`,context:a},()=>this.codec.decode(c,n,e,t));return JY(l)?QY({name:`consume_event_iterator_output`,signal:n.signal},l):l})))}};const YX={BIGINT:0,DATE:1,NAN:2,UNDEFINED:3,URL:4,REGEXP:5,SET:6,MAP:7};var XX=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw Error(`Custom serializer type must be unique.`)}serialize(e,t=[],n=[],r=[],i=[]){for(let a of this.customSerializers)if(a.condition(e)){let o=this.serialize(a.serialize(e),t,n,r,i);return n.push([a.type,...t]),o}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if(typeof e==`bigint`)return n.push([YX.BIGINT,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([YX.DATE,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([YX.NAN,...t]),[null,n,r,i];if(e instanceof URL)return n.push([YX.URL,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([YX.REGEXP,...t]),[e.toString(),n,r,i];if(e instanceof Set){let a=this.serialize(Array.from(e),t,n,r,i);return n.push([YX.SET,...t]),a}if(e instanceof Map){let a=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([YX.MAP,...t]),a}if(Array.isArray(e))return[e.map((e,a)=>e===void 0?(n.push([YX.UNDEFINED,...t,a]),e):this.serialize(e,[...t,a],n,r,i)[0]),n,r,i];if(iX(e)){let a={};for(let o in e)o===`toJSON`&&typeof e[o]==`function`||(a[o]=this.serialize(e[o],[...t,o],n,r,i)[0]);return[a,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){let i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,a=`data`;e.forEach(e=>{if(n=n[a],a=e,!Object.hasOwn(n,a))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${a}`)}),n[a]=r(t)});for(let e of t){let t=e[0],n=i,r=`data`;for(let t=1;t<e.length;t++)if(n=n[r],r=e[t],!Object.hasOwn(n,r))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${r}`);for(let e of this.customSerializers)if(e.type===t){n[r]=e.deserialize(n[r]);break}switch(t){case YX.BIGINT:n[r]=BigInt(n[r]);break;case YX.DATE:n[r]=new Date(n[r]??`Invalid Date`);break;case YX.NAN:n[r]=NaN;break;case YX.UNDEFINED:n[r]=void 0;break;case YX.URL:n[r]=new URL(n[r]);break;case YX.REGEXP:{let[,e,t]=n[r].match(/^\/(.*)\/([a-z]*)$/);n[r]=new RegExp(e,t);break}case YX.SET:n[r]=new Set(n[r]);break;case YX.MAP:n[r]=new Map(n[r]);break}}return i.data}};function ZX(e){return`/${e.map(encodeURIComponent).join(`/`)}`}function QX(e){return typeof e.forEach==`function`?KX(e):e}function $X(e){return Object.entries(mX).find(([,t])=>t.status===e)?.[0]??`MALFORMED_ORPC_ERROR_RESPONSE`}var eZ=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??`POST`,this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=QX(await cX(this.headers,n,e,t));n.lastEventId!==void 0&&(r=FX(r,{"last-event-id":n.lastEventId}));let i=await cX(this.expectedMethod,n,e,t),a=await cX(this.baseUrl,n,e,t),o=new URL(a);o.pathname=`${o.pathname.replace(/\/$/,``)}${ZX(e)}`;let s=this.serializer.serialize(t);if(i===`GET`&&!(s instanceof FormData)&&!JY(s)){let a=await cX(this.maxUrlLength,n,e,t),c=new URL(o);if(c.searchParams.append(`data`,nX(s)),c.toString().length<=a)return{body:void 0,method:i,headers:r,url:c,signal:n.signal}}return{url:o,method:i===`GET`?this.fallbackMethod:i,headers:r,body:s,signal:n.signal}}async decode(e){let t=!xX(e.status),n=await(async()=>{let t=!1;try{let n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(e){throw t?Error(`Invalid RPC response format.`,{cause:e}):Error(`Cannot parse response body, please check the response body and content-type.`,{cause:e})}})();if(!t)throw SX(n)?CX(n):new yX($X(e.status),{status:e.status,data:{...e,body:n}});return n}},tZ=class{constructor(e){this.jsonSerializer=e}serialize(e){return JY(e)?RX(e,{value:async e=>this.#e(e,!1),error:async e=>new TX({data:this.#e(bX(e).toJSON(),!1),cause:e})}):this.#e(e,!0)}#e(e,t){let[n,r,i,a]=this.jsonSerializer.serialize(e),o=r.length===0?void 0:r;if(!t||a.length===0)return{json:n,meta:o};let s=new FormData;return s.set(`data`,nX({json:n,meta:o,maps:i})),a.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return JY(e)?RX(e,{value:async e=>this.#t(e),error:async e=>{if(!(e instanceof TX))return e;let t=this.#t(e.data);return SX(t)?CX(t,{cause:e}):new TX({data:t,cause:e})}}):this.#t(e)}#t(e){if(e===void 0)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);let t=JSON.parse(e.get(`data`));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},nZ=class extends JX{constructor(e,t){let n=new eZ(new tZ(new XX(t)),t);super(n,e,t)}};function rZ(e,t){return{...e,...t}}function iZ(e,t){return{...e,...t}}function aZ(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}function oZ(e,t){return{...e,tags:[...t,...e.tags??[]]}}function sZ(e,t){return e?`${e}${t}`:t}function cZ(e,t){return e?[...e,...t]:t}function lZ(e,t){let n=e;return t.prefix&&(n=aZ(n,t.prefix)),t.tags?.length&&(n=oZ(n,t.tags)),n}function uZ(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||GX(n))return;n=n[r]}return n}function dZ(e,t){if(GX(e))return new WX({...e[`~orpc`],errorMap:HX(t.errorMap,e[`~orpc`].errorMap),route:lZ(e[`~orpc`].route,t)});let n={};for(let r in e)n[r]=dZ(e[r],t);return n}const fZ=new class e extends WX{constructor(e){super(e),this[`~orpc`].prefix=e.prefix,this[`~orpc`].tags=e.tags}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}errors(t){return new e({...this[`~orpc`],errorMap:HX(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:rZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:iZ(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t})}output(t){return new e({...this[`~orpc`],outputSchema:t})}prefix(t){return new e({...this[`~orpc`],prefix:sZ(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:cZ(this[`~orpc`].tags,t)})}router(e){return dZ(e,this[`~orpc`])}}({errorMap:{},route:{},meta:{}}),pZ={editorStateChanged:fZ.input(q({file:K().nullable(),startLine:Ws().optional(),endLine:Ws().optional()})).output(q({ok:Js()})),toolDecision:fZ.input(q({toolId:K(),decision:xc([`accept`,`reject`,`allowAlways`])})).output(q({ok:Js()}))};function mZ(e){return{...e,context:e.context??{}}}function hZ(e,t){return async n=>{let{response:r}=await e.handle({...n,body:()=>Promise.resolve(n.body)},mZ(t));return r??{status:404,headers:{},body:`No procedure matched`}}}const gZ=/^http:\/\/orpc\//;var _Z=(e=>(e[e.REQUEST=1]=`REQUEST`,e[e.RESPONSE=2]=`RESPONSE`,e[e.EVENT_ITERATOR=3]=`EVENT_ITERATOR`,e[e.ABORT_SIGNAL=4]=`ABORT_SIGNAL`,e))(_Z||{});function vZ(e,t,n){if(t===3){let r=n;return{i:e,t,p:{e:r.event,d:r.data,m:r.meta}}}if(t===4)return{i:e,t,p:n};let r=n;return{i:e,p:{u:r.url.toString().replace(gZ,`/`),b:r.body,h:Object.keys(r.headers).length>0?r.headers:void 0,m:r.method===`POST`?void 0:r.method}}}function yZ(e){let t=e.i,n=e.t??1;if(n===3){let r=e.p;return[t,n,{event:r.e,data:r.d,meta:r.m}]}if(n===4)return[t,n,e.p];let r=e.p;return[t,1,{url:r.u.startsWith(`/`)?new URL(`http://orpc${r.u}`):new URL(r.u),headers:r.h??{},method:r.m??`POST`,body:r.b}]}function bZ(e,t,n){if(t===3){let r=n;return{i:e,t,p:{e:r.event,d:r.data,m:r.meta}}}if(t===4)return{i:e,t,p:void 0};let r=n;return{i:e,p:{s:r.status===200?void 0:r.status,h:Object.keys(r.headers).length>0?r.headers:void 0,b:r.body}}}function xZ(e){let t=e.i,n=e.t;if(n===3){let r=e.p;return[t,n,{event:r.e,data:r.d,meta:r.m}]}if(n===4)return[t,n,e.p];let r=e.p;return[t,2,{status:r.s??200,headers:r.h??{},body:r.b}]}async function SZ(e,t,n){if(t===3||t===4)return OZ(vZ(e,t,n));let r=n,{body:i,headers:a}=await EZ(r.body,r.headers),o=vZ(e,1,{...r,body:i instanceof Blob?void 0:i,headers:a});return i instanceof Blob?OZ(o,i):OZ(o)}async function CZ(e){let{json:t,buffer:n}=await kZ(e),[r,i,a]=yZ(t);if(i===3||i===4)return[r,i,a];let o=a,s=await DZ(o.headers,o.body,n);return[r,i,{...o,body:s}]}async function wZ(e,t,n){if(t===3||t===4)return OZ(bZ(e,t,n));let r=n,{body:i,headers:a}=await EZ(r.body,r.headers),o=bZ(e,2,{...r,body:i instanceof Blob?void 0:i,headers:a});return i instanceof Blob?OZ(o,i):OZ(o)}async function TZ(e){let{json:t,buffer:n}=await kZ(e),[r,i,a]=xZ(t);if(i===3||i===4)return[r,i,a];let o=a,s=await DZ(o.headers,o.body,n);return[r,i,{...o,body:s}]}async function EZ(e,t){let n={...t},r=n[`content-disposition`];if(delete n[`content-type`],delete n[`content-disposition`],e instanceof Blob)return n[`content-type`]=e.type,n[`content-disposition`]=r??NX(e instanceof File?e.name:`blob`),{body:e,headers:n};if(e instanceof FormData){let t=new Response(e);return n[`content-type`]=t.headers.get(`content-type`),{body:await t.blob(),headers:n}}return e instanceof URLSearchParams?(n[`content-type`]=`application/x-www-form-urlencoded`,{body:e.toString(),headers:n}):JY(e)?(n[`content-type`]=`text/event-stream`,{body:void 0,headers:n}):{body:e,headers:n}}async function DZ(e,t,n){let r=IX(e[`content-type`]),i=IX(e[`content-disposition`]);if(typeof i==`string`){let e=PX(i)??`blob`;return new File(n===void 0?[]:[n],e,{type:r})}return r?.startsWith(`multipart/form-data`)?new Response(n,{headers:{"content-type":r}}).formData():r?.startsWith(`application/x-www-form-urlencoded`)&&typeof t==`string`?new URLSearchParams(t):t}async function OZ(e,t){let n=nX(e);return t===void 0||t.size===0?n:LY(new Blob([new TextEncoder().encode(n),new Uint8Array([255]),t]))}async function kZ(e){if(typeof e==`string`)return{json:JSON.parse(e)};let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.indexOf(255);if(n===-1){let e=new TextDecoder().decode(t);return{json:JSON.parse(e)}}let r=new TextDecoder().decode(t.subarray(0,n)),i=t.subarray(n+1);return{json:JSON.parse(r),buffer:i}}function AZ(e,t,n,r={}){let i;return new ZY(async()=>{i??=HY(`consume_event_iterator_stream`);try{let n=await KY(i,()=>e.pull(t));switch(n.event){case`message`:{let e=n.data;return n.meta&&aX(e)&&(e=AX(e,n.meta)),i?.addEvent(`message`),{value:e,done:!1}}case`error`:{let e=new TX({data:n.data});throw n.meta&&(e=AX(e,n.meta)),i?.addEvent(`error`),e}case`done`:{let e=n.data;return n.meta&&aX(e)&&(e=AX(e,n.meta)),i?.addEvent(`done`),{value:e,done:!0}}}}catch(e){throw e instanceof TX||UY(i,e,r),e}},async e=>{try{e!==`next`&&i?.addEvent(`cancelled`),await KY(i,()=>n(e))}catch(e){throw UY(i,e,r),e}finally{i?.end()}})}function jZ(e,t){return GY({name:`stream_event_iterator`},async n=>{for(;;){let r=await(async()=>{try{let{value:t,done:r}=await e.next();return r?(n?.addEvent(`done`),{event:`done`,data:t,meta:jX(t)}):(n?.addEvent(`message`),{event:`message`,data:t,meta:jX(t)})}catch(e){if(e instanceof TX)return n?.addEvent(`error`),{event:`error`,data:e.data,meta:jX(e)};try{await t({event:`error`,data:void 0})}catch(t){throw UY(n,e),t}throw e}})(),i=!1;try{let n=await t(r);if(r.event===`done`||r.event===`error`)return;if(n===`abort`){i=!0,await e.return?.();return}}catch(t){if(!i)try{await e.return?.()}catch(e){throw UY(n,t),e}throw t}}})}var MZ=class{peer;constructor(e){this.peer=new NZ(async([t,n,r])=>{await e(await SZ(t,n,r))})}get length(){return this.peer.length}open(e){return this.peer.open(e)}async request(e){return this.peer.request(e)}async message(e){return this.peer.message(await TZ(e))}close(e={}){return this.peer.close(e)}},NZ=class{idGenerator=new $Y;responseQueue=new qY;serverEventIteratorQueue=new qY;serverControllers=new Map;cleanupFns=new Map;send;constructor(e){this.send=async t=>{let n=t[0];this.serverControllers.has(n)&&await e(t)}}get length(){return(+this.responseQueue.length+this.serverEventIteratorQueue.length+this.serverControllers.size+this.cleanupFns.size)/4}open(e){this.serverEventIteratorQueue.open(e),this.responseQueue.open(e);let t=new AbortController;return this.serverControllers.set(e,t),this.cleanupFns.set(e,[]),t}async request(e){let t=e.signal;return GY({name:`send_peer_request`,signal:t},async()=>{if(t?.aborted)throw t.reason;let n=this.idGenerator.generate(),r=this.open(n);try{let i=VY();if(i){let t=oX(e.headers);i.propagation.inject(i.context.active(),t),e={...e,headers:t}}if(await this.send([n,_Z.REQUEST,e]),t?.aborted)throw await this.send([n,_Z.ABORT_SIGNAL,void 0]),t.reason;let a;if(t?.addEventListener(`abort`,a=async()=>{await this.send([n,_Z.ABORT_SIGNAL,void 0]),this.close({id:n,reason:t.reason})},{once:!0}),this.cleanupFns.get(n)?.push(()=>{t?.removeEventListener(`abort`,a)}),JY(e.body)){let t=e.body;jZ(t,async e=>r.signal.aborted?`abort`:(await this.send([n,_Z.EVENT_ITERATOR,e]),`next`))}let o=await this.responseQueue.pull(n);if(LX(o.headers)){let e=AZ(this.serverEventIteratorQueue,n,async e=>{try{e!==`next`&&await this.send([n,_Z.ABORT_SIGNAL,void 0])}finally{this.close({id:n})}},{signal:t});return{...o,body:e}}return this.close({id:n}),o}catch(e){throw this.close({id:n,reason:e}),e}})}async message([e,t,n]){if(t===_Z.ABORT_SIGNAL){this.serverControllers.get(e)?.abort();return}if(t===_Z.EVENT_ITERATOR){this.serverEventIteratorQueue.isOpen(e)&&this.serverEventIteratorQueue.push(e,n);return}this.responseQueue.isOpen(e)&&this.responseQueue.push(e,n)}close(e={}){e.id===void 0?(this.serverControllers.forEach(t=>t.abort(e.reason)),this.serverControllers.clear(),this.cleanupFns.forEach(e=>e.forEach(e=>e())),this.cleanupFns.clear()):(this.serverControllers.get(e.id)?.abort(e.reason),this.serverControllers.delete(e.id),this.cleanupFns.get(e.id)?.forEach(e=>e()),this.cleanupFns.delete(e.id)),this.responseQueue.close(e),this.serverEventIteratorQueue.close(e)}},PZ=class{peer;constructor(e){this.peer=new FZ(async([t,n,r])=>{await e(await wZ(t,n,r))})}get length(){return this.peer.length}open(e){return this.peer.open(e)}async message(e,t){return this.peer.message(await CZ(e),t)}async response(e,t){return this.peer.response(e,t)}close({abort:e=!0,...t}={}){return this.peer.close({...t,abort:e})}},FZ=class{clientEventIteratorQueue=new qY;clientControllers=new Map;send;constructor(e){this.send=async t=>{let n=t[0];this.clientControllers.has(n)&&await e(t)}}get length(){return(this.clientEventIteratorQueue.length+this.clientControllers.size)/2}open(e){this.clientEventIteratorQueue.open(e);let t=new AbortController;return this.clientControllers.set(e,t),t}async message([e,t,n],r){if(t===_Z.ABORT_SIGNAL)return this.close({id:e,reason:new zY(`Client aborted the request`)}),[e,void 0];if(t===_Z.EVENT_ITERATOR)return this.clientEventIteratorQueue.isOpen(e)&&this.clientEventIteratorQueue.push(e,n),[e,void 0];let i=this.open(e).signal,a={...n,signal:i,body:LX(n.headers)?AZ(this.clientEventIteratorQueue,e,async t=>{t!==`next`&&await this.send([e,_Z.ABORT_SIGNAL,void 0])},{signal:i}):n.body};if(r){let t,n=VY();n&&(t=n.propagation.extract(n.context.active(),a.headers)),await GY({name:`receive_peer_request`,context:t},async()=>{let t=await GY({name:`handle_request`},async()=>{try{return await r(a)}catch(t){throw this.close({id:e,reason:t,abort:!1}),t}});await GY({name:`send_peer_response`},()=>this.response(e,t))})}return[e,a]}async response(e,t){let n=this.clientControllers.get(e)?.signal;if(!(!n||n.aborted))try{if(await this.send([e,_Z.RESPONSE,t]),!n.aborted&&JY(t.body))if(t.body instanceof MX)t.body.hibernationCallback?.(e);else{let r=t.body;await jZ(r,async t=>n.aborted?`abort`:(await this.send([e,_Z.EVENT_ITERATOR,t]),`next`))}this.close({id:e,abort:!1})}catch(t){throw this.close({id:e,reason:t,abort:!1}),t}}close({abort:e=!0,...t}={}){t.id===void 0?(e&&this.clientControllers.forEach(e=>e.abort(t.reason)),this.clientControllers.clear()):(e&&this.clientControllers.get(t.id)?.abort(t.reason),this.clientControllers.delete(t.id)),this.clientEventIteratorQueue.close(t)}};function IZ(e){let t;if(typeof e==`string`)t=e;else{let n=e instanceof Uint8Array?e:new Uint8Array(e);t=Buffer.from(n).toString(`utf8`)}return Buffer.from(t+`
|
|
85747
|
-
`,`utf8`)}function LZ(e){let t=[],n=0;for(let r=0;r<e.length;r++)if(e[r]===10){let i=e.subarray(n,r).toString(`utf8`).trim();i&&t.push(i),n=r+1}return[t,e.subarray(n)]}function RZ(e,t){let n=hZ(t,{});try{m.existsSync(e)&&m.unlinkSync(e)}catch{}let r=R.createServer(e=>{let t=new PZ(t=>{!e.destroyed&&e.writable&&e.write(IZ(t))}),r=Buffer.alloc(0);e.on(`data`,async e=>{r=Buffer.concat([r,e]);let[i,a]=LZ(r);r=a;for(let e of i)await t.message(e,n)}),e.on(`close`,()=>{t.close()}),e.on(`error`,()=>{e.destroy(),t.close()})});return new Promise((t,n)=>{r.on(`error`,n),r.listen(e,()=>{r.removeListener(`error`,n),r.on(`error`,()=>{});try{m.chmodSync(e,438)}catch{}t({getSocketPath:()=>e,dispose:()=>{r.close();try{m.existsSync(e)&&m.unlinkSync(e)}catch{}}})})})}var zZ=class{peer;constructor(e){this.peer=e}async call(e){let t=await this.peer.request(e);return{...t,body:()=>Promise.resolve(t.body)}}},BZ=class extends nZ{constructor(e){super(new zZ(e),{url:`orpc:/`})}};function VZ(e,t){let n=t?.timeoutMs??2e3;return new Promise((t,r)=>{let i=R.connect(e),a=setTimeout(()=>{i.destroy(),r(Error(`Connection to ${e} timed out after ${n}ms`))},n);i.on(`connect`,()=>{clearTimeout(a);let e=new MZ(e=>{!i.destroyed&&i.writable&&i.write(IZ(e))}),n=Buffer.alloc(0);i.on(`data`,async t=>{n=Buffer.concat([n,t]);let[r,i]=LZ(n);n=i;for(let t of r)await e.message(t)}),i.on(`close`,()=>e.close()),i.on(`error`,()=>{i.destroy(),e.close()}),t({link:new BZ(e),dispose:()=>{e.close(),i.destroy()}})}),i.on(`error`,e=>{clearTimeout(a),r(e)})})}const HZ=Symbol(`ORPC_LAZY_SYMBOL`);function UZ(e,t={}){return{[HZ]:{loader:e,meta:t}}}function WZ(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&HZ in e}function GZ(e){return e[HZ].meta}function KZ(e){return WZ(e)?e[HZ].loader():Promise.resolve({default:e})}function qZ(e,t){if(t.length>e.length)return!1;for(let n=0;n<e.length;n++){if(t[n]===void 0)return!0;if(e[n]!==t[n])return!1}return!0}function JZ(e,t,n){return n.dedupeLeading&&qZ(t,e)?t:[...e,...t]}function YZ(e,t){return[...e,t]}var XZ=class{"~orpc";constructor(e){this[`~orpc`]=e}};function ZZ(e){return e instanceof XZ?!0:GX(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function QZ(e,t){return{...e,...t}}function $Z(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=FY(t),i=e[n];return new yX(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function eQ(e){return{output:e,context:{}}}function tQ(e,...t){let n=FY(t);return async(...[t,r])=>{let i=IY(n.path),{default:a}=await KZ(e),o=r?.context??{},s=await cX(n.context??{},o),c=$Z(a[`~orpc`].errorMap),l=async e=>e instanceof yX?await UX(a[`~orpc`].errorMap,e):e;try{let e=await GY({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),eX(IY(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>iQ(e.procedure,e))));return JY(e)?e instanceof MX?e:fX(e,RX(QY({name:`consume_event_iterator_output`,signal:r?.signal},e),{value:e=>e,error:e=>l(e)})):e}catch(e){throw await l(e)}}}async function nQ(e,t){let n=e[`~orpc`].inputSchema;return n?GY({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new yX(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new VX({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function rQ(e,t){let n=e[`~orpc`].outputSchema;return n?GY({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new yX(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new VX({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function iQ(e,t){let n=e[`~orpc`].middlewares,r=Math.min(Math.max(0,e[`~orpc`].inputValidationIndex),n.length),i=Math.min(Math.max(0,e[`~orpc`].outputValidationIndex),n.length),a=async(o,s,c)=>{let l=c;o===r&&(l=await nQ(e,l));let u=n[o],d=u?await GY({name:`middleware.${u.name}`,signal:t.signal},async e=>(e?.setAttribute(`middleware.index`,o),e?.setAttribute(`middleware.name`,u.name),(await u({...t,context:s,next:async(...[e])=>{let t=e?.context??{};return{output:await a(o+1,QZ(s,t),l),context:t}}},l,eQ)).output)):await GY({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await rQ(e,d):d};return a(0,t.context,t.input)}const aQ=Symbol(`ORPC_HIDDEN_ROUTER_CONTRACT`);function oQ(e,t){return new Proxy(e,{get(e,n){return n===aQ?t:Reflect.get(e,n)}})}function sQ(e){return e[aQ]}function cQ(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||ZZ(n))return;if(!WZ(n)){n=n[r];continue}let i=n,a=t.slice(e);return UZ(async()=>KZ(cQ((await KZ(i)).default,a)),GZ(i))}return n}function lQ(e){return new Proxy(e,{get(t,n){return typeof n==`string`?lQ(cQ(e,[n])):Reflect.get(t,n)}})}function uQ(e,t){if(WZ(e)){let n=GZ(e),r=n?.prefix?sZ(t.prefix,n?.prefix):t.prefix;return lQ(UZ(async()=>{let{default:n}=await KZ(e);return KZ(uQ(n,t))},{...n,prefix:r}))}if(ZZ(e)){let n=JZ(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new XZ({...e[`~orpc`],route:lZ(e[`~orpc`].route,t),errorMap:HX(t.errorMap,e[`~orpc`].errorMap),middlewares:n,inputValidationIndex:e[`~orpc`].inputValidationIndex+r,outputValidationIndex:e[`~orpc`].outputValidationIndex+r})}let n={};for(let r in e)n[r]=uQ(e[r],t);return n}function dQ(e,t,n=[]){let r=e.router,i=sQ(e.router);if(i!==void 0&&(r=i),WZ(r))n.push({router:r,path:e.path});else if(GX(r))t({contract:r,path:e.path});else for(let i in r)dQ({router:r[i],path:[...e.path,i]},t,n);return n}function fQ(e,t){return new XZ({...e[`~orpc`],errorMap:t[`~orpc`].errorMap,route:t[`~orpc`].route,meta:t[`~orpc`].meta})}const pQ={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function mQ(e,t){return t===void 0?pQ[e]:t}function hQ(e){let t=((...t)=>e(...t));return t.mapInput=t=>hQ((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?hQ(t).mapInput(n):t;return hQ((t,n,i,...a)=>e({...t,next:(...[e])=>r({...t,context:{...t.context,...e?.context},next:(...[n])=>t.next({context:{...e?.context,...n?.context}})},n,i,...a)},n,i,...a))},t}function gQ(e){return async t=>{try{return[null,await e(t)]}catch(e){if(e instanceof Error&&`digest`in e&&typeof e.digest==`string`&&e.digest.startsWith(`NEXT_`)||e instanceof Response&&`options`in e&&iX(e.options)||iX(e)&&e.isNotFound===!0)throw e;return[bX(e).toJSON(),void 0]}}}var _Q=class e extends XZ{errors(t){return new e({...this[`~orpc`],errorMap:HX(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:rZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:iZ(this[`~orpc`].route,t)})}use(t,n){let r=n?hQ(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:YZ(this[`~orpc`].middlewares,r)})}callable(...e){let t=tQ(this,...e);return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}actionable(...e){let t=gQ(tQ(this,...e));return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}},vQ=class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-mQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-mQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:mQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:mQ(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:mQ(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:mQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:mQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)})}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}middleware(e){return hQ(e)}errors(t){return new e({...this[`~orpc`],errorMap:HX(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?hQ(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:YZ(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:rZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:iZ(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:mQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:mQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new _Q({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:sZ(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:cZ(this[`~orpc`].tags,t)})}router(e){return uQ(e,this[`~orpc`])}lazy(e){return uQ(UZ(e),this[`~orpc`])}};new vQ({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:mQ(`initialInputValidationIndex`),outputValidationIndex:mQ(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function yQ(e,t,n){return GX(e)?new vQ({...e[`~orpc`],config:t,middlewares:n,inputValidationIndex:mQ(`initialInputValidationIndex`,t?.initialInputValidationIndex)+n.length,outputValidationIndex:mQ(`initialOutputValidationIndex`,t?.initialOutputValidationIndex)+n.length,dedupeLeadingMiddlewares:mQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}):new Proxy(e,{get:(r,i)=>{if(typeof i!=`string`)return Reflect.get(r,i);let a;i===`middleware`?a=e=>hQ(e):i===`use`?a=r=>yQ(e,t,YZ(n,r)):i===`router`?a=r=>oQ(uQ(r,{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:mQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e):i===`lazy`&&(a=r=>oQ(uQ(UZ(r),{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:mQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e));let o=uZ(r,[i]);if(!o)return a??o;let s=yQ(o,t,n);return a?new Proxy(a,{get(e,t){return Reflect.get(s,t)}}):s}})}function bQ(e,t={}){let n=yQ(e,t,[]),r=new Proxy(n,{get:(t,n)=>{let i;n===`$context`?i=()=>r:n===`$config`&&(i=t=>bQ(e,t));let a=Reflect.get(t,n);return!i||!a||typeof a!=`function`&&typeof a!=`object`?i||a:new Proxy(i,{get(e,t){return Reflect.get(a,t)}})}});return r}var xQ=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e,t){for(let n of this.plugins)n.init?.(e,t)}},SQ=class{constructor(e,t,n,r){this.matcher=t,this.codec=n,new xQ(r.plugins).init(r,e),this.interceptors=IY(r.interceptors),this.clientInterceptors=IY(r.clientInterceptors),this.rootInterceptors=IY(r.rootInterceptors),this.matcher.init(e)}interceptors;clientInterceptors;rootInterceptors;async handle(e,t){let n=t.prefix?.replace(/\/$/,``)||void 0;return n&&!e.url.pathname.startsWith(`${n}/`)&&e.url.pathname!==n?{matched:!1,response:void 0}:eX(this.rootInterceptors,{...t,request:e,prefix:n},async t=>GY({name:`${e.method} ${e.url.pathname}`},async e=>{let n;try{return await eX(this.interceptors,t,async({request:t,context:r,prefix:i})=>{let a=t.method,o=t.url,s=i?o.pathname.replace(i,``):o.pathname,c=await GY({name:`find_procedure`},()=>this.matcher.match(a,`/${s.replace(/^\/|\/$/g,``)}`));if(!c)return{matched:!1,response:void 0};e?.updateName(`${RY}.${c.path.join(`/`)}`),e?.setAttribute(`rpc.system`,RY),e?.setAttribute(`rpc.method`,c.path.join(`.`)),n=`decode_input`;let l=await GY({name:`decode_input`},()=>this.codec.decode(t,c.params,c.procedure));n=void 0,JY(l)&&(l=QY({name:`consume_event_iterator_input`,signal:t.signal},l));let u=tQ(c.procedure,{context:r,path:c.path,interceptors:this.clientInterceptors});n=`call_procedure`;let d=await u(l,{signal:t.signal,lastEventId:IX(t.headers[`last-event-id`])});return n=void 0,{matched:!0,response:this.codec.encode(d,c.procedure)}})}catch(t){n!==`call_procedure`&&UY(e,t);let r=n===`decode_input`&&!(t instanceof yX)?new yX(`BAD_REQUEST`,{message:`Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,cause:t}):bX(t);return{matched:!0,response:this.codec.encodeError(r)}}}))}},CQ=class{constructor(e){this.serializer=e}async decode(e,t,n){let r=e.method===`GET`?tX(e.url.searchParams.getAll(`data`).at(-1)):await e.body();return this.serializer.deserialize(r)}encode(e,t){return{status:200,headers:{},body:this.serializer.serialize(e)}}encodeError(e){return{status:e.status,headers:{},body:this.serializer.serialize(e.toJSON())}}},wQ=class{filter;tree=new sX;pendingRouters=[];constructor(e={}){this.filter=e.filter??!0}init(e,t=[]){let n=dQ({router:e,path:t},t=>{if(!cX(this.filter,t))return;let{path:n,contract:r}=t,i=ZX(n);ZZ(r)?this.tree[i]={path:n,contract:r,procedure:r,router:e}:this.tree[i]={path:n,contract:r,procedure:void 0,router:e}});this.pendingRouters.push(...n.map(e=>({...e,httpPathPrefix:ZX(e.path)})))}async match(e,t){if(this.pendingRouters.length){let e=[];for(let n of this.pendingRouters)if(t.startsWith(n.httpPathPrefix)){let{default:e}=await KZ(n.router);this.init(e,n.path)}else e.push(n);this.pendingRouters=e}let n=this.tree[t];if(n){if(!n.procedure){let{default:e}=await KZ(cQ(n.router,n.path));if(!ZZ(e))throw Error(`
|
|
85748
|
-
[Contract-First] Missing or invalid implementation for procedure at path: ${ZX(n.path)}.
|
|
85749
|
-
Ensure that the procedure is correctly defined and matches the expected contract.
|
|
85750
|
-
`);n.procedure=fQ(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},TQ=class extends SQ{constructor(e,t={}){let n=new tZ(new XX(t)),r=new wQ(t),i=new CQ(n);super(e,r,i,t)}},EQ=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=w.join(t.homedir(),Le.configDirName,`cli`);this.socketPath=w.join(e,`${process.pid}.sock`)}getEditorState(){return{...this.editorState}}onEditorChange(e){this.onEditorStateCallback=e}waitForDecision(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Aborted`));return}let i=()=>{t?.removeEventListener(`abort`,a),this.pendingDecisions.delete(e)},a=()=>{i(),r(Error(`Aborted`))};t?.addEventListener(`abort`,a,{once:!0}),this.pendingDecisions.set(e,{resolve:e=>{i(),n(e)},cleanup:i})})}async start(){let e=w.dirname(this.socketPath);m.existsSync(e)||m.mkdirSync(e,{recursive:!0});let t=bQ(pZ),n=t.router({editorStateChanged:t.editorStateChanged.handler(async({input:e})=>(this.editorState={file:e.file??void 0,startLine:e.startLine,endLine:e.endLine},this.onEditorStateCallback?.(this.editorState),{ok:!0})),toolDecision:t.toolDecision.handler(async({input:e})=>{let t=this.pendingDecisions.get(e.toolId);return t&&t.resolve(e.decision),{ok:!0}})});this.socketServer=await RZ(this.socketPath,new TQ(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},DQ=class{client=null;disposeSocket=null;currentFile=void 0;selectionStartLine=void 0;selectionEndLine=void 0;onFileChangeCallback=null;constructor(e){this.pushServer=e}findSocketPath(){let e=process.env[Le.socketEnvVar];if(e&&h.existsSync(e))return e;try{let e=T.join(n.homedir(),Le.configDirName,Le.ideDirName),t=h.readdirSync(e).filter(e=>e.endsWith(`.sock`));if(t.length===0)return null;let r=null;for(let n of t){let t=T.join(e,n);try{let e=h.statSync(t);(!r||e.mtimeMs>r.mtime)&&(r={path:t,mtime:e.mtimeMs})}catch{}}if(r&&h.existsSync(r.path))return r.path}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await VZ(e,{timeoutMs:2e3});this.client=BX(t.link),this.disposeSocket=()=>t.dispose(),await this.client.register({cliSocketPath:this.pushServer.socketPath,pid:process.pid});let n=this.pushServer.getEditorState();return this.currentFile=n.file,this.selectionStartLine=n.startLine,this.selectionEndLine=n.endLine,this.pushServer.onEditorChange(e=>{this.currentFile=e.file,this.selectionStartLine=e.startLine,this.selectionEndLine=e.endLine,this.onFileChangeCallback?.(e.file,e.startLine,e.endLine)}),!0}catch{return!1}}getCurrentFile(){return this.currentFile}getSelectionRange(){return{startLine:this.selectionStartLine,endLine:this.selectionEndLine}}isConnected(){return this.client!==null}onFileChange(e){this.onFileChangeCallback=e}async showDiff(e){if(!this.client)return!1;try{return(await this.client.showDiff({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async showToolView(e){if(!this.client)return!1;try{return(await this.client.showToolView({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async notifyDiffDecision(e){if(!this.client)throw Error(`Not connected to extension`);await this.client.notifyDiffDecision(e)}async openPlanFile(e){if(!this.client)throw Error(`Not connected to extension`);return{opened:(await this.client.openFile({file:e})).success}}async getDiagnostics(e){if(!this.client)throw Error(`Not connected to extension`);return this.client.getDiagnostics({...e&&{files:e}})}dispose(){this.disposeSocket?.(),this.disposeSocket=null,this.client=null,this.currentFile=void 0,this.selectionStartLine=void 0,this.selectionEndLine=void 0,this.onFileChangeCallback=null}};const OQ=(0,X.createContext)(null);function kQ(){let e=(0,X.use)(OQ);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function AQ({children:e,initialFile:t}){let[n,r]=(0,X.useState)(t),[i,a]=(0,X.useState)(void 0),[o,s]=(0,X.useState)(void 0),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=!1;return(async()=>{let t=new EQ;try{await t.start()}catch{}if(e){t.dispose();return}p.current=t,d(t),t.onEditorChange(e=>{r(e.file),a(e.startLine),s(e.endLine)});for(let n of[0,...[500,1e3,2e3,3e3,4e3]]){if(e||(n>0&&await new Promise(e=>setTimeout(e,n)),e))return;try{let n=new DQ(t);if(await n.connect()){if(e){n.dispose();return}let i=t.getEditorState();r(i.file),a(i.startLine),s(i.endLine),n.onFileChange((e,t,n)=>{r(e),a(t),s(n)}),f.current=n,l(n);return}}catch{}}})(),()=>{e=!0,f.current&&(f.current.dispose(),f.current=null,l(null)),p.current&&(p.current.dispose(),p.current=null,d(null))}},[]),(0,Y.jsx)(OQ.Provider,{value:{currentFile:n,selectionStartLine:i,selectionEndLine:o,connection:c,pushServer:u},children:e})}const jQ=(0,X.createContext)(null);function MQ({children:e}){let[t,n]=(0,X.useState)(`idle`),r=(0,X.useCallback)(()=>n(`upload`),[]),i=(0,X.useCallback)(()=>n(`download`),[]),a=(0,X.useCallback)(()=>n(`idle`),[]),o=(0,X.useMemo)(()=>({activity:t,setActivity:n,startUpload:r,startDownload:i,stopActivity:a}),[t,r,i,a]);return(0,Y.jsx)(jQ.Provider,{value:o,children:e})}function NQ(){let e=(0,X.use)(jQ);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}let PQ=function(e){return e.ESC=`\x1B`,e.BEL=`\x07`,e.ST=`\x1B\\`,e.ENABLE_FOCUS_REPORTING=`${e.ESC}[?1004h`,e.DISABLE_FOCUS_REPORTING=`${e.ESC}[?1004l`,e.FOCUS_IN=`${e.ESC}[I`,e.FOCUS_OUT=`${e.ESC}[O`,e.SHOW_CURSOR=`${e.ESC}[?25h`,e.HIDE_CURSOR=`${e.ESC}[?25l`,e.SET_TITLE=`${e.ESC}]2;`,e.RESET_SGR=`${e.ESC}[0m`,e.SOFT_RESET=`${e.ESC}[!p`,e.HARD_RESET=`${e.ESC}c`,e.ENABLE_BRACKETED_PASTE=`${e.ESC}[?2004h`,e.DISABLE_BRACKETED_PASTE=`${e.ESC}[?2004l`,e.PASTE_MODE_PREFIX=`${e.ESC}[200~`,e.PASTE_MODE_SUFFIX=`${e.ESC}[201~`,e.DIM=`${e.ESC}[2m`,e.BOLD=`${e.ESC}[1m`,e.RESET_BOLD=`${e.ESC}[22m`,e.ITALIC=`${e.ESC}[3m`,e.RESET_ITALIC=`${e.ESC}[23m`,e.STRIKETHROUGH=`${e.ESC}[9m`,e.RESET_STRIKETHROUGH=`${e.ESC}[29m`,e.UNDERLINE=`${e.ESC}[4m`,e.RESET_UNDERLINE=`${e.ESC}[24m`,e}({});function FQ(e){return`${PQ.ESC}]9;\n\n${e}${PQ.BEL}`}function IQ(e,t){return`${PQ.ESC}]777;notify;${e};${t}${PQ.BEL}`}function LQ(e,t){let n=Math.floor(Math.random()*1e4),r=`${PQ.ESC}]99;i=${n}:d=0:p=title;${e}${PQ.ST}`,i=`${PQ.ESC}]99;i=${n}:p=body;${t}${PQ.ST}`,a=`${PQ.ESC}]99;i=${n}:d=1:a=focus;${PQ.ST}`;return r+i+a}function RQ(e,t){let n=`9;4;${e};${t===void 0?0:Math.max(0,Math.min(100,Math.round(t)))}`;return`${PQ.ESC}]${n}${PQ.BEL}${PQ.ESC}]${n}${PQ.ST}`}function zQ(e){return e.replaceAll(`\x1B`,``).replaceAll(`\x07`,``).replaceAll(`
|
|
85751
|
-
`,` `).replaceAll(`\r`,` `).replaceAll(`;`,`:`).trim().slice(0,120)}function BQ(e){return`${PQ.ESC}]${e}${PQ.BEL}${PQ.ESC}]${e}${PQ.ST}`}function VQ(){return BQ(`1337;Progress=`)}function HQ(e){return BQ(`1337;Progress=${e}`)}function UQ(e,t){let n=Math.max(0,Math.min(100,Math.round(e))),r=t?zQ(t):``;return r?BQ(`1337;Progress=${n};${r}`)+BQ(`1337;Progress=message=${r};percent=${n}`):BQ(`1337;Progress=${n}`)}function WQ({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const GQ=WQ();function KQ(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(GQ,``)}const qQ=[`pycharm`,`intellij`,`webstorm`,`phpstorm`,`rubymine`,`clion`,`goland`,`rider`,`datagrip`,`appcode`,`dataspell`,`aqua`,`gateway`,`fleet`,`jetbrains`,`androidstudio`];function JQ(e){if(V.env.CURSOR_TRACE_ID)return e?.debug?.(`Detected Cursor terminal via CURSOR_TRACE_ID`),`cursor`;if(V.env.VSCODE_GIT_ASKPASS_MAIN?.includes(`/.cursor-server/`))return e?.debug?.(`Detected Cursor terminal via VSCODE_GIT_ASKPASS_MAIN`),`cursor`;if(V.env.VSCODE_GIT_ASKPASS_MAIN?.includes(`/.windsurf-server/`))return e?.debug?.(`Detected Windsurf terminal`),`windsurf`;let t=V.env.__CFBundleIdentifier?.toLowerCase();if(t?.includes(`vscodium`))return`codium`;if(t?.includes(`windsurf`))return`windsurf`;if(t?.includes(`com.google.android.studio`))return`androidstudio`;if(t){for(let e of qQ)if(t.includes(e))return e}if(V.env.VisualStudioVersion)return`visualstudio`;if(V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`)return`pycharm`;if(V.env.TERM===`xterm-ghostty`)return`ghostty`;if(V.env.TERM?.includes(`kitty`))return`kitty`;if(V.env.WEZTERM_PANE)return`WezTerm`;if(V.env.ITERM_SESSION_ID)return`iTerm.app`;if(V.env.TERM_PROGRAM===`Apple_Terminal`)return`Apple_Terminal`;if(V.env.TERM_PROGRAM)return V.env.TERM_PROGRAM;if(V.env.STY)return`screen`;if(V.env.KONSOLE_VERSION)return`konsole`;if(V.env.GNOME_TERMINAL_SERVICE)return`gnome-terminal`;if(V.env.XTERM_VERSION)return`xterm`;if(V.env.VTE_VERSION)return`vte-based`;if(V.env.TERMINATOR_UUID)return`terminator`;if(V.env.KITTY_WINDOW_ID)return`kitty`;if(V.env.ALACRITTY_LOG)return`alacritty`;if(V.env.TILIX_ID)return`tilix`;if(V.env.WT_SESSION)return`windows-terminal`;if(V.env.SESSIONNAME&&V.env.TERM===`cygwin`)return`cygwin`;if(V.env.MSYSTEM)return V.env.MSYSTEM.toLowerCase();if(V.env.ConEmuANSI||V.env.ConEmuPID||V.env.ConEmuTask)return`conemu`;if(V.env.WSL_DISTRO_NAME)return`wsl-${V.env.WSL_DISTRO_NAME}`;if(V.env.SSH_CONNECTION||V.env.SSH_CLIENT||V.env.SSH_TTY)return`ssh-session`;if(V.env.TERM){let e=V.env.TERM;return e.includes(`alacritty`)?`alacritty`:e.includes(`rxvt`)?`rxvt`:e.includes(`termite`)?`termite`:V.env.TERM}return V.stdout.isTTY?(e?.debug?.(`Could not detect terminal type`),null):(e?.debug?.(`Non-interactive terminal detected`),`non-interactive`)}function YQ(){switch(JQ()){case`Apple_Terminal`:return`Option+Enter`;case`cursor`:case`windsurf`:case`vscode`:case`codium`:case`iTerm.app`:case`ghostty`:case`WezTerm`:case`kitty`:case`alacritty`:return`Shift+Enter`;default:return`backslash (\\) + Enter`}}function XQ(e){V.stdout.isTTY&&V.stdout.write(e)}function ZQ(e,t){XQ(FQ(e?`${e}:\n${t}`:t))}function QQ(e,t){XQ(LQ(e,t))}function $Q(e,t){XQ(IQ(e,t))}function e$(e,t){XQ(PQ.BEL)}async function t$(e){let{title:t=`Abacus.AI`,message:n}=e;switch(JQ()){case`iTerm.app`:ZQ(t,n);break;case`kitty`:QQ(t,n);break;case`ghostty`:$Q(t,n);break;case`WezTerm`:ZQ(t,n);break;default:V.platform===`win32`&&e$(t,n);break}}async function n$(e,t){await t$({...t,message:e,title:t?.title??`Action Required`})}async function r$(e,t){await t$({...t,message:e,title:t?.title??`Task Complete`})}const i$=(0,X.createContext)(null),a$=()=>{let e=(0,X.use)(i$);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e},o$=({children:e})=>{let{isFocused:t}=WL(),n=(0,X.useCallback)(async(e,n)=>{t||await t$({message:e,title:n})},[t]),r=(0,X.useCallback)(async e=>{t||await n$(e)},[t]),i=(0,X.useCallback)(async e=>{t||await r$(e)},[t]),a=(0,X.useMemo)(()=>({notifyIfUnfocused:n,notifyActionRequired:r,notifyTaskComplete:i}),[n,r,i]);return(0,Y.jsx)(i$.Provider,{value:a,children:e})},s$=(0,X.createContext)(null),c$=()=>{let e=(0,X.use)(s$);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},l$=(0,X.memo)(({children:e,client:t,authManager:n,onAuthExpired:r})=>{let[i,a]=(0,X.useState)(!1),o=(0,X.useCallback)(()=>a(!1),[]),s=(0,X.useMemo)(()=>({apiClient:t,authManager:n,authExpired:i,setAuthExpired:a,clearAuthExpired:o,onAuthExpired:r}),[i,t,n,o,r]);return(0,Y.jsx)(s$.Provider,{value:s,children:e})});l$.displayName=`ApiClientProvider`;const u$=[`conemu`,`ghostty`,`windows-terminal`,`WezTerm`,`iTerm.app`];let d$=null;function f$(e){if(!e||!V.stdout.isTTY)return!1;if(u$.includes(e))return!0;let t=e.toLowerCase();return t.includes(`iterm`)||t.includes(`ghostty`)||t.includes(`wezterm`)||t.includes(`conemu`)}function p$(e){V.stdout.write(e)}function m$(e){switch(e){case`indeterminate`:return 3;case`error`:return 2;case`warning`:return 4;default:return 1}}function h$(){d$&&=(clearTimeout(d$),null)}function g$(){h$(),d$=setTimeout(()=>{_$()},500)}function _$(){let e=JQ();f$(e)&&(p$(RQ(0)),e?.toLowerCase().includes(`iterm`)&&p$(VQ()))}function v$(e,t){if(e instanceof Promise)return b$(e,t);let n=e,r=JQ();if(!f$(r))return;h$();let i=0;n.percentage===void 0?n.total!==void 0&&n.current!==void 0&&n.total>0&&(i=n.current/n.total*100):i=n.percentage;let a=n.state??`default`;p$(RQ(m$(a),i)),r?.toLowerCase().includes(`iterm`)&&(a===`indeterminate`?p$(HQ(2)):(p$(UQ(i,n.label)),i>=100&&p$(HQ(1)))),(a===`error`||i>=100)&&g$()}function y$(){h$(),_$()}async function b$(e,t){let{label:n,hideOnComplete:r=!0}=t??{};v$({state:`indeterminate`,label:n});try{let t=await e;return v$({percentage:100,state:`default`,label:n}),r&&g$(),t}catch(e){throw v$({percentage:100,state:`error`,label:n}),r&&g$(),e}}const x$=(0,X.createContext)(null);function S$(e,t){switch(t.type){case`INIT_SEND`:return[...e.filter(e=>e.temp!==!0),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=e.map(e=>e.type===`code_llm_tool_call`&&e.status===`transient`&&!e.toolUseResult?{...e,status:`completed`,parsedResult:{phase:`error`,toolType:Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.name??``:e.toolUseRequest?.name??``,data:{},summary:``}}:e).filter(e=>!e.isSpinny);return i.find(e=>e.id===n)?i.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...i,{id:n,status:`transient`,source:`bot`,type:`text`,segment:r}]}case`THINKING_DELTA`:{let{segId:n,content:r,startTime:i}=t;return e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...e,{id:n,status:`transient`,source:`bot`,type:`thinking`,isSpinny:!0,segment:r,thinkingStartTime:i}]}case`THINKING_COMPLETE`:return e.map(e=>e.id===t.segId?{...e,status:`completed`,isSpinny:!1,thinkingEndTime:t.endTime}:e);case`TOOL_DISPLAY_DATA`:return e.map(e=>e.id===t.toolCallId?{...e,toolDisplayData:{...e.toolDisplayData,...t.data}}:e);case`TOOL_REQUESTED`:{let{textSegId:n,toolSeg:r}=t,i;return i=n?e.filter(e=>!e.isSpinny).map(e=>e.id===n?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...i,r]}case`TOOL_EXECUTION_COMPLETE`:{let{toolCallId:n,rawResult:r,parsedResult:i,spinnySeg:a}=t;return[...e.map(e=>e.id===n?{...e,status:`completed`,toolUseResult:r,...i!==void 0&&{parsedResult:i}}:e),a]}case`TOOL_USER_MESSAGE`:return[...e,t.seg];case`TEXT_COMPLETED`:return e.map(e=>e.id===t.segId?{...e,status:`completed`}:e);case`FINALIZE`:{let n=e;return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n.filter(e=>!e.isSpinny)}case`ADD_NOTIFICATION`:{let n=t.seg,r=e[e.length-1];if(r&&r.type===`code_llm_notification`&&r.message===n.message&&r.severity===n.severity){let t=[...e];return t[t.length-1]={...r,flashKey:(r.flashKey??0)+1},t}return[...e,n]}case`ERROR`:return[...e.filter(e=>!e.isSpinny),t.errorSeg];case`REMOVE_USER_SEG`:return e.filter(e=>e.id!==t.userSegId);case`CLEAR`:return[];case`LOAD`:return t.segments;case`REMOVE_TEMP`:return e.some(e=>e.temp===!0)?e.filter(e=>e.temp!==!0):e;default:return e}}function C$(e){switch(e.type){case`text`:return{id:e.id,status:`completed`,source:e.source,type:`text`,segment:e.content};case`thinking`:return{id:e.id,status:`completed`,source:`bot`,type:`thinking`,segment:e.content,isSpinny:e.isSpinny,...e.title!==void 0&&{title:e.title}};case`tool_call`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:e.toolUseRequest,toolUseResult:e.toolUseResult??{id:e.toolUseRequest.id,content:` `},...e.parsedResult!==void 0&&{parsedResult:e.parsedResult},...e.toolDisplayData!==void 0&&{toolDisplayData:e.toolDisplayData}};case`notification`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:e.severity,...e.actions!==void 0&&{actions:e.actions}};case`tool_group`:return{id:e.id,status:`completed`,source:`bot`,type:`text`,segment:e.summary}}}const w$=(0,X.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=FJ(),o=(0,X.useRef)(i),{notifyActionRequired:s,notifyTaskComplete:c}=a$(),{startUpload:l,startDownload:u,stopActivity:d}=NQ(),{authManager:f,setAuthExpired:p,onAuthExpired:m}=c$(),{connection:h,pushServer:g}=kQ(),_=(0,X.useRef)(h),v=(0,X.useRef)(g);(0,X.useEffect)(()=>{_.current=h},[h]),(0,X.useEffect)(()=>{v.current=g},[g]);let[y,b]=(0,X.useState)(Cl.Idle),[x,S]=(0,X.useReducer)(S$,[]),C=(0,X.useRef)(new Map),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(!0),[ee,L]=(0,X.useState)(!0),R=(0,X.useRef)(!0),z=(0,X.useRef)(null),B=(0,X.useRef)(Cl.Idle),te=(0,X.useCallback)(e=>{B.current=e,b(e)},[]);(0,X.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]);let ne=(0,X.useMemo)(()=>({}),[]),[re,ie]=(0,X.useState)(null),ae=process.cwd(),oe=(0,X.useMemo)(()=>new PD(async e=>{let t=_.current,n=e,r=null;if(t&&v.current&&e.type===`edit_file`){let i=e.tool.id,a=C.current.get(i),o=e.tool.input??{},s=o.targetFile??e.filePath??``,c=a?.originalContent??e.originalContent??``,l=a?.newContent??e.newContent??o.codeEdit??``;s&&(c||l)&&await t.showDiff({filePath:s,originalContent:c,modifiedContent:l,toolId:i})&&(n={...e,diffShownInEditor:!0},r=s)}if(t&&e.type===`exit_plan_mode`&&e.planFilePath){let n=e.tool.id;if(v.current&&await t.showToolView({filePath:e.planFilePath,toolKey:n})){let e=await v.current.waitForDecision(n);return e===`allowAlways`?`allowAlways`:e}await t.openPlanFile(e.planFilePath).catch(()=>{})}let i=await new Promise(t=>{let i=!1;r&&v.current&&v.current.waitForDecision(e.tool.id).then(e=>{i||(i=!0,O(null),te(e===`accept`||e===`allowAlways`?Cl.ExecutingTool:Cl.Submitted),t(e))}).catch(()=>{}),O({request:n,resolve:e=>{i||(i=!0,O(null),te(e===`accept`||e===`allowAlways`||typeof e==`object`&&e.type===`accept_with_message`||typeof e==`object`&&e.type===`question_answers`?Cl.ExecutingTool:Cl.Submitted),setTimeout(()=>t(e),0).unref())}}),te(Cl.WaitingForToolPermission),s(`Abacus.AI is waiting for your input`)});if(r&&t){let e=i===`reject`||typeof i==`object`&&i.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return i}),[s,te]),se=(0,X.useRef)(null);function ce(){return new MD({allowedDirectories:[ae,...r?.[`add-dir`]?.map(e=>T.isAbsolute(e)?e:T.resolve(ae,e))??[]],primaryWorkspace:ae,apiClient:t,mode:o.current,permissionProvider:oe,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=_.current;return t?t.getDiagnostics(e):[]}},cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`]})}se.current||=ce();let le=se.current;(0,X.useEffect)(()=>{o.current=i,le.setMode(i)},[i,le]),(0,X.useEffect)(()=>{_D.loadSkills(ae)},[]),(0,X.useEffect)(()=>{r?.conversationId&&V(r.conversationId)},[]),(0,X.useEffect)(()=>{switch(y){case Cl.Submitted:case Cl.Streaming:v$({state:`indeterminate`,label:`Processing`});break;case Cl.ExecutingTool:v$({state:`indeterminate`,label:`Executing tools`});break;case Cl.WaitingForToolPermission:y$();break;case Cl.Idle:y$();break}},[y]);let ue=(0,X.useCallback)((e,t=`info`,n=!1)=>{S({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),de=(0,X.useCallback)(()=>{S({type:`CLEAR`}),E(null),te(Cl.Idle),ie(null),C.current.clear(),se.current=ce()},[t,ae,oe]),fe=(0,X.useCallback)(()=>{S({type:`CLEAR`})},[]),pe=(0,X.useCallback)(()=>{S({type:`REMOVE_TEMP`})},[]),me=(0,X.useCallback)(()=>{let e=le.dequeue();le.clearQueue(),A([]),e!==null&&M(e),le.stop(),O(null),te(Cl.Idle)},[le,te]),he=(0,X.useCallback)(()=>{D&&D.resolve(`reject`)},[D]),V=(0,X.useCallback)(async e=>{te(Cl.LoadingConversation),S({type:`CLEAR`}),E(null),ie(e);try{let t=await le.loadConversation(e);t.title&&E(t.title),t.segments.length>0&&S({type:`LOAD`,segments:t.segments.map(e=>C$(e))})}catch{ue(`Failed to load conversation`,`error`)}finally{te(Cl.Idle)}},[le,ue,te]),ge=(0,X.useCallback)(async(e,t)=>{await le.mcp.refresh(),t&&ue(`MCP tools refreshed`,`info`,!0)},[le,ue]),_e=(0,X.useCallback)(async({message:e,selectedModel:t,fileAttachments:n,activeSkills:r})=>{if(!e||y===Cl.LoadingConversation)return;t&&le.setModel(t);let i=e;if(n&&n.length>0){let e=n.filter(e=>!e.mimeType.startsWith(`image/`));for(let t of e){let e=typeof t.content==`string`?t.content:t.content.toString(`utf-8`);i+=`\n\n<file path="${t.filePath}">\n${e}\n</file>`}}let o=crypto.randomUUID();S({type:`INIT_SEND`,userSeg:{id:o,status:`completed`,source:`user`,type:`text`,segment:e},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),te(Cl.Submitted),l();let s=null,h=null,g,v=_.current,b=v?.getCurrentFile(),x=v?.getSelectionRange();if(v&&b)try{let e=(await v.getDiagnostics([b])).filter(e=>e.severity===`error`||e.severity===`warning`);e.length>0&&(g=e.map(e=>`${e.file}:${e.line}:${e.column} [${e.severity}] ${e.message}`).join(`
|
|
85752
|
-
`))}catch{}try{for await(let e of le.send(i,{diagnosticIssues:g,currentFile:b??void 0,selectionStartLine:x?.startLine,selectionEndLine:x?.endLine,activeSkills:r}))switch(e.type){case`text_delta`:{te(Cl.Streaming),d(),u();let t=e.content;s||=crypto.randomUUID(),S({type:`TEXT_DELTA`,segId:s,content:t});break}case`thinking_delta`:{let t=e.content;h||=crypto.randomUUID(),S({type:`THINKING_DELTA`,segId:h,content:t,startTime:Date.now()});break}case`thinking_complete`:h&&=(S({type:`THINKING_COMPLETE`,segId:h,endTime:Date.now()}),null);break;case`tool_display_data`:{let{toolCallId:t,data:n}=e,r=C.current.get(t)??{};C.current.set(t,{...r,...n}),S({type:`TOOL_DISPLAY_DATA`,toolCallId:t,data:n});break}case`tool_requested`:{te(Cl.ExecutingTool),d(),l();let t=e.tool.id,n={id:t,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:t,name:e.tool.name,input:e.tool.input},toolDisplayData:C.current.get(t)};S({type:`TOOL_REQUESTED`,toolCallId:t,textSegId:s,toolSeg:n}),s=null;break}case`tool_execution_complete`:{d(),u();let t=e.tool.id,{parsedResult:n,...r}=e.result,i={id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Analyzing result`,temp:!0,isSpinny:!0};S({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n},spinnySeg:i}),s=null;break}case`notification`:S({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:e.severity,message:e.message,...e.actions!==void 0&&{actions:e.actions}}});break;case`error`:S({type:`ERROR`,errorSeg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:`error`,message:e.error.message}});break;case`mode_changed`:a(e.mode);break;case`tool_user_message`:S({type:`TOOL_USER_MESSAGE`,seg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.message}});break;case`retry`:P({attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,isNetworkError:e.isNetworkError});break;case`network_status`:e.online?(z.current&&=(clearTimeout(z.current),null),R.current=!0,I(!0),L(!0),P(null),setTimeout(()=>{if(B.current===Cl.Idle&&le.getQueue().length>0){let e=le.dequeue();if(e){A(le.getQueue());let t=_D.matchSkill(e.trim());_e(t?{message:e,activeSkills:[t.skill.id]}:{message:e})}}},0).unref?.()):(R.current=!1,I(!1),z.current||=setTimeout(()=>{z.current=null,R.current||L(!1)},3e4));break;case`user_message_dequeued`:S({type:`INIT_SEND`,userSeg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.content},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),A(le.getQueue()),s=null,h=null;break;case`turn_complete`:s&&=(S({type:`TEXT_COMPLETED`,segId:s}),null),A(le.getQueue());break}}catch(e){if(e instanceof Ae)f.isEnvAuth()||(p(!0),f.logout().catch(()=>{}).finally(()=>{m?.()})),S({type:`REMOVE_USER_SEG`,userSegId:o}),ue(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Pe(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;S({type:`REMOVE_USER_SEG`,userSegId:o}),ue(t,`error`,!0)}M(i),le.clearQueue(),A([])}finally{d(),P(null);let e=le.getConversationId();e&&ie(e),S({type:`FINALIZE`,textSegId:s}),te(Cl.Idle),c(`Abacus.AI completed the task`)}},[le,y,ue,c,l,u,d,a,f,p]),ve=(0,X.useCallback)(e=>{le.enqueue(e),A(le.getQueue())},[le]),ye=(0,X.useCallback)(()=>{le.dequeue(),A(le.getQueue())},[le]),be=(0,X.useCallback)(()=>{le.clearQueue(),A([])},[le]),xe=(0,X.useCallback)(()=>{M(null)},[]),Se=(0,X.useCallback)(e=>le.isDirectoryAllowed(e),[le]),Ce=(0,X.useCallback)((e,t)=>le.addAllowedDirectory(e,t),[le]),we=(0,X.useCallback)(()=>le.listTerminalSessions(),[le]),Te=(0,X.useMemo)(()=>({conversationId:re,conversationTitle:w,segments:x,segmentsLength:x.length,sendMessage:_e,stop:me,rejectPendingPermission:he,agentStatus:y,clearSegments:de,clearSegmentsOnly:fe,clearTempSegments:pe,loadConversation:V,addNotification:ue,mcp:le.mcp,isDirectoryAllowed:Se,addAllowedDirectory:Ce,pendingToolPermission:D,refreshMcpTools:ge,queuedMessages:k,addToQueue:ve,removeFirstFromQueue:ye,clearQueue:be,dequeuedOnStop:j,clearDequeuedOnStop:xe,activeToolOutputs:ne,retryState:N,networkOnline:F,debouncedNetworkOnline:ee,listTerminalSessions:we}),[re,w,x,_e,me,he,y,de,fe,pe,V,ue,le,Se,Ce,D,ge,k,ve,ye,be,j,xe,ne,N,F,ee,we]);return(0,Y.jsx)(x$.Provider,{value:Te,children:e})});w$.displayName=`AgentProvider`;function T$(){let e=(0,X.use)(x$);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${w$.name}>?`);return e}const E$=q({query:K(),includePattern:K().optional(),excludePattern:K().optional(),explanation:K().optional()}),D$={displayName:`FileSearch`,getHeaderParams(e){try{return`pattern: "${e?.query||`[no pattern]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=E$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=[`pattern: "${i.query}"`];i.includePattern&&a.push(`path: "${i.includePattern}"`),i.excludePattern&&a.push(`exclude: "${i.excludePattern}"`);let o=a.join(`, `);return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error searching files`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`executing`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`pending`})})}};function O$(e){let t=[];return e.pattern&&t.push(`pattern: "${e.pattern}"`),e.path&&t.push(`path: "${e.path}"`),t.length>0?t.join(`, `):`[no pattern]`}const k$={displayName:`Search`,getHeaderParams(e){try{return O$(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=O$(e);if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error matching files`})]});if(t===`executing`)return(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`executing`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`pending`})});let i=n.data.files??[],a=i.slice(0,10),o=i.length-a.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`success`}),(0,Y.jsx)(_J,{children:n.summary}),i.length>0&&(0,Y.jsxs)(vJ,{children:[a.map((e,t)=>(0,Y.jsx)(Q,{dimColor:!0,children:e},t)),o>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,o,` more file`,o===1?``:`s`]})]})]})}};function A$(e){let t=e,n=[];t.pattern&&n.push(`pattern: "${t.pattern}"`),t.path&&n.push(`path: "${t.path}"`);let r=t.outputMode||e.output_mode;return r&&n.push(`outputMode: "${r}"`),t.glob&&n.push(`glob: "${t.glob}"`),t[`-i`]&&n.push(`case-insensitive`),n.length>0?n.join(`, `):`[no pattern]`}const j$={displayName:`Search`,getHeaderParams(e){try{return A$(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=A$(e);if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error searching content`})]});if(t===`executing`)return(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`executing`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`pending`})});let i=n.data.matches??[],a=i.slice(0,10),o=i.length-a.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`success`}),(0,Y.jsx)(_J,{children:n.summary}),i.length>0&&(0,Y.jsxs)(vJ,{children:[a.map((e,t)=>(0,Y.jsx)(Q,{dimColor:!0,children:e},t)),o>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,o,` more match`,o===1?``:`es`]})]})]})}},M$=q({query:K(),command:K().optional(),explanation:K().optional()}),N$={displayName:`Search`,getHeaderParams(e){try{return`"${e?.query||``}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=M$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`"${r.data.query}"`;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing semantic search`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`executing`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:`Completed`})]})}},P$=q({url:K()}),F$={displayName:`Web Fetch`,getHeaderParams(e){try{let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t}catch{return`[unknown]`}},renderUI(e,t,n){let r=P$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Fetched content`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`pending`})})}},I$=q({searchTerm:K(),query:K().optional(),explanation:K().optional(),allowedDomains:sc(K()).optional(),blockedDomains:sc(K()).optional()}),L$={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=I$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.searchTerm||i.query||``,o=`"${a.length>40?a.substring(0,37)+`...`:a}"`;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`success`}),(0,Y.jsx)(_J,{children:`Found results`})]})}},R$=q({shellId:K(),filter:K().optional()}),z$={displayName:`TerminalOutput`,getHeaderParams(e){try{let t=e,n=[`id: ${t.shellId||``}`];return t.filter&&n.push(`filter: ${t.filter}`),n.join(`, `)}catch{return`[unknown]`}},renderUI(e,t,n){let r=R$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`pending`})})}},B$=q({shellId:K()}),V$={displayName:`KillShell`,getHeaderParams(e){try{return`id: ${e.shellId||``}`}catch{return`[unknown]`}},renderUI(e,t,n){let r=B$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`pending`})})}};function H$(e,t,n){let r=n?100:t,i=e.split(`
|
|
85753
|
-
`).filter(Boolean);return i.length<=r?{lines:i,isTruncated:!1,hiddenCount:0}:{lines:i.slice(0,r),isTruncated:!0,hiddenCount:i.length-r}}function U$(e){return`${(e/1e3).toFixed(1)}s`}function W$({command:e,toolCallId:t,executionResult:n}){let{agentStatus:r,activeToolOutputs:i}=T$(),[a]=(0,X.useState)(Date.now()),[o,s]=(0,X.useState)(0),[c,l]=(0,X.useState)(!1),u=!n&&(r===Cl.Streaming||r===Cl.ExecutingTool),d=i[t]||``,f=n?.output||``,p=u?d:f,m=(0,X.useDeferredValue)(p),h=p!==m;(0,X.useEffect)(()=>{if(u){let e=setInterval(()=>{s(Date.now()-a)},1e3);return()=>clearInterval(e)}else n&&s(n.duration??0);return()=>{}},[u,a,n]);let{lines:g,isTruncated:_,hiddenCount:v}=(0,X.useMemo)(()=>H$(m,7,c),[m,c]),y=!u&&n!==void 0&&(_||c),{isFocused:b}=UL({id:`bash-tool-${t}`,isActive:y});HL((e,t)=>{b&&t.ctrl&&e===`o`&&l(e=>!e)},{isActive:b&&y});let x=e.length>500?e.slice(0,500)+`…`:e,S=n?.exitCode??0,C=n?.status===`error`||S!==0,w=u?`pending`:C?`error`:`success`;if(u&&g.length===0)return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w,showSpinner:!0}),(0,Y.jsx)(_J,{color:`gray`,children:`Running…`})]});if(u&&g.length>0){let e=o>0?` (${U$(o)})`:``;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w,showSpinner:!0}),(0,Y.jsxs)(vJ,{children:[g.map((e,t)=>(0,Y.jsx)(Q,{children:e},t)),_&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,v,` more line`,v===1?``:`s`,e]}),h&&(0,Y.jsx)(Q,{dimColor:!0,children:`Processing output...`})]})]})}if(n){let e=!f&&(n.duration??0)===0,t=fJ(n.duration??0),r=e?`exit ${S}`:`exit ${S} (${t})`,i=g.length>0;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w}),i&&(0,Y.jsxs)(vJ,{children:[C&&(0,Y.jsx)(Q,{color:`red`,dimColor:!0,children:`Error:`}),g.map((e,t)=>(0,Y.jsx)(Q,{color:C?`red`:void 0,dimColor:!0,children:e},t)),_&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,v,` `,c?`more `:``,`line`,v===1?``:`s`,c?``:` (ctrl+o to expand)`]})]}),(0,Y.jsx)(_J,{color:C?`red`:`gray`,children:r})]})}return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:`pending`})})}const G$=q({command:K(),explanation:K().optional(),runInBackground:kJ,shellId:K().optional(),interactiveMode:kJ,timeout:Qc().optional()});function K$({rawInput:e,status:t,parsedResult:n}){let r=G$.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:``,paramsLanguage:`bash`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.command||``,o=a.length>500?a.slice(0,500)+`…`:a,s=i.timeout?` (timeout: ${(i.timeout/1e3).toFixed(0)}s)`:``;if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return n?.userNote?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]});if(n?.data?.timedOut)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,Y.jsx)(_J,{children:`Running in the background`})]});if(n?.runInBackground)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]});let c=e?.id||`unknown`,l=n?.data;return(0,Y.jsx)(W$,{command:`${o}${s}`,toolCallId:c,executionResult:l})}const q$={read_file:jY,edit:CY,list_dir:TY,delete_file:gY,notebook_edit:kY,grep:j$,glob:k$,file_search:D$,semantic_search_server:N$,web_search:L$,web_fetch:F$,bash:{displayName:`Bash`,getHeaderParams(e){try{return e?.command||`[no command]`}catch{return`[unknown]`}},renderUI(e,t,n){return(0,Y.jsx)(K$,{rawInput:e,status:t,parsedResult:n})}},bash_output:z$,kill_shell:V$,navigate_to:sY,new_tab:lY,close_tab:$J,switch_active_tab:mY,refresh_tab:fY,get_tab_content:aY,computer:tY,get_interactive_elements:rY,perform_interactive_element_action:dY,ask_user_question:jJ,enter_plan_mode:MJ,exit_plan_mode:VJ,subagent:WJ,hand_off_to_main:HJ,task:qJ,todo_write:ZJ,get_diagnostics:PY};function J$(e){let t=e.toolUseRequest;return t?(Array.isArray(t)?t:[t]).map(e=>{let t=e;return{name:t.name??``,input:t.input??{}}}).filter(e=>e.name):[]}function Y$(e,t=4){let n=[];for(let r of e){if(n.length>=t)break;for(let e of J$(r)){if(n.length>=t)break;let r=q$[e.name];if(!r)continue;let i=``;try{i=r.getHeaderParams(e.input)}catch{}if(!i)continue;let a=r.displayName??e.name;n.push({label:a,detail:i})}}return n}const X$=(0,X.memo)(({counts:e,segments:t})=>{let{colors:n}=bz(),r=(0,X.useMemo)(()=>{let t=[];return e.toolUses>0&&t.push(`${e.toolUses} tool ${e.toolUses===1?`use`:`uses`}`),e.responses>0&&t.push(`${e.responses} ${e.responses===1?`response`:`responses`}`),t.length===0?`Conversation compacted`:t.join(`, `)+` compacted`},[e]),i=(0,X.useMemo)(()=>Y$(t),[t]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:n.textMuted,children:`⟐`}),(0,Y.jsx)(Q,{color:n.textMuted,dimColor:!0,children:r})]}),i.map((e,t)=>(0,Y.jsx)(Z,{flexDirection:`row`,paddingLeft:2,children:(0,Y.jsxs)(Q,{color:n.textMuted,dimColor:!0,children:[`⎿ `,e.label,` `,e.detail]})},t))]})});X$.displayName=`CompactedPlaceholder`;const Z$=(0,X.createContext)(null);function Q$(){let e=(0,X.use)(Z$);if(!e)throw Error(`useUpdate must be used within UpdateProvider`);return e}function $$({children:e,configService:t}){let[n,r]=(0,X.useState)(null),i=(0,X.useMemo)(()=>t.get(`autoUpdate`)!==!1,[t]);(0,X.useEffect)(()=>{if(yj())return;let e=!0,t=()=>{Sj(hj.default.version).then(t=>{e&&r(e=>e?.latestVersion===t?.latestVersion?e:t)}).catch(()=>{})};t();let n=setInterval(t,6e4);return()=>{e=!1,clearInterval(n)}},[]);let a=(0,X.useMemo)(()=>({updateInfo:n,autoUpdate:i}),[n,i]);return(0,Y.jsx)(Z$.Provider,{value:a,children:e})}const e1=(0,X.createContext)(null),t1=()=>{let e=(0,X.use)(e1);if(!e)throw Error(`${t1.name} must be used within a ${n1.name}`);return e};function n1({children:e}){let[t,n]=(0,X.useState)({columns:process.stdout.columns-8,rows:process.stdout.rows}),r=(0,X.useCallback)(()=>{n({columns:process.stdout.columns-8,rows:process.stdout.rows})},[]);(0,X.useLayoutEffect)(()=>(process.stdout.on(`resize`,r),()=>{process.stdout.off(`resize`,r)}),[r]);let i=(0,X.useMemo)(()=>({width:t.columns,height:t.rows}),[t.columns,t.rows]);return(0,Y.jsx)(e1.Provider,{value:i,children:e})}function r1(){let{height:e}=t1();return Math.max(0,e-3)}let i1=function(e){return e.Models=`models`,e.CreateConversation=`create-conversation`,e.GetConversation=`get-conversation`,e.Grep=`grep`,e.FileSearch=`file-search`,e.ListDir=`list-dir`,e.ReadFile=`read-file`,e.DeleteFile=`delete-file`,e.EditFile=`edit-file`,e.RunTerminal=`run-terminal`,e.GetTerminalOutput=`get-terminal-output`,e.MCPTool=`mcp-tool`,e.PrInfo=`pr-info`,e}({});function a1(e){return gz({queryKey:[i1.Models],queryFn:async()=>{try{return(await e.listLLMModels())?.result??[]}catch{return[]}},staleTime:300*1e3,retry:1,refetchOnMount:`always`,refetchOnWindowFocus:!1})}const o1=/\/var\/folders\/.*\/T\/TemporaryItems\/.*screencaptureui.*\//i,s1=`.abacusai/screenshots`;function c1(e){return o1.test(e)}function l1(e){try{let t=u1(e.replace(/\\ /g,` `));if(!v(t))return null;let n=T.resolve(process.cwd(),s1);v(n)||y(n,{recursive:!0});let r=T.basename(t),i=T.join(n,r);return _(t,i),i}catch{return null}}function u1(e){if(e.startsWith(`file://`))try{return decodeURIComponent(e.slice(7))}catch{return e.slice(7)}return e}let d1;function f1(){if(d1!==void 0)return d1;try{return u(`which`,[`wl-paste`],{stdio:`ignore`}),d1=`wl-paste`,`wl-paste`}catch{}try{return u(`which`,[`xclip`],{stdio:`ignore`}),d1=`xclip`,`xclip`}catch{}return d1=null,null}async function p1(){try{if(process.platform===`darwin`){let e=u(`osascript`,[`-e`,`clipboard info`],{encoding:`utf8`,timeout:2e3});return/PNGf|JPEG|TIFF|GIF/i.test(e)}if(process.platform===`win32`)return u(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()`],{encoding:`utf8`,timeout:2e3}).trim().toLowerCase()===`true`;let e=f1();if(e===`wl-paste`)return u(`wl-paste`,[`--list-types`],{encoding:`utf8`,timeout:2e3}).includes(`image/`);if(e===`xclip`)return u(`xclip`,[`-selection`,`clipboard`,`-t`,`TARGETS`,`-o`],{encoding:`utf8`,timeout:2e3}).includes(`image/`)}catch{}return!1}async function m1(e){try{let t=T.resolve(e,s1);v(t)||y(t,{recursive:!0});let n=Date.now(),r=T.join(t,`clipboard-${n}.png`);if(process.platform===`darwin`)u(`osascript`,[`-e`,`
|
|
85741
|
+
`)}function CJ(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>CJ(e));let t={};for(let[n,r]of Object.entries(e)){let e=n.replace(/_([a-z])/g,(e,t)=>t.toUpperCase());t[e]=CJ(r)}return t}function wJ(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function TJ(e){if(typeof e!=`string`)return e;let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`y`].includes(t)?!0:[`false`,`0`,`no`,`n`].includes(t)?!1:e}const EJ=Jc(wJ,Ws()),DJ=Jc(wJ,Ws().optional()),OJ=Jc(TJ,Js()),kJ=Jc(TJ,Js().optional()),AJ=q({questions:sc(q({question:K(),header:K(),options:sc(q({label:K(),description:K()})),multiSelect:OJ})),answers:yc(K(),K()).optional()}),jJ={displayName:`AskUserQuestion`,getHeaderParams(e){return``},renderUI(e,t,n){let r=AJ.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.questions||[],o=n?.data.answers??i.answers??{};if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=Object.keys(o).length>0;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:e?`success`:`rejected`}),(0,Y.jsx)(_J,{color:e?`green`:`yellow`,children:e?`User answered ${Object.keys(o).length} question${Object.keys(o).length===1?``:`s`}`:n?.userNote?(0,Y.jsxs)(Y.Fragment,{children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):`User cancelled the questions`})]})}if(t===`pending`||t===`executing`)return(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`pending`,showSpinner:!0});let s=a.length,c=Object.keys(o).length;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`AskUserQuestion`,status:`success`}),(0,Y.jsxs)(_J,{children:[`Answered `,s,` question`,s===1?``:`s`]}),c>0&&(0,Y.jsx)(vJ,{children:Object.entries(o).map(([e,t],n)=>{let r=parseInt(e.replace(`question_`,``),10),i=a[r];return(0,Y.jsxs)(Z,{flexDirection:`column`,marginBottom:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:i?.header||`Question ${r+1}`}),(0,Y.jsxs)(Q,{color:`cyan`,children:[`→ `,String(t)]})]},n)})})]})}},MJ={displayName:`EnterPlanMode`,getHeaderParams(e){return``},renderUI(e,t,n){return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):t===`pending`||t===`executing`?(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`pending`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`EnterPlanMode`,status:`success`}),(0,Y.jsx)(_J,{children:`Entered plan mode`})]})}};let NJ=function(e){return e[e.Prompt=0]=`Prompt`,e[e.Help=1]=`Help`,e[e.Bash=2]=`Bash`,e[e.Command=3]=`Command`,e[e.Files=4]=`Files`,e}({});const PJ=(0,X.createContext)(null),FJ=()=>{let e=(0,X.use)(PJ);if(!e)throw Error(`${FJ.name} must be used within ${RJ.name}`);return e},IJ=[Sl.Normal,Sl.AcceptEdits,Sl.PlanMode];function LJ(e,t){switch(t.type){case`CYCLE`:{if(e.isWaitingForYoloConfirm)return{agentMode:Sl.Yolo,isWaitingForYoloConfirm:!1};if(e.agentMode===Sl.Yolo)return{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1};let t=IJ.indexOf(e.agentMode);return t===-1?{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1}:t===IJ.length-1?{agentMode:e.agentMode,isWaitingForYoloConfirm:!0}:{agentMode:IJ[t+1],isWaitingForYoloConfirm:!1}}case`SET`:return{agentMode:t.mode,isWaitingForYoloConfirm:!1};case`RESET`:return{agentMode:Sl.Normal,isWaitingForYoloConfirm:!1};case`YOLO_TIMEOUT`:return{...e,isWaitingForYoloConfirm:!1}}}function RJ({children:e,initialMode:t}){let[{agentMode:n,isWaitingForYoloConfirm:r},i]=(0,X.useReducer)(LJ,{agentMode:t??Sl.Normal,isWaitingForYoloConfirm:!1});(0,X.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i({type:`YOLO_TIMEOUT`}),3e3);return()=>clearTimeout(e)},[r]);let a=(0,X.useMemo)(()=>({agentMode:n,setAgentMode:e=>i({type:`SET`,mode:e}),cycleAgentMode:()=>i({type:`CYCLE`}),isWaitingForYoloConfirm:r,resetToNormal:()=>i({type:`RESET`})}),[n,r]);return(0,Y.jsx)(PJ.Provider,{value:a,children:e})}const zJ=q({planFilePath:K()});function BJ({rawInput:e,status:t,parsedResult:n}){let{agentMode:r}=FJ(),i=zJ.safeParse(CJ(e)),a=(i.success?i.data.planFilePath:e?.planFilePath)||``;if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]});if(t===`pending`||t===`executing`)return(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`pending`,showSpinner:!0});let o=r===Sl.AcceptEdits?`Plan approved (auto-accept mode)`:`Plan approved`;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`ExitPlanMode`,status:`success`}),(0,Y.jsxs)(_J,{children:[o,`: `,pJ(a)]})]})}const VJ={displayName:`ExitPlanMode`,getHeaderParams(e){return e?.planFilePath||``},renderUI(e,t,n){return(0,Y.jsx)(BJ,{rawInput:e,status:t,parsedResult:n})}},HJ={displayName:`HandOff`,getHeaderParams(e){return``},renderUI(e,t,n){return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`HandOff`,status:`success`}),(0,Y.jsx)(_J,{children:`Handed off to main agent`})]})}},UJ=q({agent:K(),task:K()}),WJ={displayName:`Subagent`,getHeaderParams(e){return e?.agent||``},renderUI(e,t,n){let r=UJ.safeParse(CJ(e)),i=r.success?r.data.agent:e?.agent||``;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Subagent`,params:i,status:`success`}),(0,Y.jsxs)(_J,{children:[`Switched to `,i,` agent`]})]})}},GJ=q({description:K(),prompt:K(),subagentType:K(),model:K().optional(),resume:K().optional()});function KJ({call:e,isFirst:t}){let n=x1[e.name],r=n?.displayName??e.name,i=n?n.getHeaderParams(e.input):``,a=i.length>80?i.slice(0,80)+`...`:i;return(0,Y.jsxs)(Z,{flexDirection:`column`,marginLeft:2,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{dimColor:!0,children:t?`⎿ `:` `}),(0,Y.jsx)(Q,{color:`cyan`,children:r}),a?(0,Y.jsxs)(Q,{dimColor:!0,children:[`(`,a,`)`]}):null]}),e.status===`executing`&&(0,Y.jsx)(Z,{marginLeft:5,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Running…`})})]})}const qJ={displayName:`Task`,getHeaderParams(e){let t=GJ.safeParse(CJ(e));return t.success?`${t.data.subagentType}: ${t.data.description}`:e?.description||e?.subagent_type||``},renderUI(e,t,n,r){let i=GJ.safeParse(CJ(e)),a=i.success?i.data.subagentType:e?.subagent_type||``,o=i.success?i.data.description:e?.description||``,s=t===`executing`||t===`pending`?`pending`:t===`error`||t===`rejected`||t===`interrupted`?`error`:`success`;if(!n?.data&&r?.nestedToolCalls){let e=r.nestedToolCalls,t=(r.toolCallCount??e.length)-e.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,showSpinner:!0}),t>0&&(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ +`,t,` more tool uses`]})}),e.map((e,n)=>(0,Y.jsx)(KJ,{call:e,isFirst:t===0&&n===0},e.id))]})}if(n?.data){let e=n.data;if(e.toolCalls&&e.toolCalls.length>0){let t=e.toolCalls.slice(-4),n=e.toolCalls.length-4;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,status:s}),n>0&&(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ +`,n,` more tool uses`]})}),t.map((e,t)=>(0,Y.jsx)(KJ,{call:{...e,status:`success`},isFirst:n<=0&&t===0},t)),e.error&&(0,Y.jsx)(_J,{children:(0,Y.jsxs)(Q,{color:`red`,children:[`Error: `,e.error]})})]})}return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,status:s}),e.error&&(0,Y.jsx)(_J,{children:(0,Y.jsxs)(Q,{color:`red`,children:[`Error: `,e.error]})})]})}return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:a||`Task`,params:o,showSpinner:!0}),(0,Y.jsx)(Z,{flexDirection:`row`,marginLeft:2,children:(0,Y.jsxs)(Q,{dimColor:!0,children:[`⎿ Running `,a,` agent...`]})})]})}},JJ=(0,X.createContext)(!1),YJ=q({todos:Jc(e=>{if(e==null)return[];if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return Array.isArray(e)?e:[]},sc(q({content:K(),status:xc([`pending`,`in_progress`,`completed`,`cancelled`]),id:K().optional()})))});function XJ({rawInput:e,parsedResult:t}){if(!(0,X.useContext)(JJ))return(0,Y.jsx)(Y.Fragment,{});let n=YJ.safeParse(CJ(e)),r=n.success?n.data.todos:[],i=(0,X.useCallback)(e=>{switch(e){case`completed`:return`[x]`;case`in_progress`:return`[>]`;default:return`[ ]`}},[]),a=(0,X.useCallback)(e=>{switch(e){case`completed`:return`green`;case`in_progress`:return`blue`;default:return`gray`}},[]);return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`TodoWrite`,status:`success`}),t?.summary&&(0,Y.jsx)(_J,{children:t.summary}),r.length>0&&(0,Y.jsx)(vJ,{children:r.map((e,t)=>(0,Y.jsxs)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:[(0,Y.jsx)(Q,{color:a(e.status),children:i(e.status)}),(0,Y.jsx)(Q,{color:e.status===`completed`?`gray`:void 0,dimColor:e.status===`completed`,children:e.content})]},t))})]})}const ZJ={displayName:`TodoWrite`,getHeaderParams(e){return``},renderUI(e,t,n){return(0,Y.jsx)(XJ,{rawInput:e,parsedResult:n})}},QJ=q({id:EJ}),$J={displayName:`CloseTab`,getHeaderParams(e){let t=e;return`id: ${String(t.id??``)}`},renderUI(e,t,n){let r=QJ.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.id;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`pending`,showSpinner:!0}):n?t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error closing tab`})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`success`}),(0,Y.jsx)(_J,{children:`Closed`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`CloseTab`,params:`id: ${i}`,status:`pending`})})}},eY=q({action:xc([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:_c([EJ,EJ]).optional(),startCoordinate:_c([EJ,EJ]).optional(),duration:DJ,text:K().optional(),scrollAmount:DJ,scrollDirection:xc([`up`,`down`,`left`,`right`]).optional()}),tY={displayName:`Computer`,getHeaderParams(e){return e?.action||`action`},renderUI(e,t,n){let r=eY.safeParse(CJ(e)),i=r.success?r.data.action:e?.action||`action`;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing computer action`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`success`}),(0,Y.jsxs)(_J,{children:[`Performed `,i]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Computer`,params:i,status:`pending`})})}},nY=q({id:DJ}),rY={displayName:`GetElements`,getHeaderParams(e){let t=e;return t.id===void 0?``:`id: ${String(t.id)}`},renderUI(e,t,n){let r=nY.safeParse(CJ(e)),i=r.success&&r.data.id!==void 0?`id: ${r.data.id}`:void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error: Failed to get interactive elements`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Found elements`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetElements`,params:i,status:`pending`})})}},iY=q({id:DJ}),aY={displayName:`GetContent`,getHeaderParams(e){let t=e;return t.id===void 0?``:`id: ${String(t.id)}`},renderUI(e,t,n){let r=iY.safeParse(CJ(e)),i=r.success&&r.data.id!==void 0?`id: ${r.data.id}`:void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error: Failed to get tab content`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Got content`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetContent`,params:i,status:`pending`})})}},oY=q({url:K()}),sY={displayName:`Navigate`,getHeaderParams(e){let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t},renderUI(e,t,n){let r=oY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error navigating to URL`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:`Navigated`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Navigate`,params:a,status:`pending`})})}},cY=q({url:K().optional()}),lY={displayName:`NewTab`,getHeaderParams(e){let t=e?.url||``;return t.length>40?t.substring(0,37)+`...`:t},renderUI(e,t,n){let r=cY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=(i.length>40?i.substring(0,37)+`...`:i)||void 0;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error opening new tab`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Opened tab`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`NewTab`,params:a,status:`pending`})})}},uY=q({id:K(),action:xc([`click`,`type`,`hover`,`scroll`,`focus`,`select`]),text:K().optional(),scroll_direction:xc([`up`,`down`,`left`,`right`]).optional(),scroll_amount:DJ,held_keys:K().optional(),tab_id:DJ}),dY={displayName:`PerformAction`,getHeaderParams(e){return`id: ${(e.id||``).substring(0,20)}`},renderUI(e,t,n){let r=e,i=uY.safeParse(CJ(e)),a=i.success?i.data.action:r.action||`action`,o=`id: ${(r.id||``).substring(0,20)}`,s=a.charAt(0).toUpperCase()+a.slice(1);return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:s,params:o,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:s,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing action`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:s,params:o,status:`success`}),(0,Y.jsxs)(_J,{children:[`Performed `,a]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:s,params:o,status:`pending`})})}},fY={displayName:`Refresh`,getHeaderParams(e){return``},renderUI(e,t,n){return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`Refresh`,status:`pending`,showSpinner:!0}):n?t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Refresh`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error refreshing tab`})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Refresh`,status:`success`}),(0,Y.jsx)(_J,{children:`Refreshed`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Refresh`,status:`pending`})})}},pY=q({id:EJ}),mY={displayName:`SwitchTab`,getHeaderParams(e){let t=e;return`id: ${String(t.id??``)}`},renderUI(e,t,n){let r=pY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.id;return!n&&t===`executing`?(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`executing`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error switching tab`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`success`}),(0,Y.jsxs)(_J,{children:[`Switched to tab `,i]})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`SwitchTab`,params:`id: ${i}`,status:`pending`})})}},hY=q({targetFile:K(),explanation:K().optional()}),gY={displayName:`Delete`,getHeaderParams(e){try{return pJ(e?.targetFile||e?.target_file||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n){let r=hY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let{targetFile:i}=r.data,a=pJ(i);return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?n?.userNote?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`rejected`}),(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`rejected`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error deleting file`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:`Deleted`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Delete`,params:a,status:`pending`})})}};function _Y(e,t){return aJ(e,t)}const vY=(0,X.memo)(({line:e,pairedLine:t,lineNumber:n,dimmed:r=!1})=>{let{colors:i}=bz();if(e.type===`separator`)return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[n,` `]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`⋮ `,e.skippedLines,` unchanged lines`]})]});if(e.type===`unchanged`)return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[n,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{dimColor:!0,wrap:`wrap`,children:e.highlightedContent??e.content})})]});if(e.type===`removed`){let a=t?.type===`added`?_Y(e.content,t.content):null;return(0,Y.jsxs)(Z,{flexDirection:`row`,backgroundColor:i.diffRemoved,children:[(0,Y.jsxs)(Q,{backgroundColor:i.diffRemoved,color:i.diffRemovedText,dimColor:r,children:[n,` -`,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{color:i.diffRemovedText,dimColor:r,wrap:`wrap`,children:a?a.map((e,t)=>e.removed?(0,Y.jsx)(Q,{backgroundColor:i.diffRemovedHighlight,dimColor:r,children:e.value},t):e.added?null:(0,Y.jsx)(Q,{backgroundColor:i.diffRemoved,dimColor:r,children:e.value},t)):(0,Y.jsx)(Q,{backgroundColor:i.diffRemoved,dimColor:r,children:e.highlightedContent??e.content})})})]})}if(e.type===`added`){let a=t?.type===`removed`?_Y(t.content,e.content):null;return(0,Y.jsxs)(Z,{flexDirection:`row`,backgroundColor:i.diffAdded,children:[(0,Y.jsxs)(Q,{backgroundColor:i.diffAdded,color:i.diffAddedText,dimColor:r,children:[n,` +`,` `]}),(0,Y.jsx)(Z,{flexShrink:1,children:(0,Y.jsx)(Q,{color:i.diffAddedText,dimColor:r,wrap:`wrap`,children:a?a.map((e,t)=>e.added?(0,Y.jsx)(Q,{backgroundColor:i.diffAddedHighlight,dimColor:r,children:e.value},t):e.removed?null:(0,Y.jsx)(Q,{backgroundColor:i.diffAdded,dimColor:r,children:e.value},t)):(0,Y.jsx)(Q,{backgroundColor:i.diffAdded,dimColor:r,children:e.highlightedContent??e.content})})})]})}return null});vY.displayName=`DiffLineContent`;const yY=(0,X.memo)(({filePath:e,hunks:t})=>{let{colors:n}=bz(),r=t.reduce((e,t)=>e+t.lines.filter(e=>e.startsWith(`+`)).length,0),i=t.reduce((e,t)=>e+t.lines.filter(e=>e.startsWith(`-`)).length,0);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{bold:!0,children:e}),(r>0||i>0)&&(0,Y.jsxs)(Q,{dimColor:!0,children:[r>0&&(0,Y.jsxs)(Q,{color:n.diffAddedText,children:[`+`,r]}),r>0&&i>0&&(0,Y.jsx)(Q,{children:` `}),i>0&&(0,Y.jsxs)(Q,{color:n.diffRemovedText,children:[`-`,i]})]})]})});yY.displayName=`DiffPreviewTitle`;const bY=(0,X.memo)(({filePath:e,originalContent:t,newContent:n,dimmed:r=!1,...i})=>{let[a,o]=(0,X.useState)(n),s=a!==n;(0,X.useEffect)(()=>{if(a===n)return;let e=setTimeout(()=>o(n),0);return()=>clearTimeout(e)},[n,a]);let{colors:c}=bz(),l=(0,X.useMemo)(()=>LU(c),[c]),{diffLines:u,totalOriginalLines:d}=(0,X.useMemo)(()=>{let n=SJ(t,e,l),r=SJ(a,e,l),i=lJ(e,e,t,a,void 0,void 0,{context:1}),o=[],s=0;for(let e=0;e<i.hunks.length;e++){let t=i.hunks[e];if(!t)continue;let a=t.oldStart;if(e>0&&a>s+1){let e=a-s-1;e>0&&o.push({type:`separator`,content:``,skippedLines:e})}let c=t.oldStart,l=t.newStart;for(let e of t.lines){let t=e[0],i=e.slice(1);t!==`\\`&&(t===`+`?o.push({type:`added`,content:i,highlightedContent:r[l-1],newLineNumber:l++}):t===`-`?o.push({type:`removed`,content:i,highlightedContent:n[c-1],originalLineNumber:c++}):o.push({type:`unchanged`,content:i,highlightedContent:n[c-1],originalLineNumber:c++,newLineNumber:l++}))}s=c-1}return{diffLines:o,totalOriginalLines:t.split(`
|
|
85742
|
+
`).length}},[e,t,a,l]),f=(0,X.useMemo)(()=>{let e=new Map;for(let t=0;t<u.length;t++){let n=u[t];if(n&&n.type===`removed`){let r=u[t+1];r&&r.type===`added`&&(e.set(t,r),e.set(t+1,n))}}return e},[u]);if(u.length===0)return(0,Y.jsxs)(Z,{flexDirection:`column`,...i,children:[(0,Y.jsx)(Z,{borderStyle:`singleDouble`,width:`100%`,borderTop:!1,borderLeft:!1,borderRight:!1,borderBottom:!0}),(0,Y.jsx)(Q,{dimColor:!0,children:`No changes detected`}),(0,Y.jsx)(Z,{borderStyle:`singleDouble`,width:`100%`,borderTop:!1,borderLeft:!1,borderRight:!1,borderBottom:!0})]});let p=Math.max(d,...u.filter(e=>e.type!==`separator`).map(e=>e.originalLineNumber||e.newLineNumber||0)).toString().length;return(0,Y.jsxs)(Z,{flexDirection:`column`,...i,children:[s&&(0,Y.jsx)(Z,{marginBottom:0,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Processing diff...`})}),(0,Y.jsx)(Z,{flexDirection:`column`,children:u.map((e,t)=>{let n=f.get(t);if(e.type===`separator`)return(0,Y.jsx)(vY,{line:e,lineNumber:` `.repeat(p),dimmed:r},`sep-${t}`);let i=e.originalLineNumber||e.newLineNumber||``;return(0,Y.jsx)(vY,{line:e,pairedLine:n,lineNumber:String(i).padStart(p,` `),dimmed:r},t)})})]})});bY.displayName=`DiffPreview`;const xY=q({targetFile:K(),codeEdit:K(),overwriteFile:kJ,instructions:K().optional(),startLine:dc([Ws(),K(),$s(),Zs()]).optional().transform(e=>{if(e==null)return;let t=Number(e);return isNaN(t)?void 0:t}),endLine:dc([Ws(),K(),$s(),Zs()]).optional().transform(e=>{if(e==null)return;let t=Number(e);return isNaN(t)?void 0:t}),explanation:K().optional()});function SY({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let[i,a]=(0,X.useState)(!1),o=n!=null&&(t===`success`||n.phase===`skipped`),{isFocused:s}=UL({id:`edit-tool-${e?.targetFile||e?.target_file||`unknown`}`,isActive:o});HL((e,t)=>{s&&t.ctrl&&e===`o`&&a(e=>!e)},{isActive:s&&o});let c=xY.safeParse(CJ(e));if(!c.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let l=c.data,u=n?.data.targetFile??l.targetFile,d=!n&&(t===`executing`||t===`pending`),f=pJ(u),p=r?.isPlanFile??!1,m=n?.data.isNewFile??r?.isNewFile??!1,h=m?`Create`:`Update`;if(p&&t===`success`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`success`}),(0,Y.jsx)(_J,{children:`Updated plan`})]});if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`rejected`}),!p&&e&&t&&(0,Y.jsx)(vJ,{children:(0,Y.jsx)(bY,{filePath:u,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(d)return(0,Y.jsx)(gJ,{name:h,params:f,status:`pending`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:h,params:f,status:`pending`})});if(n.phase===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error executing tool`})]});let g=n.phase===`skipped`,_=n.summary??`Updated`,v=r?.originalContent,y=r?.finalContent??r?.newContent;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:h,params:f,status:g?`rejected`:`success`}),(0,Y.jsx)(_J,{color:g?`yellow`:void 0,children:_}),!g&&v!==void 0&&y!==void 0&&(0,Y.jsx)(vJ,{children:m?(0,Y.jsx)(xJ,{filePath:u,content:y,maxLines:i?100:15}):(0,Y.jsx)(bY,{filePath:u,originalContent:v,newContent:y})})]})}const CY={displayName:`Edit`,getHeaderParams(e){try{return pJ(e?.targetFile||e?.target_file||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,Y.jsx)(SY,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},wY=q({relativeWorkspacePath:K().optional(),explanation:K().optional()}),TY={displayName:`ListDir`,getHeaderParams(e){try{return pJ(e?.relativeWorkspacePath||e?.relative_workspace_path||`.`)}catch{return`[unknown]`}},renderUI(e,t,n){let r=wY.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`LS`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=pJ(r.data.relativeWorkspacePath||`.`);return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`List`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error listing directory`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`LS`,params:i,status:`pending`})})}},EY=q({notebookPath:K(),cellId:K().optional(),newSource:K(),cellType:xc([`code`,`markdown`]).optional(),editMode:xc([`replace`,`insert`,`delete`]).optional()});function DY(e,t,n){let r=e??`replace`;return r===`delete`?`Delete cell${t?` ${t}`:``}`:r===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${n??`code`})`:`Replace cell contents for cell ${t??`unknown`}`}function OY({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=EY.safeParse(CJ(e));if(!i.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let a=i.data,o=pJ(a.notebookPath),s=a.editMode??`replace`,c=DY(s,a.cellId,a.cellType);if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`rejected`}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,c]}),s!==`delete`&&e&&t&&(0,Y.jsx)(vJ,{children:(0,Y.jsx)(bY,{filePath:a.notebookPath,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error editing notebook`})]});if(!n&&(t===`executing`||t===`pending`))return(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`pending`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`pending`})});if(n.phase===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:n.errorMessage??`Error editing notebook`})]});let l=n.summary??`Notebook edited`,u=r?.originalContent,d=r?.newContent;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Edit notebook`,params:o,status:`success`}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,c]}),(0,Y.jsx)(_J,{children:l}),s!==`delete`&&u!==void 0&&d!==void 0&&(0,Y.jsx)(vJ,{children:s===`insert`||!u?(0,Y.jsx)(xJ,{filePath:a.notebookPath,content:d,maxLines:15}):(0,Y.jsx)(bY,{filePath:a.notebookPath,originalContent:u,newContent:d})})]})}const kY={displayName:`Edit notebook`,getHeaderParams(e){try{return pJ(e?.notebookPath||e?.notebook_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,Y.jsx)(OY,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},AY=/\/var\/folders\/.*\/T\/TemporaryItems\/.*screencaptureui.*\//i,jY=`.abacusai/screenshots`;function MY(e){return AY.test(e)}function NY(e){try{let t=PY(e.replace(/\\ /g,` `));if(!v(t))return null;let n=T.resolve(process.cwd(),jY);v(n)||y(n,{recursive:!0});let r=T.basename(t),i=T.join(n,r);return _(t,i),i}catch{return null}}function PY(e){if(e.startsWith(`file://`))try{return decodeURIComponent(e.slice(7))}catch{return e.slice(7)}return e}let FY;function IY(){if(FY!==void 0)return FY;try{return u(`which`,[`wl-paste`],{stdio:`ignore`}),FY=`wl-paste`,`wl-paste`}catch{}try{return u(`which`,[`xclip`],{stdio:`ignore`}),FY=`xclip`,`xclip`}catch{}return FY=null,null}async function LY(){try{if(process.platform===`darwin`){let e=u(`osascript`,[`-e`,`clipboard info`],{encoding:`utf8`,timeout:2e3});return/PNGf|JPEG|TIFF|GIF/i.test(e)}if(process.platform===`win32`)return u(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()`],{encoding:`utf8`,timeout:2e3}).trim().toLowerCase()===`true`;let e=IY();if(e===`wl-paste`)return u(`wl-paste`,[`--list-types`],{encoding:`utf8`,timeout:2e3}).includes(`image/`);if(e===`xclip`)return u(`xclip`,[`-selection`,`clipboard`,`-t`,`TARGETS`,`-o`],{encoding:`utf8`,timeout:2e3}).includes(`image/`)}catch{}return!1}async function RY(e){try{let t=T.resolve(e,jY);v(t)||y(t,{recursive:!0});let n=Date.now(),r=T.join(t,`clipboard-${n}.png`);if(process.platform===`darwin`)u(`osascript`,[`-e`,`
|
|
85754
85743
|
set destFile to "${r}"
|
|
85755
85744
|
try
|
|
85756
85745
|
set imgData to (clipboard info for «class PNGf»)
|
|
@@ -85767,33 +85756,44 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
|
|
|
85767
85756
|
close access fileRef
|
|
85768
85757
|
end try
|
|
85769
85758
|
end try
|
|
85770
|
-
`],{timeout:5e3});else if(process.platform===`win32`)u(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -Assembly System.Windows.Forms; [System.Windows.Forms.Clipboard]::GetImage().Save("${r}", [System.Drawing.Imaging.ImageFormat]::Png)`],{timeout:5e3});else{let e=
|
|
85771
|
-
`||e===` `){if(a.trim()){let e=r(a);e&&(yield e),a=``}o++;continue}a+=e,o++}if(a.trim()){let e=r(a);e&&(yield e)}}function
|
|
85772
|
-
`)
|
|
85773
|
-
`),
|
|
85759
|
+
`],{timeout:5e3});else if(process.platform===`win32`)u(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -Assembly System.Windows.Forms; [System.Windows.Forms.Clipboard]::GetImage().Save("${r}", [System.Drawing.Imaging.ImageFormat]::Png)`],{timeout:5e3});else{let e=IY();if(e===`wl-paste`)C(r,u(`wl-paste`,[`--no-newline`,`--type`,`image/png`],{timeout:5e3}));else if(e===`xclip`)C(r,u(`xclip`,[`-selection`,`clipboard`,`-t`,`image/png`,`-o`],{timeout:5e3}));else return null}try{if(S(r).size===0)return null}catch{return null}return r}catch{return null}}function zY(e){try{if(process.platform===`darwin`)return u(`pbcopy`,{input:e,timeout:2e3}),!0;if(process.platform===`win32`)return u(`powershell`,[`-NoProfile`,`-Command`,`$input | Set-Clipboard`],{input:e,timeout:2e3}),!0;let t=IY();if(t===`wl-paste`)try{return u(`wl-copy`,{input:e,timeout:2e3}),!0}catch{}if(t===`wl-paste`||t===`xclip`)return u(`xclip`,[`-selection`,`clipboard`],{input:e,timeout:2e3}),!0}catch{}return!1}async function BY(){try{if(process.platform===`darwin`)return u(`pbpaste`,{encoding:`utf8`,timeout:2e3});if(process.platform===`win32`)return u(`powershell`,[`-NoProfile`,`-Command`,`Get-Clipboard`],{encoding:`utf8`,timeout:2e3});let e=IY();if(e===`wl-paste`)return u(`wl-paste`,[`--no-newline`],{encoding:`utf8`,timeout:2e3});if(e===`xclip`)return u(`xclip`,[`-selection`,`clipboard`,`-o`],{encoding:`utf8`,timeout:2e3})}catch{}return null}const VY=/[ \t()[\]{};|*?$`'"#&<>!~]/;function HY(e){return e.replace(RegExp(`\\\\([${VY.source.slice(1,-1)}])`,`g`),`$1`)}const UY=n.homedir();function WY(e){return e===`~`?UY:e.startsWith(`~/`)?T.join(UY,e.slice(2)):e}function GY(e,t=process.cwd()){let n=T.resolve(t,e);return n===UY||n.startsWith(`${UY}${T.sep}`)?`~${n.slice(UY.length).split(T.sep).join(`/`)}`:n}function KY(e){let t=T.resolve(e),n=T.relative(process.cwd(),t);if(!n)return`.`;let r=n.split(T.sep).join(`/`);return r.startsWith(`.`)?r:`./${r}`}function qY(e){let t=T.resolve(e),n=process.cwd(),r=T.relative(n,t);if(!r)return`.`;if(!r.startsWith(`..`)){let e=r.split(T.sep).join(`/`);return e.startsWith(`.`)?e:`./${e}`}return t===UY||t.startsWith(`${UY}${T.sep}`)?`~${t.slice(UY.length).split(T.sep).join(`/`)}`:t}const JY=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.heic`,`.heif`,`.gif`];function YY(e){return JY.includes(T.extname(e).toLowerCase())}function XY(e){return e.includes(` `)?`'${e.replace(/'/g,`'\\''`)}'`:e}function ZY(e){return qY(e)}function QY(e){let t=e.startsWith(`'`)||e.startsWith(`"`)?e.slice(1):e;return t.startsWith(`/`)||t.startsWith(`~`)||t.startsWith(`./`)||t.startsWith(`../`)||/^file:\/\//i.test(t)||/^[A-Za-z]:[/\\]/.test(t)||t.startsWith(`\\\\`)||e.startsWith(`& '`)}function*$Y(e){let t=e.trim();if(!QY(t))return;let n=t.replace(/^& /,``);function r(e){let t=e.trim();return/^file:\/\//i.test(t)&&(t=PY(t)),t=t.replace(/\\ /g,` `),t=WY(t),T.resolve(t)}let i=`NORMAL`,a=``,o=0;for(;o<n.length;){let e=n[o];if(i===`SINGLE`){if(e===`'`&&n.slice(o,o+4)===`'\\''`){a+=`'`,o+=4;continue}if(e===`'`){let e=r(a);e&&(yield e),a=``,i=`NORMAL`,o++;continue}a+=e,o++;continue}if(i===`DOUBLE`){if(e===`"`){let e=r(a);e&&(yield e),a=``,i=`NORMAL`,o++;continue}a+=e,o++;continue}if(e===`'`){i=`SINGLE`,o++;continue}if(e===`"`){i=`DOUBLE`,o++;continue}if(e===`\\`&&o+1<n.length&&n[o+1]===` `){a+=`\\ `,o+=2;continue}if(e===` `||e===`
|
|
85760
|
+
`||e===` `){if(a.trim()){let e=r(a);e&&(yield e),a=``}o++;continue}a+=e,o++}if(a.trim()){let e=r(a);e&&(yield e)}}function eX(e){let t=[];for(let n of $Y(e)){if(!v(n))return null;let e=XY(ZY(n));t.push(`@${e}`)}return t.length===0?null:t.join(` `)+` `}const tX=new Set([`.ipynb`]);function nX(e){if(YY(e))return`image`;let t=e.slice(e.lastIndexOf(`.`)).toLowerCase();return tX.has(t)?`notebook`:`file`}function rX(e){return e===`image`?`Read image`:e===`notebook`?`Read notebook`:`Read`}const iX=q({targetFile:K(),startLineOneIndexed:DJ,endLineOneIndexed:DJ,startLine:DJ,endLine:DJ,shouldReadEntireFile:kJ,explanation:K().optional()}),aX={displayName:`Read`,getHeaderParams(e){try{let t=e,n=t.targetFile||e.target_file||`[unknown]`,r=pJ(n);if(nX(n)!==`file`)return r;let i=t.startLineOneIndexed||e.start_line_one_indexed||e.startLine||e.start_line,a=t.endLineOneIndexed||e.end_line_one_indexed||e.endLine||e.end_line;return i!==void 0&&a!==void 0?`${r}:${i}-${a}`:r}catch{return`[unknown]`}},renderUI(e,t,n){let r=iX.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Read`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,{targetFile:a,startLineOneIndexed:o,endLineOneIndexed:s}=i;if(!a||typeof a!=`string`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Read`,params:`[invalid file path]`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error: Invalid file path parameter`})]});let c=nX(a),l=rX(c),u=!n&&(t===`executing`||t===`pending`),d=pJ(a),f=o??i.startLine,p=s??i.endLine,m=d;if(c===`file`&&f!==void 0&&p!==void 0&&(m=`${d}:${f}-${p}`),u)return(0,Y.jsx)(gJ,{name:l,params:m,status:`pending`,showSpinner:!0});if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:l,params:m,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error reading file`})]});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:l,params:m,status:`pending`})});if(c===`image`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:l,params:m,status:`success`}),(0,Y.jsx)(_J,{children:`Read successfully`})]});let h=n.data.content??``,g=n.data.startLine??f??1,_=n.data.lineCount??h.split(`
|
|
85761
|
+
`).length;return(0,Y.jsx)(oX,{displayName:l,displayParams:m,content:h,filePath:a,startLine:g,lineCount:_})}};function oX({displayName:e,displayParams:t,content:n,filePath:r,startLine:i,lineCount:a}){let[o,s]=(0,X.useState)(!1),c=n.split(`
|
|
85762
|
+
`).length,l=o?100:4,u=c>4,{isFocused:d}=UL({id:`read-file-${r}`,isActive:u});return HL((e,t)=>{d&&t.ctrl&&e===`o`&&s(e=>!e)},{isActive:d&&u}),(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:e,params:t,status:`success`}),(0,Y.jsxs)(_J,{children:[`Read `,a,` lines`]}),(0,Y.jsx)(vJ,{children:(0,Y.jsx)(xJ,{content:n,filePath:r,startLine:i,maxLines:l})})]})}const sX=q({uri:K().optional()}),cX={displayName:`GetDiagnostics`,getHeaderParams(e){let t=e?.uri;return t?`for ${t}`:`for all files`},renderUI(e,t,n){let r=sX.safeParse(CJ(e)),i=r.success?r.data.uri:void 0,a=i?`for ${i}`:`for all files`;return!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`pending`,showSpinner:!0}):t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error getting diagnostics`})]}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`GetDiagnostics`,params:a,status:`pending`})})}};function lX(e){return e[0]??{}}function uX(e){return Array.isArray(e)?e:e==null?[]:[e]}function dX(e){return typeof e.bytes==`function`?e.bytes():e.arrayBuffer()}const fX=`orpc`;var pX=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function mX(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}function hX(){return globalThis[`__@orpc/shared@1.13.6/otel/config__`]}function gX(e,t={},n){return(hX()?.tracer)?.startSpan(e,t,n)}function _X(e,t,n={}){if(!e)return;let r=vX(t);e.recordException(r),(!n.signal?.aborted||n.signal.reason!==t)&&e.setStatus({code:2,message:r.message})}function vX(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function yX({name:e,context:t,...n},r){let i=hX()?.tracer;if(!i)return r();let a=async e=>{try{return await r(e)}catch(t){throw _X(e,t,n),t}finally{e.end()}};return t?i.startActiveSpan(e,n,t,a):i.startActiveSpan(e,n,a)}async function bX(e,t){let n=hX();if(!e||!n)return t();let r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}var xX=class{openIds=new Set;queues=new Map;waiters=new Map;get length(){return this.openIds.size}get waiterIds(){return Array.from(this.waiters.keys())}hasBufferedItems(e){return!!this.queues.get(e)?.length}open(e){this.openIds.add(e)}isOpen(e){return this.openIds.has(e)}push(e,t){this.assertOpen(e);let n=this.waiters.get(e);if(n?.length)n.shift()[0](t),n.length===0&&this.waiters.delete(e);else{let n=this.queues.get(e);n?n.push(t):this.queues.set(e,[t])}}async pull(e){this.assertOpen(e);let t=this.queues.get(e);if(t?.length){let n=t.shift();return t.length===0&&this.queues.delete(e),n}return new Promise((t,n)=>{let r=this.waiters.get(e),i=[t,n];r?r.push(i):this.waiters.set(e,[i])})}close({id:e,reason:t}={}){if(e===void 0){this.waiters.forEach((e,n)=>{let r=t??new pX(`[AsyncIdQueue] Queue[${n}] was closed or aborted while waiting for pulling.`);e.forEach(([,e])=>e(r))}),this.waiters.clear(),this.openIds.clear(),this.queues.clear();return}let n=t??new pX(`[AsyncIdQueue] Queue[${e}] was closed or aborted while waiting for pulling.`);this.waiters.get(e)?.forEach(([,e])=>e(n)),this.waiters.delete(e),this.openIds.delete(e),this.queues.delete(e)}assertOpen(e){if(!this.isOpen(e))throw Error(`[AsyncIdQueue] Cannot access queue[${e}] because it is not open or aborted.`)}};function SX(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}const CX=Symbol.for(`asyncDispose`),wX=Symbol.asyncDispose??CX;var TX=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=mX(async()=>{if(this.#e)return{done:!0,value:void 0};try{let t=await e();return t.done&&(this.#e=!0),t}catch(e){throw this.#e=!0,e}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n(`next`))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n(`return`)),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n(`throw`)),e}async[wX](){this.#e=!0,this.#t||(this.#t=!0,await this.#n(`dispose`))}[Symbol.asyncIterator](){return this}};function EX({name:e,...t},n){let r;return new TX(async()=>{r??=gX(e);try{let e=await bX(r,()=>n.next());return r?.addEvent(e.done?`completed`:`yielded`),e}catch(e){throw _X(r,e,t),e}},async e=>{try{e!==`next`&&await bX(r,()=>n.return?.())}catch(e){throw _X(r,e,t),e}finally{r?.end()}})}var DX=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function OX(e,t,n){let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function kX(e){if(e)return JSON.parse(e)}function AX(e){return JSON.stringify(e)}function jX(e){return NX(e)?Object.getPrototypeOf(e)?.constructor:null}function MX(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function NX(e){return!!e&&(typeof e==`object`||typeof e==`function`)}function PX(e){if(Array.isArray(e))return e.map(PX);if(MX(e)){let t={};for(let n in e)t[n]=PX(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=PX(e[n]);return t}return e}const FX=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function IX(e,...t){return typeof e==`function`?e(...t):e}function LX(e){return new Proxy(e,{get(e,t,n){let r=Reflect.get(e,t,n);return t!==`then`||typeof r!=`function`?r:new Proxy(r,{apply(t,n,r){if(r.length!==2||r.some(e=>!zX(e)))return Reflect.apply(t,n,r);let i=!0;r[0].call(n,LX(new Proxy(e,{get:(e,t,n)=>{if(i&&t===`then`){i=!1;return}return Reflect.get(e,t,n)}})))}})}})}const RX=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;function zX(e){return typeof e==`function`&&RX.test(e.toString())}function BX(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){let i=r in t?t:IX(e),a=Reflect.get(i,r);return typeof a==`function`?a.bind(i):a},has(n,r){return Reflect.has(t,r)||Reflect.has(IX(e),r)}})}function VX(e){try{return decodeURIComponent(e)}catch{return e}}const HX={BAD_REQUEST:{status:400,message:`Bad Request`},UNAUTHORIZED:{status:401,message:`Unauthorized`},FORBIDDEN:{status:403,message:`Forbidden`},NOT_FOUND:{status:404,message:`Not Found`},METHOD_NOT_SUPPORTED:{status:405,message:`Method Not Supported`},NOT_ACCEPTABLE:{status:406,message:`Not Acceptable`},TIMEOUT:{status:408,message:`Request Timeout`},CONFLICT:{status:409,message:`Conflict`},PRECONDITION_FAILED:{status:412,message:`Precondition Failed`},PAYLOAD_TOO_LARGE:{status:413,message:`Payload Too Large`},UNSUPPORTED_MEDIA_TYPE:{status:415,message:`Unsupported Media Type`},UNPROCESSABLE_CONTENT:{status:422,message:`Unprocessable Content`},TOO_MANY_REQUESTS:{status:429,message:`Too Many Requests`},CLIENT_CLOSED_REQUEST:{status:499,message:`Client Closed Request`},INTERNAL_SERVER_ERROR:{status:500,message:`Internal Server Error`},NOT_IMPLEMENTED:{status:501,message:`Not Implemented`},BAD_GATEWAY:{status:502,message:`Bad Gateway`},SERVICE_UNAVAILABLE:{status:503,message:`Service Unavailable`},GATEWAY_TIMEOUT:{status:504,message:`Gateway Timeout`}};function UX(e,t){return t??HX[e]?.status??500}function WX(e,t){return t||HX[e]?.message||e}const GX=Symbol.for(`__@orpc/client@1.13.6/error/ORPC_ERROR_CONSTRUCTORS__`);globalThis[GX]??=new WeakSet;const KX=globalThis[GX];var qX=class extends Error{defined;code;status;data;constructor(e,...t){let n=lX(t);if(n.status!==void 0&&!YX(n.status))throw Error(`[ORPCError] Invalid error status code.`);let r=WX(e,n.message);super(r,n),this.code=e,this.status=UX(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(KX.has(this)){let t=jX(e);if(t&&KX.has(t))return!0}return super[Symbol.hasInstance](e)}};KX.add(qX);function JX(e){return e instanceof qX?e:new qX(`INTERNAL_SERVER_ERROR`,{message:`Internal server error`,cause:e})}function YX(e){return e<200||e>=400}function XX(e){if(!MX(e))return!1;let t=[`defined`,`code`,`status`,`message`,`data`];return Object.keys(e).some(e=>!t.includes(e))?!1:`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`status`in e&&typeof e.status==`number`&&YX(e.status)&&`message`in e&&typeof e.message==`string`}function ZX(e,t={}){return new qX(e.code,{...t,...e})}var QX=class extends TypeError{},$X=class extends Error{data;constructor(e){super(e?.message??`An error event was received`,e),this.data=e?.data}};function eZ(e){if(e.includes(`
|
|
85763
|
+
`))throw new QX(`Event's id must not contain a newline character`)}function tZ(e){if(!Number.isInteger(e)||e<0)throw new QX(`Event's retry must be a integer and >= 0`)}function nZ(e){if(e.includes(`
|
|
85764
|
+
`))throw new QX(`Event's comment must not contain a newline character`)}const rZ=Symbol(`ORPC_EVENT_SOURCE_META`);function iZ(e,t){if(t.id===void 0&&t.retry===void 0&&!t.comments?.length)return e;if(t.id!==void 0&&eZ(t.id),t.retry!==void 0&&tZ(t.retry),t.comments!==void 0)for(let e of t.comments)nZ(e);return new Proxy(e,{get(e,n,r){return n===rZ?t:Reflect.get(e,n,r)}})}function aZ(e){return NX(e)?Reflect.get(e,rZ):void 0}var oZ=class extends TX{hibernationCallback;constructor(e){super(async()=>{throw Error(`Cannot iterate over hibernating iterator directly`)},async e=>{if(e!==`next`)throw Error(`Cannot cleanup hibernating iterator directly`)}),this.hibernationCallback=e}};function sZ(e){return`inline; filename="${e.replace(/"/g,`\\"`)}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function cZ(e){let t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&typeof t[2]==`string`)return VX(t[2]);let n=e.match(/filename="((?:\\"|[^"])*)"/i);if(n&&typeof n[1]==`string`)return n[1].replace(/\\"/g,`"`)}function lZ(e,t){let n={...e};for(let e in t)Array.isArray(t[e])?n[e]=[...uX(n[e]),...t[e]]:t[e]!==void 0&&(Array.isArray(n[e])?n[e]=[...n[e],t[e]]:n[e]===void 0?n[e]=t[e]:n[e]=[n[e],t[e]]);return n}function uZ(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function dZ(e){return!!(uZ(e[`content-type`])?.startsWith(`text/event-stream`)&&uZ(e[`content-disposition`])===void 0)}function fZ(e,t){let n=async e=>{let n=await t.error(e);if(n!==e){let t=aZ(e);t&&NX(n)&&(n=iZ(n,t))}return n};return new TX(async()=>{let{done:r,value:i}=await(async()=>{try{return await e.next()}catch(e){throw await n(e)}})(),a=await t.value(i,r);if(a!==i){let e=aZ(i);e&&NX(a)&&(a=iZ(a,e))}return{done:r,value:a}},async()=>{try{await e.return?.()}catch(e){throw await n(e)}})}function pZ(e){return{...e,context:e.context??{}}}function mZ(e,t={}){let n=t.path??[];return LX(new Proxy(async(...[t,r={}])=>await e.call(n,t,pZ(r)),{get(r,i){return typeof i==`string`?mZ(e,{...t,path:[...n,i]}):Reflect.get(r,i)}}))}var hZ=class extends Error{issues;data;constructor(e){super(e.message,e),this.issues=e.issues,this.data=e.data}};function gZ(e,t){return{...e,...t}}async function _Z(e,t){let{code:n,status:r,message:i,data:a,cause:o,defined:s}=t,c=e?.[t.code];if(!c||UX(t.code,c.status)!==t.status)return s?new qX(n,{defined:!1,status:r,message:i,data:a,cause:o}):t;if(!c.data)return s?t:new qX(n,{defined:!0,status:r,message:i,data:a,cause:o});let l=await c.data[`~standard`].validate(t.data);return l.issues?s?new qX(n,{defined:!1,status:r,message:i,data:a,cause:o}):t:new qX(n,{defined:!0,status:r,message:i,data:l.value,cause:o})}var vZ=class{"~orpc";constructor(e){if(e.route?.successStatus&&YX(e.route.successStatus))throw Error(`[ContractProcedure] Invalid successStatus.`);if(Object.values(e.errorMap).some(e=>e&&e.status&&!YX(e.status)))throw Error(`[ContractProcedure] Invalid error status code.`);this[`~orpc`]=e}};function yZ(e){return e instanceof vZ?!0:(typeof e==`object`||typeof e==`function`)&&e!==null&&`~orpc`in e&&typeof e[`~orpc`]==`object`&&e[`~orpc`]!==null&&`errorMap`in e[`~orpc`]&&`route`in e[`~orpc`]&&`meta`in e[`~orpc`]}function bZ(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]===void 0?t[n]=e:t[n]=[t[n],e]}),t}var xZ=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(let t of this.plugins)t.init?.(e)}},SZ=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new xZ(n.plugins).init(n),this.interceptors=uX(n.interceptors),this.clientInterceptors=uX(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return yX({name:`${fX}.${e.join(`/`)}`,signal:n.signal},r=>(r?.setAttribute(`rpc.system`,fX),r?.setAttribute(`rpc.method`,e.join(`.`)),SX(t)&&(t=EX({name:`consume_event_iterator_input`,signal:n.signal},t)),OX(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=hX(),a,o=i?.trace.getActiveSpan()??r;o&&i&&(a=i?.trace.setSpan(i.context.active(),o));let s=await yX({name:`encode_request`,context:a},()=>this.codec.encode(e,t,n)),c=await OX(this.clientInterceptors,{...n,input:t,path:e,request:s},({input:e,path:t,request:n,...r})=>yX({name:`send_request`,signal:r.signal,context:a},()=>this.sender.call(n,r,t,e))),l=await yX({name:`decode_response`,context:a},()=>this.codec.decode(c,n,e,t));return SX(l)?EX({name:`consume_event_iterator_output`,signal:n.signal},l):l})))}};const CZ={BIGINT:0,DATE:1,NAN:2,UNDEFINED:3,URL:4,REGEXP:5,SET:6,MAP:7};var wZ=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw Error(`Custom serializer type must be unique.`)}serialize(e,t=[],n=[],r=[],i=[]){for(let a of this.customSerializers)if(a.condition(e)){let o=this.serialize(a.serialize(e),t,n,r,i);return n.push([a.type,...t]),o}if(e instanceof Blob)return r.push(t),i.push(e),[e,n,r,i];if(typeof e==`bigint`)return n.push([CZ.BIGINT,...t]),[e.toString(),n,r,i];if(e instanceof Date)return n.push([CZ.DATE,...t]),Number.isNaN(e.getTime())?[null,n,r,i]:[e.toISOString(),n,r,i];if(Number.isNaN(e))return n.push([CZ.NAN,...t]),[null,n,r,i];if(e instanceof URL)return n.push([CZ.URL,...t]),[e.toString(),n,r,i];if(e instanceof RegExp)return n.push([CZ.REGEXP,...t]),[e.toString(),n,r,i];if(e instanceof Set){let a=this.serialize(Array.from(e),t,n,r,i);return n.push([CZ.SET,...t]),a}if(e instanceof Map){let a=this.serialize(Array.from(e.entries()),t,n,r,i);return n.push([CZ.MAP,...t]),a}if(Array.isArray(e))return[e.map((e,a)=>e===void 0?(n.push([CZ.UNDEFINED,...t,a]),e):this.serialize(e,[...t,a],n,r,i)[0]),n,r,i];if(MX(e)){let a={};for(let o in e)o===`toJSON`&&typeof e[o]==`function`||(a[o]=this.serialize(e[o],[...t,o],n,r,i)[0]);return[a,n,r,i]}return[e,n,r,i]}deserialize(e,t,n,r){let i={data:e};n&&r&&n.forEach((e,t)=>{let n=i,a=`data`;e.forEach(e=>{if(n=n[a],a=e,!Object.hasOwn(n,a))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${a}`)}),n[a]=r(t)});for(let e of t){let t=e[0],n=i,r=`data`;for(let t=1;t<e.length;t++)if(n=n[r],r=e[t],!Object.hasOwn(n,r))throw Error(`Security error: accessing non-existent path during deserialization. Path segment: ${r}`);for(let e of this.customSerializers)if(e.type===t){n[r]=e.deserialize(n[r]);break}switch(t){case CZ.BIGINT:n[r]=BigInt(n[r]);break;case CZ.DATE:n[r]=new Date(n[r]??`Invalid Date`);break;case CZ.NAN:n[r]=NaN;break;case CZ.UNDEFINED:n[r]=void 0;break;case CZ.URL:n[r]=new URL(n[r]);break;case CZ.REGEXP:{let[,e,t]=n[r].match(/^\/(.*)\/([a-z]*)$/);n[r]=new RegExp(e,t);break}case CZ.SET:n[r]=new Set(n[r]);break;case CZ.MAP:n[r]=new Map(n[r]);break}}return i.data}};function TZ(e){return`/${e.map(encodeURIComponent).join(`/`)}`}function EZ(e){return typeof e.forEach==`function`?bZ(e):e}function DZ(e){return Object.entries(HX).find(([,t])=>t.status===e)?.[0]??`MALFORMED_ORPC_ERROR_RESPONSE`}var OZ=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??`POST`,this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=EZ(await IX(this.headers,n,e,t));n.lastEventId!==void 0&&(r=lZ(r,{"last-event-id":n.lastEventId}));let i=await IX(this.expectedMethod,n,e,t),a=await IX(this.baseUrl,n,e,t),o=new URL(a);o.pathname=`${o.pathname.replace(/\/$/,``)}${TZ(e)}`;let s=this.serializer.serialize(t);if(i===`GET`&&!(s instanceof FormData)&&!SX(s)){let a=await IX(this.maxUrlLength,n,e,t),c=new URL(o);if(c.searchParams.append(`data`,AX(s)),c.toString().length<=a)return{body:void 0,method:i,headers:r,url:c,signal:n.signal}}return{url:o,method:i===`GET`?this.fallbackMethod:i,headers:r,body:s,signal:n.signal}}async decode(e){let t=!YX(e.status),n=await(async()=>{let t=!1;try{let n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(e){throw t?Error(`Invalid RPC response format.`,{cause:e}):Error(`Cannot parse response body, please check the response body and content-type.`,{cause:e})}})();if(!t)throw XX(n)?ZX(n):new qX(DZ(e.status),{status:e.status,data:{...e,body:n}});return n}},kZ=class{constructor(e){this.jsonSerializer=e}serialize(e){return SX(e)?fZ(e,{value:async e=>this.#e(e,!1),error:async e=>new $X({data:this.#e(JX(e).toJSON(),!1),cause:e})}):this.#e(e,!0)}#e(e,t){let[n,r,i,a]=this.jsonSerializer.serialize(e),o=r.length===0?void 0:r;if(!t||a.length===0)return{json:n,meta:o};let s=new FormData;return s.set(`data`,AX({json:n,meta:o,maps:i})),a.forEach((e,t)=>{s.set(t.toString(),e)}),s}deserialize(e){return SX(e)?fZ(e,{value:async e=>this.#t(e),error:async e=>{if(!(e instanceof $X))return e;let t=this.#t(e.data);return XX(t)?ZX(t,{cause:e}):new $X({data:t,cause:e})}}):this.#t(e)}#t(e){if(e===void 0)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);let t=JSON.parse(e.get(`data`));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},AZ=class extends SZ{constructor(e,t){let n=new OZ(new kZ(new wZ(t)),t);super(n,e,t)}};function jZ(e,t){return{...e,...t}}function MZ(e,t){return{...e,...t}}function NZ(e,t){return e.path?{...e,path:`${t}${e.path}`}:e}function PZ(e,t){return{...e,tags:[...t,...e.tags??[]]}}function FZ(e,t){return e?`${e}${t}`:t}function IZ(e,t){return e?[...e,...t]:t}function LZ(e,t){let n=e;return t.prefix&&(n=NZ(n,t.prefix)),t.tags?.length&&(n=PZ(n,t.tags)),n}function RZ(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||yZ(n))return;n=n[r]}return n}function zZ(e,t){if(yZ(e))return new vZ({...e[`~orpc`],errorMap:gZ(t.errorMap,e[`~orpc`].errorMap),route:LZ(e[`~orpc`].route,t)});let n={};for(let r in e)n[r]=zZ(e[r],t);return n}const BZ=new class e extends vZ{constructor(e){super(e),this[`~orpc`].prefix=e.prefix,this[`~orpc`].tags=e.tags}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}errors(t){return new e({...this[`~orpc`],errorMap:gZ(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:jZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:MZ(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t})}output(t){return new e({...this[`~orpc`],outputSchema:t})}prefix(t){return new e({...this[`~orpc`],prefix:FZ(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:IZ(this[`~orpc`].tags,t)})}router(e){return zZ(e,this[`~orpc`])}}({errorMap:{},route:{},meta:{}}),VZ={editorStateChanged:BZ.input(q({file:K().nullable(),startLine:Ws().optional(),endLine:Ws().optional()})).output(q({ok:Js()})),toolDecision:BZ.input(q({toolId:K(),decision:xc([`accept`,`reject`,`allowAlways`])})).output(q({ok:Js()}))};function HZ(e){return{...e,context:e.context??{}}}function UZ(e,t){return async n=>{let{response:r}=await e.handle({...n,body:()=>Promise.resolve(n.body)},HZ(t));return r??{status:404,headers:{},body:`No procedure matched`}}}const WZ=/^http:\/\/orpc\//;var GZ=(e=>(e[e.REQUEST=1]=`REQUEST`,e[e.RESPONSE=2]=`RESPONSE`,e[e.EVENT_ITERATOR=3]=`EVENT_ITERATOR`,e[e.ABORT_SIGNAL=4]=`ABORT_SIGNAL`,e))(GZ||{});function KZ(e,t,n){if(t===3){let r=n;return{i:e,t,p:{e:r.event,d:r.data,m:r.meta}}}if(t===4)return{i:e,t,p:n};let r=n;return{i:e,p:{u:r.url.toString().replace(WZ,`/`),b:r.body,h:Object.keys(r.headers).length>0?r.headers:void 0,m:r.method===`POST`?void 0:r.method}}}function qZ(e){let t=e.i,n=e.t??1;if(n===3){let r=e.p;return[t,n,{event:r.e,data:r.d,meta:r.m}]}if(n===4)return[t,n,e.p];let r=e.p;return[t,1,{url:r.u.startsWith(`/`)?new URL(`http://orpc${r.u}`):new URL(r.u),headers:r.h??{},method:r.m??`POST`,body:r.b}]}function JZ(e,t,n){if(t===3){let r=n;return{i:e,t,p:{e:r.event,d:r.data,m:r.meta}}}if(t===4)return{i:e,t,p:void 0};let r=n;return{i:e,p:{s:r.status===200?void 0:r.status,h:Object.keys(r.headers).length>0?r.headers:void 0,b:r.body}}}function YZ(e){let t=e.i,n=e.t;if(n===3){let r=e.p;return[t,n,{event:r.e,data:r.d,meta:r.m}]}if(n===4)return[t,n,e.p];let r=e.p;return[t,2,{status:r.s??200,headers:r.h??{},body:r.b}]}async function XZ(e,t,n){if(t===3||t===4)return nQ(KZ(e,t,n));let r=n,{body:i,headers:a}=await eQ(r.body,r.headers),o=KZ(e,1,{...r,body:i instanceof Blob?void 0:i,headers:a});return i instanceof Blob?nQ(o,i):nQ(o)}async function ZZ(e){let{json:t,buffer:n}=await rQ(e),[r,i,a]=qZ(t);if(i===3||i===4)return[r,i,a];let o=a,s=await tQ(o.headers,o.body,n);return[r,i,{...o,body:s}]}async function QZ(e,t,n){if(t===3||t===4)return nQ(JZ(e,t,n));let r=n,{body:i,headers:a}=await eQ(r.body,r.headers),o=JZ(e,2,{...r,body:i instanceof Blob?void 0:i,headers:a});return i instanceof Blob?nQ(o,i):nQ(o)}async function $Z(e){let{json:t,buffer:n}=await rQ(e),[r,i,a]=YZ(t);if(i===3||i===4)return[r,i,a];let o=a,s=await tQ(o.headers,o.body,n);return[r,i,{...o,body:s}]}async function eQ(e,t){let n={...t},r=n[`content-disposition`];if(delete n[`content-type`],delete n[`content-disposition`],e instanceof Blob)return n[`content-type`]=e.type,n[`content-disposition`]=r??sZ(e instanceof File?e.name:`blob`),{body:e,headers:n};if(e instanceof FormData){let t=new Response(e);return n[`content-type`]=t.headers.get(`content-type`),{body:await t.blob(),headers:n}}return e instanceof URLSearchParams?(n[`content-type`]=`application/x-www-form-urlencoded`,{body:e.toString(),headers:n}):SX(e)?(n[`content-type`]=`text/event-stream`,{body:void 0,headers:n}):{body:e,headers:n}}async function tQ(e,t,n){let r=uZ(e[`content-type`]),i=uZ(e[`content-disposition`]);if(typeof i==`string`){let e=cZ(i)??`blob`;return new File(n===void 0?[]:[n],e,{type:r})}return r?.startsWith(`multipart/form-data`)?new Response(n,{headers:{"content-type":r}}).formData():r?.startsWith(`application/x-www-form-urlencoded`)&&typeof t==`string`?new URLSearchParams(t):t}async function nQ(e,t){let n=AX(e);return t===void 0||t.size===0?n:dX(new Blob([new TextEncoder().encode(n),new Uint8Array([255]),t]))}async function rQ(e){if(typeof e==`string`)return{json:JSON.parse(e)};let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.indexOf(255);if(n===-1){let e=new TextDecoder().decode(t);return{json:JSON.parse(e)}}let r=new TextDecoder().decode(t.subarray(0,n)),i=t.subarray(n+1);return{json:JSON.parse(r),buffer:i}}function iQ(e,t,n,r={}){let i;return new TX(async()=>{i??=gX(`consume_event_iterator_stream`);try{let n=await bX(i,()=>e.pull(t));switch(n.event){case`message`:{let e=n.data;return n.meta&&NX(e)&&(e=iZ(e,n.meta)),i?.addEvent(`message`),{value:e,done:!1}}case`error`:{let e=new $X({data:n.data});throw n.meta&&(e=iZ(e,n.meta)),i?.addEvent(`error`),e}case`done`:{let e=n.data;return n.meta&&NX(e)&&(e=iZ(e,n.meta)),i?.addEvent(`done`),{value:e,done:!0}}}}catch(e){throw e instanceof $X||_X(i,e,r),e}},async e=>{try{e!==`next`&&i?.addEvent(`cancelled`),await bX(i,()=>n(e))}catch(e){throw _X(i,e,r),e}finally{i?.end()}})}function aQ(e,t){return yX({name:`stream_event_iterator`},async n=>{for(;;){let r=await(async()=>{try{let{value:t,done:r}=await e.next();return r?(n?.addEvent(`done`),{event:`done`,data:t,meta:aZ(t)}):(n?.addEvent(`message`),{event:`message`,data:t,meta:aZ(t)})}catch(e){if(e instanceof $X)return n?.addEvent(`error`),{event:`error`,data:e.data,meta:aZ(e)};try{await t({event:`error`,data:void 0})}catch(t){throw _X(n,e),t}throw e}})(),i=!1;try{let n=await t(r);if(r.event===`done`||r.event===`error`)return;if(n===`abort`){i=!0,await e.return?.();return}}catch(t){if(!i)try{await e.return?.()}catch(e){throw _X(n,t),e}throw t}}})}var oQ=class{peer;constructor(e){this.peer=new sQ(async([t,n,r])=>{await e(await XZ(t,n,r))})}get length(){return this.peer.length}open(e){return this.peer.open(e)}async request(e){return this.peer.request(e)}async message(e){return this.peer.message(await $Z(e))}close(e={}){return this.peer.close(e)}},sQ=class{idGenerator=new DX;responseQueue=new xX;serverEventIteratorQueue=new xX;serverControllers=new Map;cleanupFns=new Map;send;constructor(e){this.send=async t=>{let n=t[0];this.serverControllers.has(n)&&await e(t)}}get length(){return(+this.responseQueue.length+this.serverEventIteratorQueue.length+this.serverControllers.size+this.cleanupFns.size)/4}open(e){this.serverEventIteratorQueue.open(e),this.responseQueue.open(e);let t=new AbortController;return this.serverControllers.set(e,t),this.cleanupFns.set(e,[]),t}async request(e){let t=e.signal;return yX({name:`send_peer_request`,signal:t},async()=>{if(t?.aborted)throw t.reason;let n=this.idGenerator.generate(),r=this.open(n);try{let i=hX();if(i){let t=PX(e.headers);i.propagation.inject(i.context.active(),t),e={...e,headers:t}}if(await this.send([n,GZ.REQUEST,e]),t?.aborted)throw await this.send([n,GZ.ABORT_SIGNAL,void 0]),t.reason;let a;if(t?.addEventListener(`abort`,a=async()=>{await this.send([n,GZ.ABORT_SIGNAL,void 0]),this.close({id:n,reason:t.reason})},{once:!0}),this.cleanupFns.get(n)?.push(()=>{t?.removeEventListener(`abort`,a)}),SX(e.body)){let t=e.body;aQ(t,async e=>r.signal.aborted?`abort`:(await this.send([n,GZ.EVENT_ITERATOR,e]),`next`))}let o=await this.responseQueue.pull(n);if(dZ(o.headers)){let e=iQ(this.serverEventIteratorQueue,n,async e=>{try{e!==`next`&&await this.send([n,GZ.ABORT_SIGNAL,void 0])}finally{this.close({id:n})}},{signal:t});return{...o,body:e}}return this.close({id:n}),o}catch(e){throw this.close({id:n,reason:e}),e}})}async message([e,t,n]){if(t===GZ.ABORT_SIGNAL){this.serverControllers.get(e)?.abort();return}if(t===GZ.EVENT_ITERATOR){this.serverEventIteratorQueue.isOpen(e)&&this.serverEventIteratorQueue.push(e,n);return}this.responseQueue.isOpen(e)&&this.responseQueue.push(e,n)}close(e={}){e.id===void 0?(this.serverControllers.forEach(t=>t.abort(e.reason)),this.serverControllers.clear(),this.cleanupFns.forEach(e=>e.forEach(e=>e())),this.cleanupFns.clear()):(this.serverControllers.get(e.id)?.abort(e.reason),this.serverControllers.delete(e.id),this.cleanupFns.get(e.id)?.forEach(e=>e()),this.cleanupFns.delete(e.id)),this.responseQueue.close(e),this.serverEventIteratorQueue.close(e)}},cQ=class{peer;constructor(e){this.peer=new lQ(async([t,n,r])=>{await e(await QZ(t,n,r))})}get length(){return this.peer.length}open(e){return this.peer.open(e)}async message(e,t){return this.peer.message(await ZZ(e),t)}async response(e,t){return this.peer.response(e,t)}close({abort:e=!0,...t}={}){return this.peer.close({...t,abort:e})}},lQ=class{clientEventIteratorQueue=new xX;clientControllers=new Map;send;constructor(e){this.send=async t=>{let n=t[0];this.clientControllers.has(n)&&await e(t)}}get length(){return(this.clientEventIteratorQueue.length+this.clientControllers.size)/2}open(e){this.clientEventIteratorQueue.open(e);let t=new AbortController;return this.clientControllers.set(e,t),t}async message([e,t,n],r){if(t===GZ.ABORT_SIGNAL)return this.close({id:e,reason:new pX(`Client aborted the request`)}),[e,void 0];if(t===GZ.EVENT_ITERATOR)return this.clientEventIteratorQueue.isOpen(e)&&this.clientEventIteratorQueue.push(e,n),[e,void 0];let i=this.open(e).signal,a={...n,signal:i,body:dZ(n.headers)?iQ(this.clientEventIteratorQueue,e,async t=>{t!==`next`&&await this.send([e,GZ.ABORT_SIGNAL,void 0])},{signal:i}):n.body};if(r){let t,n=hX();n&&(t=n.propagation.extract(n.context.active(),a.headers)),await yX({name:`receive_peer_request`,context:t},async()=>{let t=await yX({name:`handle_request`},async()=>{try{return await r(a)}catch(t){throw this.close({id:e,reason:t,abort:!1}),t}});await yX({name:`send_peer_response`},()=>this.response(e,t))})}return[e,a]}async response(e,t){let n=this.clientControllers.get(e)?.signal;if(!(!n||n.aborted))try{if(await this.send([e,GZ.RESPONSE,t]),!n.aborted&&SX(t.body))if(t.body instanceof oZ)t.body.hibernationCallback?.(e);else{let r=t.body;await aQ(r,async t=>n.aborted?`abort`:(await this.send([e,GZ.EVENT_ITERATOR,t]),`next`))}this.close({id:e,abort:!1})}catch(t){throw this.close({id:e,reason:t,abort:!1}),t}}close({abort:e=!0,...t}={}){t.id===void 0?(e&&this.clientControllers.forEach(e=>e.abort(t.reason)),this.clientControllers.clear()):(e&&this.clientControllers.get(t.id)?.abort(t.reason),this.clientControllers.delete(t.id)),this.clientEventIteratorQueue.close(t)}};function uQ(e){let t;if(typeof e==`string`)t=e;else{let n=e instanceof Uint8Array?e:new Uint8Array(e);t=Buffer.from(n).toString(`utf8`)}return Buffer.from(t+`
|
|
85765
|
+
`,`utf8`)}function dQ(e){let t=[],n=0;for(let r=0;r<e.length;r++)if(e[r]===10){let i=e.subarray(n,r).toString(`utf8`).trim();i&&t.push(i),n=r+1}return[t,e.subarray(n)]}function fQ(e,t){let n=UZ(t,{});try{m.existsSync(e)&&m.unlinkSync(e)}catch{}let r=R.createServer(e=>{let t=new cQ(t=>{!e.destroyed&&e.writable&&e.write(uQ(t))}),r=Buffer.alloc(0);e.on(`data`,async e=>{r=Buffer.concat([r,e]);let[i,a]=dQ(r);r=a;for(let e of i)await t.message(e,n)}),e.on(`close`,()=>{t.close()}),e.on(`error`,()=>{e.destroy(),t.close()})});return new Promise((t,n)=>{r.on(`error`,n),r.listen(e,()=>{r.removeListener(`error`,n),r.on(`error`,()=>{});try{m.chmodSync(e,438)}catch{}t({getSocketPath:()=>e,dispose:()=>{r.close();try{m.existsSync(e)&&m.unlinkSync(e)}catch{}}})})})}var pQ=class{peer;constructor(e){this.peer=e}async call(e){let t=await this.peer.request(e);return{...t,body:()=>Promise.resolve(t.body)}}},mQ=class extends AZ{constructor(e){super(new pQ(e),{url:`orpc:/`})}};function hQ(e,t){let n=t?.timeoutMs??2e3;return new Promise((t,r)=>{let i=R.connect(e),a=setTimeout(()=>{i.destroy(),r(Error(`Connection to ${e} timed out after ${n}ms`))},n);i.on(`connect`,()=>{clearTimeout(a);let e=new oQ(e=>{!i.destroyed&&i.writable&&i.write(uQ(e))}),n=Buffer.alloc(0);i.on(`data`,async t=>{n=Buffer.concat([n,t]);let[r,i]=dQ(n);n=i;for(let t of r)await e.message(t)}),i.on(`close`,()=>e.close()),i.on(`error`,()=>{i.destroy(),e.close()}),t({link:new mQ(e),dispose:()=>{e.close(),i.destroy()}})}),i.on(`error`,e=>{clearTimeout(a),r(e)})})}const gQ=Symbol(`ORPC_LAZY_SYMBOL`);function _Q(e,t={}){return{[gQ]:{loader:e,meta:t}}}function vQ(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&gQ in e}function yQ(e){return e[gQ].meta}function bQ(e){return vQ(e)?e[gQ].loader():Promise.resolve({default:e})}function xQ(e,t){if(t.length>e.length)return!1;for(let n=0;n<e.length;n++){if(t[n]===void 0)return!0;if(e[n]!==t[n])return!1}return!0}function SQ(e,t,n){return n.dedupeLeading&&xQ(t,e)?t:[...e,...t]}function CQ(e,t){return[...e,t]}var wQ=class{"~orpc";constructor(e){this[`~orpc`]=e}};function TQ(e){return e instanceof wQ?!0:yZ(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function EQ(e,t){return{...e,...t}}function DQ(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=lX(t),i=e[n];return new qX(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function OQ(e){return{output:e,context:{}}}function kQ(e,...t){let n=lX(t);return async(...[t,r])=>{let i=uX(n.path),{default:a}=await bQ(e),o=r?.context??{},s=await IX(n.context??{},o),c=DQ(a[`~orpc`].errorMap),l=async e=>e instanceof qX?await _Z(a[`~orpc`].errorMap,e):e;try{let e=await yX({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),OX(uX(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>MQ(e.procedure,e))));return SX(e)?e instanceof oZ?e:BX(e,fZ(EX({name:`consume_event_iterator_output`,signal:r?.signal},e),{value:e=>e,error:e=>l(e)})):e}catch(e){throw await l(e)}}}async function AQ(e,t){let n=e[`~orpc`].inputSchema;return n?yX({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new qX(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new hZ({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function jQ(e,t){let n=e[`~orpc`].outputSchema;return n?yX({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new qX(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new hZ({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function MQ(e,t){let n=e[`~orpc`].middlewares,r=Math.min(Math.max(0,e[`~orpc`].inputValidationIndex),n.length),i=Math.min(Math.max(0,e[`~orpc`].outputValidationIndex),n.length),a=async(o,s,c)=>{let l=c;o===r&&(l=await AQ(e,l));let u=n[o],d=u?await yX({name:`middleware.${u.name}`,signal:t.signal},async e=>(e?.setAttribute(`middleware.index`,o),e?.setAttribute(`middleware.name`,u.name),(await u({...t,context:s,next:async(...[e])=>{let t=e?.context??{};return{output:await a(o+1,EQ(s,t),l),context:t}}},l,OQ)).output)):await yX({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await jQ(e,d):d};return a(0,t.context,t.input)}const NQ=Symbol(`ORPC_HIDDEN_ROUTER_CONTRACT`);function PQ(e,t){return new Proxy(e,{get(e,n){return n===NQ?t:Reflect.get(e,n)}})}function FQ(e){return e[NQ]}function IQ(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||TQ(n))return;if(!vQ(n)){n=n[r];continue}let i=n,a=t.slice(e);return _Q(async()=>bQ(IQ((await bQ(i)).default,a)),yQ(i))}return n}function LQ(e){return new Proxy(e,{get(t,n){return typeof n==`string`?LQ(IQ(e,[n])):Reflect.get(t,n)}})}function RQ(e,t){if(vQ(e)){let n=yQ(e),r=n?.prefix?FZ(t.prefix,n?.prefix):t.prefix;return LQ(_Q(async()=>{let{default:n}=await bQ(e);return bQ(RQ(n,t))},{...n,prefix:r}))}if(TQ(e)){let n=SQ(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new wQ({...e[`~orpc`],route:LZ(e[`~orpc`].route,t),errorMap:gZ(t.errorMap,e[`~orpc`].errorMap),middlewares:n,inputValidationIndex:e[`~orpc`].inputValidationIndex+r,outputValidationIndex:e[`~orpc`].outputValidationIndex+r})}let n={};for(let r in e)n[r]=RQ(e[r],t);return n}function zQ(e,t,n=[]){let r=e.router,i=FQ(e.router);if(i!==void 0&&(r=i),vQ(r))n.push({router:r,path:e.path});else if(yZ(r))t({contract:r,path:e.path});else for(let i in r)zQ({router:r[i],path:[...e.path,i]},t,n);return n}function BQ(e,t){return new wQ({...e[`~orpc`],errorMap:t[`~orpc`].errorMap,route:t[`~orpc`].route,meta:t[`~orpc`].meta})}const VQ={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function HQ(e,t){return t===void 0?VQ[e]:t}function UQ(e){let t=((...t)=>e(...t));return t.mapInput=t=>UQ((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?UQ(t).mapInput(n):t;return UQ((t,n,i,...a)=>e({...t,next:(...[e])=>r({...t,context:{...t.context,...e?.context},next:(...[n])=>t.next({context:{...e?.context,...n?.context}})},n,i,...a)},n,i,...a))},t}function WQ(e){return async t=>{try{return[null,await e(t)]}catch(e){if(e instanceof Error&&`digest`in e&&typeof e.digest==`string`&&e.digest.startsWith(`NEXT_`)||e instanceof Response&&`options`in e&&MX(e.options)||MX(e)&&e.isNotFound===!0)throw e;return[JX(e).toJSON(),void 0]}}}var GQ=class e extends wQ{errors(t){return new e({...this[`~orpc`],errorMap:gZ(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:jZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:MZ(this[`~orpc`].route,t)})}use(t,n){let r=n?UQ(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:CQ(this[`~orpc`].middlewares,r)})}callable(...e){let t=kQ(this,...e);return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}actionable(...e){let t=WQ(kQ(this,...e));return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}},KQ=class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-HQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-HQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:HQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:HQ(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:HQ(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:HQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:HQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)})}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}middleware(e){return UQ(e)}errors(t){return new e({...this[`~orpc`],errorMap:gZ(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?UQ(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:CQ(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:jZ(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:MZ(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:HQ(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:HQ(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new GQ({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:FZ(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:IZ(this[`~orpc`].tags,t)})}router(e){return RQ(e,this[`~orpc`])}lazy(e){return RQ(_Q(e),this[`~orpc`])}};new KQ({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:HQ(`initialInputValidationIndex`),outputValidationIndex:HQ(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function qQ(e,t,n){return yZ(e)?new KQ({...e[`~orpc`],config:t,middlewares:n,inputValidationIndex:HQ(`initialInputValidationIndex`,t?.initialInputValidationIndex)+n.length,outputValidationIndex:HQ(`initialOutputValidationIndex`,t?.initialOutputValidationIndex)+n.length,dedupeLeadingMiddlewares:HQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}):new Proxy(e,{get:(r,i)=>{if(typeof i!=`string`)return Reflect.get(r,i);let a;i===`middleware`?a=e=>UQ(e):i===`use`?a=r=>qQ(e,t,CQ(n,r)):i===`router`?a=r=>PQ(RQ(r,{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:HQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e):i===`lazy`&&(a=r=>PQ(RQ(_Q(r),{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:HQ(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e));let o=RZ(r,[i]);if(!o)return a??o;let s=qQ(o,t,n);return a?new Proxy(a,{get(e,t){return Reflect.get(s,t)}}):s}})}function JQ(e,t={}){let n=qQ(e,t,[]),r=new Proxy(n,{get:(t,n)=>{let i;n===`$context`?i=()=>r:n===`$config`&&(i=t=>JQ(e,t));let a=Reflect.get(t,n);return!i||!a||typeof a!=`function`&&typeof a!=`object`?i||a:new Proxy(i,{get(e,t){return Reflect.get(a,t)}})}});return r}var YQ=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e,t){for(let n of this.plugins)n.init?.(e,t)}},XQ=class{constructor(e,t,n,r){this.matcher=t,this.codec=n,new YQ(r.plugins).init(r,e),this.interceptors=uX(r.interceptors),this.clientInterceptors=uX(r.clientInterceptors),this.rootInterceptors=uX(r.rootInterceptors),this.matcher.init(e)}interceptors;clientInterceptors;rootInterceptors;async handle(e,t){let n=t.prefix?.replace(/\/$/,``)||void 0;return n&&!e.url.pathname.startsWith(`${n}/`)&&e.url.pathname!==n?{matched:!1,response:void 0}:OX(this.rootInterceptors,{...t,request:e,prefix:n},async t=>yX({name:`${e.method} ${e.url.pathname}`},async e=>{let n;try{return await OX(this.interceptors,t,async({request:t,context:r,prefix:i})=>{let a=t.method,o=t.url,s=i?o.pathname.replace(i,``):o.pathname,c=await yX({name:`find_procedure`},()=>this.matcher.match(a,`/${s.replace(/^\/|\/$/g,``)}`));if(!c)return{matched:!1,response:void 0};e?.updateName(`${fX}.${c.path.join(`/`)}`),e?.setAttribute(`rpc.system`,fX),e?.setAttribute(`rpc.method`,c.path.join(`.`)),n=`decode_input`;let l=await yX({name:`decode_input`},()=>this.codec.decode(t,c.params,c.procedure));n=void 0,SX(l)&&(l=EX({name:`consume_event_iterator_input`,signal:t.signal},l));let u=kQ(c.procedure,{context:r,path:c.path,interceptors:this.clientInterceptors});n=`call_procedure`;let d=await u(l,{signal:t.signal,lastEventId:uZ(t.headers[`last-event-id`])});return n=void 0,{matched:!0,response:this.codec.encode(d,c.procedure)}})}catch(t){n!==`call_procedure`&&_X(e,t);let r=n===`decode_input`&&!(t instanceof qX)?new qX(`BAD_REQUEST`,{message:`Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,cause:t}):JX(t);return{matched:!0,response:this.codec.encodeError(r)}}}))}},ZQ=class{constructor(e){this.serializer=e}async decode(e,t,n){let r=e.method===`GET`?kX(e.url.searchParams.getAll(`data`).at(-1)):await e.body();return this.serializer.deserialize(r)}encode(e,t){return{status:200,headers:{},body:this.serializer.serialize(e)}}encodeError(e){return{status:e.status,headers:{},body:this.serializer.serialize(e.toJSON())}}},QQ=class{filter;tree=new FX;pendingRouters=[];constructor(e={}){this.filter=e.filter??!0}init(e,t=[]){let n=zQ({router:e,path:t},t=>{if(!IX(this.filter,t))return;let{path:n,contract:r}=t,i=TZ(n);TQ(r)?this.tree[i]={path:n,contract:r,procedure:r,router:e}:this.tree[i]={path:n,contract:r,procedure:void 0,router:e}});this.pendingRouters.push(...n.map(e=>({...e,httpPathPrefix:TZ(e.path)})))}async match(e,t){if(this.pendingRouters.length){let e=[];for(let n of this.pendingRouters)if(t.startsWith(n.httpPathPrefix)){let{default:e}=await bQ(n.router);this.init(e,n.path)}else e.push(n);this.pendingRouters=e}let n=this.tree[t];if(n){if(!n.procedure){let{default:e}=await bQ(IQ(n.router,n.path));if(!TQ(e))throw Error(`
|
|
85766
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${TZ(n.path)}.
|
|
85767
|
+
Ensure that the procedure is correctly defined and matches the expected contract.
|
|
85768
|
+
`);n.procedure=BQ(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},$Q=class extends XQ{constructor(e,t={}){let n=new kZ(new wZ(t)),r=new QQ(t),i=new ZQ(n);super(e,r,i,t)}},e$=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=w.join(t.homedir(),Le.configDirName,`cli`);this.socketPath=w.join(e,`${process.pid}.sock`)}getEditorState(){return{...this.editorState}}onEditorChange(e){this.onEditorStateCallback=e}waitForDecision(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Aborted`));return}let i=()=>{t?.removeEventListener(`abort`,a),this.pendingDecisions.delete(e)},a=()=>{i(),r(Error(`Aborted`))};t?.addEventListener(`abort`,a,{once:!0}),this.pendingDecisions.set(e,{resolve:e=>{i(),n(e)},cleanup:i})})}async start(){let e=w.dirname(this.socketPath);m.existsSync(e)||m.mkdirSync(e,{recursive:!0});let t=JQ(VZ),n=t.router({editorStateChanged:t.editorStateChanged.handler(async({input:e})=>(this.editorState={file:e.file??void 0,startLine:e.startLine,endLine:e.endLine},this.onEditorStateCallback?.(this.editorState),{ok:!0})),toolDecision:t.toolDecision.handler(async({input:e})=>{let t=this.pendingDecisions.get(e.toolId);return t&&t.resolve(e.decision),{ok:!0}})});this.socketServer=await fQ(this.socketPath,new $Q(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},t$=class{client=null;disposeSocket=null;currentFile=void 0;selectionStartLine=void 0;selectionEndLine=void 0;onFileChangeCallback=null;constructor(e){this.pushServer=e}findSocketPath(){let e=process.env[Le.socketEnvVar];if(e&&h.existsSync(e))return e;try{let e=T.join(n.homedir(),Le.configDirName,Le.ideDirName),t=h.readdirSync(e).filter(e=>e.endsWith(`.sock`));if(t.length===0)return null;let r=null;for(let n of t){let t=T.join(e,n);try{let e=h.statSync(t);(!r||e.mtimeMs>r.mtime)&&(r={path:t,mtime:e.mtimeMs})}catch{}}if(r&&h.existsSync(r.path))return r.path}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await hQ(e,{timeoutMs:2e3});this.client=mZ(t.link),this.disposeSocket=()=>t.dispose(),await this.client.register({cliSocketPath:this.pushServer.socketPath,pid:process.pid});let n=this.pushServer.getEditorState();return this.currentFile=n.file,this.selectionStartLine=n.startLine,this.selectionEndLine=n.endLine,this.pushServer.onEditorChange(e=>{this.currentFile=e.file,this.selectionStartLine=e.startLine,this.selectionEndLine=e.endLine,this.onFileChangeCallback?.(e.file,e.startLine,e.endLine)}),!0}catch{return!1}}getCurrentFile(){return this.currentFile}getSelectionRange(){return{startLine:this.selectionStartLine,endLine:this.selectionEndLine}}isConnected(){return this.client!==null}onFileChange(e){this.onFileChangeCallback=e}async showDiff(e){if(!this.client)return!1;try{return(await this.client.showDiff({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async showToolView(e){if(!this.client)return!1;try{return(await this.client.showToolView({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async notifyDiffDecision(e){if(!this.client)throw Error(`Not connected to extension`);await this.client.notifyDiffDecision(e)}async openPlanFile(e){if(!this.client)throw Error(`Not connected to extension`);return{opened:(await this.client.openFile({file:e})).success}}async getDiagnostics(e){if(!this.client)throw Error(`Not connected to extension`);return this.client.getDiagnostics({...e&&{files:e}})}dispose(){this.disposeSocket?.(),this.disposeSocket=null,this.client=null,this.currentFile=void 0,this.selectionStartLine=void 0,this.selectionEndLine=void 0,this.onFileChangeCallback=null}};const n$=(0,X.createContext)(null);function r$(){let e=(0,X.use)(n$);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function i$({children:e,initialFile:t}){let[n,r]=(0,X.useState)(t),[i,a]=(0,X.useState)(void 0),[o,s]=(0,X.useState)(void 0),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=!1;return(async()=>{let t=new e$;try{await t.start()}catch{}if(e){t.dispose();return}p.current=t,d(t),t.onEditorChange(e=>{r(e.file),a(e.startLine),s(e.endLine)});for(let n of[0,...[500,1e3,2e3,3e3,4e3]]){if(e||(n>0&&await new Promise(e=>setTimeout(e,n)),e))return;try{let n=new t$(t);if(await n.connect()){if(e){n.dispose();return}let i=t.getEditorState();r(i.file),a(i.startLine),s(i.endLine),n.onFileChange((e,t,n)=>{r(e),a(t),s(n)}),f.current=n,l(n);return}}catch{}}})(),()=>{e=!0,f.current&&(f.current.dispose(),f.current=null,l(null)),p.current&&(p.current.dispose(),p.current=null,d(null))}},[]),(0,Y.jsx)(n$.Provider,{value:{currentFile:n,selectionStartLine:i,selectionEndLine:o,connection:c,pushServer:u},children:e})}const a$=(0,X.createContext)(null);function o$({children:e}){let[t,n]=(0,X.useState)(`idle`),r=(0,X.useCallback)(()=>n(`upload`),[]),i=(0,X.useCallback)(()=>n(`download`),[]),a=(0,X.useCallback)(()=>n(`idle`),[]),o=(0,X.useMemo)(()=>({activity:t,setActivity:n,startUpload:r,startDownload:i,stopActivity:a}),[t,r,i,a]);return(0,Y.jsx)(a$.Provider,{value:o,children:e})}function s$(){let e=(0,X.use)(a$);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}let c$=function(e){return e.ESC=`\x1B`,e.BEL=`\x07`,e.ST=`\x1B\\`,e.ENABLE_FOCUS_REPORTING=`${e.ESC}[?1004h`,e.DISABLE_FOCUS_REPORTING=`${e.ESC}[?1004l`,e.FOCUS_IN=`${e.ESC}[I`,e.FOCUS_OUT=`${e.ESC}[O`,e.SHOW_CURSOR=`${e.ESC}[?25h`,e.HIDE_CURSOR=`${e.ESC}[?25l`,e.SET_TITLE=`${e.ESC}]2;`,e.RESET_SGR=`${e.ESC}[0m`,e.SOFT_RESET=`${e.ESC}[!p`,e.HARD_RESET=`${e.ESC}c`,e.ENABLE_BRACKETED_PASTE=`${e.ESC}[?2004h`,e.DISABLE_BRACKETED_PASTE=`${e.ESC}[?2004l`,e.PASTE_MODE_PREFIX=`${e.ESC}[200~`,e.PASTE_MODE_SUFFIX=`${e.ESC}[201~`,e.DIM=`${e.ESC}[2m`,e.BOLD=`${e.ESC}[1m`,e.RESET_BOLD=`${e.ESC}[22m`,e.ITALIC=`${e.ESC}[3m`,e.RESET_ITALIC=`${e.ESC}[23m`,e.STRIKETHROUGH=`${e.ESC}[9m`,e.RESET_STRIKETHROUGH=`${e.ESC}[29m`,e.UNDERLINE=`${e.ESC}[4m`,e.RESET_UNDERLINE=`${e.ESC}[24m`,e}({});function l$(e){return`${c$.ESC}]9;\n\n${e}${c$.BEL}`}function u$(e,t){return`${c$.ESC}]777;notify;${e};${t}${c$.BEL}`}function d$(e,t){let n=Math.floor(Math.random()*1e4),r=`${c$.ESC}]99;i=${n}:d=0:p=title;${e}${c$.ST}`,i=`${c$.ESC}]99;i=${n}:p=body;${t}${c$.ST}`,a=`${c$.ESC}]99;i=${n}:d=1:a=focus;${c$.ST}`;return r+i+a}function f$(e,t){let n=`9;4;${e};${t===void 0?0:Math.max(0,Math.min(100,Math.round(t)))}`;return`${c$.ESC}]${n}${c$.BEL}${c$.ESC}]${n}${c$.ST}`}function p$(e){return e.replaceAll(`\x1B`,``).replaceAll(`\x07`,``).replaceAll(`
|
|
85769
|
+
`,` `).replaceAll(`\r`,` `).replaceAll(`;`,`:`).trim().slice(0,120)}function m$(e){return`${c$.ESC}]${e}${c$.BEL}${c$.ESC}]${e}${c$.ST}`}function h$(){return m$(`1337;Progress=`)}function g$(e){return m$(`1337;Progress=${e}`)}function _$(e,t){let n=Math.max(0,Math.min(100,Math.round(e))),r=t?p$(t):``;return r?m$(`1337;Progress=${n};${r}`)+m$(`1337;Progress=message=${r};percent=${n}`):m$(`1337;Progress=${n}`)}function v$({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const y$=v$();function b$(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(y$,``)}const x$=[`pycharm`,`intellij`,`webstorm`,`phpstorm`,`rubymine`,`clion`,`goland`,`rider`,`datagrip`,`appcode`,`dataspell`,`aqua`,`gateway`,`fleet`,`jetbrains`,`androidstudio`];function S$(e){if(V.env.CURSOR_TRACE_ID)return e?.debug?.(`Detected Cursor terminal via CURSOR_TRACE_ID`),`cursor`;if(V.env.VSCODE_GIT_ASKPASS_MAIN?.includes(`/.cursor-server/`))return e?.debug?.(`Detected Cursor terminal via VSCODE_GIT_ASKPASS_MAIN`),`cursor`;if(V.env.VSCODE_GIT_ASKPASS_MAIN?.includes(`/.windsurf-server/`))return e?.debug?.(`Detected Windsurf terminal`),`windsurf`;let t=V.env.__CFBundleIdentifier?.toLowerCase();if(t?.includes(`vscodium`))return`codium`;if(t?.includes(`windsurf`))return`windsurf`;if(t?.includes(`com.google.android.studio`))return`androidstudio`;if(t){for(let e of x$)if(t.includes(e))return e}if(V.env.VisualStudioVersion)return`visualstudio`;if(V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`)return`pycharm`;if(V.env.TERM===`xterm-ghostty`)return`ghostty`;if(V.env.TERM?.includes(`kitty`))return`kitty`;if(V.env.WEZTERM_PANE)return`WezTerm`;if(V.env.ITERM_SESSION_ID)return`iTerm.app`;if(V.env.TERM_PROGRAM===`Apple_Terminal`)return`Apple_Terminal`;if(V.env.TERM_PROGRAM)return V.env.TERM_PROGRAM;if(V.env.STY)return`screen`;if(V.env.KONSOLE_VERSION)return`konsole`;if(V.env.GNOME_TERMINAL_SERVICE)return`gnome-terminal`;if(V.env.XTERM_VERSION)return`xterm`;if(V.env.VTE_VERSION)return`vte-based`;if(V.env.TERMINATOR_UUID)return`terminator`;if(V.env.KITTY_WINDOW_ID)return`kitty`;if(V.env.ALACRITTY_LOG)return`alacritty`;if(V.env.TILIX_ID)return`tilix`;if(V.env.WT_SESSION)return`windows-terminal`;if(V.env.SESSIONNAME&&V.env.TERM===`cygwin`)return`cygwin`;if(V.env.MSYSTEM)return V.env.MSYSTEM.toLowerCase();if(V.env.ConEmuANSI||V.env.ConEmuPID||V.env.ConEmuTask)return`conemu`;if(V.env.WSL_DISTRO_NAME)return`wsl-${V.env.WSL_DISTRO_NAME}`;if(V.env.SSH_CONNECTION||V.env.SSH_CLIENT||V.env.SSH_TTY)return`ssh-session`;if(V.env.TERM){let e=V.env.TERM;return e.includes(`alacritty`)?`alacritty`:e.includes(`rxvt`)?`rxvt`:e.includes(`termite`)?`termite`:V.env.TERM}return V.stdout.isTTY?(e?.debug?.(`Could not detect terminal type`),null):(e?.debug?.(`Non-interactive terminal detected`),`non-interactive`)}function C$(){switch(S$()){case`Apple_Terminal`:return`Option+Enter`;case`cursor`:case`windsurf`:case`vscode`:case`codium`:case`iTerm.app`:case`ghostty`:case`WezTerm`:case`kitty`:case`alacritty`:return`Shift+Enter`;default:return`backslash (\\) + Enter`}}function w$(e){V.stdout.isTTY&&V.stdout.write(e)}function T$(e,t){w$(l$(e?`${e}:\n${t}`:t))}function E$(e,t){w$(d$(e,t))}function D$(e,t){w$(u$(e,t))}function O$(e,t){w$(c$.BEL)}async function k$(e){let{title:t=`Abacus.AI`,message:n}=e;switch(S$()){case`iTerm.app`:T$(t,n);break;case`kitty`:E$(t,n);break;case`ghostty`:D$(t,n);break;case`WezTerm`:T$(t,n);break;default:V.platform===`win32`&&O$(t,n);break}}async function A$(e,t){await k$({...t,message:e,title:t?.title??`Action Required`})}async function j$(e,t){await k$({...t,message:e,title:t?.title??`Task Complete`})}const M$=(0,X.createContext)(null),N$=()=>{let e=(0,X.use)(M$);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e},P$=({children:e})=>{let{isFocused:t}=WL(),n=(0,X.useCallback)(async(e,n)=>{t||await k$({message:e,title:n})},[t]),r=(0,X.useCallback)(async e=>{t||await A$(e)},[t]),i=(0,X.useCallback)(async e=>{t||await j$(e)},[t]),a=(0,X.useMemo)(()=>({notifyIfUnfocused:n,notifyActionRequired:r,notifyTaskComplete:i}),[n,r,i]);return(0,Y.jsx)(M$.Provider,{value:a,children:e})},F$=(0,X.createContext)(null),I$=()=>{let e=(0,X.use)(F$);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},L$=(0,X.memo)(({children:e,client:t,authManager:n,onAuthExpired:r})=>{let[i,a]=(0,X.useState)(!1),o=(0,X.useCallback)(()=>a(!1),[]),s=(0,X.useMemo)(()=>({apiClient:t,authManager:n,authExpired:i,setAuthExpired:a,clearAuthExpired:o,onAuthExpired:r}),[i,t,n,o,r]);return(0,Y.jsx)(F$.Provider,{value:s,children:e})});L$.displayName=`ApiClientProvider`;const R$=[`conemu`,`ghostty`,`windows-terminal`,`WezTerm`,`iTerm.app`];let z$=null;function B$(e){if(!e||!V.stdout.isTTY)return!1;if(R$.includes(e))return!0;let t=e.toLowerCase();return t.includes(`iterm`)||t.includes(`ghostty`)||t.includes(`wezterm`)||t.includes(`conemu`)}function V$(e){V.stdout.write(e)}function H$(e){switch(e){case`indeterminate`:return 3;case`error`:return 2;case`warning`:return 4;default:return 1}}function U$(){z$&&=(clearTimeout(z$),null)}function W$(){U$(),z$=setTimeout(()=>{G$()},500)}function G$(){let e=S$();B$(e)&&(V$(f$(0)),e?.toLowerCase().includes(`iterm`)&&V$(h$()))}function K$(e,t){if(e instanceof Promise)return J$(e,t);let n=e,r=S$();if(!B$(r))return;U$();let i=0;n.percentage===void 0?n.total!==void 0&&n.current!==void 0&&n.total>0&&(i=n.current/n.total*100):i=n.percentage;let a=n.state??`default`;V$(f$(H$(a),i)),r?.toLowerCase().includes(`iterm`)&&(a===`indeterminate`?V$(g$(2)):(V$(_$(i,n.label)),i>=100&&V$(g$(1)))),(a===`error`||i>=100)&&W$()}function q$(){U$(),G$()}async function J$(e,t){let{label:n,hideOnComplete:r=!0}=t??{};K$({state:`indeterminate`,label:n});try{let t=await e;return K$({percentage:100,state:`default`,label:n}),r&&W$(),t}catch(e){throw K$({percentage:100,state:`error`,label:n}),r&&W$(),e}}const Y$=(0,X.createContext)(null);function X$(e,t){switch(t.type){case`INIT_SEND`:return[...e.filter(e=>e.temp!==!0),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=e.map(e=>e.type===`code_llm_tool_call`&&e.status===`transient`&&!e.toolUseResult?{...e,status:`completed`,parsedResult:{phase:`error`,toolType:Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.name??``:e.toolUseRequest?.name??``,data:{},summary:``}}:e).filter(e=>!e.isSpinny);return i.find(e=>e.id===n)?i.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...i,{id:n,status:`transient`,source:`bot`,type:`text`,segment:r}]}case`THINKING_DELTA`:{let{segId:n,content:r,startTime:i}=t;return e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...e,{id:n,status:`transient`,source:`bot`,type:`thinking`,isSpinny:!0,segment:r,thinkingStartTime:i}]}case`THINKING_COMPLETE`:return e.map(e=>e.id===t.segId?{...e,status:`completed`,isSpinny:!1,thinkingEndTime:t.endTime}:e);case`TOOL_DISPLAY_DATA`:return e.map(e=>e.id===t.toolCallId?{...e,toolDisplayData:{...e.toolDisplayData,...t.data}}:e);case`TOOL_REQUESTED`:{let{textSegId:n,toolSeg:r}=t,i;return i=n?e.filter(e=>!e.isSpinny).map(e=>e.id===n?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...i,r]}case`TOOL_EXECUTION_COMPLETE`:{let{toolCallId:n,rawResult:r,parsedResult:i,spinnySeg:a}=t;return[...e.map(e=>e.id===n?{...e,status:`completed`,toolUseResult:r,...i!==void 0&&{parsedResult:i}}:e),a]}case`TOOL_USER_MESSAGE`:return[...e,t.seg];case`TEXT_COMPLETED`:return e.map(e=>e.id===t.segId?{...e,status:`completed`}:e);case`FINALIZE`:{let n=e;return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n.filter(e=>!e.isSpinny)}case`ADD_NOTIFICATION`:{let n=t.seg,r=e[e.length-1];if(r&&r.type===`code_llm_notification`&&r.message===n.message&&r.severity===n.severity){let t=[...e];return t[t.length-1]={...r,flashKey:(r.flashKey??0)+1},t}return[...e,n]}case`ERROR`:return[...e.filter(e=>!e.isSpinny),t.errorSeg];case`REMOVE_USER_SEG`:return e.filter(e=>e.id!==t.userSegId);case`CLEAR`:return[];case`LOAD`:return t.segments;case`REMOVE_TEMP`:return e.some(e=>e.temp===!0)?e.filter(e=>e.temp!==!0):e;default:return e}}function Z$(e){switch(e.type){case`text`:return{id:e.id,status:`completed`,source:e.source,type:`text`,segment:e.content};case`thinking`:return{id:e.id,status:`completed`,source:`bot`,type:`thinking`,segment:e.content,isSpinny:e.isSpinny,...e.title!==void 0&&{title:e.title}};case`tool_call`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:e.toolUseRequest,toolUseResult:e.toolUseResult??{id:e.toolUseRequest.id,content:` `},...e.parsedResult!==void 0&&{parsedResult:e.parsedResult},...e.toolDisplayData!==void 0&&{toolDisplayData:e.toolDisplayData}};case`notification`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:e.severity,...e.actions!==void 0&&{actions:e.actions}};case`tool_group`:return{id:e.id,status:`completed`,source:`bot`,type:`text`,segment:e.summary}}}const Q$=(0,X.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=FJ(),o=(0,X.useRef)(i),{notifyActionRequired:s,notifyTaskComplete:c}=N$(),{startUpload:l,startDownload:u,stopActivity:d}=s$(),{authManager:f,setAuthExpired:p,onAuthExpired:m}=I$(),{connection:h,pushServer:g}=r$(),_=(0,X.useRef)(h),v=(0,X.useRef)(g);(0,X.useEffect)(()=>{_.current=h},[h]),(0,X.useEffect)(()=>{v.current=g},[g]);let[y,b]=(0,X.useState)(Cl.Idle),[x,S]=(0,X.useReducer)(X$,[]),C=(0,X.useRef)(new Map),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(!0),[ee,L]=(0,X.useState)(!0),R=(0,X.useRef)(!0),z=(0,X.useRef)(null),B=(0,X.useRef)(Cl.Idle),te=(0,X.useCallback)(e=>{B.current=e,b(e)},[]);(0,X.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]);let ne=(0,X.useMemo)(()=>({}),[]),[re,ie]=(0,X.useState)(null),ae=process.cwd(),oe=(0,X.useMemo)(()=>new PD(async e=>{let t=_.current,n=e,r=null;if(t&&v.current&&e.type===`edit_file`){let i=e.tool.id,a=C.current.get(i),o=e.tool.input??{},s=o.targetFile??e.filePath??``,c=a?.originalContent??e.originalContent??``,l=a?.newContent??e.newContent??o.codeEdit??``;s&&(c||l)&&await t.showDiff({filePath:s,originalContent:c,modifiedContent:l,toolId:i})&&(n={...e,diffShownInEditor:!0},r=s)}if(t&&e.type===`exit_plan_mode`&&e.planFilePath){let n=e.tool.id;if(v.current&&await t.showToolView({filePath:e.planFilePath,toolKey:n})){let e=await v.current.waitForDecision(n);return e===`allowAlways`?`allowAlways`:e}await t.openPlanFile(e.planFilePath).catch(()=>{})}let i=await new Promise(t=>{let i=!1;r&&v.current&&v.current.waitForDecision(e.tool.id).then(e=>{i||(i=!0,O(null),te(e===`accept`||e===`allowAlways`?Cl.ExecutingTool:Cl.Submitted),t(e))}).catch(()=>{}),O({request:n,resolve:e=>{i||(i=!0,O(null),te(e===`accept`||e===`allowAlways`||typeof e==`object`&&e.type===`accept_with_message`||typeof e==`object`&&e.type===`question_answers`?Cl.ExecutingTool:Cl.Submitted),setTimeout(()=>t(e),0).unref())}}),te(Cl.WaitingForToolPermission),s(`Abacus.AI is waiting for your input`)});if(r&&t){let e=i===`reject`||typeof i==`object`&&i.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return i}),[s,te]),se=(0,X.useRef)(null);function ce(){return new MD({allowedDirectories:[ae,...r?.[`add-dir`]?.map(e=>T.isAbsolute(e)?e:T.resolve(ae,e))??[]],primaryWorkspace:ae,apiClient:t,mode:o.current,permissionProvider:oe,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=_.current;return t?t.getDiagnostics(e):[]}},cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`]})}se.current||=ce();let le=se.current;(0,X.useEffect)(()=>{o.current=i,le.setMode(i)},[i,le]),(0,X.useEffect)(()=>{_D.loadSkills(ae)},[]),(0,X.useEffect)(()=>{r?.conversationId&&V(r.conversationId)},[]),(0,X.useEffect)(()=>{switch(y){case Cl.Submitted:case Cl.Streaming:K$({state:`indeterminate`,label:`Processing`});break;case Cl.ExecutingTool:K$({state:`indeterminate`,label:`Executing tools`});break;case Cl.WaitingForToolPermission:q$();break;case Cl.Idle:q$();break}},[y]);let ue=(0,X.useCallback)((e,t=`info`,n=!1)=>{S({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),de=(0,X.useCallback)(()=>{S({type:`CLEAR`}),E(null),te(Cl.Idle),ie(null),C.current.clear(),se.current=ce()},[t,ae,oe]),fe=(0,X.useCallback)(()=>{S({type:`CLEAR`})},[]),pe=(0,X.useCallback)(()=>{S({type:`REMOVE_TEMP`})},[]),me=(0,X.useCallback)(()=>{let e=le.dequeue();le.clearQueue(),A([]),e!==null&&M(e),le.stop(),O(null),te(Cl.Idle)},[le,te]),he=(0,X.useCallback)(()=>{D&&D.resolve(`reject`)},[D]),V=(0,X.useCallback)(async e=>{te(Cl.LoadingConversation),S({type:`CLEAR`}),E(null),ie(e);try{let t=await le.loadConversation(e);t.title&&E(t.title),t.segments.length>0&&S({type:`LOAD`,segments:t.segments.map(e=>Z$(e))})}catch{ue(`Failed to load conversation`,`error`)}finally{te(Cl.Idle)}},[le,ue,te]),ge=(0,X.useCallback)(async(e,t)=>{await le.mcp.refresh(),t&&ue(`MCP tools refreshed`,`info`,!0)},[le,ue]),_e=(0,X.useCallback)(async({message:e,selectedModel:t,fileAttachments:n,activeSkills:r})=>{if(!e||y===Cl.LoadingConversation)return;t&&le.setModel(t);let i=e;if(n&&n.length>0){let e=n.filter(e=>!e.mimeType.startsWith(`image/`));for(let t of e){let e=typeof t.content==`string`?t.content:t.content.toString(`utf-8`);i+=`\n\n<file path="${t.filePath}">\n${e}\n</file>`}}let o=crypto.randomUUID();S({type:`INIT_SEND`,userSeg:{id:o,status:`completed`,source:`user`,type:`text`,segment:e},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),te(Cl.Submitted),l();let s=null,h=null,g,v=_.current,b=v?.getCurrentFile(),x=v?.getSelectionRange();if(v&&b)try{let e=(await v.getDiagnostics([b])).filter(e=>e.severity===`error`||e.severity===`warning`);e.length>0&&(g=e.map(e=>`${e.file}:${e.line}:${e.column} [${e.severity}] ${e.message}`).join(`
|
|
85770
|
+
`))}catch{}try{for await(let e of le.send(i,{diagnosticIssues:g,currentFile:b??void 0,selectionStartLine:x?.startLine,selectionEndLine:x?.endLine,activeSkills:r}))switch(e.type){case`text_delta`:{te(Cl.Streaming),d(),u();let t=e.content;s||=crypto.randomUUID(),S({type:`TEXT_DELTA`,segId:s,content:t});break}case`thinking_delta`:{let t=e.content;h||=crypto.randomUUID(),S({type:`THINKING_DELTA`,segId:h,content:t,startTime:Date.now()});break}case`thinking_complete`:h&&=(S({type:`THINKING_COMPLETE`,segId:h,endTime:Date.now()}),null);break;case`tool_display_data`:{let{toolCallId:t,data:n}=e,r=C.current.get(t)??{};C.current.set(t,{...r,...n}),S({type:`TOOL_DISPLAY_DATA`,toolCallId:t,data:n});break}case`tool_requested`:{te(Cl.ExecutingTool),d(),l();let t=e.tool.id,n={id:t,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:t,name:e.tool.name,input:e.tool.input},toolDisplayData:C.current.get(t)};S({type:`TOOL_REQUESTED`,toolCallId:t,textSegId:s,toolSeg:n}),s=null;break}case`tool_execution_complete`:{d(),u();let t=e.tool.id,{parsedResult:n,...r}=e.result,i={id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Analyzing result`,temp:!0,isSpinny:!0};S({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n},spinnySeg:i}),s=null;break}case`notification`:S({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:e.severity,message:e.message,...e.actions!==void 0&&{actions:e.actions}}});break;case`error`:S({type:`ERROR`,errorSeg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:`error`,message:e.error.message}});break;case`mode_changed`:a(e.mode);break;case`tool_user_message`:S({type:`TOOL_USER_MESSAGE`,seg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.message}});break;case`retry`:P({attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,isNetworkError:e.isNetworkError});break;case`network_status`:e.online?(z.current&&=(clearTimeout(z.current),null),R.current=!0,I(!0),L(!0),P(null),setTimeout(()=>{if(B.current===Cl.Idle&&le.getQueue().length>0){let e=le.dequeue();if(e){A(le.getQueue());let t=_D.matchSkill(e.trim());_e(t?{message:e,activeSkills:[t.skill.id]}:{message:e})}}},0).unref?.()):(R.current=!1,I(!1),z.current||=setTimeout(()=>{z.current=null,R.current||L(!1)},3e4));break;case`user_message_dequeued`:S({type:`INIT_SEND`,userSeg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.content},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),A(le.getQueue()),s=null,h=null;break;case`turn_complete`:s&&=(S({type:`TEXT_COMPLETED`,segId:s}),null),A(le.getQueue());break}}catch(e){if(e instanceof Ae)f.isEnvAuth()||(p(!0),f.logout().catch(()=>{}).finally(()=>{m?.()})),S({type:`REMOVE_USER_SEG`,userSegId:o}),ue(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Pe(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;S({type:`REMOVE_USER_SEG`,userSegId:o}),ue(t,`error`,!0)}M(i),le.clearQueue(),A([])}finally{d(),P(null);let e=le.getConversationId();e&&ie(e),S({type:`FINALIZE`,textSegId:s}),te(Cl.Idle),c(`Abacus.AI completed the task`)}},[le,y,ue,c,l,u,d,a,f,p]),ve=(0,X.useCallback)(e=>{le.enqueue(e),A(le.getQueue())},[le]),ye=(0,X.useCallback)(()=>{le.dequeue(),A(le.getQueue())},[le]),be=(0,X.useCallback)(()=>{le.clearQueue(),A([])},[le]),xe=(0,X.useCallback)(()=>{M(null)},[]),Se=(0,X.useCallback)(e=>le.isDirectoryAllowed(e),[le]),Ce=(0,X.useCallback)((e,t)=>le.addAllowedDirectory(e,t),[le]),we=(0,X.useCallback)(()=>le.listTerminalSessions(),[le]),Te=(0,X.useMemo)(()=>({conversationId:re,conversationTitle:w,segments:x,segmentsLength:x.length,sendMessage:_e,stop:me,rejectPendingPermission:he,agentStatus:y,clearSegments:de,clearSegmentsOnly:fe,clearTempSegments:pe,loadConversation:V,addNotification:ue,mcp:le.mcp,isDirectoryAllowed:Se,addAllowedDirectory:Ce,pendingToolPermission:D,refreshMcpTools:ge,queuedMessages:k,addToQueue:ve,removeFirstFromQueue:ye,clearQueue:be,dequeuedOnStop:j,clearDequeuedOnStop:xe,activeToolOutputs:ne,retryState:N,networkOnline:F,debouncedNetworkOnline:ee,listTerminalSessions:we}),[re,w,x,_e,me,he,y,de,fe,pe,V,ue,le,Se,Ce,D,ge,k,ve,ye,be,j,xe,ne,N,F,ee,we]);return(0,Y.jsx)(Y$.Provider,{value:Te,children:e})});Q$.displayName=`AgentProvider`;function $$(){let e=(0,X.use)(Y$);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${Q$.name}>?`);return e}const e1=q({query:K(),includePattern:K().optional(),excludePattern:K().optional(),explanation:K().optional()}),t1={displayName:`FileSearch`,getHeaderParams(e){try{return`pattern: "${e?.query||`[no pattern]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=e1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=[`pattern: "${i.query}"`];i.includePattern&&a.push(`path: "${i.includePattern}"`),i.excludePattern&&a.push(`exclude: "${i.excludePattern}"`);let o=a.join(`, `);return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error searching files`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`executing`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:o,status:`pending`})})}};function n1(e){let t=[];return e.pattern&&t.push(`pattern: "${e.pattern}"`),e.path&&t.push(`path: "${e.path}"`),t.length>0?t.join(`, `):`[no pattern]`}const r1={displayName:`Search`,getHeaderParams(e){try{return n1(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=n1(e);if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error matching files`})]});if(t===`executing`)return(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`executing`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`pending`})});let i=n.data.files??[],a=i.slice(0,10),o=i.length-a.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`success`}),(0,Y.jsx)(_J,{children:n.summary}),i.length>0&&(0,Y.jsxs)(vJ,{children:[a.map((e,t)=>(0,Y.jsx)(Q,{dimColor:!0,children:e},t)),o>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,o,` more file`,o===1?``:`s`]})]})]})}};function i1(e){let t=e,n=[];t.pattern&&n.push(`pattern: "${t.pattern}"`),t.path&&n.push(`path: "${t.path}"`);let r=t.outputMode||e.output_mode;return r&&n.push(`outputMode: "${r}"`),t.glob&&n.push(`glob: "${t.glob}"`),t[`-i`]&&n.push(`case-insensitive`),n.length>0?n.join(`, `):`[no pattern]`}const a1={displayName:`Search`,getHeaderParams(e){try{return i1(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=i1(e);if(t===`error`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error searching content`})]});if(t===`executing`)return(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`executing`,showSpinner:!0});if(!n)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`pending`})});let i=n.data.matches??[],a=i.slice(0,10),o=i.length-a.length;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:r,status:`success`}),(0,Y.jsx)(_J,{children:n.summary}),i.length>0&&(0,Y.jsxs)(vJ,{children:[a.map((e,t)=>(0,Y.jsx)(Q,{dimColor:!0,children:e},t)),o>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,o,` more match`,o===1?``:`es`]})]})]})}},o1=q({query:K(),command:K().optional(),explanation:K().optional()}),s1={displayName:`Search`,getHeaderParams(e){try{return`"${e?.query||``}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=o1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`"${r.data.query}"`;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing semantic search`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`executing`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Search`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:`Completed`})]})}},c1=q({url:K()}),l1={displayName:`Web Fetch`,getHeaderParams(e){try{let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t}catch{return`[unknown]`}},renderUI(e,t,n){let r=c1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`success`}),(0,Y.jsx)(_J,{children:n.summary??`Fetched content`})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Fetch`,params:a,status:`pending`})})}},u1=q({searchTerm:K(),query:K().optional(),explanation:K().optional(),allowedDomains:sc(K()).optional(),blockedDomains:sc(K()).optional()}),d1={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=u1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.searchTerm||i.query||``,o=`"${a.length>40?a.substring(0,37)+`...`:a}"`;return t===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`WebSearch`,params:o,status:`success`}),(0,Y.jsx)(_J,{children:`Found results`})]})}},f1=q({shellId:K(),filter:K().optional()}),p1={displayName:`TerminalOutput`,getHeaderParams(e){try{let t=e,n=[`id: ${t.shellId||``}`];return t.filter&&n.push(`filter: ${t.filter}`),n.join(`, `)}catch{return`[unknown]`}},renderUI(e,t,n){let r=f1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`TerminalOutput`,params:i,status:`pending`})})}},m1=q({shellId:K()}),h1={displayName:`KillShell`,getHeaderParams(e){try{return`id: ${e.shellId||``}`}catch{return`[unknown]`}},renderUI(e,t,n){let r=m1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:``,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`rejected`}),n?.userNote?(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`pending`,showSpinner:!0}):n?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`KillShell`,params:i,status:`pending`})})}};function g1(e,t,n){let r=n?100:t,i=e.split(`
|
|
85771
|
+
`).filter(Boolean);return i.length<=r?{lines:i,isTruncated:!1,hiddenCount:0}:{lines:i.slice(0,r),isTruncated:!0,hiddenCount:i.length-r}}function _1(e){return`${(e/1e3).toFixed(1)}s`}function v1({command:e,toolCallId:t,executionResult:n}){let{agentStatus:r,activeToolOutputs:i}=$$(),[a]=(0,X.useState)(Date.now()),[o,s]=(0,X.useState)(0),[c,l]=(0,X.useState)(!1),u=!n&&(r===Cl.Streaming||r===Cl.ExecutingTool),d=i[t]||``,f=n?.output||``,p=u?d:f,m=(0,X.useDeferredValue)(p),h=p!==m;(0,X.useEffect)(()=>{if(u){let e=setInterval(()=>{s(Date.now()-a)},1e3);return()=>clearInterval(e)}else n&&s(n.duration??0);return()=>{}},[u,a,n]);let{lines:g,isTruncated:_,hiddenCount:v}=(0,X.useMemo)(()=>g1(m,7,c),[m,c]),y=!u&&n!==void 0&&(_||c),{isFocused:b}=UL({id:`bash-tool-${t}`,isActive:y});HL((e,t)=>{b&&t.ctrl&&e===`o`&&l(e=>!e)},{isActive:b&&y});let x=e.length>500?e.slice(0,500)+`…`:e,S=n?.exitCode??0,C=n?.status===`error`||S!==0,w=u?`pending`:C?`error`:`success`;if(u&&g.length===0)return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w,showSpinner:!0}),(0,Y.jsx)(_J,{color:`gray`,children:`Running…`})]});if(u&&g.length>0){let e=o>0?` (${_1(o)})`:``;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w,showSpinner:!0}),(0,Y.jsxs)(vJ,{children:[g.map((e,t)=>(0,Y.jsx)(Q,{children:e},t)),_&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,v,` more line`,v===1?``:`s`,e]}),h&&(0,Y.jsx)(Q,{dimColor:!0,children:`Processing output...`})]})]})}if(n){let e=!f&&(n.duration??0)===0,t=fJ(n.duration??0),r=e?`exit ${S}`:`exit ${S} (${t})`,i=g.length>0;return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:w}),i&&(0,Y.jsxs)(vJ,{children:[C&&(0,Y.jsx)(Q,{color:`red`,dimColor:!0,children:`Error:`}),g.map((e,t)=>(0,Y.jsx)(Q,{color:C?`red`:void 0,dimColor:!0,children:e},t)),_&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`… +`,v,` `,c?`more `:``,`line`,v===1?``:`s`,c?``:` (ctrl+o to expand)`]})]}),(0,Y.jsx)(_J,{color:C?`red`:`gray`,children:r})]})}return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(gJ,{name:`Bash`,params:x,paramsLanguage:`bash`,status:`pending`})})}const y1=q({command:K(),explanation:K().optional(),runInBackground:kJ,shellId:K().optional(),interactiveMode:kJ,timeout:Qc().optional()});function b1({rawInput:e,status:t,parsedResult:n}){let r=y1.safeParse(CJ(e));if(!r.success)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:``,paramsLanguage:`bash`,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.command||``,o=a.length>500?a.slice(0,500)+`…`:a,s=i.timeout?` (timeout: ${(i.timeout/1e3).toFixed(0)}s)`:``;if(t===`interrupted`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`interrupted`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return n?.userNote?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,Y.jsxs)(_J,{color:`yellow`,children:[`Rejected · `,(0,Y.jsxs)(Q,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,Y.jsx)(_J,{color:`yellow`,children:`Rejected`})]});if(n?.data?.timedOut)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,Y.jsx)(_J,{children:`Running in the background`})]});if(n?.runInBackground)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,Y.jsx)(_J,{children:n.summary})]});let c=e?.id||`unknown`,l=n?.data;return(0,Y.jsx)(v1,{command:`${o}${s}`,toolCallId:c,executionResult:l})}const x1={read_file:aX,edit:CY,list_dir:TY,delete_file:gY,notebook_edit:kY,grep:a1,glob:r1,file_search:t1,semantic_search_server:s1,web_search:d1,web_fetch:l1,bash:{displayName:`Bash`,getHeaderParams(e){try{return e?.command||`[no command]`}catch{return`[unknown]`}},renderUI(e,t,n){return(0,Y.jsx)(b1,{rawInput:e,status:t,parsedResult:n})}},bash_output:p1,kill_shell:h1,navigate_to:sY,new_tab:lY,close_tab:$J,switch_active_tab:mY,refresh_tab:fY,get_tab_content:aY,computer:tY,get_interactive_elements:rY,perform_interactive_element_action:dY,ask_user_question:jJ,enter_plan_mode:MJ,exit_plan_mode:VJ,subagent:WJ,hand_off_to_main:HJ,task:qJ,todo_write:ZJ,get_diagnostics:cX};function S1(e){let t=e.toolUseRequest;return t?(Array.isArray(t)?t:[t]).map(e=>{let t=e;return{name:t.name??``,input:t.input??{}}}).filter(e=>e.name):[]}function C1(e,t=4){let n=[];for(let r of e){if(n.length>=t)break;for(let e of S1(r)){if(n.length>=t)break;let r=x1[e.name];if(!r)continue;let i=``;try{i=r.getHeaderParams(e.input)}catch{}if(!i)continue;let a=r.displayName??e.name;n.push({label:a,detail:i})}}return n}const w1=(0,X.memo)(({counts:e,segments:t})=>{let{colors:n}=bz(),r=(0,X.useMemo)(()=>{let t=[];return e.toolUses>0&&t.push(`${e.toolUses} tool ${e.toolUses===1?`use`:`uses`}`),e.responses>0&&t.push(`${e.responses} ${e.responses===1?`response`:`responses`}`),t.length===0?`Conversation compacted`:t.join(`, `)+` compacted`},[e]),i=(0,X.useMemo)(()=>C1(t),[t]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:n.textMuted,children:`⟐`}),(0,Y.jsx)(Q,{color:n.textMuted,dimColor:!0,children:r}),(0,Y.jsx)(Q,{color:n.textMuted,dimColor:!0,children:`(ctrl+o to expand)`})]}),i.map((e,t)=>(0,Y.jsx)(Z,{flexDirection:`row`,paddingLeft:2,children:(0,Y.jsxs)(Q,{color:n.textMuted,dimColor:!0,children:[`⎿ `,e.label,` `,e.detail]})},t))]})});w1.displayName=`CompactedPlaceholder`;const T1=(0,X.createContext)(null);function E1(){let e=(0,X.use)(T1);if(!e)throw Error(`useUpdate must be used within UpdateProvider`);return e}function D1({children:e,configService:t}){let[n,r]=(0,X.useState)(null),i=(0,X.useMemo)(()=>t.get(`autoUpdate`)!==!1,[t]);(0,X.useEffect)(()=>{if(yj())return;let e=!0,t=()=>{Sj(hj.default.version).then(t=>{e&&r(e=>e?.latestVersion===t?.latestVersion?e:t)}).catch(()=>{})};t();let n=setInterval(t,6e4);return()=>{e=!1,clearInterval(n)}},[]);let a=(0,X.useMemo)(()=>({updateInfo:n,autoUpdate:i}),[n,i]);return(0,Y.jsx)(T1.Provider,{value:a,children:e})}const O1=(0,X.createContext)(null),k1=()=>{let e=(0,X.use)(O1);if(!e)throw Error(`${k1.name} must be used within a ${A1.name}`);return e};function A1({children:e}){let[t,n]=(0,X.useState)({columns:process.stdout.columns-8,rows:process.stdout.rows}),r=(0,X.useCallback)(()=>{n({columns:process.stdout.columns-8,rows:process.stdout.rows})},[]);(0,X.useLayoutEffect)(()=>(process.stdout.on(`resize`,r),()=>{process.stdout.off(`resize`,r)}),[r]);let i=(0,X.useMemo)(()=>({width:t.columns,height:t.rows}),[t.columns,t.rows]);return(0,Y.jsx)(O1.Provider,{value:i,children:e})}function j1(){let{height:e}=k1();return Math.max(0,e-3)}let M1=function(e){return e.Models=`models`,e.CreateConversation=`create-conversation`,e.GetConversation=`get-conversation`,e.Grep=`grep`,e.FileSearch=`file-search`,e.ListDir=`list-dir`,e.ReadFile=`read-file`,e.DeleteFile=`delete-file`,e.EditFile=`edit-file`,e.RunTerminal=`run-terminal`,e.GetTerminalOutput=`get-terminal-output`,e.MCPTool=`mcp-tool`,e.PrInfo=`pr-info`,e}({});function N1(e){return gz({queryKey:[M1.Models],queryFn:async()=>{try{return(await e.listLLMModels())?.result??[]}catch{return[]}},staleTime:300*1e3,retry:1,refetchOnMount:`always`,refetchOnWindowFocus:!1})}async function P1(e,t){let n=await e.getDeploymentConversation({deploymentConversationId:t});if(!n?.success||!n.result?.history)return 0;let r=0;for(let e of n.result.history)e.computePointsUsed&&typeof e.computePointsUsed==`number`&&(r+=e.computePointsUsed);return r}function F1(e){return typeof e==`string`?e:typeof e==`object`&&e&&`segment`in e?e.segment:null}function I1(){return process.platform===`win32`}async function L1(e){return new Promise(t=>setTimeout(t,e))}function R1({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const z1=R1();function B1(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(z1,``)}const V1=new Intl.Segmenter,H1=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$`,`v`),U1=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+`,`v`),W1=RegExp(`^\\p{RGI_Emoji}$`,`v`),G1=/^[\d#*]\u20E3$/,K1=/\p{Extended_Pictographic}/gu;function q1(e){if(e.length>50)return!1;if(G1.test(e))return!0;if(e.includes(``)){let t=e.match(K1);return t!==null&&t.length>=2}return!1}function J1(e){return e.replace(U1,``)}function Y1(e){return H1.test(e)}function X1(e,t){let n=0;if(e.length>1)for(let r of e.slice(1))r>=``&&r<=``&&(n+=dP(r.codePointAt(0),t));return n}function Z1(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(``))&&(i=B1(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of V1.segment(i)){if(Y1(e))continue;if(W1.test(e)||q1(e)){a+=2;continue}let t=J1(e).codePointAt(0);a+=dP(t,o),a+=X1(e,o)}return a}const Q1=[RegExp(`\x1B\\[2J`,`g`),RegExp(`\x1B\\[H`,`g`),RegExp(`\x1B\\[\\d+(;\\d+)?H`,`g`),RegExp(`\x1Bc`,`g`),RegExp(`\x1B\\[!p`,`g`),RegExp(`\x1B\\[\\?1049[hl]`,`g`),RegExp(`\x1B\\[\\d*[ABCD]`,`g`),RegExp(`\x1B\\[s`,`g`),RegExp(`\x1B\\[u`,`g`),RegExp(`\x1B\\[\\d*J`,`g`),RegExp(`\x1B\\[\\d*K`,`g`),RegExp(`\x1B\\[\\?25[hl]`,`g`),RegExp(`\x07`,`g`)];function $1(e){let t=e;for(let e of Q1)t=t.replace(e,``);return t}const e0=new Map,t0=1e3;function n0(e){let t=!0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>127){t=!1;break}if(t)return e.split(``);if(e.length<=t0){let t=e0.get(e);if(t)return t}let n=Array.from(e);return e.length<=t0&&e0.set(e,n),n}function r0(e){return n0(e).length}function i0(e,t,n){return n0(e).slice(t,n).join(``)}function a0(e){return n0(M(b$(e))).filter(e=>{let t=e.codePointAt(0);return t===void 0?!1:t===10||t===13||t===9?!0:!(t>=0&&t<=31||t>=128&&t<=159)}).join(``)}const o0=new Map,s0=e=>{if(/^[\u0020-\u007E]*$/.test(e))return e.length;if(o0.has(e))return o0.get(e);let t=Z1(e);return o0.set(e,t),t};v$();function c0(e,t){if(!h0(e[t]))return!1;let n=t+1;for(;n<e.length&&_0(e[n]);)n++;return n>=e.length||!h0(e[n])}function l0(e,t){let{lines:n,cursorRow:r,cursorCol:i}=e;switch(t.type){case`vim_delete_word_forward`:case`vim_change_word_forward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=w0(n,o,s,!0);if(e)o=e.row,s=e.col;else{let e=n[o]||``,t=C0(e,s);s=t===null?r0(e):t+1;break}}return o!==r||s!==i?O0(P0(e),r,i,o,s,``):e}case`vim_delete_word_backward`:case`vim_change_word_backward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=T0(n,o,s);if(e)o=e.row,s=e.col;else break}return o!==r||s!==i?O0(P0(e),o,s,r,i,``):e}case`vim_delete_word_end`:case`vim_change_word_end`:{let{count:a}=t.payload,o=r,s=i,c=r,l=i;for(let e=0;e<a;e++){let t=w0(n,o,s,!1);if(t){if(c=t.row,l=t.col+1,e<a-1){let e=w0(n,t.row,t.col+1,!0);if(e)o=e.row,s=e.col;else break}}else break}if(c<n.length){let e=r0(n[c]||``);l=Math.min(l,e)}return c!==r||l!==i?O0(P0(e),r,i,c,l,``):e}case`vim_delete_line`:{let{count:i}=t.payload;if(n.length===0)return e;let a=Math.min(i,n.length-r),o=n.length;if(o===1||a>=o)return{...P0(e),lines:[``],cursorRow:0,cursorCol:0,preferredCol:null};let s=P0(e),c=[...s.lines];c.splice(r,a);let l=Math.min(r,c.length-1);return{...s,lines:c,cursorRow:l,cursorCol:0,preferredCol:null}}case`vim_change_line`:{let{count:i}=t.payload;if(n.length===0)return e;let a=Math.min(i,n.length-r),o=P0(e),{startOffset:s,endOffset:c}=D0(r,a,o.lines),{startRow:l,startCol:u,endRow:d,endCol:f}=E0(s,c,o.lines);return O0(o,l,u,d,f,``)}case`vim_delete_to_end_of_line`:case`vim_change_to_end_of_line`:{let t=n[r]||``;return i<r0(t)?O0(P0(e),r,i,r,r0(t),``):e}case`vim_change_movement`:{let{movement:a,count:o}=t.payload,s=n.length;switch(a){case`h`:{let t=Math.max(0,i-o);return O0(P0(e),r,t,r,i,``)}case`j`:{let t=Math.min(o,s-r);if(t>0)if(s===1){let t=e.lines[0]||``;return O0(P0(e),0,0,0,r0(t),``)}else{let n=P0(e),{startOffset:i,endOffset:a}=D0(r,t,n.lines),{startRow:o,startCol:s,endRow:c,endCol:l}=E0(i,a,n.lines);return O0(n,o,s,c,l,``)}return e}case`k`:if(Math.min(o,r+1)>0)if(e.lines.length===1){let t=e.lines[0]||``;return O0(P0(e),0,0,0,r0(t),``)}else{let t=Math.max(0,r-o+1),n=r-t+1,i=P0(e),{startOffset:a,endOffset:s}=D0(t,n,i.lines),{startRow:c,startCol:l,endRow:u,endCol:d}=E0(a,s,i.lines);return{...O0(i,c,l,u,d,``),cursorRow:t,cursorCol:0}}return e;case`l`:return O0(P0(e),r,i,r,Math.min(r0(n[r]||``),i+o),``);default:return e}}case`vim_move_left`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=r,s=i;for(let e=0;e<n;e++)if(s>0)s--;else if(o>0){o--;let e=r0(a[o]||``);s=e===0?0:e-1}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_right`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=r,s=i;for(let e=0;e<n;e++){let e=a[o]||``,t=r0(e);if(t===0)o<a.length-1&&(o++,s=0);else if(s<t-1){s++;let n=n0(e);for(;s<n.length&&_0(n[s])&&s<t-1;)s++}else o<a.length-1&&(o++,s=0)}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_up`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=Math.max(0,r-n),s=r0(a[o]||``),c=Math.min(i,s>0?s-1:0);return{...e,cursorRow:o,cursorCol:c,preferredCol:null}}case`vim_move_down`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=Math.min(a.length-1,r+n),s=r0(a[o]||``),c=Math.min(i,s>0?s-1:0);return{...e,cursorRow:o,cursorCol:c,preferredCol:null}}case`vim_move_word_forward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=w0(n,o,s,!0);if(e)o=e.row,s=e.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_word_backward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=T0(n,o,s);if(e)o=e.row,s=e.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_word_end`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){if(e===0){let e=n0(n[o]||``);if(s<e.length&&h0(e[s])&&(s+1>=e.length||!v0(e[s+1])||h0(e[s])&&c0(e,s))){let e=w0(n,o,s+1,!1);if(e){o=e.row,s=e.col;continue}}}let t=w0(n,o,s,!1);if(t)o=t.row,s=t.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_delete_char`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=r0(a[r]||``);if(i<o){let t=Math.min(n,o-i);return O0(P0(e),r,i,r,i+t,``)}return e}case`vim_insert_at_cursor`:return e;case`vim_append_at_cursor`:{let{cursorRow:t,cursorCol:n,lines:r}=e,i=n<r0(r[t]||``)?n+1:n;return{...e,cursorCol:i,preferredCol:null}}case`vim_open_line_below`:{let{cursorRow:t,lines:n}=e,r=P0(e),i=r0(n[t]||``);return O0(r,t,i,t,i,`
|
|
85772
|
+
`)}case`vim_open_line_above`:{let{cursorRow:t}=e;return{...O0(P0(e),t,0,t,0,`
|
|
85773
|
+
`),cursorRow:t,cursorCol:0}}case`vim_append_at_line_end`:{let{cursorRow:t,lines:n}=e,r=r0(n[t]||``);return{...e,cursorCol:r,preferredCol:null}}case`vim_insert_at_line_start`:{let{cursorRow:t,lines:n}=e,r=n[t]||``,i=0,a=n0(r);for(;i<a.length&&/\s/.test(a[i]);)i++;return{...e,cursorCol:i,preferredCol:null}}case`vim_move_to_line_start`:return{...e,cursorCol:0,preferredCol:null};case`vim_move_to_line_end`:{let{cursorRow:t,lines:n}=e,r=r0(n[t]||``);return{...e,cursorCol:r>0?r-1:0,preferredCol:null}}case`vim_move_to_first_nonwhitespace`:{let{cursorRow:t,lines:n}=e,r=n[t]||``,i=0,a=n0(r);for(;i<a.length&&/\s/.test(a[i]);)i++;return{...e,cursorCol:i,preferredCol:null}}case`vim_move_to_first_line`:return{...e,cursorRow:0,cursorCol:0,preferredCol:null};case`vim_move_to_last_line`:{let{lines:t}=e,n=t.length-1;return{...e,cursorRow:n,cursorCol:0,preferredCol:null}}case`vim_move_to_line`:{let{lineNumber:n}=t.payload,{lines:r}=e,i=Math.min(Math.max(0,n-1),r.length-1);return{...e,cursorRow:i,cursorCol:0,preferredCol:null}}case`vim_escape_insert_mode`:{let{cursorCol:t}=e,n=t>0?t-1:0;return{...e,cursorCol:n,preferredCol:null}}default:return e}}let u0=0;const d0=/\[Pasted text (#\d+) \+\d+ lines\]/g;function f0(e){return e.length>500?!0:e.split(/\r\n|\r|\n/).length>5}function p0(e){u0++;let t=`#${u0}`;return{placeholder:`[Pasted text ${t} +${e.split(/\r\n|\r|\n/).length} lines]`,id:t}}function m0(e){return e===void 0?!1:!/[\s,.;!?]/.test(e)}const h0=e=>/[\w\p{L}\p{N}]/u.test(e),g0=e=>/\s/.test(e),_0=e=>/\p{M}/u.test(e),v0=e=>h0(e)||_0(e),y0=e=>/[\p{Script=Latin}]/u.test(e)?`latin`:/[\p{Script=Han}]/u.test(e)?`han`:/[\p{Script=Arabic}]/u.test(e)?`arabic`:/[\p{Script=Hiragana}]/u.test(e)?`hiragana`:/[\p{Script=Katakana}]/u.test(e)?`katakana`:/[\p{Script=Cyrillic}]/u.test(e)?`cyrillic`:`other`,b0=(e,t)=>!h0(e)||!h0(t)?!1:y0(e)!==y0(t),x0=(e,t)=>{let n=n0(e),r=t;if(r>=n.length)return null;let i=n[r];if(h0(i))for(;r<n.length&&v0(n[r]);){if(r+1<n.length&&h0(n[r+1])&&b0(n[r],n[r+1])){r++;break}r++}else if(!g0(i))for(;r<n.length&&!h0(n[r])&&!g0(n[r]);)r++;for(;r<n.length&&g0(n[r]);)r++;return r<n.length?r:null},S0=(e,t)=>{let n=n0(e),r=t;if(r<=0)return null;for(r--;r>=0&&g0(n[r]);)r--;if(r<0)return null;if(h0(n[r])){for(;r>=0&&h0(n[r]);){if(r-1>=0&&h0(n[r-1])&&b0(n[r],n[r-1]))return r;r--}return r+1}else{for(;r>=0&&!h0(n[r])&&!g0(n[r]);)r--;return r+1}},C0=(e,t)=>{let n=n0(e),r=t,i=r<n.length&&v0(n[r])&&(r+1>=n.length||!v0(n[r+1])||h0(n[r])&&r+1<n.length&&h0(n[r+1])&&b0(n[r],n[r+1])),a=r<n.length&&!v0(n[r])&&!g0(n[r])&&(r+1>=n.length||g0(n[r+1])||v0(n[r+1]));if(i||a)for(r++;r<n.length&&g0(n[r]);)r++;if(r<n.length&&!v0(n[r]))for(;r<n.length&&g0(n[r]);)r++;let o=!1,s=-1;if(r<n.length&&v0(n[r]))for(;r<n.length&&v0(n[r]);){if(o=!0,h0(n[r])&&(s=r),r+1<n.length&&h0(n[r+1])&&b0(n[r],n[r+1])){r++,h0(n[r-1])&&(s=r-1);break}r++}else if(r<n.length&&!g0(n[r]))for(;r<n.length&&!h0(n[r])&&!g0(n[r]);)o=!0,s=r,r++;return o&&s>=t?s:null},w0=(e,t,n,r)=>{let i=e[t]||``,a=r?x0(i,n):C0(i,n);if(a!==null)return{row:t,col:a};for(let n=t+1;n<e.length;n++){let t=e[n]||``,i=n0(t);if(i.length===0){let t=!1;for(let r=n+1;r<e.length;r++){let n=n0(e[r]||``),i=0;for(;i<n.length&&g0(n[i]);)i++;if(i<n.length){t=!0;break}}if(!t)return{row:n,col:0};continue}let a=0;for(;a<i.length&&g0(i[a]);)a++;if(a<i.length){if(r)return{row:n,col:a};{let e=C0(t,a);if(e!==null)return{row:n,col:e}}}}return null},T0=(e,t,n)=>{let r=S0(e[t]||``,n);if(r!==null)return{row:t,col:r};for(let n=t-1;n>=0;n--){let t=e[n]||``,r=n0(t);if(r.length===0)continue;let i=r.length;for(;i>0&&g0(r[i-1]);)i--;if(i>0){let e=S0(t,i);if(e!==null)return{row:n,col:e}}}return null},E0=(e,t,n)=>{let r=0,i=0,a=0,o=0,s=0;for(let t=0;t<n.length;t++){let o=n[t].length+1;if(r+o>e){i=t,a=e-r;break}r+=o}r=0;for(let e=0;e<n.length;e++){let i=n[e].length+(e<n.length-1?1:0);if(r+i>=t){o=e,s=t-r;break}r+=i}return{startRow:i,startCol:a,endRow:o,endCol:s}},D0=(e,t,n)=>{let r=0;for(let t=0;t<e;t++)r+=n[t].length+1;let i=r;for(let r=0;r<t;r++){let t=e+r;t<n.length&&(i+=n[t].length,t<n.length-1&&(i+=1))}return{startOffset:r,endOffset:i}},O0=(e,t,n,r,i,a)=>{let o=t=>e.lines[t]||``,s=e=>r0(o(e)),c=(e,t,n)=>Math.min(Math.max(e,t),n);if(t>r||t===r&&n>i||t<0||n<0||r>=e.lines.length||r<e.lines.length&&i>s(r))return e;let l=[...e.lines],u=c(n,0,s(t)),d=c(i,0,s(r)),f=i0(o(t),0,u),p=i0(o(r),d),m=a.replace(/\r\n/g,`
|
|
85774
85774
|
`).replace(/\r/g,`
|
|
85775
85775
|
`).split(`
|
|
85776
|
-
`),h=f+m[0];if(m.length===1)l.splice(t,r-t+1,h+p);else{let e=m[m.length-1]+p,n=m.slice(1,-1);l.splice(t,r-t+1,h,...n,e)}let g=t+m.length-1,_=(m.length>1?0:u)+
|
|
85777
|
-
`);for(let e=0;e<a.length;e++){let o=a[e],s=
|
|
85776
|
+
`),h=f+m[0];if(m.length===1)l.splice(t,r-t+1,h+p);else{let e=m[m.length-1]+p,n=m.slice(1,-1);l.splice(t,r-t+1,h,...n,e)}let g=t+m.length-1,_=(m.length>1?0:u)+r0(m[m.length-1]);return{...e,lines:l,cursorRow:Math.min(Math.max(g,0),l.length-1),cursorCol:Math.max(0,Math.min(_,r0(l[g]||``))),preferredCol:null}};function k0(e,t,n){return e<t?t:e>n?n:e}function A0(e,t){let n=t,r=0;for(;r<e.length;){let t=r0(e[r]),i=t+(r<e.length-1?1:0);if(n<=t)return[r,n];n-=i,r++}if(e.length>0){let t=e.length-1;return[t,r0(e[t])]}return[0,0]}function j0(e,t){let n=0,r=0,i=0;if(t===0)return[0,0];let a=e.split(`
|
|
85777
|
+
`);for(let e=0;e<a.length;e++){let o=a[e],s=r0(o),c=s+(e<a.length-1?1:0);if(t<=i+s)return n=e,r=t-i,[n,r];if(t<=i+c)return n=e,r=s,t===i+c&&e<a.length-1?[e+1,0]:[n,r];i+=c}return a.length>0?(n=a.length-1,r=r0(a[n])):(n=0,r=0),[n,r]}function M0(e,t){let n=[],r=[],i=[];return e.forEach((e,a)=>{if(r[a]=[],e.length===0)r[a].push([n.length,0]),i.push([a,0]),n.push(``);else{let o=0,s=n0(e);for(;o<s.length;){let e=``,c=0,l=0,u=-1,d=0;for(let n=o;n<s.length;n++){let r=s[n],i=s0(r);if(c+i>t){u!==-1&&d>0&&o+d<n?(e=s.slice(o,o+d).join(``),l=d):l===0&&i>t&&(e=r,l=1);break}e+=r,c+=i,l++,r===` `&&(u=n,d=l-1)}l===0&&o<s.length&&(e=s[o],l=1),l===0&&o<s.length&&(e=s[o],l=1),r[a].push([n.length,o]),i.push([a,o]),n.push(e);let f=o;o+=l,f+l<s.length&&o<s.length&&s[o]===` `&&o++}}}),(e.length===0||e.length===1&&e[0]===``)&&n.length===0&&(n.push(``),r[0]||=[],r[0].push([0,0]),i.push([0,0])),{visualLines:n,logicalToVisualMap:r,visualToLogicalMap:i}}function N0(e,t){let{logicalToVisualMap:n,visualLines:r}=e,[i,a]=t,o=n[i];if(!o||o.length===0)return[0,0];let s=o.findIndex(([,e],t)=>{let n=t+1<o.length?o[t+1][1]:1/0;return a>=e&&a<n});s===-1&&(s=a===0?0:o.length-1);let[c,l]=o[s],u=a-l;return[c,Math.min(u,r0(r[c]??``))]}const P0=e=>{let t={lines:[...e.lines],cursorRow:e.cursorRow,cursorCol:e.cursorCol},n=[...e.undoStack,t];return n.length>100&&n.shift(),{...e,undoStack:n,redoStack:[]}};function F0(e,t){let n=P0,r=t=>e.lines[t]??``,i=e=>r0(r(e));switch(t.type){case`set_text`:{let r=e;t.pushToUndo!==!1&&(r=n(e));let i=t.payload.replace(/\r\n?/g,`
|
|
85778
85778
|
`).split(`
|
|
85779
|
-
`),a=i.length===0?[``]:i,o=a.length-1;return{...r,lines:a,cursorRow:o,cursorCol:
|
|
85779
|
+
`),a=i.length===0?[``]:i,o=a.length-1;return{...r,lines:a,cursorRow:o,cursorCol:r0(a[o]??``),preferredCol:null}}case`insert`:{let r=n(e),i=[...r.lines],a=r.cursorRow,o=r.cursorCol,s=e=>i[e]??``,c=a0(t.payload.replace(/\r\n/g,`
|
|
85780
85780
|
`).replace(/\r/g,`
|
|
85781
85781
|
`)).split(`
|
|
85782
|
-
`),l=s(a),u
|
|
85783
|
-
`,o[t-1]=e+n,o.splice(t,1),s--,c=i}return{...a,lines:o,cursorRow:s,cursorCol:c,preferredCol:null,clipboard:l}}case`delete_word_right`:{let{cursorRow:t,cursorCol:i,lines:a}=e,o=r(t),s=
|
|
85784
|
-
`,l[t]=o+e,l.splice(t+1,1)}else{let e=
|
|
85785
|
-
`+a,o[t]=s+a,o.splice(t+1,1),{...i,lines:o,preferredCol:null,clipboard:c}}return e}case`kill_line_left`:{let{cursorRow:t,cursorCol:i}=e;if(i>0){let a=n(e),o=r(t),s=[...a.lines],c
|
|
85782
|
+
`),l=s(a),u=i0(l,0,o),d=i0(l,o);if(c.length>1){i[a]=u+c[0];let e=c.slice(1),t=e.pop()??``;i.splice(a+1,0,...e),i.splice(a+c.length-1,0,t+d),a=a+c.length-1,o=r0(t)}else i[a]=u+c[0]+d,o=r0(u)+r0(c[0]);return{...r,lines:i,cursorRow:a,cursorCol:o,preferredCol:null}}case`backspace`:{let t=n(e),r=[...t.lines],i=t.cursorRow,a=t.cursorCol,o=e=>r[e]??``;if(a===0&&i===0)return e;if(a>0){let e=o(i);r[i]=i0(e,0,a-1)+i0(e,a),a--}else if(i>0){let e=o(i-1),t=o(i),n=r0(e);r[i-1]=e+t,r.splice(i,1),i--,a=n}return{...t,lines:r,cursorRow:i,cursorCol:a,preferredCol:null}}case`set_viewport`:{let{width:n,height:r}=t.payload;return n===e.viewportWidth&&r===e.viewportHeight?e:{...e,viewportWidth:n,viewportHeight:r}}case`move`:{let{dir:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a,visualLayout:o,preferredCol:s}=e;if(n===`left`||n===`right`||n===`up`||n===`down`||n===`home`||n===`end`){let t=N0(o,[r,i]),{visualLines:c,visualToLogicalMap:l}=o,u=t[0],d=t[1],f=s,p=r0(c[u]??``);switch(n){case`left`:f=null,d>0?d--:u>0&&(u--,d=r0(c[u]??``));break;case`right`:f=null,d<p?d++:u<c.length-1&&(u++,d=0);break;case`up`:u>0&&(f===null&&(f=d),u--,d=k0(f,0,r0(c[u]??``)));break;case`down`:u<c.length-1&&(f===null&&(f=d),u++,d=k0(f,0,r0(c[u]??``)));break;case`home`:f=null,d=0;break;case`end`:f=null,d=p;break;default:{let t=n;return console.error(`Unknown visual movement direction: ${String(t)}`),e}}if(l[u]){let[t,n]=l[u];return{...e,cursorRow:t,cursorCol:k0(n+d,0,r0(a[t]??``)),preferredCol:f}}return e}switch(n){case`wordLeft`:{if(i===0&&r===0)return e;let t=r,n=i;if(i===0)t--,n=r0(a[t]??``);else{let e=a[r],t=n0(e),o=i,s=!0;for(let e=0;e<o;e++)if(m0(t[e])){s=!1;break}if(s&&o>0)o--;else{for(;o>0&&!m0(t[o-1]);)o--;for(;o>0&&m0(t[o-1]);)o--}n=o}return{...e,cursorRow:t,cursorCol:n,preferredCol:null}}case`wordRight`:{if(r===a.length-1&&i===r0(a[r]??``))return e;let t=r,n=i,o=n0(a[r]??``);if(i>=o.length)t++,n=0;else{let e=i;for(;e<o.length&&!m0(o[e]);)e++;for(;e<o.length&&m0(o[e]);)e++;n=e}return{...e,cursorRow:t,cursorCol:n,preferredCol:null}}default:return e}}case`set_cursor`:return{...e,...t.payload};case`delete`:{let{cursorRow:t,cursorCol:a,lines:o}=e,s=r(t);if(a<i(t)){let r=n(e),i=[...r.lines];return i[t]=i0(s,0,a)+i0(s,a+1),{...r,lines:i,preferredCol:null}}else if(t<o.length-1){let i=n(e),a=r(t+1),o=[...i.lines];return o[t]=s+a,o.splice(t+1,1),{...i,lines:o,preferredCol:null}}return e}case`delete_word_left`:{let{cursorRow:t,cursorCol:i}=e;if(i===0&&t===0)return e;let a=n(e),o=[...a.lines],s=t,c=i,l=``;if(c>0){let e=r(s),t=S0(e,c),n=t===null?0:t;l=i0(e,n,c),o[s]=i0(e,0,n)+i0(e,c),c=n}else{let e=r(t-1),n=r(t),i=r0(e);l=`
|
|
85783
|
+
`,o[t-1]=e+n,o.splice(t,1),s--,c=i}return{...a,lines:o,cursorRow:s,cursorCol:c,preferredCol:null,clipboard:l}}case`delete_word_right`:{let{cursorRow:t,cursorCol:i,lines:a}=e,o=r(t),s=r0(o);if(i>=s&&t===a.length-1)return e;let c=n(e),l=[...c.lines],u=``;if(i>=s){let e=r(t+1);u=`
|
|
85784
|
+
`,l[t]=o+e,l.splice(t+1,1)}else{let e=x0(o,i),n=e===null?s:e;n<=i&&(n=s),u=i0(o,i,n),l[t]=i0(o,0,i)+i0(o,n)}return{...c,lines:l,preferredCol:null,clipboard:u}}case`kill_line_right`:{let{cursorRow:t,cursorCol:a,lines:o}=e,s=r(t),c=``;if(a<i(t)){let r=n(e),i=[...r.lines];return c=i0(s,a),i[t]=i0(s,0,a),{...r,lines:i,clipboard:c}}else if(t<o.length-1){let i=n(e),a=r(t+1),o=[...i.lines];return c=`
|
|
85785
|
+
`+a,o[t]=s+a,o.splice(t+1,1),{...i,lines:o,preferredCol:null,clipboard:c}}return e}case`kill_line_left`:{let{cursorRow:t,cursorCol:i}=e;if(i>0){let a=n(e),o=r(t),s=[...a.lines],c=i0(o,0,i);return s[t]=i0(o,i),{...a,lines:s,cursorCol:0,preferredCol:null,clipboard:c}}return e}case`yank`:{if(!e.clipboard)return e;let t=n(e),i=[...t.lines],a=t.cursorRow,o=t.cursorCol,s=r(a),c=i0(s,0,o),l=i0(s,o),u=e.clipboard.replace(/\r\n/g,`
|
|
85786
85786
|
`).replace(/\r/g,`
|
|
85787
85787
|
`).split(`
|
|
85788
|
-
`);if(u.length>1){i[a]=c+u[0];let e=u.slice(1,-1),t=u[u.length-1]??``;i.splice(a+1,0,...e,t+l),a=a+u.length-1,o=
|
|
85789
|
-
`),n);return{...e,cursorRow:r,cursorCol:i,preferredCol:null}}case`create_undo_snapshot`:return n(e);case`vim_delete_word_forward`:case`vim_delete_word_backward`:case`vim_delete_word_end`:case`vim_change_word_forward`:case`vim_change_word_backward`:case`vim_change_word_end`:case`vim_delete_line`:case`vim_change_line`:case`vim_delete_to_end_of_line`:case`vim_change_to_end_of_line`:case`vim_change_movement`:case`vim_move_left`:case`vim_move_right`:case`vim_move_up`:case`vim_move_down`:case`vim_move_word_forward`:case`vim_move_word_backward`:case`vim_move_word_end`:case`vim_delete_char`:case`vim_insert_at_cursor`:case`vim_append_at_cursor`:case`vim_open_line_below`:case`vim_open_line_above`:case`vim_append_at_line_end`:case`vim_insert_at_line_start`:case`vim_move_to_line_start`:case`vim_move_to_line_end`:case`vim_move_to_first_nonwhitespace`:case`vim_move_to_first_line`:case`vim_move_to_last_line`:case`vim_move_to_line`:case`vim_escape_insert_mode`:return
|
|
85790
|
-
`),[i,a]=
|
|
85791
|
-
`),[u]),y=(0,X.useMemo)(()=>
|
|
85792
|
-
`})},[]),O=(0,X.useCallback)(()=>{l({type:`backspace`})},[]),k=(0,X.useCallback)(()=>{l({type:`delete`})},[]),A=(0,X.useCallback)(e=>{l({type:`move`,payload:{dir:e}})},[l]),j=(0,X.useCallback)(()=>{l({type:`undo`})},[]),M=(0,X.useCallback)(()=>{l({type:`redo`})},[]),N=(0,X.useCallback)(e=>{e||s.current.clear(),l({type:`set_text`,payload:e})},[]),P=(0,X.useCallback)(e=>e.replace(
|
|
85788
|
+
`);if(u.length>1){i[a]=c+u[0];let e=u.slice(1,-1),t=u[u.length-1]??``;i.splice(a+1,0,...e,t+l),a=a+u.length-1,o=r0(t)}else i[a]=c+u[0]+l,o=r0(c)+r0(u[0]);return{...t,lines:i,cursorRow:a,cursorCol:o,preferredCol:null}}case`transpose_chars`:{let{cursorRow:t,cursorCol:i}=e,a=r(t),o=r0(a);if(o<2||i===0&&t===0)return e;let s=n(e),c=[...s.lines],l=t,u=i;if(i>0&&i<o){let e=i0(a,0,i-1),n=i0(a,i-1,i),r=i0(a,i,i+1),o=i0(a,i+1);c[t]=e+r+n+o,u=i+1}else if(i===0&&t>0){let e=r(t-1),n=r0(e);if(n>0&&o>0){let r=i0(e,n-1),i=i0(a,0,1);c[t-1]=i0(e,0,n-1)+i,c[t]=r+i0(a,1)}}else if(i===o&&i>0){let e=i0(a,0,i-2),n=i0(a,i-2,i-1);c[t]=e+i0(a,i-1,i)+n,u=i-1}return{...s,lines:c,cursorRow:l,cursorCol:u,preferredCol:null}}case`undo`:{let t=e.undoStack[e.undoStack.length-1];if(!t)return e;let n={lines:[...e.lines],cursorRow:e.cursorRow,cursorCol:e.cursorCol};return{...e,...t,undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,n]}}case`redo`:{let t=e.redoStack[e.redoStack.length-1];if(!t)return e;let n={lines:[...e.lines],cursorRow:e.cursorRow,cursorCol:e.cursorCol};return{...e,...t,redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,n]}}case`replace_range`:{let{startRow:r,startCol:i,endRow:a,endCol:o,text:s}=t.payload;return O0(n(e),r,i,a,o,s)}case`move_to_offset`:{let{offset:n}=t.payload,[r,i]=j0(e.lines.join(`
|
|
85789
|
+
`),n);return{...e,cursorRow:r,cursorCol:i,preferredCol:null}}case`create_undo_snapshot`:return n(e);case`vim_delete_word_forward`:case`vim_delete_word_backward`:case`vim_delete_word_end`:case`vim_change_word_forward`:case`vim_change_word_backward`:case`vim_change_word_end`:case`vim_delete_line`:case`vim_change_line`:case`vim_delete_to_end_of_line`:case`vim_change_to_end_of_line`:case`vim_change_movement`:case`vim_move_left`:case`vim_move_right`:case`vim_move_up`:case`vim_move_down`:case`vim_move_word_forward`:case`vim_move_word_backward`:case`vim_move_word_end`:case`vim_delete_char`:case`vim_insert_at_cursor`:case`vim_append_at_cursor`:case`vim_open_line_below`:case`vim_open_line_above`:case`vim_append_at_line_end`:case`vim_insert_at_line_start`:case`vim_move_to_line_start`:case`vim_move_to_line_end`:case`vim_move_to_first_nonwhitespace`:case`vim_move_to_first_line`:case`vim_move_to_last_line`:case`vim_move_to_line`:case`vim_escape_insert_mode`:return l0(e,t);default:{let n=t;return console.error(`Unknown action encountered: ${String(n)}`),e}}}function I0(e,t){let n=F0(e,t);return n.lines!==e.lines||n.viewportWidth!==e.viewportWidth?{...n,visualLayout:M0(n.lines,n.viewportWidth)}:n}function L0({initialText:e=``,initialCursorOffset:t=0,viewport:r,stdin:i,setRawMode:a,onChange:o}){let s=(0,X.useRef)(new Map),[c,l]=(0,X.useReducer)(I0,(0,X.useMemo)(()=>{let n=e.split(`
|
|
85790
|
+
`),[i,a]=A0(n.length===0?[``]:n,t),o=M0(n.length===0?[``]:n,r.width);return{lines:n.length===0?[``]:n,cursorRow:i,cursorCol:a,preferredCol:null,undoStack:[],redoStack:[],clipboard:null,selectionAnchor:null,viewportWidth:r.width,viewportHeight:r.height,visualLayout:o}},[e,t,r.width,r.height])),{lines:u,cursorRow:d,cursorCol:f,preferredCol:m,selectionAnchor:g,visualLayout:_}=c,v=(0,X.useMemo)(()=>u.join(`
|
|
85791
|
+
`),[u]),y=(0,X.useMemo)(()=>N0(_,[d,f]),[_,d,f]),{visualLines:b,visualToLogicalMap:x}=_,[S,C]=(0,X.useState)(0),w=(0,X.useEffectEvent)(e=>{o?.(e)});(0,X.useEffect)(()=>{w(v)},[v]),(0,X.useEffect)(()=>{l({type:`set_viewport`,payload:{width:r.width,height:r.height}})},[r.width,r.height]),(0,X.useEffect)(()=>{let{height:e}=r,t=b.length,n=Math.max(0,t-e),i=S;y[0]<S?i=y[0]:y[0]>=S+e&&(i=y[0]-e+1),i=k0(i,0,n),i!==S&&C(i)},[y,S,r,b.length]);let E=(0,X.useCallback)((e,{paste:t=!1,isPaste:n=!1}={})=>{if((t||n)&&f0(e)){let{placeholder:t,id:n}=p0(e);s.current.set(n,e),l({type:`insert`,payload:t});return}if(/[\n\r]/.test(e)){l({type:`insert`,payload:e});return}let r=``;for(let t of n0(e))t.codePointAt(0)===127?(r.length>0&&(l({type:`insert`,payload:r}),r=``),l({type:`backspace`})):r+=t;r.length>0&&l({type:`insert`,payload:r})},[]),D=(0,X.useCallback)(()=>{l({type:`insert`,payload:`
|
|
85792
|
+
`})},[]),O=(0,X.useCallback)(()=>{l({type:`backspace`})},[]),k=(0,X.useCallback)(()=>{l({type:`delete`})},[]),A=(0,X.useCallback)(e=>{l({type:`move`,payload:{dir:e}})},[l]),j=(0,X.useCallback)(()=>{l({type:`undo`})},[]),M=(0,X.useCallback)(()=>{l({type:`redo`})},[]),N=(0,X.useCallback)(e=>{e||s.current.clear(),l({type:`set_text`,payload:e})},[]),P=(0,X.useCallback)(e=>e.replace(d0,(e,t)=>s.current.get(t)??`[Pasted text ${t}]`),[]),F=(0,X.useCallback)(()=>{l({type:`delete_word_left`})},[]),I=(0,X.useCallback)(()=>{l({type:`delete_word_right`})},[]),ee=(0,X.useCallback)(()=>{l({type:`kill_line_right`})},[]),L=(0,X.useCallback)(()=>{l({type:`kill_line_left`})},[]),R=(0,X.useCallback)(()=>{l({type:`yank`})},[]),z=(0,X.useCallback)(()=>{l({type:`transpose_chars`})},[]),B=(0,X.useCallback)(e=>{l({type:`vim_delete_word_forward`,payload:{count:e}})},[]),te=(0,X.useCallback)(e=>{l({type:`vim_delete_word_backward`,payload:{count:e}})},[]),ne=(0,X.useCallback)(e=>{l({type:`vim_delete_word_end`,payload:{count:e}})},[]),re=(0,X.useCallback)(e=>{l({type:`vim_change_word_forward`,payload:{count:e}})},[]),ie=(0,X.useCallback)(e=>{l({type:`vim_change_word_backward`,payload:{count:e}})},[]),ae=(0,X.useCallback)(e=>{l({type:`vim_change_word_end`,payload:{count:e}})},[]),oe=(0,X.useCallback)(e=>{l({type:`vim_delete_line`,payload:{count:e}})},[]),se=(0,X.useCallback)(e=>{l({type:`vim_change_line`,payload:{count:e}})},[]),ce=(0,X.useCallback)(()=>{l({type:`vim_delete_to_end_of_line`})},[]),le=(0,X.useCallback)(()=>{l({type:`vim_change_to_end_of_line`})},[]),ue=(0,X.useCallback)((e,t)=>{l({type:`vim_change_movement`,payload:{movement:e,count:t}})},[]),de=(0,X.useCallback)(e=>{l({type:`vim_move_left`,payload:{count:e}})},[]),fe=(0,X.useCallback)(e=>{l({type:`vim_move_right`,payload:{count:e}})},[]),pe=(0,X.useCallback)(e=>{l({type:`vim_move_up`,payload:{count:e}})},[]),me=(0,X.useCallback)(e=>{l({type:`vim_move_down`,payload:{count:e}})},[]),he=(0,X.useCallback)(e=>{l({type:`vim_move_word_forward`,payload:{count:e}})},[]),V=(0,X.useCallback)(e=>{l({type:`vim_move_word_backward`,payload:{count:e}})},[]),ge=(0,X.useCallback)(e=>{l({type:`vim_move_word_end`,payload:{count:e}})},[]),_e=(0,X.useCallback)(e=>{l({type:`vim_delete_char`,payload:{count:e}})},[]),ve=(0,X.useCallback)(()=>{l({type:`vim_insert_at_cursor`})},[]),ye=(0,X.useCallback)(()=>{l({type:`vim_append_at_cursor`})},[]),be=(0,X.useCallback)(()=>{l({type:`vim_open_line_below`})},[]),xe=(0,X.useCallback)(()=>{l({type:`vim_open_line_above`})},[]),Se=(0,X.useCallback)(()=>{l({type:`vim_append_at_line_end`})},[]),Ce=(0,X.useCallback)(()=>{l({type:`vim_insert_at_line_start`})},[]),we=(0,X.useCallback)(()=>{l({type:`vim_move_to_line_start`})},[]),Te=(0,X.useCallback)(()=>{l({type:`vim_move_to_line_end`})},[]),H=(0,X.useCallback)(()=>{l({type:`vim_move_to_first_nonwhitespace`})},[]),Ee=(0,X.useCallback)(()=>{l({type:`vim_move_to_first_line`})},[]),De=(0,X.useCallback)(()=>{l({type:`vim_move_to_last_line`})},[]),Oe=(0,X.useCallback)(e=>{l({type:`vim_move_to_line`,payload:{lineNumber:e}})},[]),U=(0,X.useCallback)(()=>{l({type:`vim_escape_insert_mode`})},[]),ke=(0,X.useCallback)(async(e={})=>{let t=e.editor??process.env.VISUAL??process.env.EDITOR??(process.platform===`win32`?`notepad`:`vi`),r=h.mkdtempSync(T.join(n.tmpdir(),`gemini-edit-`)),o=T.join(r,`buffer.txt`);h.writeFileSync(o,v,`utf8`),l({type:`create_undo_snapshot`});let s=i?.isRaw??!1;try{a?.(!1);let{status:e,error:n}=p(t,[o],{stdio:`inherit`});if(n)throw n;if(typeof e==`number`&&e!==0)throw Error(`External editor exited with status ${e}`);let r=h.readFileSync(o,`utf8`);r=r.replace(/\r\n?/g,`
|
|
85793
85793
|
`),l({type:`set_text`,payload:r,pushToUndo:!1})}catch(e){console.error(`[useTextBuffer] external editor error`,e)}finally{s&&a?.(!0);try{h.unlinkSync(o)}catch{}try{h.rmdirSync(r)}catch{}}},[v,i,a]),Ae=(0,X.useCallback)((e,t)=>{if(t.paste){E(e,{paste:!0});return}t.return||e===`\r`||e===`
|
|
85794
|
-
`||e===`\\\r`?D():t.leftArrow&&!t.meta&&!t.ctrl||t.ctrl&&e===`b`?A(`left`):t.rightArrow&&!t.meta&&!t.ctrl||t.ctrl&&e===`f`?A(`right`):t.upArrow||t.ctrl&&e===`p`?A(`up`):t.downArrow||t.ctrl&&e===`n`?A(`down`):(t.ctrl||t.meta)&&t.leftArrow||t.meta&&e===`b`?A(`wordLeft`):(t.ctrl||t.meta)&&t.rightArrow||t.meta&&e===`f`?A(`wordRight`):t.home||t.ctrl&&e===`a`?A(`home`):t.end||t.ctrl&&e===`e`?A(`end`):t.ctrl&&e===`k`?ee():t.ctrl&&e===`u`?L():t.ctrl&&e===`y`?R():t.ctrl&&e===`t`?z():t.ctrl&&e===`w`||(t.meta||t.ctrl)&&(t.backspace||e===``)?F():(t.meta||t.ctrl)&&t.delete||t.meta&&e===`d`&&!t.ctrl&&!t.shift?I():t.super&&t.backspace?L():t.super&&t.delete?ee():t.backspace||e===``||t.ctrl&&e===`h`?O():t.delete||t.ctrl&&e===`d`&&!t.meta&&!t.shift?k():t.ctrl&&!t.shift&&e===`z`?j():t.ctrl&&t.shift&&e===`z`?M():e&&!t.ctrl&&!t.meta&&E(e,{paste:!1})},[D,A,F,I,O,k,E,j,M,ee,L,R,z]),je=(0,X.useMemo)(()=>b.slice(S,S+r.height),[b,S,r.height]),Me=(0,X.useCallback)((e,t,n,r,i)=>{l({type:`replace_range`,payload:{startRow:e,startCol:t,endRow:n,endCol:r,text:i}})},[]),Ne=(0,X.useCallback)((e,t,n)=>{let[r,i]=
|
|
85795
|
-
`)}formatServerList(e){let t=[];if(e.length===0)t.push(`No MCP servers found.`),t.push(``),t.push(`Use the following commands to manage MCP servers:`),t.push(``),t.push(
|
|
85796
|
-
`)}async findConfigSources(){let e=[],t=process.platform===`win32`?T.join(n.homedir(),`AppData`,`Roaming`,`Claude`,`claude_desktop_config.json`):process.platform===`darwin`?T.join(n.homedir(),`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`):T.join(n.homedir(),`.config`,`Claude`,`claude_desktop_config.json`);e.push({path:t,type:`claude-desktop`,label:`Claude Desktop`,exists:h.existsSync(t)});let r=T.join(n.homedir(),`.codeium`,`windsurf`,`mcp_config.json`);e.push({path:r,type:`windsurf`,label:`Windsurf`,exists:h.existsSync(r)});let i=T.join(n.homedir(),`.cursor`,`mcp.json`);e.push({path:i,type:`cursor-global`,label:`Cursor (Global)`,exists:h.existsSync(i)});let a=T.join(process.cwd(),`.cursor`,`mcp.json`);e.push({path:a,type:`cursor-workspace`,label:`Cursor (Workspace)`,exists:h.existsSync(a)});let o=[Le.fullName,`AbacusAI`,`CodeLLM`];for(let t of o){let n=this.getUserDataDir(t);if(n){let r=T.join(n,`User`,`mcp.json`);h.existsSync(r)&&e.push({path:r,type:`abacusai-user`,label:`${t} (User)`,exists:!0})}}let s=process.platform===`win32`?T.join(n.homedir(),`AppData`,`Roaming`,`Code`,`User`):process.platform===`darwin`?T.join(n.homedir(),`Library`,`Application Support`,`Code`,`User`):T.join(n.homedir(),`.config`,`Code`,`User`),c=T.join(s,`mcp.json`);return e.push({path:c,type:`vscode-user`,label:`VSCode (User)`,exists:h.existsSync(c)}),e}getUserDataDir(e){try{switch(process.platform){case`win32`:{let t=process.env.APPDATA;return t?T.join(t,e):null}case`darwin`:return T.join(n.homedir(),`Library`,`Application Support`,e);case`linux`:{let t=process.env.XDG_CONFIG_HOME||T.join(n.homedir(),`.config`);return T.join(t,e)}default:return null}}catch{return null}}async loadServersFromSource(e){let t=await b.readFile(e.path,`utf8`),n=[],r;try{r=this.parseJsonWithFallback(t)}catch(e){throw Error(`JSON parsing failed: ${e instanceof Error?e.message:String(e)}`)}if(e.type.startsWith(`vscode`)||e.type===`abacusai-user`){let t;if(r.servers&&!r.mcp?t=r.servers:r.mcp?.servers&&(t=r.mcp.servers),t)for(let[r,i]of Object.entries(t))n.push({id:`${e.type}.${r}`,name:r,config:i,status:`stopped`,description:`${e.label} - ${this.getServerTypeDescription(i)}`})}else if([`cursor-global`,`cursor-workspace`,`claude-desktop`,`windsurf`].includes(e.type)){let t=r;if(t.mcpServers)for(let[r,i]of Object.entries(t.mcpServers)){let t=i.url?{type:`http`,url:i.url,headers:{}}:{type:`stdio`,command:i.command||``,args:i.args||[],env:i.env||{}};n.push({id:`${e.type}.${r}`,name:r,config:t,status:`stopped`,description:`${e.label} - ${this.getServerTypeDescription(t)}`})}}return n}parseJsonWithFallback(e){try{return JSON.parse(e)}catch(t){try{let t=e.replace(/,(\s*[}\]])/g,`$1`).replace(/([}\]]),(\s*[}\]])/g,`$1$2`);return JSON.parse(t)}catch(e){let n=t instanceof Error?t.message:String(t),r=e instanceof Error?e.message:String(e);throw Error(`JSON parsing failed. Original error: ${n}. After fixing trailing commas: ${r}`)}}}async addServerToSource(e,t,n){let r=e.path,i=T.dirname(r);if(await b.mkdir(i,{recursive:!0}),[`vscode-user`,`vscode-workspace`,`abacusai-user`].includes(e.type))if(r.endsWith(`mcp.json`)){let e={servers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.servers=e.servers||{},e.servers[t]=n;let i=JSON.stringify(e,null,2);await b.writeFile(r,i,`utf8`)}else{let e={};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcp=e.mcp||{servers:{}},e.mcp.servers=e.mcp.servers||{},e.mcp.servers[t]=n;let i=JSON.stringify(e,null,2);await b.writeFile(r,i,`utf8`)}else if(e.type===`cursor-global`){let e={mcpServers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcpServers=e.mcpServers||{};let i=`url`in n?{url:n.url}:{command:n.command,args:n.args?[...n.args]:void 0,env:n.env?Object.fromEntries(Object.entries(n.env).map(([e,t])=>[e,String(t)])):void 0};e.mcpServers[t]=i;let a=JSON.stringify(e,null,2);await b.writeFile(r,a,`utf8`)}else if(e.type===`cursor-workspace`){let e={mcpServers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcpServers=e.mcpServers||{};let i=`url`in n?{url:n.url}:{command:n.command,args:n.args?[...n.args]:void 0,env:n.env?Object.fromEntries(Object.entries(n.env).map(([e,t])=>[e,String(t)])):void 0};e.mcpServers[t]=i;let a=JSON.stringify(e,null,2);await b.writeFile(r,a,`utf8`)}else throw Error(`Unsupported config source type: ${e.type}`)}async removeServerFromSource(e,t){if(!h.existsSync(e))return!1;let n=await b.readFile(e,`utf8`),r=e.includes(`.cursor`)||e.includes(`claude_desktop_config.json`)||e.includes(`mcp_config.json`);if(e.endsWith(`mcp.json`)){let r=this.parseJsonWithFallback(n);if(!r.servers||!r.servers[t])return!1;delete r.servers[t];let i=JSON.stringify(r,null,2);return await b.writeFile(e,i,`utf8`),!0}else if(e.endsWith(`settings.json`)){let r=this.parseJsonWithFallback(n),i=r?.mcp||{servers:{}};if(!i.servers||!i.servers[t])return!1;delete i.servers[t],r.mcp=i;let a=JSON.stringify(r,null,2);return await b.writeFile(e,a,`utf8`),!0}else if(r){let r=this.parseJsonWithFallback(n);if(!r.mcpServers||!r.mcpServers[t])return!1;delete r.mcpServers[t];let i=JSON.stringify(r,null,2);return await b.writeFile(e,i,`utf8`),!0}else throw Error(`Unsupported config file format: ${e}`)}validateServerConfig(e){if(!e||typeof e!=`object`)throw Error(`Server configuration must be a valid object`);if(`mcpServers`in e||`servers`in e)throw Error(`Invalid configuration format. Server configuration should not contain "mcpServers" or "servers" properties. Each server should be configured individually.`);if(`url`in e){if(!e.url)throw Error(`URL is required for HTTP servers`);if(typeof e.url!=`string`)throw Error(`URL must be a string`);if(!e.url.startsWith(`http://`)&&!e.url.startsWith(`https://`))throw Error(`URL must start with http:// or https://`)}else if(`command`in e){if(!e.command)throw Error(`Command is required for stdio servers`);if(typeof e.command!=`string`)throw Error(`Command must be a string`);if(e.args&&!Array.isArray(e.args))throw Error(`Arguments must be an array`);if(e.args&&e.args.some(e=>typeof e!=`string`))throw Error(`All arguments must be strings`)}else throw Error(`Server configuration must have either "url" or "command" property`)}getServerTypeDescription(e){if(`url`in e)return`HTTP server at ${e.url}`;if(`command`in e){let t=e.args&&e.args.length>0?` ${e.args.join(` `)}`:``;return`Command: ${e.command}${t}`}return`Unknown server type`}getServerSourceLabel(e){return e.id.startsWith(`claude-desktop`)?`Claude Desktop`:e.id.startsWith(`windsurf`)?`Windsurf`:e.id.startsWith(`cursor-global`)?`Cursor (Global)`:e.id.startsWith(`cursor-workspace`)?`Cursor (Workspace)`:e.id.startsWith(`abacusai-user`)?e.description?.includes(`${Le.fullName}-dev`)||e.description?.includes(`CodeLLM-dev`)?`${Le.fullName}-dev (User)`:`${Le.fullName} (User)`:e.id.startsWith(`vscode-user`)?`VSCode (User)`:e.id.startsWith(`vscode-workspace`)?`VSCode (Workspace)`:`Other`}},
|
|
85794
|
+
`||e===`\\\r`?D():t.leftArrow&&!t.meta&&!t.ctrl||t.ctrl&&e===`b`?A(`left`):t.rightArrow&&!t.meta&&!t.ctrl||t.ctrl&&e===`f`?A(`right`):t.upArrow||t.ctrl&&e===`p`?A(`up`):t.downArrow||t.ctrl&&e===`n`?A(`down`):(t.ctrl||t.meta)&&t.leftArrow||t.meta&&e===`b`?A(`wordLeft`):(t.ctrl||t.meta)&&t.rightArrow||t.meta&&e===`f`?A(`wordRight`):t.home||t.ctrl&&e===`a`?A(`home`):t.end||t.ctrl&&e===`e`?A(`end`):t.ctrl&&e===`k`?ee():t.ctrl&&e===`u`?L():t.ctrl&&e===`y`?R():t.ctrl&&e===`t`?z():t.ctrl&&e===`w`||(t.meta||t.ctrl)&&(t.backspace||e===``)?F():(t.meta||t.ctrl)&&t.delete||t.meta&&e===`d`&&!t.ctrl&&!t.shift?I():t.super&&t.backspace?L():t.super&&t.delete?ee():t.backspace||e===``||t.ctrl&&e===`h`?O():t.delete||t.ctrl&&e===`d`&&!t.meta&&!t.shift?k():t.ctrl&&!t.shift&&e===`z`?j():t.ctrl&&t.shift&&e===`z`?M():e&&!t.ctrl&&!t.meta&&E(e,{paste:!1})},[D,A,F,I,O,k,E,j,M,ee,L,R,z]),je=(0,X.useMemo)(()=>b.slice(S,S+r.height),[b,S,r.height]),Me=(0,X.useCallback)((e,t,n,r,i)=>{l({type:`replace_range`,payload:{startRow:e,startCol:t,endRow:n,endCol:r,text:i}})},[]),Ne=(0,X.useCallback)((e,t,n)=>{let[r,i]=j0(v,e),[a,o]=j0(v,t);Me(r,i,a,o,n)},[v,Me]),Pe=(0,X.useCallback)(e=>{l({type:`move_to_offset`,payload:{offset:e}})},[]);return(0,X.useMemo)(()=>({lines:u,text:v,cursor:[d,f],preferredCol:m,selectionAnchor:g,allVisualLines:b,viewportVisualLines:je,visualCursor:y,visualScrollRow:S,visualToLogicalMap:x,setText:N,getExpandedText:P,insert:E,newline:D,backspace:O,del:k,move:A,undo:j,redo:M,replaceRange:Me,replaceRangeByOffset:Ne,moveToOffset:Pe,deleteWordLeft:F,deleteWordRight:I,killLineRight:ee,killLineLeft:L,yank:R,transposeChars:z,handleInput:Ae,openInExternalEditor:ke,vimDeleteWordForward:B,vimDeleteWordBackward:te,vimDeleteWordEnd:ne,vimChangeWordForward:re,vimChangeWordBackward:ie,vimChangeWordEnd:ae,vimDeleteLine:oe,vimChangeLine:se,vimDeleteToEndOfLine:ce,vimChangeToEndOfLine:le,vimChangeMovement:ue,vimMoveLeft:de,vimMoveRight:fe,vimMoveUp:pe,vimMoveDown:me,vimMoveWordForward:he,vimMoveWordBackward:V,vimMoveWordEnd:ge,vimDeleteChar:_e,vimInsertAtCursor:ve,vimAppendAtCursor:ye,vimOpenLineBelow:be,vimOpenLineAbove:xe,vimAppendAtLineEnd:Se,vimInsertAtLineStart:Ce,vimMoveToLineStart:we,vimMoveToLineEnd:Te,vimMoveToFirstNonWhitespace:H,vimMoveToFirstLine:Ee,vimMoveToLastLine:De,vimMoveToLine:Oe,vimEscapeInsertMode:U}),[u,v,d,f,m,g,b,je,y,S,N,E,D,O,k,A,j,M,Me,Ne,Pe,F,I,ee,L,R,z,Ae,ke,B,te,ne,re,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,V,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe,U,x,P])}const R0=/^#(?:[0-9a-fA-F]{3}){1,2}$/;function z0(e,t){if(!e)return e;if(R0.test(t))return pj.hex(t)(e);let n=pj[t];return typeof n==`function`?n(e):e}function B0(e){let t=e.flags.includes(`g`)?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function V0(e,t){if(!t?.length||!e)return e;let n=[{text:e,styled:!1}];for(let e of t){let t=B0(e.regex),r=[];for(let i of n){if(i.styled||!i.text){r.push(i);continue}let n=0,a;for(;(a=t.exec(i.text))!==null;){let o=a.index,s=o+a[0].length;o>n&&r.push({text:i.text.slice(n,o),styled:!1});let c=z0(i.text.slice(o,s),e.color);r.push({text:c,styled:!0}),s===n&&(t.lastIndex+=1),n=s}n<i.text.length&&r.push({text:i.text.slice(n),styled:!1})}n=r}return n.map(e=>e.text).join(``)}const H0=(0,X.memo)(({initialValue:e,onChange:t,onSubmit:n,placeholder:r=`Type text...`,ref:i,placeholderProps:a,onKeyDown:o,grammar:s,disabled:c,width:l=2**53-1,height:u=2**53-1,ghostText:d,...f})=>{let{isFocused:p}=WL(),m=L0({initialText:e,initialCursorOffset:0,viewport:{width:l,height:u},onChange:e=>t?.(e,m)});(0,X.useEffect)(()=>{i&&(i.current=m)},[m,i]);let h=(0,X.useCallback)(async()=>{let e=m.text;if(e.trim()){try{if(await Promise.resolve(n?.(e))===!1)return}catch{return}m.text===e&&m.setText(``)}},[m,n]);HL((0,X.useCallback)((e,t)=>{let n=!1;if(o?.({input:e,key:t,target:m,preventDefault:()=>{n=!0}}),!n&&!c){if(!c&&t.return&&!t.ctrl&&!t.meta&&!t.shift){if(m.text.endsWith(`\\`)){m.backspace(),m.newline();return}h();return}m.handleInput(e,t)}},[m,h,o,c]),{isActive:!c});let g=m.viewportVisualLines,[_,v]=m.visualCursor,y=m.visualScrollRow,b=p,x=(0,X.useMemo)(()=>e=>V0(e,s),[s]);return!m.text&&r?(0,Y.jsx)(Z,{...f,children:b?(0,Y.jsxs)(Q,{dimColor:!0,...a,children:[pj.inverse(r.slice(0,1)),r.slice(1)]}):(0,Y.jsx)(Q,{color:`gray`,...a,children:r})}):(0,Y.jsx)(Z,{flexDirection:`column`,flexGrow:1,...f,children:g.map((e,t)=>{let n=y+t,r=_-y;if(!(b&&t===r))return(0,Y.jsx)(Q,{children:(s?.length?x(e):e)||` `},`line-${n}`);let i=e.slice(0,v),a=e[v]??` `,o=e.slice(v+1),c=s?.length?x(i):i,l=s?.length?x(o):o,u=d&&!o&&v>=e.length;return(0,Y.jsxs)(Q,{children:[c,pj.inverse(a),l,u&&pj.dim(d)]},`line-${n}`)})})});H0.displayName=`Input`;var U0=class{constructor(){}async listServers(){let e=await this.findConfigSources(),t=[];for(let n of e)if(n.exists)try{let e=await this.loadServersFromSource(n);t.push(...e)}catch{}return t}async addServer(e,t){this.validateServerConfig(t);let n=await this.findConfigSources(),r=n.find(e=>e.type===`abacusai-user`&&e.exists),i=n.find(e=>e.type===`vscode-user`&&e.exists),a=n.filter(e=>e.exists),o=n.find(e=>e.type===`cursor-global`),s=n.find(e=>e.type===`vscode-user`),c=r||i||a[0]||s||o;if(!c)throw Error(`No suitable configuration location found.`);await this.addServerToSource(c,e,t)}async removeServer(e){let t=await this.findConfigSources(),n=!1;for(let r of t)if(r.exists)try{await this.removeServerFromSource(r.path,e)&&(n=!0)}catch{}if(!n)throw Error(`Server '${e}' not found in any configuration file`)}async getServer(e){return(await this.listServers()).find(t=>t.name===e||t.id===e)}async addServerFromJson(e,t){let n;try{n=this.parseJsonWithFallback(t)}catch(e){throw Error(`Invalid JSON syntax: ${e instanceof Error?e.message:String(e)}`)}try{this.validateServerConfig(n)}catch(e){throw Error(`Invalid server configuration: ${e instanceof Error?e.message:String(e)}`)}await this.addServer(e,n)}async addServerFromUrl(e,t,n){let r;r=t.startsWith(`http://`)||t.startsWith(`https://`)?{url:t}:{command:t,args:n||[]},await this.addServer(e,r)}formatServerInfo(e){let t=[`Name: ${e.name}`,`ID: ${e.id}`,`Source: ${e.description||`Unknown`}`,`Status: ${e.status||`unknown`}`];return`url`in e.config?(t.push(`Type: HTTP`),t.push(`URL: ${e.config.url}`),e.config.headers&&Object.keys(e.config.headers).length>0&&t.push(`Headers: ${JSON.stringify(e.config.headers,null,2)}`)):`command`in e.config&&(t.push(`Type: Command`),t.push(`Command: ${e.config.command}`),e.config.args&&e.config.args.length>0&&t.push(`Arguments: ${e.config.args.join(` `)}`),e.config.env&&Object.keys(e.config.env).length>0&&t.push(`Environment: ${JSON.stringify(e.config.env,null,2)}`),e.config.cwd&&t.push(`Working Directory: ${e.config.cwd}`)),t.join(`
|
|
85795
|
+
`)}formatServerList(e){let t=[];if(e.length===0)t.push(`No MCP servers found.`),t.push(``),t.push(`Use the following commands to manage MCP servers:`),t.push(``),t.push(q0);else{t.push(`📡 MCP Servers:`),t.push(``);let n={};for(let t of e){let e=this.getServerSourceLabel(t);n[e]||(n[e]=[]),n[e].push(t)}for(let[e,r]of Object.entries(n)){t.push(` ${e}:`);for(let e of r){let n=`url`in e.config?`🌐`:`💻`;t.push(` ${n} ${e.name}`)}t.push(``)}t.push(`📝 Example - Add GitHub MCP Server:`),t.push(` /mcp add-json github '{"command":"npx","args":["-y","@modelcontextprotocol/server-github"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"your_token"}}'`),t.push(``)}return t.join(`
|
|
85796
|
+
`)}async findConfigSources(){let e=[],t=process.platform===`win32`?T.join(n.homedir(),`AppData`,`Roaming`,`Claude`,`claude_desktop_config.json`):process.platform===`darwin`?T.join(n.homedir(),`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`):T.join(n.homedir(),`.config`,`Claude`,`claude_desktop_config.json`);e.push({path:t,type:`claude-desktop`,label:`Claude Desktop`,exists:h.existsSync(t)});let r=T.join(n.homedir(),`.codeium`,`windsurf`,`mcp_config.json`);e.push({path:r,type:`windsurf`,label:`Windsurf`,exists:h.existsSync(r)});let i=T.join(n.homedir(),`.cursor`,`mcp.json`);e.push({path:i,type:`cursor-global`,label:`Cursor (Global)`,exists:h.existsSync(i)});let a=T.join(process.cwd(),`.cursor`,`mcp.json`);e.push({path:a,type:`cursor-workspace`,label:`Cursor (Workspace)`,exists:h.existsSync(a)});let o=[Le.fullName,`AbacusAI`,`CodeLLM`];for(let t of o){let n=this.getUserDataDir(t);if(n){let r=T.join(n,`User`,`mcp.json`);h.existsSync(r)&&e.push({path:r,type:`abacusai-user`,label:`${t} (User)`,exists:!0})}}let s=process.platform===`win32`?T.join(n.homedir(),`AppData`,`Roaming`,`Code`,`User`):process.platform===`darwin`?T.join(n.homedir(),`Library`,`Application Support`,`Code`,`User`):T.join(n.homedir(),`.config`,`Code`,`User`),c=T.join(s,`mcp.json`);return e.push({path:c,type:`vscode-user`,label:`VSCode (User)`,exists:h.existsSync(c)}),e}getUserDataDir(e){try{switch(process.platform){case`win32`:{let t=process.env.APPDATA;return t?T.join(t,e):null}case`darwin`:return T.join(n.homedir(),`Library`,`Application Support`,e);case`linux`:{let t=process.env.XDG_CONFIG_HOME||T.join(n.homedir(),`.config`);return T.join(t,e)}default:return null}}catch{return null}}async loadServersFromSource(e){let t=await b.readFile(e.path,`utf8`),n=[],r;try{r=this.parseJsonWithFallback(t)}catch(e){throw Error(`JSON parsing failed: ${e instanceof Error?e.message:String(e)}`)}if(e.type.startsWith(`vscode`)||e.type===`abacusai-user`){let t;if(r.servers&&!r.mcp?t=r.servers:r.mcp?.servers&&(t=r.mcp.servers),t)for(let[r,i]of Object.entries(t))n.push({id:`${e.type}.${r}`,name:r,config:i,status:`stopped`,description:`${e.label} - ${this.getServerTypeDescription(i)}`})}else if([`cursor-global`,`cursor-workspace`,`claude-desktop`,`windsurf`].includes(e.type)){let t=r;if(t.mcpServers)for(let[r,i]of Object.entries(t.mcpServers)){let t=i.url?{type:`http`,url:i.url,headers:{}}:{type:`stdio`,command:i.command||``,args:i.args||[],env:i.env||{}};n.push({id:`${e.type}.${r}`,name:r,config:t,status:`stopped`,description:`${e.label} - ${this.getServerTypeDescription(t)}`})}}return n}parseJsonWithFallback(e){try{return JSON.parse(e)}catch(t){try{let t=e.replace(/,(\s*[}\]])/g,`$1`).replace(/([}\]]),(\s*[}\]])/g,`$1$2`);return JSON.parse(t)}catch(e){let n=t instanceof Error?t.message:String(t),r=e instanceof Error?e.message:String(e);throw Error(`JSON parsing failed. Original error: ${n}. After fixing trailing commas: ${r}`)}}}async addServerToSource(e,t,n){let r=e.path,i=T.dirname(r);if(await b.mkdir(i,{recursive:!0}),[`vscode-user`,`vscode-workspace`,`abacusai-user`].includes(e.type))if(r.endsWith(`mcp.json`)){let e={servers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.servers=e.servers||{},e.servers[t]=n;let i=JSON.stringify(e,null,2);await b.writeFile(r,i,`utf8`)}else{let e={};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcp=e.mcp||{servers:{}},e.mcp.servers=e.mcp.servers||{},e.mcp.servers[t]=n;let i=JSON.stringify(e,null,2);await b.writeFile(r,i,`utf8`)}else if(e.type===`cursor-global`){let e={mcpServers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcpServers=e.mcpServers||{};let i=`url`in n?{url:n.url}:{command:n.command,args:n.args?[...n.args]:void 0,env:n.env?Object.fromEntries(Object.entries(n.env).map(([e,t])=>[e,String(t)])):void 0};e.mcpServers[t]=i;let a=JSON.stringify(e,null,2);await b.writeFile(r,a,`utf8`)}else if(e.type===`cursor-workspace`){let e={mcpServers:{}};if(h.existsSync(r))try{let t=await b.readFile(r,`utf8`);e=this.parseJsonWithFallback(t)}catch{}e.mcpServers=e.mcpServers||{};let i=`url`in n?{url:n.url}:{command:n.command,args:n.args?[...n.args]:void 0,env:n.env?Object.fromEntries(Object.entries(n.env).map(([e,t])=>[e,String(t)])):void 0};e.mcpServers[t]=i;let a=JSON.stringify(e,null,2);await b.writeFile(r,a,`utf8`)}else throw Error(`Unsupported config source type: ${e.type}`)}async removeServerFromSource(e,t){if(!h.existsSync(e))return!1;let n=await b.readFile(e,`utf8`),r=e.includes(`.cursor`)||e.includes(`claude_desktop_config.json`)||e.includes(`mcp_config.json`);if(e.endsWith(`mcp.json`)){let r=this.parseJsonWithFallback(n);if(!r.servers||!r.servers[t])return!1;delete r.servers[t];let i=JSON.stringify(r,null,2);return await b.writeFile(e,i,`utf8`),!0}else if(e.endsWith(`settings.json`)){let r=this.parseJsonWithFallback(n),i=r?.mcp||{servers:{}};if(!i.servers||!i.servers[t])return!1;delete i.servers[t],r.mcp=i;let a=JSON.stringify(r,null,2);return await b.writeFile(e,a,`utf8`),!0}else if(r){let r=this.parseJsonWithFallback(n);if(!r.mcpServers||!r.mcpServers[t])return!1;delete r.mcpServers[t];let i=JSON.stringify(r,null,2);return await b.writeFile(e,i,`utf8`),!0}else throw Error(`Unsupported config file format: ${e}`)}validateServerConfig(e){if(!e||typeof e!=`object`)throw Error(`Server configuration must be a valid object`);if(`mcpServers`in e||`servers`in e)throw Error(`Invalid configuration format. Server configuration should not contain "mcpServers" or "servers" properties. Each server should be configured individually.`);if(`url`in e){if(!e.url)throw Error(`URL is required for HTTP servers`);if(typeof e.url!=`string`)throw Error(`URL must be a string`);if(!e.url.startsWith(`http://`)&&!e.url.startsWith(`https://`))throw Error(`URL must start with http:// or https://`)}else if(`command`in e){if(!e.command)throw Error(`Command is required for stdio servers`);if(typeof e.command!=`string`)throw Error(`Command must be a string`);if(e.args&&!Array.isArray(e.args))throw Error(`Arguments must be an array`);if(e.args&&e.args.some(e=>typeof e!=`string`))throw Error(`All arguments must be strings`)}else throw Error(`Server configuration must have either "url" or "command" property`)}getServerTypeDescription(e){if(`url`in e)return`HTTP server at ${e.url}`;if(`command`in e){let t=e.args&&e.args.length>0?` ${e.args.join(` `)}`:``;return`Command: ${e.command}${t}`}return`Unknown server type`}getServerSourceLabel(e){return e.id.startsWith(`claude-desktop`)?`Claude Desktop`:e.id.startsWith(`windsurf`)?`Windsurf`:e.id.startsWith(`cursor-global`)?`Cursor (Global)`:e.id.startsWith(`cursor-workspace`)?`Cursor (Workspace)`:e.id.startsWith(`abacusai-user`)?e.description?.includes(`${Le.fullName}-dev`)||e.description?.includes(`CodeLLM-dev`)?`${Le.fullName}-dev (User)`:`${Le.fullName} (User)`:e.id.startsWith(`vscode-user`)?`VSCode (User)`:e.id.startsWith(`vscode-workspace`)?`VSCode (Workspace)`:`Other`}},W0=class{standaloneService;constructor(){this.standaloneService=new U0}async listServers(){return this.standaloneService.listServers()}async addServer(e,t){return this.standaloneService.addServer(e,t)}async removeServer(e){return this.standaloneService.removeServer(e)}async getServer(e){return this.standaloneService.getServer(e)}async addServerFromJson(e,t){return this.standaloneService.addServerFromJson(e,t)}async addServerFromUrl(e,t,n){return this.standaloneService.addServerFromUrl(e,t,n)}formatServerInfo(e){return this.standaloneService.formatServerInfo(e)}formatServerList(e){return this.standaloneService.formatServerList(e)}};function G0(e,t){try{let r=T.join(n.tmpdir(),`abacus-tui-logs`);h.existsSync(r)||h.mkdirSync(r,{recursive:!0});let i=T.join(r,`mcp-errors.log`),a=new Date().toISOString(),o=t instanceof Error?t.message:String(t),s=t instanceof Error?t.stack:``,c=`[${a}] ${e}: ${o}\n${s?`Stack: ${s}\n`:``}\n`;h.appendFileSync(i,c,`utf8`)}catch{console.error(`[MCP] ${e}:`,t)}}var K0=class{mcpService;mcp;constructor(e){this.mcpService=new W0,this.mcp=e}async listServers(){let e=await this.mcpService.listServers();if(this.mcp){let t=this.mcp.listServers();for(let n of e)n.status=t.find(e=>e.config.id===n.id||e.config.id===n.name)?`running`:`stopped`}return this.mcpService.formatServerList(e)}async addServer(e,t,n){await this.mcpService.addServerFromUrl(e,t,n),this.mcp&&this.mcp.refresh().catch(t=>{G0(`Failed to refresh MCP connections after adding server '${e}'`,t)})}async removeServer(e){await this.mcpService.removeServer(e),this.mcp&&this.mcp.removeServer(e).catch(t=>{G0(`Failed to disconnect MCP server '${e}'`,t)})}async getServer(e){let t=await this.mcpService.getServer(e);return t?(this.mcp&&(t.status=this.mcp.listServers().find(e=>e.config.id===t.id||e.config.id===t.name)?`running`:`stopped`),this.mcpService.formatServerInfo(t)):null}async addServerFromJson(e,t){await this.mcpService.addServerFromJson(e,t),this.mcp&&this.mcp.refresh().catch(t=>{G0(`Failed to refresh MCP connections after adding server '${e}' from JSON`,t)})}async getServerNames(){let e=await this.mcpService.listServers();if(this.mcp){let t=this.mcp.listServers();for(let n of e)n.status=t.find(e=>e.config.id===n.id||e.config.id===n.name)?`running`:`stopped`}return e.map(e=>({name:e.name,status:e.status}))}formatHelp(){return q0}};const q0=`
|
|
85797
85797
|
MCP (Model Context Protocol) Commands:
|
|
85798
85798
|
|
|
85799
85799
|
/mcp list List configured MCP servers
|
|
@@ -85809,12 +85809,12 @@ TUI Features:
|
|
|
85809
85809
|
- Full MCP server management from command line
|
|
85810
85810
|
- All commands work independently in TUI
|
|
85811
85811
|
- Direct file-based configuration access
|
|
85812
|
-
`;var
|
|
85813
|
-
Restart iTerm2 for changes to take effect.`,requiresRestart:!0}:{success:!1,message:`Failed to install iTerm2 Shift+Enter key binding`}}catch(e){return{success:!1,message:`Failed to configure iTerm2: ${e instanceof Error?e.message:String(e)}`}}}async function
|
|
85812
|
+
`;var J0=class{startTime;constructor(){this.startTime=performance.now()}getElapsedSeconds(){return(performance.now()-this.startTime)/1e3}getElapsedMs(){return performance.now()-this.startTime}getFormattedDuration(){return Y0(this.getElapsedMs())}reset(){this.startTime=performance.now()}};function Y0(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),(i>0||a.length===0)&&a.push(`${i}s`),a.join(` `)}const X0=`\\x1b\\r`,Z0=j(l);function Q0(e){if(!h.existsSync(e))return null;let t=`${e}.${pe(4).toString(`hex`)}.bak`;try{return h.copyFileSync(e,t),t}catch{return null}}async function $0(e){let t=n.homedir(),r;r=V.platform===`win32`?T.join(t,`AppData`,`Roaming`,e,`User`):V.platform===`darwin`?T.join(t,`Library`,`Application Support`,e,`User`):T.join(t,`.config`,e,`User`);let i=T.join(r,`keybindings.json`);try{h.existsSync(r)||h.mkdirSync(r,{recursive:!0});let t=[];if(h.existsSync(i)){let n=h.readFileSync(i,`utf-8`);if(!Q0(i))return{success:!1,message:`Failed to backup existing ${e} keybindings`};let r=n.replace(/\/\/.*$/gm,``).replace(/\/\*[\s\S]*?\*\//g,``);try{t=JSON.parse(r||`[]`)}catch{t=[]}if(t.find(e=>e.key===`shift+enter`&&e.command===`workbench.action.terminal.sendSequence`&&e.when===`terminalFocus`))return{success:!1,message:`Found existing ${e} Shift+Enter key binding. Remove it to continue.\nSee: ${i}`}}return t.push({key:`shift+enter`,command:`workbench.action.terminal.sendSequence`,args:{text:`\x1B\r`},when:`terminalFocus`}),h.writeFileSync(i,JSON.stringify(t,null,2),`utf-8`),{success:!0,message:`Installed ${e} terminal Shift+Enter key binding\nSee: ${i}`}}catch(t){return{success:!1,message:`Failed to install ${e} terminal Shift+Enter key binding: ${t instanceof Error?t.message:String(t)}`}}}async function e2(e,t){try{let{stdout:n,stderr:r}=await Z0(e,t,{encoding:`utf8`});return{stdout:n,stderr:r,code:0}}catch(e){if(e&&typeof e==`object`&&`code`in e){let t=e;return{stdout:t.stdout||``,stderr:t.stderr||``,code:typeof t.code==`number`?t.code:1}}return{stdout:``,stderr:e instanceof Error?e.message:String(e),code:1}}}async function t2(){if(V.platform!==`darwin`)return{success:!1,message:`iTerm2 setup is only available on macOS`};try{let{code:e}=await e2(`defaults`,[`write`,`com.googlecode.iterm2`,`GlobalKeyMap`,`-dict-add`,`0xd-0x20000`,`<dict><key>Text</key><string>\x1B\r</string><key>Action</key><integer>12</integer></dict>`]);return e===0?{success:!0,message:`Installed iTerm2 Shift+Enter key binding
|
|
85813
|
+
Restart iTerm2 for changes to take effect.`,requiresRestart:!0}:{success:!1,message:`Failed to install iTerm2 Shift+Enter key binding`}}catch(e){return{success:!1,message:`Failed to configure iTerm2: ${e instanceof Error?e.message:String(e)}`}}}async function n2(){if(V.platform!==`darwin`)return{success:!1,message:`Apple Terminal setup is only available on macOS`};let e=T.join(n.homedir(),`Library`,`Preferences`,`com.apple.Terminal.plist`),t=Q0(e);try{let{stdout:n,code:r}=await e2(`defaults`,[`read`,`com.apple.Terminal`,`Default Window Settings`]);if(r!==0||!n.trim())return{success:!1,message:`Failed to read default Terminal.app profile`};let i=n.trim(),{code:a}=await e2(`/usr/libexec/PlistBuddy`,[`-c`,`Add :'Window Settings':'${i}':useOptionAsMetaKey bool true`,e]);return a!==0&&({code:a}=await e2(`/usr/libexec/PlistBuddy`,[`-c`,`Set :'Window Settings':'${i}':useOptionAsMetaKey true`,e])),await e2(`killall`,[`cfprefsd`]),{success:!0,message:`Configured Terminal.app to use Option as Meta key
|
|
85814
85814
|
Option+Enter will now insert a newline
|
|
85815
|
-
Restart Terminal.app for changes to take effect.`,requiresRestart:!0,backupPath:t||void 0}}catch(e){return{success:!1,message:`Failed to configure Terminal.app: ${e instanceof Error?e.message:String(e)}`}}}async function
|
|
85815
|
+
Restart Terminal.app for changes to take effect.`,requiresRestart:!0,backupPath:t||void 0}}catch(e){return{success:!1,message:`Failed to configure Terminal.app: ${e instanceof Error?e.message:String(e)}`}}}async function r2(){let e=[],t=V.env.XDG_CONFIG_HOME;t?e.push(T.join(t,`ghostty`,`config`)):e.push(T.join(n.homedir(),`.config`,`ghostty`,`config`)),V.platform===`darwin`&&e.push(T.join(n.homedir(),`Library`,`Application Support`,`com.mitchellh.ghostty`,`config`));let r=null,i=!1;for(let t of e)if(h.existsSync(t)){r=t,i=!0;break}r||=e[0];try{let e=``;if(i){if(e=h.readFileSync(r,`utf-8`),e.includes(`shift+enter`))return{success:!1,message:`Found existing Ghostty Shift+Enter key binding. Remove it to continue.\nSee: ${r}`};if(!Q0(r))return{success:!1,message:`Failed to backup existing Ghostty config`}}else{let e=T.dirname(r);h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}let t=e;return e&&!e.endsWith(`
|
|
85816
85816
|
`)&&(t+=`
|
|
85817
|
-
`),t+=`keybind = shift+enter=text:${
|
|
85817
|
+
`),t+=`keybind = shift+enter=text:${X0}\n`,h.writeFileSync(r,t,`utf-8`),{success:!0,message:`Installed Ghostty Shift+Enter key binding\nSee: ${r}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install Ghostty Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function i2(){let e=T.join(n.homedir(),`.wezterm.lua`);try{let t=``,n=!1;if(h.existsSync(e)){if(n=!0,t=h.readFileSync(e,`utf-8`),t.includes(`mods="SHIFT"`)&&t.includes(`key="Enter"`))return{success:!1,message:`Found existing WezTerm Shift+Enter key binding. Remove it to continue.\nSee: ${e}`};if(!Q0(e))return{success:!1,message:`Failed to backup existing WezTerm config`}}let r=`{key="Enter", mods="SHIFT", action=wezterm.action{SendString="${X0}"}}`;if(!n)t=`local wezterm = require 'wezterm'
|
|
85818
85818
|
local config = wezterm.config_builder()
|
|
85819
85819
|
|
|
85820
85820
|
config.keys = {
|
|
@@ -85822,40 +85822,40 @@ config.keys = {
|
|
|
85822
85822
|
}
|
|
85823
85823
|
|
|
85824
85824
|
return config
|
|
85825
|
-
`;else{let e=t.match(/config\.keys\s*=\s*\{([^}]*)\}/s);if(e){let n=e[1]??``,i=n.trim()?`${n.trim()},\n ${r},`:`\n ${r},\n`;t=t.replace(/config\.keys\s*=\s*\{[^}]*\}/s,`config.keys = {${i}}`)}else t.match(/return\s+config/s)?t=t.replace(/return\s+config/s,`config.keys = {\n ${r},\n}\n\nreturn config`):t+=`\nconfig.keys = {\n ${r},\n}\n`}return h.writeFileSync(e,t,`utf-8`),{success:!0,message:`Installed WezTerm Shift+Enter key binding\nSee: ${e}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install WezTerm Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function
|
|
85825
|
+
`;else{let e=t.match(/config\.keys\s*=\s*\{([^}]*)\}/s);if(e){let n=e[1]??``,i=n.trim()?`${n.trim()},\n ${r},`:`\n ${r},\n`;t=t.replace(/config\.keys\s*=\s*\{[^}]*\}/s,`config.keys = {${i}}`)}else t.match(/return\s+config/s)?t=t.replace(/return\s+config/s,`config.keys = {\n ${r},\n}\n\nreturn config`):t+=`\nconfig.keys = {\n ${r},\n}\n`}return h.writeFileSync(e,t,`utf-8`),{success:!0,message:`Installed WezTerm Shift+Enter key binding\nSee: ${e}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install WezTerm Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function a2(){let e=[],t=V.env.XDG_CONFIG_HOME;t?e.push(T.join(t,`kitty`,`kitty.conf`)):e.push(T.join(n.homedir(),`.config`,`kitty`,`kitty.conf`)),V.platform===`darwin`&&e.push(T.join(n.homedir(),`Library`,`Preferences`,`kitty`,`kitty.conf`));let r=null,i=!1;for(let t of e)if(h.existsSync(t)){r=t,i=!0;break}r||=e[0];try{let e=``;if(i){if(e=h.readFileSync(r,`utf-8`),e.includes(`shift+enter`)&&e.includes(`send_text`))return{success:!1,message:`Found existing Kitty Shift+Enter key binding. Remove it to continue.\nSee: ${r}`};if(!Q0(r))return{success:!1,message:`Failed to backup existing Kitty config`}}else{let e=T.dirname(r);h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}let t=e;return e&&!e.endsWith(`
|
|
85826
85826
|
`)&&(t+=`
|
|
85827
|
-
`),t+=`map shift+enter send_text all ${
|
|
85827
|
+
`),t+=`map shift+enter send_text all ${X0}\n`,h.writeFileSync(r,t,`utf-8`),{success:!0,message:`Installed Kitty Shift+Enter key binding\nSee: ${r}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install Kitty Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function o2(){let e=[],t=V.env.XDG_CONFIG_HOME;t?(e.push(T.join(t,`alacritty`,`alacritty.toml`)),e.push(T.join(t,`alacritty`,`alacritty.yml`))):(e.push(T.join(n.homedir(),`.config`,`alacritty`,`alacritty.toml`)),e.push(T.join(n.homedir(),`.config`,`alacritty`,`alacritty.yml`))),V.platform===`darwin`&&(e.push(T.join(n.homedir(),`.alacritty.toml`)),e.push(T.join(n.homedir(),`.alacritty.yml`)));let r=null,i=!1,a=!0;for(let t of e)if(h.existsSync(t)){r=t,i=!0,a=t.endsWith(`.toml`);break}r||=e[0];try{let e=``;if(i){if(e=h.readFileSync(r,`utf-8`),e.includes(`Shift`)&&e.includes(`Return`))return{success:!1,message:`Found existing Alacritty Shift+Enter key binding. Remove it to continue.\nSee: ${r}`};if(!Q0(r))return{success:!1,message:`Failed to backup existing Alacritty config`}}else{let e=T.dirname(r);h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}let t=e;return e&&!e.endsWith(`
|
|
85828
85828
|
`)&&(t+=`
|
|
85829
85829
|
`),a?t+=`
|
|
85830
85830
|
[[keyboard.bindings]]
|
|
85831
85831
|
key = "Return"
|
|
85832
85832
|
mods = "Shift"
|
|
85833
|
-
chars = "${
|
|
85833
|
+
chars = "${X0}"
|
|
85834
85834
|
`:t+=`
|
|
85835
85835
|
key_bindings:
|
|
85836
|
-
- { key: Return, mods: Shift, chars: "${
|
|
85837
|
-
`,h.writeFileSync(r,t,`utf-8`),{success:!0,message:`Installed Alacritty Shift+Enter key binding\nSee: ${r}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install Alacritty Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function
|
|
85838
|
-
`),_=Math.max(0,g.length-p);if(HL((0,X.useCallback)((e,t)=>{if(t.escape||e===`q`){m.current();return}if(t.leftArrow){u(e=>{let t=e-1;return t<-1?h.current.length-1:t}),f(0);return}if(t.rightArrow){u(e=>{let t=e+1;return t>=h.current.length?-1:t}),f(0);return}if(t.upArrow){f(e=>Math.max(0,e-1));return}if(t.downArrow){f(e=>Math.min(_,e+1));return}if(t.pageUp||e===`u`){f(e=>Math.max(0,e-p));return}if(t.pageDown||e===`d`){f(e=>Math.min(_,e+p));return}},[_,p]),{isActive:!0}),r)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:
|
|
85839
|
-
`))}`}const g2=(0,X.memo)(({version:e,cwd:t,onDismiss:n})=>{let[i,a]=(0,X.useState)({type:`input`}),s=(0,X.useRef)(null),c=(0,X.useRef)(n);c.current=n;let l=(0,X.useCallback)(n=>{let i=n.trim();if(!i)return;let s=p2(t);a({type:`confirm`,info:{description:i,platform:`${o()}`,arch:r(),shell:d2(),terminal:f2(),version:`v${e}`,gitBranch:s.branch,gitCommit:s.commit,gitRemote:s.remote,hasLocalChanges:s.hasLocalChanges,includeGitInfo:!1}})},[t,e]),u=(0,X.useCallback)(()=>{i.type===`confirm`&&a({type:`submitted`,feedbackId:m2()})},[i]),d=(0,X.useCallback)(()=>{i.type===`confirm`&&a({type:`confirm`,info:{...i.info,includeGitInfo:!i.info.includeGitInfo}})},[i]),f=(0,X.useCallback)(()=>{if(i.type!==`submitted`)return;let e=i,t=p.current;t?.type===`confirm`&&MN(h2(t.info,e.feedbackId)),c.current()},[i]),p=(0,X.useRef)(null);if(HL((0,X.useCallback)((e,t)=>{if(t.escape){c.current();return}if(i.type===`confirm`){if(t.return){u();return}if(e===`g`){d();return}}if(i.type===`submitted`){t.return?f():c.current();return}},[i,u,f,d]),{isActive:i.type!==`input`}),i.type===`confirm`&&(p.current=i),i.type===`input`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:r2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Describe the issue below:`}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(L0,{ref:s,placeholder:`Describe your feedback or bug...`,onSubmit:l,onKeyDown:e=>{e.key.escape&&(e.preventDefault(),c.current())}})]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Enter to continue · Esc to cancel`})]});if(i.type===`confirm`){let{info:e}=i;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:r2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` This report will include:`}),(0,Y.jsxs)(Q,{children:[` - Your feedback / bug description: `,(0,Y.jsx)(Q,{color:`yellow`,children:e.description})]}),(0,Y.jsxs)(Q,{children:[` - Environment info: `,(0,Y.jsxs)(Q,{color:`yellow`,children:[e.platform,` (`,e.arch,`), `,e.shell,`, `,e.terminal,`, `,e.version]})]}),(0,Y.jsxs)(Q,{children:[` - Git repo metadata: `,e.includeGitInfo?(0,Y.jsxs)(Q,{color:`yellow`,children:[e.gitBranch,`, `,e.gitCommit,` @ `,e.gitRemote,e.hasLocalChanges?`, has local changes`:``]}):(0,Y.jsx)(Q,{dimColor:!0,children:`not included (press g to include)`})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`We will use your feedback to debug related issues or to improve the CLI's functionality.`]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Enter to submit · g to toggle git info · Esc to cancel`})]})}return i.type===`submitted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:r2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{color:`green`,children:` Thank you for your report!`}),(0,Y.jsxs)(Q,{children:[` Feedback ID: `,(0,Y.jsx)(Q,{color:`cyan`,children:i.feedbackId})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Press Enter to open your browser and draft a GitHub issue, or any other key to close.`]})]}):null});g2.displayName=`FeedbackOverlay`;const _2=.25,v2=(0,X.memo)(({text:e,color:t=`#94a3b8`})=>{let[n,r]=(0,X.useState)(0),i=e.length;(0,X.useEffect)(()=>{let e=setInterval(()=>{(0,X.startTransition)(()=>{r(e=>e+1)})},100);return()=>clearInterval(e)},[]);let a=(0,X.useMemo)(()=>y2(t),[t]);return(0,Y.jsx)(Q,{children:(0,X.useMemo)(()=>{let t=n%i,r=Math.max(i*.6,3),o=``;for(let n=0;n<i;n++){let s=Math.abs(n-t),c=i-s,l=Math.min(s,c),u=b2(a,Math.max(0,1-l/r));o+=pj.rgb(u.r,u.g,u.b)(e[n])}return o},[n,i,a,e])})});v2.displayName=`Shimmer`;function y2(e){let t=e.replace(`#`,``);return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function b2(e,t){let n=Math.floor(e.r*_2),r=Math.floor(e.g*_2),i=Math.floor(e.b*_2);return{r:Math.floor(n+(e.r-n)*t),g:Math.floor(r+(e.g-r)*t),b:Math.floor(i+(e.b-i)*t)}}const x2=(0,X.memo)(({initialEmail:e,auth:t,onDismiss:n})=>{let[r,i]=(0,X.useState)(()=>e?{type:`connecting`,email:e}:{type:`input`,mode:`email`}),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useRef)(!1),d=(0,X.useRef)(n);d.current=n;let f=(0,X.useCallback)(async e=>{i({type:`connecting`,email:e});try{let n=await t.initiateDeviceCode(e);if(u.current)return;if(!n.success||!n.verificationUri||!n.userCode){i({type:`error`,message:n.error??`Failed to initiate login`,canRetry:!0});return}i({type:`polling`,verificationUri:n.verificationUri,userCode:n.userCode,pollingInterval:n.pollingInterval??5})}catch(e){if(u.current)return;i({type:`error`,message:e instanceof Error?e.message:`Failed to connect`,canRetry:!0})}},[t]);(0,X.useEffect)(()=>{e&&f(e)},[]),(0,X.useEffect)(()=>{r.type===`polling`&&(o(!1),c(!1),MN(r.verificationUri).then(e=>{u.current||o(e)}))},[r.type===`polling`?r.verificationUri:null]),(0,X.useEffect)(()=>{if(r.type!==`polling`)return;let e=!0,n=r.pollingInterval*1e3,a=Date.now()+600*1e3,{userCode:o}=r;return(async()=>{for(;e&&!u.current&&Date.now()<a;){if(await new Promise(e=>setTimeout(e,n)),!e||u.current)return;try{let n=await t.pollDeviceCode(o);if(!e||u.current)return;if(n.success&&n.deviceCode){try{if(await t.completeDeviceCodeLogin(n.deviceCode,n.chatWebUrl),!e||u.current)return;i({type:`success`})}catch(t){if(!e||u.current)return;i({type:`error`,message:t instanceof Error?t.message:`Failed to complete login`,canRetry:!1})}return}}catch{}}e&&!u.current&&i({type:`error`,message:`Authentication timed out. Please try again.`,canRetry:!0})})(),()=>{e=!1}},[r.type===`polling`?r.userCode:null,t]),(0,X.useEffect)(()=>{if(r.type===`success`){let e=setTimeout(()=>d.current(),1500);return()=>clearTimeout(e)}},[r.type]);let p=(0,X.useCallback)(e=>{let n=e.trim();if(n){if(r.type===`input`&&r.mode===`apikey`){t.loginWithApiKey(n).then(()=>{u.current||i({type:`success`})}).catch(e=>{u.current||i({type:`error`,message:e instanceof Error?e.message:`API key login failed`,canRetry:!0})});return}f(n)}},[r,f,t]),m=(0,X.useCallback)(()=>{u.current=!0,d.current()},[]),h=(0,X.useCallback)(()=>{r.type===`polling`&&NN(r.verificationUri).then(e=>{e&&c(!0)})},[r]);if(HL((0,X.useCallback)((e,t)=>{if(t.escape){m();return}if(r.type===`input`&&t.ctrl&&(e===`a`||e===``)){i(e=>e.type===`input`?{type:`input`,mode:e.mode===`email`?`apikey`:`email`}:e);return}if(r.type===`polling`&&e===`c`){h();return}if(r.type===`error`&&r.canRetry&&t.return){i({type:`input`,mode:`email`});return}},[r,m,h]),{isActive:r.type!==`input`}),r.type===`input`){let e=r.mode===`email`;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:e?` Email:`:` API Key:`}),(0,Y.jsx)(L0,{ref:l,placeholder:e?`you@example.com`:`Paste your API key`,onSubmit:p,onKeyDown:e=>{e.key.paste&&(e.preventDefault(),e.target.insert(e.input)),e.key.escape&&(e.preventDefault(),m()),e.key.ctrl&&(e.input===`a`||e.input===``)&&(e.preventDefault(),i(e=>e.type===`input`?{type:`input`,mode:e.mode===`email`?`apikey`:`email`}:e))}})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Enter to submit · Esc to cancel · Ctrl+A to switch to`,` `,e?`API key`:`email`]})]})}return r.type===`connecting`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(v2,{text:`Logging in as ${r.email}...`})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`polling`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{children:[` `,a?(0,Y.jsx)(Q,{color:`yellow`,children:`Opening browser to sign in...`}):(0,Y.jsx)(v2,{text:`Opening browser to sign in...`})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Browser didn't open? Use the URL below to sign in`,` `,(0,Y.jsxs)(Q,{dimColor:!1,color:s?`green`:`gray`,children:[`(`,s?`copied!`:`c to copy`,`)`]})]}),(0,Y.jsxs)(Q,{color:`cyan`,children:[` `,r.verificationUri]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{children:[` `,`Your one-time code:`,` `,(0,Y.jsx)(Q,{color:`yellowBright`,bold:!0,children:r.userCode})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(v2,{text:`Waiting for authentication...`})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`success`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{color:`green`,children:[` `,`✓ Logged in successfully!`]}),(0,Y.jsx)(Q,{})]}):r.type===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{color:`red`,children:[` `,`✗ `,r.message]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,r.canRetry?`Enter to retry · `:``,`Esc to close`]})]}):null});x2.displayName=`LoginOverlay`;const S2=new class{commands=new Map;register(e){this.commands.has(e.id)||this.commands.set(e.id,e)}clear(){this.commands.clear()}get(e){return this.commands.get(e)}getAll(){return Array.from(this.commands.values())}getAliasesForMode(e,t){return e.alias?Array.isArray(e.alias)?e.alias:e.alias[t]??[]:[]}buildCommandMatch(e,t){if(e.subcommands&&e.subcommands.length>0){if(t.length===0)return{command:e,args:``,query:``,needsSubcommand:!0};let n=t[0],r=e.subcommands.find(e=>e.id===n);if(!r){let n=t.join(` `);return{command:e,args:n,query:n,needsSubcommand:!0}}let i=t.slice(1).join(` `);return{command:e,subcommand:r,args:i,query:i}}let n=t.join(` `);return{command:e,args:n,query:n}}findCommandByAlias(e,t){let n=e.toLowerCase();for(let e of this.commands.values())if(this.getAliasesForMode(e,t).some(e=>e.toLowerCase()===n))return e}matchByAlias(e,t){let n=e.trim().split(/\s+/).filter(Boolean);if(n.length===0)return null;let[r,...i]=n,a=this.findCommandByAlias(r,t);return!a||!(a.requiresArgument||a.subcommands&&a.subcommands.length>0)&&i.length>0?null:this.buildCommandMatch(a,i)}parseArgs(e){let t=[],n=``,r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(i){n+=o,i=!1;continue}if(o===`\\`){i=!0;continue}if(o===`'`||o===`"`){r===o?r=null:r===null?r=o:n+=o;continue}if(o===` `&&r===null){n.length>0&&(t.push(n),n=``);continue}n+=o}return n.length>0&&t.push(n),t}async execute(e){if(e.needsSubcommand)return!1;let t=e.args?this.parseArgs(e.args):[];return(e.subcommand||e.command).requiresArgument&&t.length===0?!1:e.subcommand?.execute?(await e.subcommand.execute(t),!0):e.command.execute?(await e.command.execute(t),!0):!1}match(e,t){let n=e.trim();if(t!==void 0&&!n.startsWith(`/`))return this.matchByAlias(n,t);if(!n.startsWith(`/`))return null;let r=n.slice(1).split(/\s+/).filter(Boolean);if(r.length===0)return null;let[i,...a]=r,o=this.commands.get(i);if(!o)return null;let s=e.trimStart().slice(1+i.length),c=s.length>0&&/\s/.test(s[0]);return a.length===0&&!c?{command:o,args:``,query:``,exactMatch:!0}:this.buildCommandMatch(o,a)}search(e,t){let n=this.getAll().filter(e=>!e.isAvailable||!t||e.isAvailable(t));return e?new yv(n,{selector:e=>`${e.id} ${e.description}`}).find(e).map(e=>e.item):n}searchSubcommands(e,t){return e.subcommands?t?new yv(e.subcommands,{selector:e=>`${e.id} ${e.description}`}).find(t).map(e=>e.item):e.subcommands:[]}},C2=_z;function w2(){let e=S2.getAll(),t=[],n=Math.max(0,...e.map(e=>e.subcommands&&e.subcommands.length>0?Math.max(0,...e.subcommands.map(e=>e.usage?.length||0)):e.usage?.length||0));t.push(`Abacus.AI CLI`,``,`Abacus.AI CLI has read access to files in the current directory and can run commands and edit files with your permission.`,``,`Use npx -y @abacus-ai/cli@latest to run latest version of abacusai interactive mode directly from your terminal`,``,`Usage Modes:`,`- REPL: abacusai (interactive session)`,`- Non-interactive: abacusai -p "question"`,``,`Run abacusai --help for all command line options`,``,`For first time users, use /login to authenticate to Abacus.AI CLI`,``,`Common Tasks:`,`- Ask questions about your codebase > How does agent.py work?`,`- Edit files > Update code.ts to...`,`- Fix errors > cargo build`,`- Run commands > /help`,`- Run bash commands > wc`,``,`Interactive Mode Commands:`,``);for(let r of e)if(r.subcommands&&r.subcommands.length>0)for(let e of r.subcommands)t.push(` ${(e.usage||``).padEnd(n+2)} ${e.description||``}`);else t.push(` ${(r.usage||``).padEnd(n+2)} ${r.description||``}`);return t.push(``,`Type any command and press Enter to execute.`),t.join(`
|
|
85840
|
-
`)}function
|
|
85841
|
-
|
|
85842
|
-
Please restart your terminal for changes to take effect.`),n(t,`info`)}else n(e.message,`warning`)}catch(e){n(`Terminal setup failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}},{id:`theme`,description:`Switch between color themes`,usage:`/theme [theme_name]`,completionProvider:e=>{let t=
|
|
85843
|
-
`),`info`)}},{id:`diff`,description:`Show git diff of all changes in an interactive viewer`,usage:`/diff`,uiProvider:(t,n)=>(0,Y.jsx)(
|
|
85844
|
-
`)};return(0,Y.jsx)(
|
|
85845
|
-
`)[n]||``,a=-1;for(let e=Math.min(r,i.length)-1;e>=0;e--){let t=i[e];if(t===`@`){a=e;break}if(!
|
|
85846
|
-
`),a=[],o=!1;if(n&&i.length>r){let e=Math.max(1,Math.floor(r/2)),t=i.slice(0,e).map((e,t)=>({line:e,originalIndex:t})),n=i.slice(-e).map((t,n)=>({line:t,originalIndex:i.length-e+n}));a=[...t,...n],o=!0}else a=i.map((e,t)=>({line:e,originalIndex:t}));return(0,Y.jsxs)(Z,{flexDirection:`column`,paddingX:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:`${
|
|
85847
|
-
`).map(e=>t.test(e)?e.split(`;`).slice(1).join(`;`):e)}function
|
|
85848
|
-
`)}return J2(X2(e))}var Q2=Te((()=>{}));const $2=1e3;function e4(){let[e,t]=(0,X.useState)({submittedCommand:null,runId:0,output:``,isRunning:!1}),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(-1),c=(0,X.useRef)(!1);(0,X.useEffect)(()=>{c.current||(c.current=!0,Promise.resolve().then(()=>(Q2(),K2)).then(e=>{let t=e.shellHistory??e.default;a((typeof t==`function`?t():[]).slice(-$2))}).catch(()=>{}))},[]);let l=(0,X.useCallback)(e=>{let n=e.trim();n&&(a(e=>e.length>0&&e[e.length-1]===n?e:[...e,n].slice(-$2)),s(-1),t(e=>({submittedCommand:n,runId:e.runId+1,output:``,isRunning:!0})))},[]),u=(0,X.useCallback)(e=>{t(t=>(t.submittedCommand&&r(n=>[...n,{command:t.submittedCommand,output:e}].slice(-1e3)),{submittedCommand:null,runId:t.runId,output:``,isRunning:!1}))},[]);return{submitCommand:l,renderer:(0,X.useCallback)(r=>(0,Y.jsx)(W2,{state:e,setState:t,onCommandComplete:u,commandHistory:n,currentPrompt:r.prompt,availableHeight:r.availableHeight}),[e,u,n]),navigateHistory:(0,X.useCallback)(e=>{if(i.length===0)return null;let t=o;return e===`up`?t=o===-1?i.length-1:Math.max(0,o-1):(t=o===-1?-1:o+1,t>=i.length&&(t=-1)),s(t),t===-1?``:i[t]},[i,o]),getActivity:()=>e.isRunning?`pending`:`idle`}}function t4(){return new Promise(e=>{l(`gh`,[`pr`,`view`,`--json`,`number,url`],{timeout:1e4},(t,n)=>{if(t){e(null);return}try{let t=JSON.parse(n.trim());if(typeof t.number==`number`&&typeof t.url==`string`&&t.number>0){e({number:t.number,url:t.url});return}}catch{}e(null)})})}function n4(e){let t=$R(),n=(0,X.useRef)(e);(0,X.useEffect)(()=>{let r=n.current===Cl.Idle,i=e===Cl.Idle;n.current=e,i&&!r&&t.invalidateQueries({queryKey:[i1.PrInfo]})},[e,t]);let{data:r}=hz({queryKey:[i1.PrInfo],queryFn:t4,staleTime:1/0,retry:!1,refetchOnMount:!1,refetchOnWindowFocus:!1});return r??null}function r4({href:e,children:t}){let{colors:n}=bz(),r=`\x1b]8;;${e}\x07`;return(0,Y.jsx)(Q,{color:n.link,underline:!0,transform:e=>`${r}${e}]8;;`,children:t})}r4.displayName=`Link`;const i4=(0,X.memo)(({hints:e,availableHeight:t})=>{let{agentMode:n,isWaitingForYoloConfirm:r}=FJ(),{agentStatus:i}=T$(),a=n4(i);if(t!==void 0&&t<1)return null;let o;if(e?.exitKey)o=(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press `,e.exitKey===`c`?`Ctrl+C`:`Ctrl+D`,` again to exit`]});else if(r)o=(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press `,(0,Y.jsx)(Q,{color:`redBright`,children:`shift+tab`}),` again to enable YOLO mode (dangerous)`]});else switch(n){case Sl.Normal:o=(0,Y.jsx)(Q,{dimColor:!0,children:`? for shortcuts • shift+tab to cycle modes`});break;case Sl.AcceptEdits:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`cyanBright`,children:`⏵⏵`}),` accept edits on (shift+tab to cycle)`]});break;case Sl.PlanMode:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`cyanBright`,children:`⏸`}),` plan mode on (shift+tab to cycle)`]});break;case Sl.Yolo:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`redBright`,children:`⚠`}),` YOLO mode - all tools auto-accepted (shift+tab to cycle)`]});break;default:o=(0,Y.jsx)(Q,{dimColor:!0,children:`? for shortcuts`})}return a?(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsxs)(r4,{href:a.url,children:[`PR#`,a.number]}),(0,Y.jsx)(Q,{dimColor:!0,children:`•`}),o]}):o});i4.displayName=`AgentModeIndicator`;const a4=15e3,o4=/^(node_modules|\.git|dist|build|out|coverage|\.vscode|\.idea|\.DS_Store)$/;let s4=null;function c4(e,t){let n=e.replace(/\\/g,`/`);return{path:n,name:T.posix.basename(n),isDirectory:t}}function l4(e){return e.name.startsWith(`.`)||e.path.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`)}async function u4(e){try{let t=await d4(`git`,[`rev-parse`,`--show-toplevel`],e);if(!t)return null;let[n,r]=await Promise.all([f4(`git`,[`ls-files`],t),f4(`git`,[`ls-files`,`--others`,`--exclude-standard`],t)]),i=[],a=new Set;for(let e of[...n,...r]){if(!e)continue;let n=T.resolve(t,e);i.push(c4(n,!1));let r=T.posix.dirname(e);for(;r&&r!==`.`;){let e=T.resolve(t,r);if(a.has(e))break;a.add(e),i.push(c4(e,!0)),r=T.posix.dirname(r)}}return i}catch{return null}}function d4(e,t,n){return new Promise((r,i)=>{let a=f(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]}),o=``;a.stdout.on(`data`,e=>o+=e.toString()),a.on(`close`,e=>e===0?r(o.trim()):i()),a.on(`error`,i)})}function f4(e,t,n){return new Promise(r=>{let i=[],a=f(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});F({input:a.stdout}).on(`line`,e=>i.push(e.trim())),a.on(`close`,()=>r(i)),a.on(`error`,()=>r(i))})}async function p4(e,t){let n=[`--files`,`--no-messages`,`--max-depth`,`100`];t.includeHidden&&n.push(`--hidden`),t.useGitignore||n.push(`--no-ignore`);for(let e of t.globs)n.push(`-g`,e);for(let e of t.ignoreGlobs)n.push(`-g`,e);return new Promise(t=>{let r=[],i=f(ve,n,{cwd:e,stdio:[`ignore`,`pipe`,`pipe`]});F({input:i.stdout}).on(`line`,t=>{let n=y1(t.trim());n&&r.push(c4(T.resolve(e,n),!1))}),i.on(`close`,()=>t(r)),i.on(`error`,()=>t(r))})}async function m4(e,t){let n=[],r=async(e,i)=>{if(!(i>12||n.length>=a4))try{let a=await b.readdir(e,{withFileTypes:!0}),o=[];for(let r of a){if(!t&&r.name.startsWith(`.`))continue;let i=T.join(e,r.name);r.isDirectory()?o4.test(r.name)||(n.push(c4(i,!0)),o.push(i)):r.isFile()&&n.push(c4(i,!1))}await Promise.all(o.map(e=>r(e,i+1)))}catch{}};return await r(e,0),n}function h4(e){let t=e.includeHidden??!1,n=e.globs??[],r=e.ignoreGlobs??[],i=e.useRipgrep??!0,a=e.useGitignore??!0,o=e.root,s=new Set,c=[],l=e=>{c.length>=a4||s.has(e.path)||(s.add(e.path),!(!t&&l4(e))&&c.push(e))},u=i&&a&&n.length===0&&r.length===0;return{docs:c,ready:(async()=>{if(u){let e=await u4(o);if(e){for(let t of e)l(t);return}}if(i){let e=await p4(o,{includeHidden:t,globs:n,ignoreGlobs:r,useGitignore:a});for(let t of e)l(t);let i=await m4(o,t);for(let e of i)e.isDirectory&&l(e)}else{let e=await m4(o,t);for(let t of e)l(t)}})()}}function g4(e){let t=T.resolve(e.root);if(s4&&s4.key===t&&Date.now()-s4.at<6e4)return s4.index;let n=h4(e);return s4={key:t,index:n,at:Date.now()},n}async function _4(e,t,n){let r=new Map;for(let n=0;n<e.length;n+=64){let i=e.slice(n,n+64);await Promise.all(i.map(async e=>{try{let n=T.isAbsolute(e.path)?e.path:T.resolve(t,e.path),i=await b.stat(n);r.set(e.path,i.mtimeMs)}catch{r.set(e.path,0)}}))}let i=[...e].sort((e,t)=>{let n=(r.get(t.path)??0)-(r.get(e.path)??0);return n===0?e.path.split(`/`).length-t.path.split(`/`).length||e.name.localeCompare(t.name):n}).slice(0,n);return{paths:i.map(e=>e.path),isDirectory:i.map(e=>e.isDirectory)}}async function v4(e,t){let n=t.root,r=t.maxResults??100;if(!(await b.stat(n).catch(()=>null))?.isDirectory())return{paths:[],isDirectory:[]};let i=g4(t);await i.ready;let a=e.trim();if(!a)return _4(i.docs,n,r);let o=new yv(i.docs,{selector:e=>e.path,limit:r}).find(a);return{paths:o.map(e=>e.item.path),isDirectory:o.map(e=>e.item.isDirectory)}}function y4(e){let[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)([]),a=(0,X.useRef)(null),o=(0,X.useRef)(null),s=(0,X.useRef)(null);return(0,X.useEffect)(()=>(o.current&&clearTimeout(o.current),a.current&&a.current.abort(),o.current=setTimeout(()=>{if(e===s.current)return;s.current=e;let t=new AbortController;a.current=t,(async()=>{try{let r=await v4(e,{root:process.cwd()});if(t.signal.aborted)return;n(r.paths.map(C1)),i(r.isDirectory)}catch{}})()},100),()=>{o.current&&clearTimeout(o.current),a.current&&a.current.abort()}),[e]),{results:t,isDirectory:r}}const b4=(0,X.memo)(({onAccept:e,onCancel:t,availableHeight:n})=>{let{prompt:r,bufferRef:i}=D2(),[a,o]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=i.current;if(!e){o(``);return}let t=A2(e.text,e.cursor)?.query??``;o(e=>e===t?e:t)},[i,r]);let s=(0,X.useDeferredValue)(a),{results:c,isDirectory:l}=y4(s),u=a!==s,d=c.map((e,t)=>l[t]?`${e}/`:e),f=(0,X.useCallback)((t,n)=>{let r=i.current;if(!r)return e();let a=A2(r.text,r.cursor);if(a){let e=c[n];r.replaceRange(a.startRow,a.startCol,a.endRow,a.endCol,`@${e}${l[n]?`/`:``} `)}e()},[i,e,c,l]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(F2,{items:d,limit:Math.max(1,Math.min(10,n-2)),maxHeight:n,isActive:!0,showIndex:!0,showIndicators:!0,onSubmit:f,onTab:f,onCancel:t}),u&&(0,Y.jsx)(Z,{marginTop:0,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Searching...`})})]})});b4.displayName=`FileMentionPicker`;const x4=[[`! for terminal/bash mode`,`/ for commands`,`@ for file paths`],[`esc esc to clear input`,`shift + tab to cycle agent modes`,`${YQ().toLowerCase()} for newline`],[`ctrl + z to undo`,`ctrl + v to paste images`]],S4=(0,X.memo)(({availableHeight:e})=>e!==void 0&&e<3?null:(0,Y.jsx)(Z,{flexDirection:`row`,columnGap:5,rowGap:1,flexWrap:`wrap`,children:(e!==void 0&&e<6?x4.slice(0,1):e!==void 0&&e<9?x4.slice(0,2):x4).map((e,t)=>(0,Y.jsx)(Z,{flexDirection:`column`,children:e.map(e=>(0,Y.jsx)(Q,{dimColor:!0,children:e},e))},t))}));S4.displayName=`Help`;function C4(){return{mode:NJ.Prompt,render:({prompt:e,hints:t,availableHeight:n})=>(0,Y.jsx)(i4,{hints:t,availableHeight:n})}}function w4(){return{mode:NJ.Help,render:({availableHeight:e})=>(0,Y.jsx)(S4,{availableHeight:e})}}function T4(e){return{mode:NJ.Files,render:({prompt:t,availableHeight:n})=>(0,Y.jsx)(b4,{onAccept:e,onCancel:e,availableHeight:n}),shouldPreventDefault:(e,t)=>t.upArrow||t.downArrow||t.escape||t.return||t.tab}}function E4(e,t){let n=e4(),r=L2(t);return{handlers:(0,X.useMemo)(()=>{let t={mode:NJ.Bash,render:n.renderer,onSubmit:n.submitCommand},i={mode:NJ.Command,render:r.renderer,onSubmit:r.executeCommand,shouldPreventDefault:r.shouldPreventDefault};return new Map([[NJ.Prompt,C4()],[NJ.Help,w4()],[NJ.Bash,t],[NJ.Command,i],[NJ.Files,T4(e)]])},[n,r,e]),getActivity:n.getActivity,bashNavigateHistory:n.navigateHistory}}const D4={[NJ.Prompt]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[NJ.Help]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[NJ.Bash]:{color:`greenBright`,placeholder:j1()?`Try "dir"`:`Try "ls -la"`,prefix:`!`},[NJ.Command]:{color:`magentaBright`,placeholder:`Try "/resume <chat title>"`,prefix:`❯`},[NJ.Files]:{color:`cyanBright`,placeholder:`Try "@help.md"`,prefix:`@`}},O4={"!":{mode:NJ.Bash,preventDefault:!0,atStartOnly:!0},"?":{mode:NJ.Help,preventDefault:!0,atStartOnly:!0},"@":{mode:NJ.Files,preventDefault:!1,atStartOnly:!1}},k4=(0,X.memo)(({hints:e,composerRef:t})=>{let{prompt:n,setPrompt:r,mode:i,setMode:a,bufferRef:o,activity:s,setActivity:c,queuedMessages:l,addToQueue:u,clearQueue:d,addAttachment:f,clearAttachments:p,ghostText:m,commandOverlay:h}=D2(),{updateInfo:g,autoUpdate:_}=Q$(),v=(0,X.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),y=(0,X.useCallback)(()=>{},[]),b=(0,X.useRef)({text:``,timer:null}),x=(0,X.useRef)(null);x.current||(x.current=new VD(`cli-repl`),x.current.load());let S=x.current,C=(0,X.useRef)(``),w=(0,X.useRef)(0),E=(0,X.useRef)(null);(0,X.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.length>0,saveAndClear:()=>{let e=n.trimStart();e&&(S.append(e),S.resetNavigation()),o.current?.setText(``),y(),p()},clear:()=>{o.current?.setText(``),y(),p()},clearQueue:()=>d()}));let{currentFile:D,selectionStartLine:O,selectionEndLine:k}=kQ(),{sendMessage:A,segments:j,clearSegments:M,clearSegmentsOnly:N,clearTempSegments:P,stop:F,addNotification:I,mcp:ee,isDirectoryAllowed:L,addAllowedDirectory:R,refreshMcpTools:B,loadConversation:te,agentStatus:ne,segmentsLength:re,conversationId:ie,dequeuedOnStop:ae,clearDequeuedOnStop:oe,listTerminalSessions:se}=T$(),{apiClient:ce,authManager:le}=c$(),{data:ue=[],refetch:de}=a1(ce),{cycleAgentMode:fe,resetToNormal:pe,isWaitingForYoloConfirm:me}=FJ(),{setTheme:he}=bz(),V=r1(),{handlers:ge,getActivity:_e,bashNavigateHistory:ve}=E4(()=>a(NJ.Prompt),(0,X.useCallback)(()=>{o.current?.setText(``)},[o])),ye=ge.get(i)||null,[be,xe]=(0,X.useState)([]),[Se,Ce]=(0,X.useState)(``),[we,Te]=(0,X.useState)(null),[H,Ee]=(0,X.useState)(!1),[De,Oe]=(0,X.useState)(!1),U=(0,X.useMemo)(()=>({agentStatus:ne,segmentsLength:re,isLoggedIn:we??!1}),[ne,re,we]),ke=(0,X.useCallback)(async()=>{try{let e=await ce.getConversationsList(Le.agentType,process.cwd());e?.result&&xe(e.result.slice(0,25))}catch{}},[ce]);(0,X.useEffect)(()=>{ke()},[ke]),(0,X.useEffect)(()=>{ce.getUserInfo().then(e=>Te(!!e?.result?.email)).catch(()=>{Te(le.isAuthenticated())})},[ce,le]),(0,X.useEffect)(()=>{ae&&(o.current?.setText(ae),oe())},[ae,oe,o]);let Ae=Se||ue[0]?.llmName||``;(0,X.useEffect)(()=>{if(!H){Oe(!1);return}let e=setInterval(()=>Oe(e=>!e),500);return()=>clearInterval(e)},[H]),(0,X.useEffect)(()=>{T2({onExit:()=>{qj(0)},onNewChat:()=>{M(),d(),o.current?.setText(``)},onClearChat:()=>{N(),o.current?.setText(``)},onStop:()=>{F()},onModelChange:e=>{let t=ue.find(t=>t.llmName===e);t?(Ce(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=be.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()));if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await te(t.deploymentConversationId),I(`Resumed conversation: ${t.name||t.deploymentConversationId}`,`info`)}catch(e){I(`Failed to load conversation: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}else I(`Conversation "${e}" not found`,`error`)},onLogin:async e=>{try{if(le.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}if(!e){I(`Usage: /login <email> or /login <api_key>`,`error`);return}if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){let t=e,n=await NA(),r=await ce.authenticateDeviceForCodeLlm(t,n);if(!r?.success||!r?.result){I(r?.error??`Failed to start device code login`,`error`);return}let{verificationUri:i,userCode:a,pollingInterval:o}=r.result;I(`Open the URL and enter the code to authenticate.\n\nURL: ${i}\nCode: ${a}\n\nPolling for completion...`,`info`),(async()=>{let e=(o||5)*1e3,t=Date.now()+600*1e3;for(;Date.now()<t;){await M1(e);try{let e=await ce.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await le.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);ce.setChatWebDomain(e)}I(`Authentication successful!`,`info`),Te(!0),await ke(),await de();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await le.loginWithApiKey(e);try{(await ce.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),Te(!0),await ke(),await de()):(await le.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await le.logout(),I(`API key authentication failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}o.current?.setText(``)}catch(e){I(`Login failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},onLogout:async()=>{if(le.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await le.logout(),Te(!1)},getUserInfo:async()=>{try{let e=await ce.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=le.getAuthKind(),o=a.type===`env_api_key`?`API key (env)`:a.type===`env_device_code`?`Device code (env)`:a.type===`api_key`?`API key`:a.type===`device_code`?`Device code`:a.type===`oauth_token`?`OAuth token`:`Unknown`;I(`User Status:\n\nName: ${t||`N/A`}\nEmail: ${n||`N/A`}\nTeam: ${i}\nAuth Method: ${o}`,`info`)}else I(`Failed to get user info`,`error`)}catch{I(`Failed to get user info`,`error`)}},getModels:async()=>ue.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>be.map(e=>{let t=e.name||e.deploymentConversationId||`Untitled`;return{id:e.deploymentConversationId||``,title:t.length>50?t.substring(0,47)+`...`:t,messageCount:e.hasHistory,date:e.createdAt}}),addNotification:I,mcp:ee,isDirectoryAllowed:L,addAllowedDirectory:R,refreshMcpTools:B,getAgentStatus:()=>ne,getTotalCredits:ie?()=>_1(ce,ie):void 0,setTheme:he,loginAuth:{initiateDeviceCode:async e=>{let t=await NA(),n=await ce.authenticateDeviceForCodeLlm(e,t);return!n?.success||!n?.result?{success:!1,error:n?.error??`Failed to start device code login`}:{success:!0,verificationUri:n.result.verificationUri,userCode:n.result.userCode,pollingInterval:n.result.pollingInterval}},pollDeviceCode:async e=>{let t=await ce.pollDeviceCode(e);return t?.success&&t.result?.deviceCode?{success:!0,deviceCode:t.result.deviceCode,chatWebUrl:t.result.chatWebUrl}:{success:!1}},completeDeviceCodeLogin:async(e,t)=>{if(await le.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);ce.setChatWebDomain(e)}Te(!0),await ke(),await de()},loginWithApiKey:async e=>{if(await le.loginWithApiKey(e),!(await ce.getUserInfo())?.result?.email)throw await le.logout(),Error(`Invalid API key — authentication failed`);Te(!0),await ke(),await de()},isEnvAuth:()=>le.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:le.isEnvAuth(),shouldHide:le.isEnvAuth()}),getUpdateInfo:()=>g,listTerminalSessions:se,getLastAssistantMessage:()=>{for(let e=j.length-1;e>=0;e--){let t=j[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=A1(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>j})},[ue,j,M,N,d,o,ce,de,F,I,ee,L,R,B,te,be,ke,ne,ie,he,le,g,se]);let je=(0,X.useCallback)(async e=>{try{let t=await z.stat(e),n=await z.readFile(e),r=T.extname(e).toLowerCase(),i=r===`.jpg`||r===`.jpeg`?`image/jpeg`:`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:T.resolve(e),fileName:T.basename(e),content:n.toString(`base64`),mimeType:i,mime_type:i,size:t.size,metadata:{uploadedAt:new Date().toISOString(),source:`tui-clipboard`,isImage:!0,encoding:`base64`}})}catch{}},[f]),Me=(0,X.useCallback)(async()=>{if(await p1()){let e=await m1(process.cwd());if(e){let t=T1(E1(e));o.current?.insert(`@${t} `),await je(e);return}}let e=await g1();if(!e)return;let t=k1(e.trim());if(t){o.current?.insert(t);return}o.current?.insert(e,{isPaste:!0})},[o,je]),Ne=(0,X.useCallback)(e=>{let t=e.target.cursor[0]===0&&e.target.cursor[1]===0;if(!e.key.paste){let t=process.platform===`darwin`&&e.key.super&&e.input===`v`,n=process.platform!==`darwin`&&e.key.ctrl&&e.input===`v`||process.platform===`linux`&&e.key.ctrl&&e.key.shift&&e.input===`V`;if(t||n){Me(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=t.trim();if(c1(n)){let t=l1(n);if(t){let n=T1(E1(t));o.current?.insert(`@${n} `),je(t),e.preventDefault();return}}let r=k1(t.trim());if(r){o.current?.insert(r),e.preventDefault();return}(async()=>{if(await p1()){let e=await m1(process.cwd());if(e){let t=T1(E1(e));o.current?.insert(`@${t} `),await je(e);return}}o.current?.insert(t,{isPaste:!0})})(),e.preventDefault();return}if(e.input.length>3&&!e.key.ctrl&&!e.key.meta&&!e.key.paste){b.current.text+=e.input,b.current.timer&&clearTimeout(b.current.timer),b.current.timer=setTimeout(()=>{let e=b.current.text;b.current={text:``,timer:null};let t=k1(e.trim());if(t){o.current?.insert(t);return}o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===NJ.Prompt&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.length>0&&n.trim()===``){let t=l[0];o.current?.setText(t),d(),e.preventDefault();return}if(ye?.shouldPreventDefault&&ye.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===NJ.Prompt||i===NJ.Help||i===NJ.Files)&&(e.key.upArrow||e.key.downArrow)){let t=e.target,r=t.visualCursor[0]===0,i=t.visualCursor[0]>=t.allVisualLines.length-1;if(e.key.upArrow&&r){if(S.getEntries().length>0){S.isNavigating()||(C.current=n);let t=S.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!S.isNavigating()){e.preventDefault();return}let t=S.navigateDown();t?o.current?.setText(t.message):o.current?.setText(C.current),e.preventDefault();return}}if(i===NJ.Bash&&ve){let t=e.target,n=e.key.upArrow&&t.visualCursor[0]===0,r=e.key.downArrow&&t.visualCursor[0]>=t.allVisualLines.length-1;if(n||r){let t=ve(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(me){pe(),e.preventDefault();return}i!==NJ.Prompt&&(a(NJ.Prompt),S.resetNavigation(),C.current=``,e.preventDefault());return}if(i===NJ.Prompt&&e.key.shift&&e.key.tab){fe(),e.preventDefault();return}let r=O4[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==NJ.Command&&e.preventDefault();return}},[i,a,ye,ve,o,Me,je,l,n,d,me,pe,fe,S]);(0,X.useEffect)(()=>{if(i===NJ.Prompt)return;let e=n.trim();if(i===NJ.Files){let e=o.current;e&&(A2(e.text,e.cursor)||a(NJ.Prompt))}else if(i===NJ.Command)if(e.length===0)a(NJ.Prompt);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(NJ.Prompt)}else i===NJ.Help&&e.length===0&&a(NJ.Prompt)},[i,n,o,a]);let Pe=(0,X.useCallback)((e,t)=>{let n=w.current;w.current=e.length,r(e);let o=e.trim(),s=o.startsWith(`/`),c=o.slice(1).split(/\s/)[0]||``,l=s&&(c===``||!/[/\\.]/.test(c)&&/^[a-zA-Z]/.test(c)),u=ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission;e.length>0&&!l&&!u&&P();let d=A2(e,t.cursor);if(o.length===0&&n>0&&(i===NJ.Command||i===NJ.Bash||i===NJ.Help)){a(NJ.Prompt);return}if(d){i!==NJ.Files&&a(NJ.Files);return}if(i===NJ.Files){d||a(NJ.Prompt);return}i===NJ.Help&&o.length>0&&a(NJ.Prompt),E.current&&=(clearTimeout(E.current),null),!l&&i===NJ.Command&&o.length>0?a(NJ.Prompt):l&&i!==NJ.Command&&(E.current=setTimeout(()=>{E.current=null,a(NJ.Command)},80))},[i,r,a,P,ne]),Fe=(0,X.useCallback)(async e=>{let t=e.trim(),n=S2.match(t,i);if(n&&await S2.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=_D.matchSkill(t);if(e){if(we===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=v(t);if(ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission){u(n),o.current?.setText(``),y();return}A({message:n,selectedModel:Se||ue[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),y(),p();return}}if(ye?.onSubmit){ye.onSubmit(e),i===NJ.Bash?(o.current?.setText(``),c(_e())):i===NJ.Command&&a(NJ.Prompt),p();return}switch(i){case NJ.Prompt:if(we===!1){let t=e.trimStart();t&&(S.append(t),S.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission){let t=v(e.trimStart());u(t),S.append(t),S.resetNavigation(),C.current=``,y(),o.current?.setText(``);return}let t=Se||ue[0]?.llmName||void 0,n=v(e);S.append(n),S.resetNavigation(),C.current=``,A({message:n,selectedModel:t}),y(),p();return;default:}},[i,ye,A,_e,c,Se,a,o,ne,u,I,p,we,v,y,S,ue]),{color:Ie,placeholder:Re,prefix:ze}=D4[i],W=re>0?``:Re,Be=(0,X.useMemo)(()=>j2(),[]),Ve=(i===NJ.Bash?_e():s)===`pending`||ne===Cl.WaitingForToolPermission,He=S1(process.cwd()),Ue=(0,X.useMemo)(()=>(0,Y.jsx)(Z,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,Y.jsxs)(Y.Fragment,{children:[h,(0,Y.jsx)(X.Activity,{mode:h?`hidden`:`visible`,children:(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(M2,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,alignItems:`flex-end`,children:[Ue,we===!1&&(0,Y.jsx)(Q,{dimColor:!0,children:` Not logged in`}),we===!1&&Ae&&(0,Y.jsx)(Q,{dimColor:!0,children:` •`}),Ae&&(0,Y.jsxs)(Q,{children:[` `,ue.find(e=>e.llmName===Ae)?.name||Ae]}),(we===!1||Ae)&&(0,Y.jsx)(Q,{dimColor:!0,children:` •`}),(0,Y.jsxs)(Q,{color:`yellowBright`,children:[` `,He]})]}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:Ie,dimColor:De,children:ze}),(0,Y.jsx)(L0,{ref:o,onChange:Pe,onKeyDown:Ne,onSubmit:Fe,placeholder:W,grammar:Be,disabled:Ve,ghostText:m??void 0})]}),(0,Y.jsx)(Z,{flexDirection:`row`,children:Ue}),(0,Y.jsxs)(Z,{justifyContent:`space-between`,children:[(0,Y.jsx)(N2,{mode:i,prompt:n,handler:ye,onExitFilesMode:()=>a(NJ.Prompt),onSubmitPrompt:Fe,hints:e,availableHeight:V,onLoadingChange:Ee,commandContext:U}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[D&&O!==void 0&&k!==void 0?(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsxs)(Q,{color:`cyan`,children:[k-O+1,` lines selected`]}),` `,`in `,(0,Y.jsx)(Q,{color:`cyan`,children:T.basename(D)})]}):D&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`in `,(0,Y.jsx)(Q,{color:`cyan`,children:T.basename(D)})]}),e?.escClear&&(0,Y.jsx)(Q,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&g&&(0,Y.jsx)(Q,{dimColor:!0,children:`·`}),g&&(0,Y.jsx)(Q,{wrap:`truncate-middle`,dimColor:!0,children:g.isEphemeral?`Update available (${g.latestVersion})`:_?`Update available (${g.latestVersion}) · Restart to auto-update`:`Update available (${g.latestVersion}) · Run: ${Cj()}`})]})]})]})})]})});k4.displayName=`ComposerInner`;const A4=(0,X.memo)(({hints:e,composerRef:t})=>(0,Y.jsx)(O2,{children:(0,Y.jsx)(X.Suspense,{fallback:(0,Y.jsx)(Q,{dimColor:!0,children:`Loading models...`}),children:(0,Y.jsx)(k4,{hints:e,composerRef:t})})}));A4.displayName=`Composer`;var j4=class extends X.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t}),this.props.onError&&this.props.onError(e,t)}render(){let{hasError:e,error:t,errorInfo:n}=this.state,{fallback:r,children:i}=this.props;return e?r?typeof r==`function`?r(t,n):r:(0,Y.jsxs)(Z,{flexDirection:`column`,padding:1,children:[(0,Y.jsx)(Q,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,Y.jsxs)(Z,{marginTop:1,flexDirection:`column`,children:[(0,Y.jsx)(Q,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,Y.jsx)(Q,{color:`gray`,children:n.componentStack})]})]}):i}};const M4=(0,X.memo)(({duration:e,credits:t,conversationId:n})=>{let{colors:r}=bz();return(0,Y.jsxs)(Z,{flexDirection:`column`,paddingY:1,children:[(0,Y.jsx)(Q,{color:r.primary,children:`
|
|
85836
|
+
- { key: Return, mods: Shift, chars: "${X0}" }
|
|
85837
|
+
`,h.writeFileSync(r,t,`utf-8`),{success:!0,message:`Installed Alacritty Shift+Enter key binding\nSee: ${r}`,requiresRestart:!0}}catch(e){return{success:!1,message:`Failed to install Alacritty Shift+Enter key binding: ${e instanceof Error?e.message:String(e)}`}}}async function s2(){let e=S$();if(!e)return{success:!1,message:`Could not detect terminal. You can use backslash (\\) + Enter for newlines.`};switch(e){case`cursor`:return $0(`Cursor`);case`windsurf`:return $0(`Windsurf`);case`vscode`:return $0(`Code`);case`codium`:return $0(`VSCodium`);case`ghostty`:return r2();case`iTerm.app`:return t2();case`Apple_Terminal`:return n2();case`WezTerm`:return i2();case`kitty`:return a2();case`alacritty`:return o2();default:return{success:!1,message:`Terminal "${e}" is not supported for automatic setup.\n\nYou can use backslash (\\) + Enter for newlines.\n\nSupported terminals:\n- VS Code, Cursor, Windsurf, VSCodium\n- Ghostty\n- iTerm2\n- Apple Terminal\n- WezTerm\n- Kitty\n- Alacritty`}}}const c2={topLeft:``,top:`─`,topRight:``,left:``,right:``,bottomLeft:``,bottom:`─`,bottomRight:``},l2={topLeft:``,top:`╌`,topRight:``,left:``,right:``,bottomLeft:``,bottom:`╌`,bottomRight:``},u2=(0,X.memo)(({title:e,subtitle:t})=>(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsxs)(Q,{children:[` `,e]}),t&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,t]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1})]}));u2.displayName=`PermissionPreviewHeader`;const d2=(0,X.memo)(({title:e,subtitle:t,options:n,onDismiss:r})=>{let[i,a]=(0,X.useState)(0),o=(0,X.useRef)(n);o.current=n;let s=(0,X.useRef)(i);s.current=i;let c=(0,X.useRef)(r);c.current=r;let l=(0,X.useCallback)(async()=>{let e=o.current[s.current];e&&await e.action(),c.current()},[]),u=(0,X.useRef)(l);return u.current=l,HL((0,X.useCallback)((e,t)=>{if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o.current.length-1,e+1));return}if(t.escape){c.current();return}if(t.return){u.current();return}},[]),{isActive:!0}),(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsxs)(Q,{children:[` `,e]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),t&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,t]}),t&&(0,Y.jsx)(Q,{}),n.map((e,t)=>{let n=t===i;return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:n?`cyan`:void 0,children:n?` ❯ `:` `}),(0,Y.jsx)(Q,{color:n?void 0:`gray`,children:`${t+1}. ${e.label}`})]},t)}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Enter to confirm · Esc to cancel`})]})});d2.displayName=`CommandOverlay`;const f2=j(c);async function p2(e){try{let{stdout:t}=await f2(`git diff HEAD`,{cwd:e,maxBuffer:10*1024*1024});if(!t.trim())return{files:[],fullDiff:``};let n=[],r=t.split(/(?=^diff --git)/m).filter(Boolean);for(let e of r){let t=e.match(/^diff --git a\/(.+?) b\/(.+?)$/m);if(t){let r=t[2],i=(e.match(/^\+(?!\+\+)/gm)||[]).length,a=(e.match(/^-(?!--)/gm)||[]).length;n.push({filePath:r,additions:i,deletions:a,diff:e})}}return{files:n,fullDiff:t}}catch{return{files:[],fullDiff:``}}}const m2=(0,X.memo)(({line:e,colors:t})=>e.startsWith(`+`)&&!e.startsWith(`+++`)?(0,Y.jsx)(Q,{backgroundColor:t.diffAdded,color:t.diffAddedText,children:e}):e.startsWith(`-`)&&!e.startsWith(`---`)?(0,Y.jsx)(Q,{backgroundColor:t.diffRemoved,color:t.diffRemovedText,children:e}):e.startsWith(`@@`)?(0,Y.jsx)(Q,{color:`cyan`,children:e}):e.startsWith(`diff --git`)?(0,Y.jsx)(Q,{bold:!0,color:`yellow`,children:e}):(0,Y.jsx)(Q,{dimColor:!0,children:e}));m2.displayName=`DiffLine`;const h2=(0,X.memo)(({cwd:e,onDismiss:t})=>{let{colors:n}=bz(),[r,i]=(0,X.useState)(!0),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(-1),[d,f]=(0,X.useState)(0),[p]=(0,X.useState)(20),m=(0,X.useRef)(t);m.current=t;let h=(0,X.useRef)(a);h.current=a,(0,X.useEffect)(()=>{p2(e).then(({files:e,fullDiff:t})=>{o(e),c(t),i(!1)})},[e]);let g=(l===-1?s:a[l]?.diff??``).split(`
|
|
85838
|
+
`),_=Math.max(0,g.length-p);if(HL((0,X.useCallback)((e,t)=>{if(t.escape||e===`q`){m.current();return}if(t.leftArrow){u(e=>{let t=e-1;return t<-1?h.current.length-1:t}),f(0);return}if(t.rightArrow){u(e=>{let t=e+1;return t>=h.current.length?-1:t}),f(0);return}if(t.upArrow){f(e=>Math.max(0,e-1));return}if(t.downArrow){f(e=>Math.min(_,e+1));return}if(t.pageUp||e===`u`){f(e=>Math.max(0,e-p));return}if(t.pageDown||e===`d`){f(e=>Math.min(_,e+p));return}},[_,p]),{isActive:!0}),r)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{children:` Loading diff...`})]});if(a.length===0)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{children:` No changes detected`}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Press Esc or q to close`})]});let v=g.slice(d,d+p),y=a.reduce((e,t)=>e+t.additions,0),b=a.reduce((e,t)=>e+t.deletions,0);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:2,children:[(0,Y.jsx)(Q,{bold:!0,children:` Git Diff`}),(0,Y.jsxs)(Q,{dimColor:!0,children:[a.length,` file`,a.length===1?``:`s`,` changed`]}),(0,Y.jsxs)(Q,{color:n.diffAddedText,children:[`+`,y]}),(0,Y.jsxs)(Q,{color:n.diffRemovedText,children:[`-`,b]})]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,flexWrap:`wrap`,children:[(0,Y.jsx)(Q,{color:l===-1?`cyan`:`gray`,bold:l===-1,children:l===-1?`[All]`:` All `}),a.map((e,t)=>(0,Y.jsx)(Q,{color:l===t?`cyan`:`gray`,bold:l===t,children:l===t?`[${e.filePath}]`:` ${e.filePath} `},e.filePath))]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Z,{flexDirection:`column`,height:p,children:v.map((e,t)=>(0,Y.jsx)(m2,{line:e,colors:n},d+t))}),_>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Lines `,d+1,`-`,Math.min(d+p,g.length),` of`,` `,g.length]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Left/Right: switch files · Up/Down: scroll · u/d: page up/down · q/Esc: close`]})]})});h2.displayName=`DiffOverlay`;function g2(){return process.env.SHELL??process.env.ComSpec??`unknown`}function _2(){return process.env.TERM_PROGRAM??process.env.TERMINAL_EMULATOR??process.env.TERM??`unknown`}function v2(e){try{return{branch:d(`git rev-parse --abbrev-ref HEAD`,{cwd:e,encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]}).trim(),commit:d(`git rev-parse --short HEAD`,{cwd:e,encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]}).trim(),remote:d(`git remote get-url origin`,{cwd:e,encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]}).trim().replace(/\/\/[^@]+@/,`//`),hasLocalChanges:d(`git status --porcelain`,{cwd:e,encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]}).trim().length>0}}catch{return{branch:`unknown`,commit:`unknown`,remote:`unknown`,hasLocalChanges:!1}}}function y2(){return[8,4,4,4,12].map(e=>Array.from({length:e},()=>`0123456789abcdef`[Math.floor(Math.random()*16)]).join(``)).join(`-`)}function b2(e,t){let n=encodeURIComponent(`[Feedback] ${e.description.slice(0,80)}`),r=[`## Feedback / Bug Report`,``,`**Feedback ID:** \`${t}\``,``,`### Description`,e.description,``,`### Environment`,`- **Platform:** ${e.platform}`,`- **Architecture:** ${e.arch}`,`- **Shell:** ${e.shell}`,`- **Terminal:** ${e.terminal}`,`- **CLI Version:** ${e.version}`];return e.includeGitInfo&&r.push(``,`### Git Repository`,`- **Branch:** ${e.gitBranch}`,`- **Commit:** ${e.gitCommit}`,`- **Remote:** ${e.gitRemote}`,`- **Local changes:** ${e.hasLocalChanges?`yes`:`no`}`),`https://github.com/abacusai/abacusai-desktop/issues/new?title=${n}&body=${encodeURIComponent(r.join(`
|
|
85839
|
+
`))}`}const x2=(0,X.memo)(({version:e,cwd:t,onDismiss:n})=>{let[i,a]=(0,X.useState)({type:`input`}),s=(0,X.useRef)(null),c=(0,X.useRef)(n);c.current=n;let l=(0,X.useCallback)(n=>{let i=n.trim();if(!i)return;let s=v2(t);a({type:`confirm`,info:{description:i,platform:`${o()}`,arch:r(),shell:g2(),terminal:_2(),version:`v${e}`,gitBranch:s.branch,gitCommit:s.commit,gitRemote:s.remote,hasLocalChanges:s.hasLocalChanges,includeGitInfo:!1}})},[t,e]),u=(0,X.useCallback)(()=>{i.type===`confirm`&&a({type:`submitted`,feedbackId:y2()})},[i]),d=(0,X.useCallback)(()=>{i.type===`confirm`&&a({type:`confirm`,info:{...i.info,includeGitInfo:!i.info.includeGitInfo}})},[i]),f=(0,X.useCallback)(()=>{if(i.type!==`submitted`)return;let e=i,t=p.current;t?.type===`confirm`&&MN(b2(t.info,e.feedbackId)),c.current()},[i]),p=(0,X.useRef)(null);if(HL((0,X.useCallback)((e,t)=>{if(t.escape){c.current();return}if(i.type===`confirm`){if(t.return){u();return}if(e===`g`){d();return}}if(i.type===`submitted`){t.return?f():c.current();return}},[i,u,f,d]),{isActive:i.type!==`input`}),i.type===`confirm`&&(p.current=i),i.type===`input`)return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Describe the issue below:`}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(H0,{ref:s,placeholder:`Describe your feedback or bug...`,onSubmit:l,onKeyDown:e=>{e.key.escape&&(e.preventDefault(),c.current())}})]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Enter to continue · Esc to cancel`})]});if(i.type===`confirm`){let{info:e}=i;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` This report will include:`}),(0,Y.jsxs)(Q,{children:[` - Your feedback / bug description: `,(0,Y.jsx)(Q,{color:`yellow`,children:e.description})]}),(0,Y.jsxs)(Q,{children:[` - Environment info: `,(0,Y.jsxs)(Q,{color:`yellow`,children:[e.platform,` (`,e.arch,`), `,e.shell,`, `,e.terminal,`, `,e.version]})]}),(0,Y.jsxs)(Q,{children:[` - Git repo metadata: `,e.includeGitInfo?(0,Y.jsxs)(Q,{color:`yellow`,children:[e.gitBranch,`, `,e.gitCommit,` @ `,e.gitRemote,e.hasLocalChanges?`, has local changes`:``]}):(0,Y.jsx)(Q,{dimColor:!0,children:`not included (press g to include)`})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`We will use your feedback to debug related issues or to improve the CLI's functionality.`]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{dimColor:!0,children:` Enter to submit · g to toggle git info · Esc to cancel`})]})}return i.type===`submitted`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{borderStyle:c2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Q,{color:`green`,children:` Thank you for your report!`}),(0,Y.jsxs)(Q,{children:[` Feedback ID: `,(0,Y.jsx)(Q,{color:`cyan`,children:i.feedbackId})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Press Enter to open your browser and draft a GitHub issue, or any other key to close.`]})]}):null});x2.displayName=`FeedbackOverlay`;const S2=.25,C2=(0,X.memo)(({text:e,color:t=`#94a3b8`})=>{let[n,r]=(0,X.useState)(0),i=e.length;(0,X.useEffect)(()=>{let e=setInterval(()=>{(0,X.startTransition)(()=>{r(e=>e+1)})},100);return()=>clearInterval(e)},[]);let a=(0,X.useMemo)(()=>w2(t),[t]);return(0,Y.jsx)(Q,{children:(0,X.useMemo)(()=>{let t=n%i,r=Math.max(i*.6,3),o=``;for(let n=0;n<i;n++){let s=Math.abs(n-t),c=i-s,l=Math.min(s,c),u=T2(a,Math.max(0,1-l/r));o+=pj.rgb(u.r,u.g,u.b)(e[n])}return o},[n,i,a,e])})});C2.displayName=`Shimmer`;function w2(e){let t=e.replace(`#`,``);return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function T2(e,t){let n=Math.floor(e.r*S2),r=Math.floor(e.g*S2),i=Math.floor(e.b*S2);return{r:Math.floor(n+(e.r-n)*t),g:Math.floor(r+(e.g-r)*t),b:Math.floor(i+(e.b-i)*t)}}const E2=(0,X.memo)(({initialEmail:e,auth:t,onDismiss:n})=>{let[r,i]=(0,X.useState)(()=>e?{type:`connecting`,email:e}:{type:`input`,mode:`email`}),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useRef)(!1),d=(0,X.useRef)(n);d.current=n;let f=(0,X.useCallback)(async e=>{i({type:`connecting`,email:e});try{let n=await t.initiateDeviceCode(e);if(u.current)return;if(!n.success||!n.verificationUri||!n.userCode){i({type:`error`,message:n.error??`Failed to initiate login`,canRetry:!0});return}i({type:`polling`,verificationUri:n.verificationUri,userCode:n.userCode,pollingInterval:n.pollingInterval??5})}catch(e){if(u.current)return;i({type:`error`,message:e instanceof Error?e.message:`Failed to connect`,canRetry:!0})}},[t]);(0,X.useEffect)(()=>{e&&f(e)},[]),(0,X.useEffect)(()=>{r.type===`polling`&&(o(!1),c(!1),MN(r.verificationUri).then(e=>{u.current||o(e)}))},[r.type===`polling`?r.verificationUri:null]),(0,X.useEffect)(()=>{if(r.type!==`polling`)return;let e=!0,n=r.pollingInterval*1e3,a=Date.now()+600*1e3,{userCode:o}=r;return(async()=>{for(;e&&!u.current&&Date.now()<a;){if(await new Promise(e=>setTimeout(e,n)),!e||u.current)return;try{let n=await t.pollDeviceCode(o);if(!e||u.current)return;if(n.success&&n.deviceCode){try{if(await t.completeDeviceCodeLogin(n.deviceCode,n.chatWebUrl),!e||u.current)return;i({type:`success`})}catch(t){if(!e||u.current)return;i({type:`error`,message:t instanceof Error?t.message:`Failed to complete login`,canRetry:!1})}return}}catch{}}e&&!u.current&&i({type:`error`,message:`Authentication timed out. Please try again.`,canRetry:!0})})(),()=>{e=!1}},[r.type===`polling`?r.userCode:null,t]),(0,X.useEffect)(()=>{if(r.type===`success`){let e=setTimeout(()=>d.current(),1500);return()=>clearTimeout(e)}},[r.type]);let p=(0,X.useCallback)(e=>{let n=e.trim();if(n){if(r.type===`input`&&r.mode===`apikey`){t.loginWithApiKey(n).then(()=>{u.current||i({type:`success`})}).catch(e=>{u.current||i({type:`error`,message:e instanceof Error?e.message:`API key login failed`,canRetry:!0})});return}f(n)}},[r,f,t]),m=(0,X.useCallback)(()=>{u.current=!0,d.current()},[]),h=(0,X.useCallback)(()=>{r.type===`polling`&&NN(r.verificationUri).then(e=>{e&&c(!0)})},[r]);if(HL((0,X.useCallback)((e,t)=>{if(t.escape){m();return}if(r.type===`input`&&t.ctrl&&(e===`a`||e===``)){i(e=>e.type===`input`?{type:`input`,mode:e.mode===`email`?`apikey`:`email`}:e);return}if(r.type===`polling`&&e===`c`){h();return}if(r.type===`error`&&r.canRetry&&t.return){i({type:`input`,mode:`email`});return}},[r,m,h]),{isActive:r.type!==`input`}),r.type===`input`){let e=r.mode===`email`;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:e?` Email:`:` API Key:`}),(0,Y.jsx)(H0,{ref:l,placeholder:e?`you@example.com`:`Paste your API key`,onSubmit:p,onKeyDown:e=>{e.key.paste&&(e.preventDefault(),e.target.insert(e.input)),e.key.escape&&(e.preventDefault(),m()),e.key.ctrl&&(e.input===`a`||e.input===``)&&(e.preventDefault(),i(e=>e.type===`input`?{type:`input`,mode:e.mode===`email`?`apikey`:`email`}:e))}})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Enter to submit · Esc to cancel · Ctrl+A to switch to`,` `,e?`API key`:`email`]})]})}return r.type===`connecting`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(C2,{text:`Logging in as ${r.email}...`})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`polling`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{children:[` `,a?(0,Y.jsx)(Q,{color:`yellow`,children:`Opening browser to sign in...`}):(0,Y.jsx)(C2,{text:`Opening browser to sign in...`})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Browser didn't open? Use the URL below to sign in`,` `,(0,Y.jsxs)(Q,{dimColor:!1,color:s?`green`:`gray`,children:[`(`,s?`copied!`:`c to copy`,`)`]})]}),(0,Y.jsxs)(Q,{color:`cyan`,children:[` `,r.verificationUri]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{children:[` `,`Your one-time code:`,` `,(0,Y.jsx)(Q,{color:`yellowBright`,bold:!0,children:r.userCode})]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(C2,{text:`Waiting for authentication...`})]}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`success`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{color:`green`,children:[` `,`✓ Logged in successfully!`]}),(0,Y.jsx)(Q,{})]}):r.type===`error`?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{color:`red`,children:[` `,`✗ `,r.message]}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,r.canRetry?`Enter to retry · `:``,`Esc to close`]})]}):null});E2.displayName=`LoginOverlay`;const D2=new class{commands=new Map;register(e){this.commands.has(e.id)||this.commands.set(e.id,e)}clear(){this.commands.clear()}get(e){return this.commands.get(e)}getAll(){return Array.from(this.commands.values())}getAliasesForMode(e,t){return e.alias?Array.isArray(e.alias)?e.alias:e.alias[t]??[]:[]}buildCommandMatch(e,t){if(e.subcommands&&e.subcommands.length>0){if(t.length===0)return{command:e,args:``,query:``,needsSubcommand:!0};let n=t[0],r=e.subcommands.find(e=>e.id===n);if(!r){let n=t.join(` `);return{command:e,args:n,query:n,needsSubcommand:!0}}let i=t.slice(1).join(` `);return{command:e,subcommand:r,args:i,query:i}}let n=t.join(` `);return{command:e,args:n,query:n}}findCommandByAlias(e,t){let n=e.toLowerCase();for(let e of this.commands.values())if(this.getAliasesForMode(e,t).some(e=>e.toLowerCase()===n))return e}matchByAlias(e,t){let n=e.trim().split(/\s+/).filter(Boolean);if(n.length===0)return null;let[r,...i]=n,a=this.findCommandByAlias(r,t);return!a||!(a.requiresArgument||a.subcommands&&a.subcommands.length>0)&&i.length>0?null:this.buildCommandMatch(a,i)}parseArgs(e){let t=[],n=``,r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(i){n+=o,i=!1;continue}if(o===`\\`){i=!0;continue}if(o===`'`||o===`"`){r===o?r=null:r===null?r=o:n+=o;continue}if(o===` `&&r===null){n.length>0&&(t.push(n),n=``);continue}n+=o}return n.length>0&&t.push(n),t}async execute(e){if(e.needsSubcommand)return!1;let t=e.args?this.parseArgs(e.args):[];return(e.subcommand||e.command).requiresArgument&&t.length===0?!1:e.subcommand?.execute?(await e.subcommand.execute(t),!0):e.command.execute?(await e.command.execute(t),!0):!1}match(e,t){let n=e.trim();if(t!==void 0&&!n.startsWith(`/`))return this.matchByAlias(n,t);if(!n.startsWith(`/`))return null;let r=n.slice(1).split(/\s+/).filter(Boolean);if(r.length===0)return null;let[i,...a]=r,o=this.commands.get(i);if(!o)return null;let s=e.trimStart().slice(1+i.length),c=s.length>0&&/\s/.test(s[0]);return a.length===0&&!c?{command:o,args:``,query:``,exactMatch:!0}:this.buildCommandMatch(o,a)}search(e,t){let n=this.getAll().filter(e=>!e.isAvailable||!t||e.isAvailable(t));return e?new yv(n,{selector:e=>`${e.id} ${e.description}`}).find(e).map(e=>e.item):n}searchSubcommands(e,t){return e.subcommands?t?new yv(e.subcommands,{selector:e=>`${e.id} ${e.description}`}).find(t).map(e=>e.item):e.subcommands:[]}},O2=_z;function k2(){let e=D2.getAll(),t=[],n=Math.max(0,...e.map(e=>e.subcommands&&e.subcommands.length>0?Math.max(0,...e.subcommands.map(e=>e.usage?.length||0)):e.usage?.length||0));t.push(`Abacus.AI CLI`,``,`Abacus.AI CLI has read access to files in the current directory and can run commands and edit files with your permission.`,``,`Use npx -y @abacus-ai/cli@latest to run latest version of abacusai interactive mode directly from your terminal`,``,`Usage Modes:`,`- REPL: abacusai (interactive session)`,`- Non-interactive: abacusai -p "question"`,``,`Run abacusai --help for all command line options`,``,`For first time users, use /login to authenticate to Abacus.AI CLI`,``,`Common Tasks:`,`- Ask questions about your codebase > How does agent.py work?`,`- Edit files > Update code.ts to...`,`- Fix errors > cargo build`,`- Run commands > /help`,`- Run bash commands > wc`,``,`Interactive Mode Commands:`,``);for(let r of e)if(r.subcommands&&r.subcommands.length>0)for(let e of r.subcommands)t.push(` ${(e.usage||``).padEnd(n+2)} ${e.description||``}`);else t.push(` ${(r.usage||``).padEnd(n+2)} ${r.description||``}`);return t.push(``,`Type any command and press Enter to execute.`),t.join(`
|
|
85840
|
+
`)}function A2(e){let t=e.mcp?new K0(e.mcp):void 0,n=(t,n=`info`,r)=>{e.addNotification?.(t,n,r)},r=[{id:`version`,description:`Show CLI version`,usage:`/version`,execute:()=>{let t=e.getUpdateInfo?.();n(t?`Abacus.AI CLI version ${hj.default.version} (${t.latestVersion} available)`:`Abacus.AI CLI version ${hj.default.version}`,`info`)}},{id:`exit`,description:`Exit the application`,usage:`/exit`,alias:{[NJ.Prompt]:[`exit`,`quit`]},execute:()=>{e.onExit?.()}},{id:`new`,description:`Start a new conversation`,usage:`/new`,isAvailable:e=>e.segmentsLength>0,execute:()=>{e.onNewChat?.()}},{id:`clear`,description:`Clear the output display while keeping the current conversation`,usage:`/clear`,alias:{[NJ.Prompt]:[`cls`,`clear`]},isAvailable:e=>e.segmentsLength>0,execute:()=>{e.onClearChat?.()}},{id:`stop`,description:`Stop the current streaming response and any running bash tools`,usage:`/stop`,isAvailable:e=>e.agentStatus===Cl.Submitted||e.agentStatus===Cl.Streaming||e.agentStatus===Cl.ExecutingTool||e.agentStatus===Cl.WaitingForToolPermission,execute:async()=>{let t=e.getAgentStatus?.(),r=t===Cl.Submitted||t===Cl.Streaming||t===Cl.ExecutingTool||t===Cl.WaitingForToolPermission;e.onStop?.(),r?n(`Agent stopped successfully`,`info`):n(`No active agent process to stop`,`warning`)}},{id:`help`,description:`Show commands and functionalities`,usage:`/help`,alias:{[NJ.Prompt]:[`help`]},execute:()=>{e.onHelp?e.onHelp():n(k2(),`info`)}},{id:`model`,description:`Switch to a different model`,usage:`/model <model_name>`,requiresArgument:!0,ghostProvider:e=>e?null:`claude-sonnet`,completionProvider:async t=>{if(!e.getModels)return[];let n=await e.getModels();if(!n?.length)return[];let r=n.map(e=>({label:e.label,id:e.value,description:e.model?.provider??``,badge:e.model?.isDefault?`default`:void 0}));return t.trim()?new yv(r,{selector:e=>`${e.label} ${e.description}`}).find(t).map(e=>e.item):r},execute:async t=>{let r=t.join(` `).trim();if(!r){n(`Please specify a model name`,`error`);return}if(e.getModels){let t=await e.getModels();if(!t||t.length===0){n(`No models are available`,`error`);return}let i=t.find(e=>e.label===r||e.value===r);if(!i){n(`Model "${r}" not found`,`error`);return}e.onModelChange?.(i.value)}else e.onModelChange?.(r)}},{id:`resume`,description:`Resume a previous chat conversation`,usage:`/resume <chat_title>`,requiresArgument:!0,completionProvider:async t=>{if(!e.getChatTitles)return[];let n=await e.getChatTitles();if(!n?.length)return[];let r=n.map(e=>({label:e.title,id:e.id,description:e.messageCount?`${e.messageCount} msgs`:void 0}));return t.trim()?new yv(r,{selector:e=>`${e.label} ${e.description??``}`}).find(t).map(e=>e.item):r},execute:t=>{let n=t.join(` `).trim();n&&e.onResumeChat?.(n)}},{id:`login`,description:`Log in to Abacus.AI CLI with email or API key`,usage:`/login [email|api_key]`,ghostProvider:e=>e?null:`example@gmail.com`,uiProvider:(t,r)=>{if(e.checkEnvAuth){let{isEnvAuth:t}=e.checkEnvAuth();if(t)return n(`You are logged in via environment variables. Remove ${Le.envPrefix}API_KEY to logout.`,`warning`),r.onDismiss(),null}if(!e.loginAuth)return n(`Login not available`,`error`),r.onDismiss(),null;let i=t.filter(Boolean).join(` `).trim(),a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i);return i&&!a?(e.onLogin?.(i),r.onDismiss(),null):(0,Y.jsx)(E2,{initialEmail:a?i:void 0,auth:e.loginAuth,onDismiss:r.onDismiss})},execute:async t=>{if(e.checkEnvAuth){let{isEnvAuth:t}=e.checkEnvAuth();if(t){n(`You are logged in via environment variables. Remove ${Le.envPrefix}API_KEY to logout.`,`warning`);return}}let r=t.filter(Boolean).join(` `).trim();r&&e.onLogin?.(r)}},{id:`logout`,description:`Log out of Abacus.AI CLI`,usage:`/logout`,execute:async()=>{if(e.checkEnvAuth){let{isEnvAuth:t}=e.checkEnvAuth();if(t){n(`You are logged in via environment variables. Remove ${Le.envPrefix}API_KEY to logout.`,`warning`);return}}try{e.onLogout?.(),n(`Logged out successfully`,`info`)}catch(e){n(`Logout failed: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`status`,description:`Show current user status`,usage:`/status`,execute:async()=>{try{await e.getUserInfo?.()}catch(e){n(`Failed to get status: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`usage`,description:`Show total credits consumed in current conversation`,usage:`/usage`,isAvailable:()=>e.getTotalCredits!==void 0,execute:async()=>{if(!e.getTotalCredits){n(`Usage information not available`,`error`);return}try{let t=await e.getTotalCredits();n(t>0?`Total credits consumed: ${Math.floor(t*100)/100}`:`No credits consumed yet in this conversation`,`info`)}catch(e){n(`Failed to get usage: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`terminal-setup`,description:`Automatically configure terminal for Shift+Enter newlines`,usage:`/terminal-setup`,execute:async()=>{try{n(`Setting up terminal keybindings...`,`info`);let e=await s2();if(e.success){let t=e.message;e.backupPath&&(t+=`\n\nBackup created: ${e.backupPath}`),e.requiresRestart&&(t+=`
|
|
85841
|
+
|
|
85842
|
+
Please restart your terminal for changes to take effect.`),n(t,`info`)}else n(e.message,`warning`)}catch(e){n(`Terminal setup failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}},{id:`theme`,description:`Switch between color themes`,usage:`/theme [theme_name]`,completionProvider:e=>{let t=O2.themes.map(e=>({label:e.displayName,id:e.name,badge:e.name===O2.default?`default`:void 0}));return e.trim()?new yv(t,{selector:e=>e.label}).find(e).map(e=>e.item):t},execute:async t=>{let r=t.join(` `).trim();if(r)try{let t=O2.themes.find(e=>e.displayName.toLowerCase()===r.toLowerCase()||e.name.toLowerCase()===r.toLowerCase());t?e.setTheme?(e.setTheme(t.name),n(`${t.displayName} applied`,`info`)):n(`Theme switching not available`,`error`):n(`Theme "${r}" not found`,`error`)}catch(e){n(`Failed to switch theme: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}},{id:`mcp`,description:`MCP server management`,usage:`/mcp <subcommand>`,subcommands:[{id:`list`,description:`List configured MCP servers`,usage:`/mcp list`,execute:async()=>{if(!t){n(`MCP service not available`,`error`);return}try{n(await t.listServers(),`info`)}catch(e){n(`Failed to list MCP servers: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`add`,description:`Add an MCP server`,usage:`/mcp add <name> <commandOrUrl> [args...]`,requiresArgument:!0,ghostProvider:e=>e?null:`my-server npx -y @mcp/server`,execute:async e=>{if(!t){n(`MCP service not available`,`error`);return}if(e.length<2){n(`Usage: /mcp add <name> <commandOrUrl> [args...]`,`error`),n(`[TIP] Use /mcp add-json for JSON configuration`,`info`);return}let[r,i,...a]=e;if(i.trim().startsWith(`{`)){n(`Invalid: JSON detected. Use /mcp add-json for JSON configuration`,`error`);return}try{await t.addServer(r,i,a),n(`Added MCP server '${r}'`,`info`)}catch(e){n(`Failed to add MCP server: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`add-json`,description:`Add an MCP server with JSON configuration`,usage:`/mcp add-json <name> <json>`,requiresArgument:!0,execute:async e=>{if(!t){n(`MCP service not available`,`error`);return}if(e.length!==2){n(`Usage: /mcp add-json <name> <json>`,`error`),n(`Example: /mcp add-json github '{"command":"npx","args":["-y","@modelcontextprotocol/server-github"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"your_token"}}'`,`info`);return}try{let[r,i]=e;await t.addServerFromJson(r,i),n(`Added MCP server '${r}' from JSON`,`info`)}catch(e){n(`Failed to add MCP server: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`remove`,description:`Remove an MCP server`,usage:`/mcp remove <name>`,requiresArgument:!0,completionProvider:async e=>{if(!t)return[];let n=(await t.getServerNames()).map(e=>({label:e.name,badge:e.status??`unknown`}));return e.trim()?new yv(n,{selector:e=>e.label}).find(e).map(e=>e.item):n},execute:async e=>{if(!t){n(`MCP service not available`,`error`);return}if(e.length!==1){n(`Usage: /mcp remove <name>`,`error`);return}try{await t.removeServer(e[0]),n(`Removed MCP server '${e[0]}'`,`info`)}catch(e){n(`Failed to remove MCP server: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}},{id:`get`,description:`Get details about an MCP server`,usage:`/mcp get <name>`,requiresArgument:!0,completionProvider:async e=>{if(!t)return[];let n=(await t.getServerNames()).map(e=>({label:e.name,badge:e.status??`unknown`}));return e.trim()?new yv(n,{selector:e=>e.label}).find(e).map(e=>e.item):n},execute:async e=>{if(!t){n(`MCP service not available`,`error`);return}if(e.length!==1){n(`Usage: /mcp get <name>`,`error`);return}try{let r=await t.getServer(e[0]);r?n(r,`info`):n(`Server '${e[0]}' not found`,`error`)}catch(e){n(`Failed to get MCP server: ${e instanceof Error?e.message:`Unknown error occurred`}`,`error`)}}}]},{id:`add-dir`,description:`Add a directory to the agent's allowed access paths for this session`,usage:`/add-dir <path>`,requiresArgument:!0,ghostProvider:e=>e?null:`../my-project`,completionProvider:async e=>{try{let t=O((e.trim()||`.`).replace(/^~/,i())),n,r;try{(await z.stat(t)).isDirectory()?(n=t,r=``):(n=T.dirname(t),r=T.basename(t))}catch{n=T.dirname(t),r=T.basename(t)}let a=(await z.readdir(n,{withFileTypes:!0})).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(e=>{let t=T.join(n,e.name);return{label:T.relative(process.cwd(),t)||e.name,description:t}});return r?new yv(a,{selector:e=>e.label}).find(r).map(e=>e.item):a}catch{return[]}},uiProvider:(t,r)=>{let a=t.join(` `).trim();if(!a)return null;let o=O(a.replace(/^~/,i()));if(e.isDirectoryAllowed){let t=e.isDirectoryAllowed(o);if(t.allowed)return n(`'${o}' is already accessible (covered by ${t.coveredBy})`,`info`),r.onDismiss(),null}return(0,Y.jsx)(d2,{title:`Add ${o} to workspace`,subtitle:`${Le.longName} will be able to read files in this directory and make edits when auto-accept edits is on.`,options:[{label:`Yes, for this session`,action:()=>{if(!e.addAllowedDirectory){n(`Cannot add directory: session not available`,`error`);return}e.addAllowedDirectory(o),n(`Added '${o}' to allowed directories (session only)`,`info`)}},{label:`Yes, and remember this directory`,action:()=>{if(!e.addAllowedDirectory){n(`Cannot add directory: session not available`,`error`);return}e.addAllowedDirectory(o,{persist:!0}),n(`Added '${o}' to allowed directories (persistent)`,`info`)}},{label:`No`,action:()=>{}}],onDismiss:r.onDismiss})},execute:async t=>{let r=t.join(` `).trim();if(!r){n(`Usage: /add-dir <path>`,`error`);return}if(!e.addAllowedDirectory){n(`Cannot add directory: session not available`,`error`);return}try{let t=O(r.replace(/^~/,i()));if(e.isDirectoryAllowed){let r=e.isDirectoryAllowed(t);if(r.allowed){n(`'${t}' is already accessible (covered by ${r.coveredBy})`,`info`);return}}e.addAllowedDirectory(t),n(`Added '${t}' to allowed directories`,`info`)}catch(e){n(`Failed to add directory: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}},{id:`ps`,description:`List all background running terminals`,usage:`/ps`,execute:()=>{if(!e.listTerminalSessions){n(`Terminal sessions not available`,`error`);return}let t=e.listTerminalSessions();if(t.length===0){n(`No terminal sessions found`,`info`);return}let r=t.filter(e=>e.isRunning),i=t.filter(e=>!e.isRunning),a=[];if(a.push(`Terminal Sessions:`),a.push(``),r.length>0){a.push(`Running (${r.length}):`);for(let e of r){let t=Y0(Date.now()-e.startTime),n=e.command.length>50?e.command.substring(0,47)+`...`:e.command;a.push(` [${e.id}] ${n} (${t})`)}a.push(``)}if(i.length>0){a.push(`Completed (${i.length}):`);for(let e of i.slice(-5)){let t=e.exitCode??0,n=t===0?`ok`:`exit ${t}`,r=e.command.length>50?e.command.substring(0,47)+`...`:e.command;a.push(` [${e.id}] ${r} (${n})`)}i.length>5&&a.push(` ... and ${i.length-5} more`)}n(a.join(`
|
|
85843
|
+
`),`info`)}},{id:`diff`,description:`Show git diff of all changes in an interactive viewer`,usage:`/diff`,uiProvider:(t,n)=>(0,Y.jsx)(h2,{cwd:e.getCwd?.()??process.cwd(),onDismiss:n.onDismiss}),execute:async()=>{n(`Use /diff in interactive mode to view changes`,`info`)}},{id:`copy`,description:`Copy the last assistant response to clipboard`,usage:`/copy`,isAvailable:e=>e.segmentsLength>0,execute:()=>{let t=e.getLastAssistantMessage?.();if(!t){n(`No assistant response to copy`,`warning`);return}zY(t)?n(`Copied to clipboard`,`info`,!0):n(`Failed to copy to clipboard`,`error`)}},{id:`export`,description:`Export the current conversation to a file or clipboard`,usage:`/export`,uiProvider:(t,r)=>{let i=e=>{let t=[];for(let n of e)if(n.type===`text`&&n.segment){let e=n.source===`user`?`Human`:`Assistant`,r=typeof n.segment==`string`?n.segment:``;r&&t.push(`## ${e}\n\n${r}\n`)}return t.join(`
|
|
85844
|
+
`)};return(0,Y.jsx)(d2,{title:`Export Conversation`,subtitle:`Select export method:`,options:[{label:`Copy to clipboard`,description:`Copy the conversation to your system clipboard`,action:async()=>{let t=e.getSegmentsForExport?.()??[];if(t.length===0){n(`No conversation to export`,`warning`);return}let r=i(t);if(!r.trim()){n(`No text content to export`,`warning`);return}zY(r)?n(`Conversation copied to clipboard`,`info`):n(`Failed to copy to clipboard`,`error`)}},{label:`Save to file`,description:`Save the conversation to a file in the current directory`,action:async()=>{let t=e.getSegmentsForExport?.()??[];if(t.length===0){n(`No conversation to export`,`warning`);return}let r=i(t);if(!r.trim()){n(`No text content to export`,`warning`);return}let a=e.getCwd?.()??process.cwd(),o=T.join(a,`conversation.txt`);try{await z.writeFile(o,r,`utf-8`),n(`Conversation saved to ${o}`,`info`)}catch(e){n(`Failed to save file: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}}],onDismiss:r.onDismiss})},execute:async()=>{n(`Use /export in interactive mode to export conversation`,`info`)}},{id:`feedback`,description:`Submit feedback about Abacus.AI CLI`,usage:`/feedback`,uiProvider:(t,n)=>{let r=e.getCwd?.()??process.cwd();return(0,Y.jsx)(x2,{version:hj.default.version,cwd:r,onDismiss:n.onDismiss})},execute:async()=>{n(`Use /feedback in interactive mode to submit feedback`,`info`)}}];D2.clear(),(async()=>{let t=r;if(e.checkEnvAuth){let{shouldHide:n}=e.checkEnvAuth();n&&(t=r.filter(e=>e.id!==`login`&&e.id!==`logout`))}t.forEach(e=>D2.register(e))})()}const j2=(0,X.createContext)(null);function M2(){let e=(0,X.use)(j2);if(!e)throw Error(`${M2.name} must be used within ${N2.name}`);return e}function N2({children:e}){let[t,n]=(0,X.useState)(``),[r,i]=(0,X.useState)(NJ.Prompt),a=(0,X.useRef)(null),[o,s]=(0,X.useState)(`idle`),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),{queuedMessages:f,addToQueue:p,removeFirstFromQueue:m,clearQueue:h}=$$(),[g,_]=(0,X.useState)([]),v=(0,X.useCallback)(e=>{_(t=>[...t,e])},[]),y=(0,X.useCallback)(()=>{_([])},[]),b=(0,X.useMemo)(()=>({prompt:t,setPrompt:n,mode:r,setMode:i,bufferRef:a,activity:o,setActivity:s,queuedMessages:f,addToQueue:p,removeFirstFromQueue:m,clearQueue:h,attachments:g,setAttachments:_,addAttachment:v,clearAttachments:y,ghostText:c,setGhostText:l,commandOverlay:u,setCommandOverlay:d}),[t,r,o,f,p,m,h,g,v,y,c,u]);return(0,Y.jsx)(j2.Provider,{value:b,children:e})}const P2=/[A-Za-z0-9_.~/\\-]/;function F2(e,t){let[n,r]=t,i=e.split(`
|
|
85845
|
+
`)[n]||``,a=-1;for(let e=Math.min(r,i.length)-1;e>=0;e--){let t=i[e];if(t===`@`){a=e;break}if(!P2.test(t))break}if(a===-1)return null;if(a>0){let e=i[a-1];if(e&&!/\s/.test(e))return null}let o=a+1;for(;o<i.length&&P2.test(i[o]);)o++;let s=Math.min(r,o);return{query:i.slice(a+1,s),startRow:n,startCol:a,endRow:n,endCol:o}}function I2(){return[{regex:RegExp(`(?:^|\\s)@(?:'[^']*'|(?:[A-Za-z0-9_.~/-]|\\\\ )+)`,`gm`),color:`cyanBright`},{regex:RegExp(`^/[A-Za-z0-9_./\\-]+`,`gm`),color:`magentaBright`},{regex:RegExp(`\\[Pasted text #\\d+ \\+\\d+ lines\\]`,`g`),color:`yellowBright`}]}const L2=(0,X.memo)(()=>{let{queuedMessages:e}=M2();return e.length===0?null:(0,Y.jsx)(Z,{flexDirection:`column`,children:e.map((e,t)=>(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`white`,children:`❯`}),(0,Y.jsx)(Q,{dimColor:!0,italic:!0,children:e.trim()})]},t))})});L2.displayName=`MessageQueue`;const R2=(0,X.memo)(({mode:e,prompt:t,handler:n,onExitFilesMode:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})=>n?(0,Y.jsx)(Y.Fragment,{children:n.render({prompt:t,onExit:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})}):null);R2.displayName=`ModePanel`;function z2(e){return typeof e==`string`?{label:e}:e}const B2=(0,X.memo)(({items:e,limit:t=10,maxHeight:n,initialIndex:r=0,isActive:i=!0,showIndex:a=!0,showIndicators:o=!1,onHighlight:s,onSubmit:c,onTab:l,onCancel:u,onEscape:d,renderItem:f})=>{let p=e.length,[m,h]=(0,X.useState)(Math.max(0,Math.min(r,Math.max(0,p-1)))),[g,_]=(0,X.useState)(0),v=(0,X.useMemo)(()=>e.map(z2),[e]),y=(0,X.useMemo)(()=>{if(n!==void 0&&n>0){let e=(o?2:0)+(a?1:0);return Math.max(1,Math.min(t,n-e))}return t},[n,t,o,a]),b=Math.max(1,Math.min(y,p||y)),x=Math.floor(b/2);(0,X.useEffect)(()=>{m>=p&&(h(p===0?0:p-1),_(0))},[p,m]);let S=(0,X.useEffectEvent)(e=>{typeof s==`function`&&p>0&&s(v[e].label,e)});(0,X.useEffect)(()=>{S(m)},[m]);let C=(0,X.useCallback)(e=>{let t=Math.max(0,p-b);return Math.max(0,Math.min(e,t))},[p,b]),w=(0,X.useCallback)(()=>{if(p===0||m<=0)return;let e=m-1;h(e),e<g+x&&_(C(e-x)),e>g+b-1&&_(C(e-b+1))},[p,m,g,x,b,C]),T=(0,X.useCallback)(()=>{if(p===0||m>=p-1)return;let e=m+1;h(e),e>g+x&&_(C(e-x)),e<g&&_(C(e))},[p,m,g,x,C]);HL((e,t)=>{if(i){if(t.upArrow){w();return}if(t.downArrow){T();return}if(t.escape){d?.(),u?.();return}if(t.tab&&!t.ctrl&&!t.meta&&!t.shift){p>0&&l?.(v[m].label,m);return}t.return&&!t.ctrl&&!t.meta&&!t.shift&&(p>0?c?.(v[m].label,m):(d?.(),u?.()))}},{isActive:i});let E=(0,X.useMemo)(()=>{if(p===0)return[];let e=Math.min(p,g+b);return v.slice(g,e)},[v,p,g,b]),D=n===void 0||n>=3,O=o&&D,k=a&&D;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[O&&p>0&&g>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`▲ `,k&&p>1&&`(${m+1}/${p})`]}),p===0?(0,Y.jsx)(Q,{dimColor:!0,children:`No matches`}):E.map((e,t)=>{let n=g+t,r=n===m;return f?(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:r?`cyanBright`:void 0,children:r?`> `:` `}),f(e,r)]},`${e.label}-${n}`):(0,Y.jsxs)(Q,{color:r?`cyanBright`:void 0,wrap:`truncate-end`,children:[r?`> `:` `,e.label,e.description?(0,Y.jsxs)(Q,{dimColor:!0,children:[` `,e.description]}):null,e.badge?(0,Y.jsxs)(Q,{color:`yellow`,children:[` [`,e.badge,`]`]}):null]},`${e.label}-${n}`)}),O&&p>0&&g+b<p&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`▼ `,k&&p>1&&`(${m+1}/${p})`]}),!O&&k&&p>1&&(0,Y.jsx)(Q,{dimColor:!0,children:`(${m+1}/${p})`})]})});B2.displayName=`Select`;const V2=(0,X.memo)(({prompt:e,onAccept:t,onCancel:n,availableHeight:r,onLoadingChange:i,commandContext:a,onSubmitPrompt:o})=>{let{bufferRef:s,setGhostText:c,setCommandOverlay:l}=M2(),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(!1),g=(0,X.useCallback)(()=>{s.current?.setText(``)},[s]),_=(0,X.useDeferredValue)((0,X.useMemo)(()=>{let t=e.trim();return t.startsWith(`/`)?t.slice(1):``},[e])),v=(0,X.useMemo)(()=>u?u.exactMatch?{type:`commands`,query:u.command.id}:u.needsSubcommand?{type:`subcommands`,query:u.query}:u.subcommand?.completionProvider||u.command.completionProvider?{type:`completions`,query:u.query}:null:{type:`commands`,query:_},[u,_]);(0,X.useEffect)(()=>{let t=e.trimStart();if(!t.startsWith(`/`)){d(null);return}d(D2.match(t))},[e]),(0,X.useEffect)(()=>{if(!u||u.needsSubcommand||u.exactMatch){c(null);return}let e=u.subcommand?.ghostProvider||u.command.ghostProvider;if(!e){c(null);return}return c(e(u.query||``)),()=>c(null)},[u,u?.query,c]),(0,X.useEffect)(()=>{if(u)return;let t=e.trimStart();if(!t.startsWith(`/`))return;let n=_D.matchSkill(t);if(!n){c(null);return}let r=n.skill.frontmatter[`argument-hint`];if(!r){c(null);return}return c(n.args?null:r),()=>c(null)},[u,e,c]),(0,X.useEffect)(()=>(i?.(m),()=>{i?.(!1)}),[m,i]),(0,X.useEffect)(()=>{let e=u?.subcommand?.completionProvider||u?.command.completionProvider;if(!e||u?.needsSubcommand){p([]),h(!1);return}h(!0);let t=e(u.query||``);if(t instanceof Promise)t.then(e=>{p(e.map(e=>typeof e==`string`?e:e.label)),h(!1)}).catch(()=>{p([]),h(!1)});else if(Symbol.asyncIterator in Object(t)){let e=t;(async()=>{for await(let t of e)p(t.map(e=>typeof e==`string`?e:e.label));h(!1)})().catch(()=>{p([]),h(!1)})}else Array.isArray(t)&&(p(t.map(e=>typeof e==`string`?e:e.label)),h(!1))},[u,u?.query]);let y=(0,X.useMemo)(()=>{if(!v)return[];if(v.type===`subcommands`&&u?.command.subcommands)return D2.searchSubcommands(u.command,v.query).map((e,t)=>({type:`subcommand`,display:`${e.id} - ${e.description}`,subcommandIdx:t}));if(v.type===`completions`)return m||f.length===0?[]:f.map(e=>({type:`completion`,display:e,value:e}));let e=D2.search(_,a).map((e,t)=>({type:`command`,display:`${e.id} - ${e.description}`,commandIdx:t})),t=_D.search(_).map(e=>({type:`skill`,display:`${e.id} - ${e.frontmatter.description} [skill]`,skill:e}));return[...e,...t]},[v,u,f,m,_,a]),b=(0,X.useMemo)(()=>y.map(e=>e.display),[y]),x=(0,X.useCallback)((e,t)=>{if(!v)return null;let n=y[t];if(!n)return null;if(n.type===`subcommand`&&u?.command.subcommands){let e=D2.searchSubcommands(u.command,v.query)[n.subcommandIdx];return e?`/${u.command.id} ${e.id} `:null}if(n.type===`completion`&&u)return m?null:`${u.subcommand?`/${u.command.id} ${u.subcommand.id}`:`/${u.command.id}`} ${n.value}`;if(n.type===`command`){let e=D2.search(_,a)[n.commandIdx];return e?`/${e.id} `:null}return n.type===`skill`?`/${n.skill.id} `:null},[v,u,_,m,a,y]),S=(0,X.useCallback)((e,t)=>{let n=s.current;if(!n)return;let r=x(e,t);r&&n.setText(r)},[s,x]),C=(0,X.useCallback)(async(e,n)=>{let r=s.current;if(!r){t();return}if(!v)return;let i=y[n];if(i){if(i.type===`subcommand`&&u?.command.subcommands){let e=D2.searchSubcommands(u.command,v.query)[i.subcommandIdx];e&&(e.requiresArgument||e.completionProvider?r.setText(`/${u.command.id} ${e.id} `):(await e.execute([]),r.setText(``),t()));return}if(i.type===`completion`&&u){if(m)return;let e=u.command;if(e.uiProvider){let t={onDismiss:()=>{l(null),g()},clearBuffer:g},n=e.uiProvider([i.value],t);if(n){l(n);return}}let n=u.subcommand||u.command;n.execute&&(await n.execute([i.value]),r.setText(``),t());return}if(i.type===`skill`){r.setText(`/${i.skill.id} `);return}if(i.type===`command`){let e=D2.search(_,a)[i.commandIdx];if(!e)return;if(e.subcommands&&e.subcommands.length>0){r.setText(`/${e.id} `);return}if(e.requiresArgument||e.completionProvider){r.setText(`/${e.id} `);return}if(e.uiProvider){let t={onDismiss:()=>{l(null),g()},clearBuffer:g},n=e.uiProvider([],t);if(n){l(n);return}}e.execute&&(await e.execute([]),r.setText(``),t())}}},[s,u,_,t,v,m,a,g,l,y]),w=!!v&&b.length>0;return HL((e,n)=>{if(!n.return||n.ctrl||n.meta||n.shift)return;let r=s.current;if(!r)return;let i=r.text.trimStart();if(!i.startsWith(`/`))return;let a=D2.match(i);if(!a||a.needsSubcommand){o&&o(i);return}let c=a.subcommand||a.command;if(!(c.completionProvider&&c.requiresArgument)){if(a.command.uiProvider){let e=a.args?a.args.split(/\s+/).filter(Boolean):[],t={onDismiss:()=>{l(null),g()},clearBuffer:g},n=a.command.uiProvider(e,t);if(n){l(n);return}}(async()=>{await D2.execute(a)&&(r.setText(``),t())})()}},{isActive:!w}),w?(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(B2,{items:b,limit:Math.max(1,Math.min(10,r-2)),maxHeight:r,isActive:!0,showIndex:!0,showIndicators:!0,onSubmit:C,onTab:S,onCancel:n})}):null});V2.displayName=`CommandPicker`;function H2(e){let{setCommandOverlay:t}=M2(),n=(0,X.useCallback)((n,r)=>{if(!n.uiProvider)return!1;let i={onDismiss:()=>{t(null),e()},clearBuffer:e},a=n.uiProvider(r,i);return a?(t(a),!0):!1},[t,e]);return{executeCommand:(0,X.useCallback)(async t=>{let r=t.trimStart();if(!r.startsWith(`/`))return;let i=D2.match(r);if(!i||i.needsSubcommand)return;let a=i.subcommand||i.command;if(a.completionProvider&&a.requiresArgument){e();return}if(i.command.uiProvider&&i.args!==void 0){let e=i.args.split(/\s+/).filter(Boolean);if(n(i.command,e))return}try{await D2.execute(i)&&e()}catch{}},[e,n]),showCommandUI:n,renderer:(0,X.useCallback)(({prompt:e,onExit:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a})=>(0,Y.jsx)(V2,{prompt:e,onAccept:t,onCancel:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a}),[]),shouldPreventDefault:(0,X.useCallback)((e,t)=>!!(t.return||t.upArrow||t.downArrow||t.escape||t.tab),[])}}function U2({output:e,command:t,truncate:n=!1,maxLines:r=10}){let i=e.split(`
|
|
85846
|
+
`),a=[],o=!1;if(n&&i.length>r){let e=Math.max(1,Math.floor(r/2)),t=i.slice(0,e).map((e,t)=>({line:e,originalIndex:t})),n=i.slice(-e).map((t,n)=>({line:t,originalIndex:i.length-e+n}));a=[...t,...n],o=!0}else a=i.map((e,t)=>({line:e,originalIndex:t}));return(0,Y.jsxs)(Z,{flexDirection:`column`,paddingX:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:`${GY(process.cwd())}$ ${t}`}),e&&a.map((e,t)=>o&&t===Math.floor(a.length/2)?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsxs)(Q,{dimColor:!0,children:[`... (`,i.length-r,` lines hidden) ...`]}),(0,Y.jsx)(Q,{children:e.line})]},`trunc-${e.originalIndex}`):(0,Y.jsx)(Q,{children:e.line},`line-${e.originalIndex}`))]})}const W2=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];function G2(){let e=t.platform(),n={};for(let[e,t]of Object.entries(process.env))t!==void 0&&(n[e]=t);return e===`win32`?{command:process.env.COMSPEC||`cmd.exe`,args:[],env:n}:{command:process.env.SHELL||`/bin/bash`,args:[],env:{...n,BASH_SILENCE_DEPRECATION_WARNING:`1`,PS1:``}}}var K2=class{shell=null;queue=[];notify=null;isProcessing=!1;destroyed=!1;isWindows;signalHandlers=new Map;constructor(){this.isWindows=t.platform()===`win32`,this.startShell(),this.setupSignalForwarding()}setupSignalForwarding(){for(let e of W2){let t=()=>{if(this.shell&&!this.shell.killed&&this.shell.exitCode===null)try{this.shell.kill(e)}catch{}};this.signalHandlers.set(e,t),process.on(e,t)}}removeSignalHandlers(){for(let[e,t]of this.signalHandlers)process.removeListener(e,t);this.signalHandlers.clear()}startShell(){if(this.shell||this.destroyed)return;let{command:e,args:t,env:n}=G2();this.shell=f(e,t,{stdio:[`pipe`,`pipe`,`pipe`],env:n,cwd:process.cwd(),shell:!1}),this.shell.stdin&&this.shell.stdin.on(`error`,e=>{if(e.code!==`EPIPE`)throw e}),this.shell.stdout&&this.shell.stdout.on(`data`,e=>{let t=e.toString(`utf8`);if(this.queue.push({type:`stdout`,data:t}),this.notify){let e=this.notify;this.notify=null,e()}}),this.shell.stderr&&this.shell.stderr.on(`data`,e=>{let t=e.toString(`utf8`);if(!(t.includes(`no job control in this shell`)||t.includes(`The default interactive shell is now zsh`)||t.includes(`To update your account to use zsh`)||t.includes("please run `chsh -s /bin/zsh`")||t.includes(`For more details, please visit`))&&(this.queue.push({type:`stderr`,data:t}),this.notify)){let e=this.notify;this.notify=null,e()}}),this.shell.on(`exit`,()=>{this.shell=null,this.startShell()})}async executeCommand(e){if(!this.shell||!this.shell.stdin)throw Error(`Shell not initialized`);this.queue.length=0;let t=`__CMD_END_${Date.now()}_${Math.random().toString(36).substring(7)}__`,n;return n=this.isWindows?`${e}\necho ${t}\n`:`${e}\necho "${t}"\n`,this.shell.stdin.write(n),this.isProcessing=!0,{stream:this.createStream(t),exit:this.createExitPromise(t)}}async*createStream(e){for(;;){for(;this.queue.length>0;){let t=this.queue.shift();if(t){if(t.data.includes(e)){let n=t.data.replace(e,``).replace(/\n$/,``);n&&(yield{type:t.type,data:n}),this.isProcessing=!1;return}yield t}}if(!this.isProcessing)return;await new Promise(e=>{this.notify=e})}}async createExitPromise(e){for(;this.isProcessing;)await new Promise(e=>setTimeout(e,100));return 0}killProcessGracefully(e){try{e.kill(`SIGTERM`);let t=setTimeout(()=>{e&&!e.killed&&e.kill(`SIGKILL`)},5e3);t.unref&&t.unref()}catch{}}destroy(){this.destroyed=!0,this.removeSignalHandlers(),this.shell&&=(this.shell.stdin?.on(`error`,e=>{if(e.code!==`EPIPE`)throw e}),this.killProcessGracefully(this.shell),null)}};let q2=null;function J2(){return q2||=new K2,q2}function Y2({state:e,setState:t,onCommandComplete:n,commandHistory:r,currentPrompt:i,availableHeight:a}){let{submittedCommand:o,runId:s}=e,c=(0,X.useMemo)(()=>o?.trim()||``,[o]),l=(0,X.useRef)(-1),u=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!c||s===l.current)return;l.current=s,u.current&&u.current.abort();let e=new AbortController;return u.current=e,t(e=>({...e,isRunning:!0,output:``})),X2({command:c,setOutput:e=>{t(t=>({...t,output:e}))},signal:e.signal}).then(r=>{e.signal.aborted||(t(e=>({...e,isRunning:!1})),r!==void 0&&n(r))}).catch(r=>{e.signal.aborted||(t(e=>({...e,isRunning:!1})),n(``))}),()=>{e.abort(),u.current=null}},[c,s,t,n]);let d=i.trim().length>0,f=o?2:3,p=r.slice(-f),m=Math.max(0,r.length-f),h=p.length+(o?1:0),g=Math.max(1,a-h),_=h>0?Math.max(3,Math.floor(g/h)):10,v=d||a<15||h>1;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[p.map((e,t)=>{let n=m+t;return(0,Y.jsx)(U2,{output:e.output,command:e.command,truncate:v,maxLines:_},`history-${n}`)}),o&&(0,Y.jsx)(U2,{output:e.output,command:c||o,truncate:v,maxLines:_},`submitted-${s}`)]})}async function X2({command:e,setOutput:t,signal:n}){let{stream:r,exit:i}=await J2().executeCommand(e),a=``;try{for await(let e of r){if(n.aborted)return;a+=$1(e.data),n.aborted||t(a)}return n.aborted?void 0:(await i,a)}catch(e){if(n.aborted)return;throw e}}var Z2=Ee({parseShellHistory:()=>e4,shellHistory:()=>n4,shellHistoryPath:()=>t4});function Q2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r===131&&n+1<e.length?(t.push(e[n+1]^32),n++):t.push(r)}return Buffer.from(t)}function $2(e){return e4(Q2(h.readFileSync(e)).toString(`utf8`))}function e4(e){let t=/^: \d+:0;/;return e.trim().split(`
|
|
85847
|
+
`).map(e=>t.test(e)?e.split(`;`).slice(1).join(`;`):e)}function t4({extraPaths:e=[]}={}){if(process.env.HISTFILE)return process.env.HISTFILE;let t=n.homedir(),r=new Set([T.join(t,`.bash_history`),T.join(t,`.zsh_history`),T.join(t,`.history`)]);for(let t of e)r.add(t);return(()=>{let e,t=0;for(let n of r)h.existsSync(n)&&h.statSync(n).size>t&&(t=h.statSync(n).size,e=n);return e})()}function n4(e={}){if(process.platform===`win32`){let t=t4(e);if(t)return $2(t);let{stdout:n}=s.spawnSync(`doskey`,[`/history`],{encoding:`utf8`});return n.trim().split(`\r
|
|
85848
|
+
`)}return $2(t4(e))}var r4=Te((()=>{}));const i4=1e3;function a4(){let[e,t]=(0,X.useState)({submittedCommand:null,runId:0,output:``,isRunning:!1}),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(-1),c=(0,X.useRef)(!1);(0,X.useEffect)(()=>{c.current||(c.current=!0,Promise.resolve().then(()=>(r4(),Z2)).then(e=>{let t=e.shellHistory??e.default;a((typeof t==`function`?t():[]).slice(-i4))}).catch(()=>{}))},[]);let l=(0,X.useCallback)(e=>{let n=e.trim();n&&(a(e=>e.length>0&&e[e.length-1]===n?e:[...e,n].slice(-i4)),s(-1),t(e=>({submittedCommand:n,runId:e.runId+1,output:``,isRunning:!0})))},[]),u=(0,X.useCallback)(e=>{t(t=>(t.submittedCommand&&r(n=>[...n,{command:t.submittedCommand,output:e}].slice(-1e3)),{submittedCommand:null,runId:t.runId,output:``,isRunning:!1}))},[]);return{submitCommand:l,renderer:(0,X.useCallback)(r=>(0,Y.jsx)(Y2,{state:e,setState:t,onCommandComplete:u,commandHistory:n,currentPrompt:r.prompt,availableHeight:r.availableHeight}),[e,u,n]),navigateHistory:(0,X.useCallback)(e=>{if(i.length===0)return null;let t=o;return e===`up`?t=o===-1?i.length-1:Math.max(0,o-1):(t=o===-1?-1:o+1,t>=i.length&&(t=-1)),s(t),t===-1?``:i[t]},[i,o]),getActivity:()=>e.isRunning?`pending`:`idle`}}function o4(){return new Promise(e=>{l(`gh`,[`pr`,`view`,`--json`,`number,url`],{timeout:1e4},(t,n)=>{if(t){e(null);return}try{let t=JSON.parse(n.trim());if(typeof t.number==`number`&&typeof t.url==`string`&&t.number>0){e({number:t.number,url:t.url});return}}catch{}e(null)})})}function s4(e){let t=$R(),n=(0,X.useRef)(e);(0,X.useEffect)(()=>{let r=n.current===Cl.Idle,i=e===Cl.Idle;n.current=e,i&&!r&&t.invalidateQueries({queryKey:[M1.PrInfo]})},[e,t]);let{data:r}=hz({queryKey:[M1.PrInfo],queryFn:o4,staleTime:1/0,retry:!1,refetchOnMount:!1,refetchOnWindowFocus:!1});return r??null}function c4({href:e,children:t}){let{colors:n}=bz(),r=`\x1b]8;;${e}\x07`;return(0,Y.jsx)(Q,{color:n.link,underline:!0,transform:e=>`${r}${e}]8;;`,children:t})}c4.displayName=`Link`;const l4=(0,X.memo)(({hints:e,availableHeight:t})=>{let{agentMode:n,isWaitingForYoloConfirm:r}=FJ(),{agentStatus:i}=$$(),a=s4(i);if(t!==void 0&&t<1)return null;let o;if(e?.exitKey)o=(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press `,e.exitKey===`c`?`Ctrl+C`:`Ctrl+D`,` again to exit`]});else if(r)o=(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press `,(0,Y.jsx)(Q,{color:`redBright`,children:`shift+tab`}),` again to enable YOLO mode (dangerous)`]});else switch(n){case Sl.Normal:o=(0,Y.jsx)(Q,{dimColor:!0,children:`? for shortcuts • shift+tab to cycle modes`});break;case Sl.AcceptEdits:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`cyanBright`,children:`⏵⏵`}),` accept edits on (shift+tab to cycle)`]});break;case Sl.PlanMode:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`cyanBright`,children:`⏸`}),` plan mode on (shift+tab to cycle)`]});break;case Sl.Yolo:o=(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsx)(Q,{color:`redBright`,children:`⚠`}),` YOLO mode - all tools auto-accepted (shift+tab to cycle)`]});break;default:o=(0,Y.jsx)(Q,{dimColor:!0,children:`? for shortcuts`})}return a?(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsxs)(c4,{href:a.url,children:[`PR#`,a.number]}),(0,Y.jsx)(Q,{dimColor:!0,children:`•`}),o]}):o});l4.displayName=`AgentModeIndicator`;const u4=15e3,d4=/^(node_modules|\.git|dist|build|out|coverage|\.vscode|\.idea|\.DS_Store)$/;let f4=null;function p4(e,t){let n=e.replace(/\\/g,`/`);return{path:n,name:T.posix.basename(n),isDirectory:t}}function m4(e){return e.name.startsWith(`.`)||e.path.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`)}async function h4(e){try{let t=await g4(`git`,[`rev-parse`,`--show-toplevel`],e);if(!t)return null;let[n,r]=await Promise.all([_4(`git`,[`ls-files`],t),_4(`git`,[`ls-files`,`--others`,`--exclude-standard`],t)]),i=[],a=new Set;for(let e of[...n,...r]){if(!e)continue;let n=T.resolve(t,e);i.push(p4(n,!1));let r=T.posix.dirname(e);for(;r&&r!==`.`;){let e=T.resolve(t,r);if(a.has(e))break;a.add(e),i.push(p4(e,!0)),r=T.posix.dirname(r)}}return i}catch{return null}}function g4(e,t,n){return new Promise((r,i)=>{let a=f(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]}),o=``;a.stdout.on(`data`,e=>o+=e.toString()),a.on(`close`,e=>e===0?r(o.trim()):i()),a.on(`error`,i)})}function _4(e,t,n){return new Promise(r=>{let i=[],a=f(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});F({input:a.stdout}).on(`line`,e=>i.push(e.trim())),a.on(`close`,()=>r(i)),a.on(`error`,()=>r(i))})}async function v4(e,t){let n=[`--files`,`--no-messages`,`--max-depth`,`100`];t.includeHidden&&n.push(`--hidden`),t.useGitignore||n.push(`--no-ignore`);for(let e of t.globs)n.push(`-g`,e);for(let e of t.ignoreGlobs)n.push(`-g`,e);return new Promise(t=>{let r=[],i=f(ve,n,{cwd:e,stdio:[`ignore`,`pipe`,`pipe`]});F({input:i.stdout}).on(`line`,t=>{let n=HY(t.trim());n&&r.push(p4(T.resolve(e,n),!1))}),i.on(`close`,()=>t(r)),i.on(`error`,()=>t(r))})}async function y4(e,t){let n=[],r=async(e,i)=>{if(!(i>12||n.length>=u4))try{let a=await b.readdir(e,{withFileTypes:!0}),o=[];for(let r of a){if(!t&&r.name.startsWith(`.`))continue;let i=T.join(e,r.name);r.isDirectory()?d4.test(r.name)||(n.push(p4(i,!0)),o.push(i)):r.isFile()&&n.push(p4(i,!1))}await Promise.all(o.map(e=>r(e,i+1)))}catch{}};return await r(e,0),n}function b4(e){let t=e.includeHidden??!1,n=e.globs??[],r=e.ignoreGlobs??[],i=e.useRipgrep??!0,a=e.useGitignore??!0,o=e.root,s=new Set,c=[],l=e=>{c.length>=u4||s.has(e.path)||(s.add(e.path),!(!t&&m4(e))&&c.push(e))},u=i&&a&&n.length===0&&r.length===0;return{docs:c,ready:(async()=>{if(u){let e=await h4(o);if(e){for(let t of e)l(t);return}}if(i){let e=await v4(o,{includeHidden:t,globs:n,ignoreGlobs:r,useGitignore:a});for(let t of e)l(t);let i=await y4(o,t);for(let e of i)e.isDirectory&&l(e)}else{let e=await y4(o,t);for(let t of e)l(t)}})()}}function x4(e){let t=T.resolve(e.root);if(f4&&f4.key===t&&Date.now()-f4.at<6e4)return f4.index;let n=b4(e);return f4={key:t,index:n,at:Date.now()},n}async function S4(e,t,n){let r=new Map;for(let n=0;n<e.length;n+=64){let i=e.slice(n,n+64);await Promise.all(i.map(async e=>{try{let n=T.isAbsolute(e.path)?e.path:T.resolve(t,e.path),i=await b.stat(n);r.set(e.path,i.mtimeMs)}catch{r.set(e.path,0)}}))}let i=[...e].sort((e,t)=>{let n=(r.get(t.path)??0)-(r.get(e.path)??0);return n===0?e.path.split(`/`).length-t.path.split(`/`).length||e.name.localeCompare(t.name):n}).slice(0,n);return{paths:i.map(e=>e.path),isDirectory:i.map(e=>e.isDirectory)}}async function C4(e,t){let n=t.root,r=t.maxResults??100;if(!(await b.stat(n).catch(()=>null))?.isDirectory())return{paths:[],isDirectory:[]};let i=x4(t);await i.ready;let a=e.trim();if(!a)return S4(i.docs,n,r);let o=new yv(i.docs,{selector:e=>e.path,limit:r}).find(a);return{paths:o.map(e=>e.item.path),isDirectory:o.map(e=>e.item.isDirectory)}}function w4(e){let[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)([]),a=(0,X.useRef)(null),o=(0,X.useRef)(null),s=(0,X.useRef)(null);return(0,X.useEffect)(()=>(o.current&&clearTimeout(o.current),a.current&&a.current.abort(),o.current=setTimeout(()=>{if(e===s.current)return;s.current=e;let t=new AbortController;a.current=t,(async()=>{try{let r=await C4(e,{root:process.cwd()});if(t.signal.aborted)return;n(r.paths.map(KY)),i(r.isDirectory)}catch{}})()},100),()=>{o.current&&clearTimeout(o.current),a.current&&a.current.abort()}),[e]),{results:t,isDirectory:r}}const T4=(0,X.memo)(({onAccept:e,onCancel:t,availableHeight:n})=>{let{prompt:r,bufferRef:i}=M2(),[a,o]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=i.current;if(!e){o(``);return}let t=F2(e.text,e.cursor)?.query??``;o(e=>e===t?e:t)},[i,r]);let s=(0,X.useDeferredValue)(a),{results:c,isDirectory:l}=w4(s),u=a!==s,d=c.map((e,t)=>l[t]?`${e}/`:e),f=(0,X.useCallback)((t,n)=>{let r=i.current;if(!r)return e();let a=F2(r.text,r.cursor);if(a){let e=c[n];r.replaceRange(a.startRow,a.startCol,a.endRow,a.endCol,`@${e}${l[n]?`/`:``} `)}e()},[i,e,c,l]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(B2,{items:d,limit:Math.max(1,Math.min(10,n-2)),maxHeight:n,isActive:!0,showIndex:!0,showIndicators:!0,onSubmit:f,onTab:f,onCancel:t}),u&&(0,Y.jsx)(Z,{marginTop:0,children:(0,Y.jsx)(Q,{dimColor:!0,children:`Searching...`})})]})});T4.displayName=`FileMentionPicker`;const E4=[[`! for terminal/bash mode`,`/ for commands`,`@ for file paths`],[`esc esc to clear input`,`shift + tab to cycle agent modes`,`${C$().toLowerCase()} for newline`],[`ctrl + z to undo`,`ctrl + v to paste images`]],D4=(0,X.memo)(({availableHeight:e})=>e!==void 0&&e<3?null:(0,Y.jsx)(Z,{flexDirection:`row`,columnGap:5,rowGap:1,flexWrap:`wrap`,children:(e!==void 0&&e<6?E4.slice(0,1):e!==void 0&&e<9?E4.slice(0,2):E4).map((e,t)=>(0,Y.jsx)(Z,{flexDirection:`column`,children:e.map(e=>(0,Y.jsx)(Q,{dimColor:!0,children:e},e))},t))}));D4.displayName=`Help`;function O4(){return{mode:NJ.Prompt,render:({prompt:e,hints:t,availableHeight:n})=>(0,Y.jsx)(l4,{hints:t,availableHeight:n})}}function k4(){return{mode:NJ.Help,render:({availableHeight:e})=>(0,Y.jsx)(D4,{availableHeight:e})}}function A4(e){return{mode:NJ.Files,render:({prompt:t,availableHeight:n})=>(0,Y.jsx)(T4,{onAccept:e,onCancel:e,availableHeight:n}),shouldPreventDefault:(e,t)=>t.upArrow||t.downArrow||t.escape||t.return||t.tab}}function j4(e,t){let n=a4(),r=H2(t);return{handlers:(0,X.useMemo)(()=>{let t={mode:NJ.Bash,render:n.renderer,onSubmit:n.submitCommand},i={mode:NJ.Command,render:r.renderer,onSubmit:r.executeCommand,shouldPreventDefault:r.shouldPreventDefault};return new Map([[NJ.Prompt,O4()],[NJ.Help,k4()],[NJ.Bash,t],[NJ.Command,i],[NJ.Files,A4(e)]])},[n,r,e]),getActivity:n.getActivity,bashNavigateHistory:n.navigateHistory}}const M4={[NJ.Prompt]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[NJ.Help]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[NJ.Bash]:{color:`greenBright`,placeholder:I1()?`Try "dir"`:`Try "ls -la"`,prefix:`!`},[NJ.Command]:{color:`magentaBright`,placeholder:`Try "/resume <chat title>"`,prefix:`❯`},[NJ.Files]:{color:`cyanBright`,placeholder:`Try "@help.md"`,prefix:`@`}},N4={"!":{mode:NJ.Bash,preventDefault:!0,atStartOnly:!0},"?":{mode:NJ.Help,preventDefault:!0,atStartOnly:!0},"@":{mode:NJ.Files,preventDefault:!1,atStartOnly:!1}},P4=(0,X.memo)(({hints:e,composerRef:t})=>{let{prompt:n,setPrompt:r,mode:i,setMode:a,bufferRef:o,activity:s,setActivity:c,queuedMessages:l,addToQueue:u,clearQueue:d,addAttachment:f,clearAttachments:p,ghostText:m,commandOverlay:h}=M2(),{updateInfo:g,autoUpdate:_}=E1(),v=(0,X.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),y=(0,X.useCallback)(()=>{},[]),b=(0,X.useRef)({text:``,timer:null}),x=(0,X.useRef)(null);x.current||(x.current=new VD(`cli-repl`),x.current.load());let S=x.current,C=(0,X.useRef)(``),w=(0,X.useRef)(0),E=(0,X.useRef)(null);(0,X.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.length>0,saveAndClear:()=>{let e=n.trimStart();e&&(S.append(e),S.resetNavigation()),o.current?.setText(``),y(),p()},clear:()=>{o.current?.setText(``),y(),p()},clearQueue:()=>d()}));let{currentFile:D,selectionStartLine:O,selectionEndLine:k}=r$(),{sendMessage:A,segments:j,clearSegments:M,clearSegmentsOnly:N,clearTempSegments:P,stop:F,addNotification:I,mcp:ee,isDirectoryAllowed:L,addAllowedDirectory:R,refreshMcpTools:B,loadConversation:te,agentStatus:ne,segmentsLength:re,conversationId:ie,dequeuedOnStop:ae,clearDequeuedOnStop:oe,listTerminalSessions:se}=$$(),{apiClient:ce,authManager:le}=I$(),{data:ue=[],refetch:de}=N1(ce),{cycleAgentMode:fe,resetToNormal:pe,isWaitingForYoloConfirm:me}=FJ(),{setTheme:he}=bz(),V=j1(),{handlers:ge,getActivity:_e,bashNavigateHistory:ve}=j4(()=>a(NJ.Prompt),(0,X.useCallback)(()=>{o.current?.setText(``)},[o])),ye=ge.get(i)||null,[be,xe]=(0,X.useState)([]),[Se,Ce]=(0,X.useState)(``),[we,Te]=(0,X.useState)(null),[H,Ee]=(0,X.useState)(!1),[De,Oe]=(0,X.useState)(!1),U=(0,X.useMemo)(()=>({agentStatus:ne,segmentsLength:re,isLoggedIn:we??!1}),[ne,re,we]),ke=(0,X.useCallback)(async()=>{try{let e=await ce.getConversationsList(Le.agentType,process.cwd());e?.result&&xe(e.result.slice(0,25))}catch{}},[ce]);(0,X.useEffect)(()=>{ke()},[ke]),(0,X.useEffect)(()=>{ce.getUserInfo().then(e=>Te(!!e?.result?.email)).catch(()=>{Te(le.isAuthenticated())})},[ce,le]),(0,X.useEffect)(()=>{ae&&(o.current?.setText(ae),oe())},[ae,oe,o]);let Ae=Se||ue[0]?.llmName||``;(0,X.useEffect)(()=>{if(!H){Oe(!1);return}let e=setInterval(()=>Oe(e=>!e),500);return()=>clearInterval(e)},[H]),(0,X.useEffect)(()=>{A2({onExit:()=>{qj(0)},onNewChat:()=>{M(),d(),o.current?.setText(``)},onClearChat:()=>{N(),o.current?.setText(``)},onStop:()=>{F()},onModelChange:e=>{let t=ue.find(t=>t.llmName===e);t?(Ce(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=be.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()));if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await te(t.deploymentConversationId),I(`Resumed conversation: ${t.name||t.deploymentConversationId}`,`info`)}catch(e){I(`Failed to load conversation: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}else I(`Conversation "${e}" not found`,`error`)},onLogin:async e=>{try{if(le.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}if(!e){I(`Usage: /login <email> or /login <api_key>`,`error`);return}if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){let t=e,n=await NA(),r=await ce.authenticateDeviceForCodeLlm(t,n);if(!r?.success||!r?.result){I(r?.error??`Failed to start device code login`,`error`);return}let{verificationUri:i,userCode:a,pollingInterval:o}=r.result;I(`Open the URL and enter the code to authenticate.\n\nURL: ${i}\nCode: ${a}\n\nPolling for completion...`,`info`),(async()=>{let e=(o||5)*1e3,t=Date.now()+600*1e3;for(;Date.now()<t;){await L1(e);try{let e=await ce.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await le.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);ce.setChatWebDomain(e)}I(`Authentication successful!`,`info`),Te(!0),await ke(),await de();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await le.loginWithApiKey(e);try{(await ce.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),Te(!0),await ke(),await de()):(await le.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await le.logout(),I(`API key authentication failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}o.current?.setText(``)}catch(e){I(`Login failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},onLogout:async()=>{if(le.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await le.logout(),Te(!1)},getUserInfo:async()=>{try{let e=await ce.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=le.getAuthKind(),o=a.type===`env_api_key`?`API key (env)`:a.type===`env_device_code`?`Device code (env)`:a.type===`api_key`?`API key`:a.type===`device_code`?`Device code`:a.type===`oauth_token`?`OAuth token`:`Unknown`;I(`User Status:\n\nName: ${t||`N/A`}\nEmail: ${n||`N/A`}\nTeam: ${i}\nAuth Method: ${o}`,`info`)}else I(`Failed to get user info`,`error`)}catch{I(`Failed to get user info`,`error`)}},getModels:async()=>ue.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>be.map(e=>{let t=e.name||e.deploymentConversationId||`Untitled`;return{id:e.deploymentConversationId||``,title:t.length>50?t.substring(0,47)+`...`:t,messageCount:e.hasHistory,date:e.createdAt}}),addNotification:I,mcp:ee,isDirectoryAllowed:L,addAllowedDirectory:R,refreshMcpTools:B,getAgentStatus:()=>ne,getTotalCredits:ie?()=>P1(ce,ie):void 0,setTheme:he,loginAuth:{initiateDeviceCode:async e=>{let t=await NA(),n=await ce.authenticateDeviceForCodeLlm(e,t);return!n?.success||!n?.result?{success:!1,error:n?.error??`Failed to start device code login`}:{success:!0,verificationUri:n.result.verificationUri,userCode:n.result.userCode,pollingInterval:n.result.pollingInterval}},pollDeviceCode:async e=>{let t=await ce.pollDeviceCode(e);return t?.success&&t.result?.deviceCode?{success:!0,deviceCode:t.result.deviceCode,chatWebUrl:t.result.chatWebUrl}:{success:!1}},completeDeviceCodeLogin:async(e,t)=>{if(await le.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);ce.setChatWebDomain(e)}Te(!0),await ke(),await de()},loginWithApiKey:async e=>{if(await le.loginWithApiKey(e),!(await ce.getUserInfo())?.result?.email)throw await le.logout(),Error(`Invalid API key — authentication failed`);Te(!0),await ke(),await de()},isEnvAuth:()=>le.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:le.isEnvAuth(),shouldHide:le.isEnvAuth()}),getUpdateInfo:()=>g,listTerminalSessions:se,getLastAssistantMessage:()=>{for(let e=j.length-1;e>=0;e--){let t=j[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=F1(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>j})},[ue,j,M,N,d,o,ce,de,F,I,ee,L,R,B,te,be,ke,ne,ie,he,le,g,se]);let je=(0,X.useCallback)(async e=>{try{let t=await z.stat(e),n=await z.readFile(e),r=T.extname(e).toLowerCase(),i=r===`.jpg`||r===`.jpeg`?`image/jpeg`:`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:T.resolve(e),fileName:T.basename(e),content:n.toString(`base64`),mimeType:i,mime_type:i,size:t.size,metadata:{uploadedAt:new Date().toISOString(),source:`tui-clipboard`,isImage:!0,encoding:`base64`}})}catch{}},[f]),Me=(0,X.useCallback)(async()=>{if(await LY()){let e=await RY(process.cwd());if(e){let t=XY(ZY(e));o.current?.insert(`@${t} `),await je(e);return}}let e=await BY();if(!e)return;let t=eX(e.trim());if(t){o.current?.insert(t);return}o.current?.insert(e,{isPaste:!0})},[o,je]),Ne=(0,X.useCallback)(e=>{let t=e.target.cursor[0]===0&&e.target.cursor[1]===0;if(!e.key.paste){let t=process.platform===`darwin`&&e.key.super&&e.input===`v`,n=process.platform!==`darwin`&&e.key.ctrl&&e.input===`v`||process.platform===`linux`&&e.key.ctrl&&e.key.shift&&e.input===`V`;if(t||n){Me(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=t.trim();if(MY(n)){let t=NY(n);if(t){let n=XY(ZY(t));o.current?.insert(`@${n} `),je(t),e.preventDefault();return}}let r=eX(t.trim());if(r){o.current?.insert(r),e.preventDefault();return}(async()=>{if(await LY()){let e=await RY(process.cwd());if(e){let t=XY(ZY(e));o.current?.insert(`@${t} `),await je(e);return}}o.current?.insert(t,{isPaste:!0})})(),e.preventDefault();return}if(e.input.length>3&&!e.key.ctrl&&!e.key.meta&&!e.key.paste){b.current.text+=e.input,b.current.timer&&clearTimeout(b.current.timer),b.current.timer=setTimeout(()=>{let e=b.current.text;b.current={text:``,timer:null};let t=eX(e.trim());if(t){o.current?.insert(t);return}o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===NJ.Prompt&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.length>0&&n.trim()===``){let t=l[0];o.current?.setText(t),d(),e.preventDefault();return}if(ye?.shouldPreventDefault&&ye.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===NJ.Prompt||i===NJ.Help||i===NJ.Files)&&(e.key.upArrow||e.key.downArrow)){let t=e.target,r=t.visualCursor[0]===0,i=t.visualCursor[0]>=t.allVisualLines.length-1;if(e.key.upArrow&&r){if(S.getEntries().length>0){S.isNavigating()||(C.current=n);let t=S.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!S.isNavigating()){e.preventDefault();return}let t=S.navigateDown();t?o.current?.setText(t.message):o.current?.setText(C.current),e.preventDefault();return}}if(i===NJ.Bash&&ve){let t=e.target,n=e.key.upArrow&&t.visualCursor[0]===0,r=e.key.downArrow&&t.visualCursor[0]>=t.allVisualLines.length-1;if(n||r){let t=ve(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(me){pe(),e.preventDefault();return}i!==NJ.Prompt&&(a(NJ.Prompt),S.resetNavigation(),C.current=``,e.preventDefault());return}if(i===NJ.Prompt&&e.key.shift&&e.key.tab){fe(),e.preventDefault();return}let r=N4[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==NJ.Command&&e.preventDefault();return}},[i,a,ye,ve,o,Me,je,l,n,d,me,pe,fe,S]);(0,X.useEffect)(()=>{if(i===NJ.Prompt)return;let e=n.trim();if(i===NJ.Files){let e=o.current;e&&(F2(e.text,e.cursor)||a(NJ.Prompt))}else if(i===NJ.Command)if(e.length===0)a(NJ.Prompt);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(NJ.Prompt)}else i===NJ.Help&&e.length===0&&a(NJ.Prompt)},[i,n,o,a]);let Pe=(0,X.useCallback)((e,t)=>{let n=w.current;w.current=e.length,r(e);let o=e.trim(),s=o.startsWith(`/`),c=o.slice(1).split(/\s/)[0]||``,l=s&&(c===``||!/[/\\.]/.test(c)&&/^[a-zA-Z]/.test(c)),u=ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission;e.length>0&&!l&&!u&&P();let d=F2(e,t.cursor);if(o.length===0&&n>0&&(i===NJ.Command||i===NJ.Bash||i===NJ.Help)){a(NJ.Prompt);return}if(d){i!==NJ.Files&&a(NJ.Files);return}if(i===NJ.Files){d||a(NJ.Prompt);return}i===NJ.Help&&o.length>0&&a(NJ.Prompt),E.current&&=(clearTimeout(E.current),null),!l&&i===NJ.Command&&o.length>0?a(NJ.Prompt):l&&i!==NJ.Command&&(E.current=setTimeout(()=>{E.current=null,a(NJ.Command)},80))},[i,r,a,P,ne]),Fe=(0,X.useCallback)(async e=>{let t=e.trim(),n=D2.match(t,i);if(n&&await D2.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=_D.matchSkill(t);if(e){if(we===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=v(t);if(ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission){u(n),o.current?.setText(``),y();return}A({message:n,selectedModel:Se||ue[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),y(),p();return}}if(ye?.onSubmit){ye.onSubmit(e),i===NJ.Bash?(o.current?.setText(``),c(_e())):i===NJ.Command&&a(NJ.Prompt),p();return}switch(i){case NJ.Prompt:if(we===!1){let t=e.trimStart();t&&(S.append(t),S.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ne===Cl.Submitted||ne===Cl.Streaming||ne===Cl.ExecutingTool||ne===Cl.WaitingForToolPermission){let t=v(e.trimStart());u(t),S.append(t),S.resetNavigation(),C.current=``,y(),o.current?.setText(``);return}let t=Se||ue[0]?.llmName||void 0,n=v(e);S.append(n),S.resetNavigation(),C.current=``,A({message:n,selectedModel:t}),y(),p();return;default:}},[i,ye,A,_e,c,Se,a,o,ne,u,I,p,we,v,y,S,ue]),{color:Ie,placeholder:Re,prefix:ze}=M4[i],W=re>0?``:Re,Be=(0,X.useMemo)(()=>I2(),[]),Ve=(i===NJ.Bash?_e():s)===`pending`||ne===Cl.WaitingForToolPermission,He=GY(process.cwd()),Ue=(0,X.useMemo)(()=>(0,Y.jsx)(Z,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,Y.jsxs)(Y.Fragment,{children:[h,(0,Y.jsx)(X.Activity,{mode:h?`hidden`:`visible`,children:(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(L2,{}),(0,Y.jsxs)(Z,{flexDirection:`row`,alignItems:`flex-end`,children:[Ue,we===!1&&(0,Y.jsx)(Q,{dimColor:!0,children:` Not logged in`}),we===!1&&Ae&&(0,Y.jsx)(Q,{dimColor:!0,children:` •`}),Ae&&(0,Y.jsxs)(Q,{children:[` `,ue.find(e=>e.llmName===Ae)?.name||Ae]}),(we===!1||Ae)&&(0,Y.jsx)(Q,{dimColor:!0,children:` •`}),(0,Y.jsxs)(Q,{color:`yellowBright`,children:[` `,He]})]}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:Ie,dimColor:De,children:ze}),(0,Y.jsx)(H0,{ref:o,onChange:Pe,onKeyDown:Ne,onSubmit:Fe,placeholder:W,grammar:Be,disabled:Ve,ghostText:m??void 0})]}),(0,Y.jsx)(Z,{flexDirection:`row`,children:Ue}),(0,Y.jsxs)(Z,{justifyContent:`space-between`,children:[(0,Y.jsx)(R2,{mode:i,prompt:n,handler:ye,onExitFilesMode:()=>a(NJ.Prompt),onSubmitPrompt:Fe,hints:e,availableHeight:V,onLoadingChange:Ee,commandContext:U}),(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[D&&O!==void 0&&k!==void 0?(0,Y.jsxs)(Q,{dimColor:!0,children:[(0,Y.jsxs)(Q,{color:`cyan`,children:[k-O+1,` lines selected`]}),` `,`in `,(0,Y.jsx)(Q,{color:`cyan`,children:T.basename(D)})]}):D&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`in `,(0,Y.jsx)(Q,{color:`cyan`,children:T.basename(D)})]}),e?.escClear&&(0,Y.jsx)(Q,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&g&&(0,Y.jsx)(Q,{dimColor:!0,children:`·`}),g&&(0,Y.jsx)(Q,{wrap:`truncate-middle`,dimColor:!0,children:g.isEphemeral?`Update available (${g.latestVersion})`:_?`Update available (${g.latestVersion}) · Restart to auto-update`:`Update available (${g.latestVersion}) · Run: ${Cj()}`})]})]})]})})]})});P4.displayName=`ComposerInner`;const F4=(0,X.memo)(({hints:e,composerRef:t})=>(0,Y.jsx)(N2,{children:(0,Y.jsx)(X.Suspense,{fallback:(0,Y.jsx)(Q,{dimColor:!0,children:`Loading models...`}),children:(0,Y.jsx)(P4,{hints:e,composerRef:t})})}));F4.displayName=`Composer`;var I4=class extends X.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t}),this.props.onError&&this.props.onError(e,t)}render(){let{hasError:e,error:t,errorInfo:n}=this.state,{fallback:r,children:i}=this.props;return e?r?typeof r==`function`?r(t,n):r:(0,Y.jsxs)(Z,{flexDirection:`column`,padding:1,children:[(0,Y.jsx)(Q,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,Y.jsxs)(Z,{marginTop:1,flexDirection:`column`,children:[(0,Y.jsx)(Q,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,Y.jsx)(Q,{color:`gray`,children:n.componentStack})]})]}):i}};const L4=(0,X.memo)(({duration:e,credits:t,conversationId:n})=>{let{colors:r}=bz();return(0,Y.jsxs)(Z,{flexDirection:`column`,paddingY:1,children:[(0,Y.jsx)(Q,{color:r.primary,children:`
|
|
85849
85849
|
▞▀▖▌ ▞▀▖▜▘ ▞▀▖▌ ▜▘
|
|
85850
85850
|
▙▄▌▛▀▖▝▀▖▞▀▖▌ ▌▞▀▘ ▙▄▌▐ ▌ ▌ ▐
|
|
85851
85851
|
▌ ▌▌ ▌▞▀▌▌ ▖▌ ▌▝▀▖▗▖▌ ▌▐ ▌ ▖▌ ▐
|
|
85852
85852
|
▘ ▘▀▀ ▝▀▘▝▀ ▝▀▘▀▀ ▝▘▘ ▘▀▘ ▝▀ ▀▀▘▀▘
|
|
85853
|
-
`}),(0,Y.jsx)(Z,{height:1}),(0,Y.jsx)(Q,{color:r.info,children:`https://desktop.abacus.ai`}),(0,Y.jsx)(Z,{height:1}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Spent `,e,` in the CLI`]}),t>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`Total credits used: `,Math.floor(t*100)/100]}),n&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`abacusai --resume `,n]})]})});
|
|
85854
|
-
]`).replace(`lheading`,
|
|
85853
|
+
`}),(0,Y.jsx)(Z,{height:1}),(0,Y.jsx)(Q,{color:r.info,children:`https://desktop.abacus.ai`}),(0,Y.jsx)(Z,{height:1}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Spent `,e,` in the CLI`]}),t>0&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`Total credits used: `,Math.floor(t*100)/100]}),n&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`abacusai --resume `,n]})]})});L4.displayName=`ExitMessage`;function R4(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var z4=R4();function B4(e){z4=e}var V4={exec:()=>null};function H4(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(W4.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var U4=(()=>{try{return!0}catch{return!1}})(),W4={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},G4=/^(?:[ \t]*(?:\n|$))+/,K4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,q4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,J4=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,X4=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Z4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Q4=H4(Z4).replace(/bull/g,X4).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),$4=H4(Z4).replace(/bull/g,X4).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),e3=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,t3=/^[^\n]+/,n3=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,r3=H4(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,n3).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),i3=H4(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X4).getRegex(),a3=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,o3=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,s3=H4(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,o3).replace(`tag`,a3).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),c3=H4(e3).replace(`hr`,J4).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,a3).getRegex(),l3={blockquote:H4(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,c3).getRegex(),code:K4,def:r3,fences:q4,heading:Y4,hr:J4,html:s3,lheading:Q4,list:i3,newline:G4,paragraph:c3,table:V4,text:t3},u3=H4(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,J4).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,a3).getRegex(),d3={...l3,lheading:$4,table:u3,paragraph:H4(e3).replace(`hr`,J4).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,u3).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,a3).getRegex()},f3={...l3,html:H4(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,o3).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:V4,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H4(e3).replace(`hr`,J4).replace(`heading`,` *#{1,6} *[^
|
|
85854
|
+
]`).replace(`lheading`,Q4).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},p3=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,m3=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,h3=/^( {2,}|\\)\n(?!\s*$)/,g3=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,_3=/[\p{P}\p{S}]/u,v3=/[\s\p{P}\p{S}]/u,y3=/[^\s\p{P}\p{S}]/u,b3=H4(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,v3).getRegex(),x3=/(?!~)[\p{P}\p{S}]/u,S3=/(?!~)[\s\p{P}\p{S}]/u,C3=/(?:[^\s\p{P}\p{S}]|~)/u,w3=/(?![*_])[\p{P}\p{S}]/u,T3=/(?![*_])[\s\p{P}\p{S}]/u,E3=/(?:[^\s\p{P}\p{S}]|[*_])/u,D3=H4(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,U4?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),O3=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,k3=H4(O3,`u`).replace(/punct/g,_3).getRegex(),A3=H4(O3,`u`).replace(/punct/g,x3).getRegex(),j3=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,M3=H4(j3,`gu`).replace(/notPunctSpace/g,y3).replace(/punctSpace/g,v3).replace(/punct/g,_3).getRegex(),N3=H4(j3,`gu`).replace(/notPunctSpace/g,C3).replace(/punctSpace/g,S3).replace(/punct/g,x3).getRegex(),P3=H4(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,y3).replace(/punctSpace/g,v3).replace(/punct/g,_3).getRegex(),F3=H4(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,w3).getRegex(),I3=H4(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,E3).replace(/punctSpace/g,T3).replace(/punct/g,w3).getRegex(),L3=H4(/\\(punct)/,`gu`).replace(/punct/g,_3).getRegex(),R3=H4(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),z3=H4(o3).replace(`(?:-->|$)`,`-->`).getRegex(),B3=H4(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,z3).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),V3=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,H3=H4(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,V3).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),U3=H4(/^!?\[(label)\]\[(ref)\]/).replace(`label`,V3).replace(`ref`,n3).getRegex(),W3=H4(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,n3).getRegex(),G3=H4(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,U3).replace(`nolink`,W3).getRegex(),K3=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,q3={_backpedal:V4,anyPunctuation:L3,autolink:R3,blockSkip:D3,br:h3,code:m3,del:V4,delLDelim:V4,delRDelim:V4,emStrongLDelim:k3,emStrongRDelimAst:M3,emStrongRDelimUnd:P3,escape:p3,link:H3,nolink:W3,punctuation:b3,reflink:U3,reflinkSearch:G3,tag:B3,text:g3,url:V4},J3={...q3,link:H4(/^!?\[(label)\]\((.*?)\)/).replace(`label`,V3).getRegex(),reflink:H4(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,V3).getRegex()},Y3={...q3,emStrongRDelimAst:N3,emStrongLDelim:A3,delLDelim:F3,delRDelim:I3,url:H4(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,K3).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:H4(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,K3).getRegex()},X3={...Y3,br:H4(h3).replace(`{2,}`,`*`).getRegex(),text:H4(Y3.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Z3={normal:l3,gfm:d3,pedantic:f3},Q3={normal:q3,gfm:Y3,breaks:X3,pedantic:J3},$3={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},e6=e=>$3[e];function t6(e,t){if(t){if(W4.escapeTest.test(e))return e.replace(W4.escapeReplace,e6)}else if(W4.escapeTestNoEncode.test(e))return e.replace(W4.escapeReplaceNoEncode,e6);return e}function n6(e){try{e=encodeURI(e).replace(W4.percentDecode,`%`)}catch{return null}return e}function r6(e,t){let n=e.replace(W4.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(W4.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(W4.slashPipe,`|`);return n}function i6(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function a6(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function o6(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function s6(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function c6(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
85855
85855
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
85856
|
-
`)}var
|
|
85857
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=
|
|
85858
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e
|
|
85856
|
+
`)}var l6=class{options;rules;lexer;constructor(e){this.options=e||z4}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:i6(e,`
|
|
85857
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=c6(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=i6(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:i6(t[0],`
|
|
85858
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=i6(t[0],`
|
|
85859
85859
|
`).split(`
|
|
85860
85860
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
85861
85861
|
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -85866,17 +85866,17 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
85866
85866
|
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
85867
85867
|
`+e.join(`
|
|
85868
85868
|
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
85869
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=
|
|
85869
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=o6(t[2].split(`
|
|
85870
85870
|
`,1)[0],t[1].length),l=e.split(`
|
|
85871
85871
|
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
85872
85872
|
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
85873
85873
|
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
85874
85874
|
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
85875
85875
|
`+l}u=!l.trim(),r+=p+`
|
|
85876
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=
|
|
85877
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
85878
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t
|
|
85879
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(
|
|
85876
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=r6(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
85877
|
+
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(r6(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
85878
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=i6(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=a6(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),s6(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return s6(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},u6=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||z4,this.options.tokenizer=this.options.tokenizer||new l6,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:W4,block:Z3.normal,inline:Q3.normal};this.options.pedantic?(t.block=Z3.pedantic,t.inline=Q3.pedantic):this.options.gfm&&(t.block=Z3.gfm,this.options.breaks?t.inline=Q3.breaks:t.inline=Q3.gfm),this.tokenizer.rules=t}static get rules(){return{block:Z3,inline:Q3}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(W4.carriageReturn,`
|
|
85879
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(W4.tabCharGlobal,` `).replace(W4.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
85880
85880
|
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
85881
85881
|
`)?``:`
|
|
85882
85882
|
`)+r.raw,n.text+=`
|
|
@@ -85889,9 +85889,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
85889
85889
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
85890
85890
|
`)?``:`
|
|
85891
85891
|
`)+r.raw,n.text+=`
|
|
85892
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},
|
|
85893
|
-
`;return r?`<pre><code class="language-`+
|
|
85894
|
-
`:`<pre><code>`+(n?i:
|
|
85892
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},d6=class{options;parser;constructor(e){this.options=e||z4}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(W4.notSpaceStart)?.[0],i=e.replace(W4.endingNewline,``)+`
|
|
85893
|
+
`;return r?`<pre><code class="language-`+t6(r)+`">`+(n?i:t6(i,!0))+`</code></pre>
|
|
85894
|
+
`:`<pre><code>`+(n?i:t6(i,!0))+`</code></pre>
|
|
85895
85895
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
85896
85896
|
${this.parser.parse(e)}</blockquote>
|
|
85897
85897
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -85907,38 +85907,38 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
85907
85907
|
`}tablerow({text:e}){return`<tr>
|
|
85908
85908
|
${e}</tr>
|
|
85909
85909
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
85910
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${
|
|
85911
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+
|
|
85912
|
-
`)return!1}return!1},
|
|
85913
|
-
`)return!1}return!1}
|
|
85914
|
-
`)return!1}return!1},
|
|
85910
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${t6(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=n6(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+t6(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=n6(e);if(i===null)return t6(n);e=i;let a=`<img src="${e}" alt="${t6(n)}"`;return t&&(a+=` title="${t6(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:t6(e.text)}},f6=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},p6=class e{options;renderer;textRenderer;constructor(e){this.options=e||z4,this.options.renderer=this.options.renderer||new d6,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new f6}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},m6=class{options;block;constructor(e){this.options=e||z4}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?u6.lex:u6.lexInline}provideParser(){return this.block?p6.parse:p6.parseInline}},h6=new class{defaults=R4();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=p6;Renderer=d6;TextRenderer=f6;Lexer=u6;Tokenizer=l6;Hooks=m6;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new d6(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new l6(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new m6;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];m6.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&m6.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return u6.lex(e,t??this.defaults)}parser(e,t){return p6.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?u6.lex:u6.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?p6.parse:p6.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?u6.lex:u6.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?p6.parse:p6.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
85911
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+t6(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function g6(e,t){return h6.parse(e,t)}g6.options=g6.setOptions=function(e){return h6.setOptions(e),g6.defaults=h6.defaults,B4(g6.defaults),g6},g6.getDefaults=R4,g6.defaults=z4,g6.use=function(...e){return h6.use(...e),g6.defaults=h6.defaults,B4(g6.defaults),g6},g6.walkTokens=function(e,t){return h6.walkTokens(e,t)},g6.parseInline=h6.parseInline,g6.Parser=p6,g6.parser=p6.parse,g6.Renderer=d6,g6.TextRenderer=f6,g6.Lexer=u6,g6.lexer=u6.lex,g6.Tokenizer=l6,g6.Hooks=m6,g6.parse=g6,g6.options,g6.setOptions,g6.use,g6.walkTokens,g6.parseInline,p6.parse,u6.lex;var _6=Object.defineProperty,v6=Object.defineProperties,y6=Object.getOwnPropertyDescriptors,b6=Object.getOwnPropertySymbols,x6=Object.prototype.hasOwnProperty,S6=Object.prototype.propertyIsEnumerable,C6=(e,t,n)=>t in e?_6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w6=(e,t)=>{for(var n in t||={})x6.call(t,n)&&C6(e,n,t[n]);if(b6)for(var n of b6(t))S6.call(t,n)&&C6(e,n,t[n]);return e},T6=(e,t)=>v6(e,y6(t)),E6=(e,t)=>{let n=!1,r=!1;for(let i=0;i<t;i+=1){if(e[i]===`\\`&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){r=!r,i+=2;continue}!r&&e[i]==="`"&&(n=!n)}return n||r},D6=(e,t)=>{let n=e.substring(t,t+3)==="```",r=t>0&&e.substring(t-1,t+2)==="```",i=t>1&&e.substring(t-2,t+1)==="```";return n||r||i},O6=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]===`\\`&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!D6(e,n)&&(t+=1)}return t},k6=(e,t)=>{let n=!1,r=!1,i=-1;for(let a=0;a<e.length;a+=1){if(e[a]===`\\`&&a+1<e.length&&e[a+1]==="`"){a+=1;continue}if(e.substring(a,a+3)==="```"){r=!r,a+=2;continue}if(!r&&e[a]==="`")if(n){if(i<t&&t<a)return!0;n=!1,i=-1}else n=!0,i=a}return!1},A6=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,j6=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(A6,(t,n,r,i)=>E6(e,i)?t:`${n}\\>${r}`),M6=/(\*\*)([^*]*\*?)$/,N6=/(__)([^_]*?)$/,P6=/(\*\*\*)([^*]*?)$/,F6=/(\*)([^*]*?)$/,I6=/(_)([^_]*?)$/,L6=/(`)([^`]*?)$/,R6=/(~~)([^~]*?)$/,z6=/^[\s_~*`]*$/,B6=/^[\s]*[-*+][\s]+$/,V6=/[\p{L}\p{N}_]/u,H6=/^```[^`\n]*```?$/,U6=/^\*{4,}$/,W6=/(__)([^_]+)_$/,G6=/(~~)([^~]+)~$/,K6=/~~/g,q6=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:V6.test(e)},J6=(e,t)=>{let n=1;for(let r=t-1;r>=0;--r)if(e[r]===`]`)n+=1;else if(e[r]===`[`&&(--n,n===0))return r;return-1},Y6=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r+=1)if(e[r]===`[`)n+=1;else if(e[r]===`]`&&(--n,n===0))return r;return-1},X6=(e,t)=>{let n=!1,r=!1;for(let i=0;i<e.length&&i<t;i+=1){if(e[i]===`\\`&&e[i+1]===`$`){i+=1;continue}e[i]===`$`&&(e[i+1]===`$`?(r=!r,i+=1,n=!1):r||(n=!n))}return n||r},Z6=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
|
|
85912
|
+
`)return!1}return!1},Q6=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`?Z6(e,t):!1;if(e[n]===`
|
|
85913
|
+
`)return!1}return!1},$6=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`>`)return!1;if(e[n]===`<`){let t=n+1<e.length?e[n+1]:``;return t>=`a`&&t<=`z`||t>=`A`&&t<=`Z`||t===`/`}if(e[n]===`
|
|
85914
|
+
`)return!1}return!1},e8=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
|
|
85915
85915
|
`){r=n+1;break}let i=e.length;for(let n=t;n<e.length;n+=1)if(e[n]===`
|
|
85916
|
-
`){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},
|
|
85916
|
+
`){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},t8=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&X6(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&q6(n)&&q6(r)||(!n||n===` `||n===` `||n===`
|
|
85917
85917
|
`)&&(!r||r===` `||r===` `||r===`
|
|
85918
|
-
`)),
|
|
85919
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);return
|
|
85920
|
-
`)?!0:
|
|
85921
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);return
|
|
85922
|
-
`)?!0:
|
|
85918
|
+
`)),n8=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`*`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;t8(e,i,a,o)||(t+=1)}return t},r8=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&X6(e,t)||Q6(e,t)||$6(e,t)||n===`_`||r===`_`||n&&r&&q6(n)&&q6(r)),i8=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`_`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;r8(e,i,a,o)||(t+=1)}return t},a8=e=>{let t=0,n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]==="`"&&i+2<e.length&&e[i+1]==="`"&&e[i+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,r=!r,i+=2;continue}r||(e[i]===`*`?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0))}return n>=3&&(t+=Math.floor(n/3)),t},o8=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`*`&&r+1<e.length&&e[r+1]===`*`&&(t+=1,r+=1)}return t},s8=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`_`&&r+1<e.length&&e[r+1]===`_`&&(t+=1,r+=1)}return t},c8=(e,t,n)=>{if(!t||z6.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
|
|
85919
|
+
`),i=r===-1?0:r+1,a=e.substring(i,n);return B6.test(a)&&t.includes(`
|
|
85920
|
+
`)?!0:e8(e,n,`*`)},l8=e=>{let t=e.match(M6);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return E6(e,r)||k6(e,r)||c8(e,n,r)?e:o8(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},u8=(e,t,n)=>{if(!t||z6.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
|
|
85921
|
+
`),i=r===-1?0:r+1,a=e.substring(i,n);return B6.test(a)&&t.includes(`
|
|
85922
|
+
`)?!0:e8(e,n,`_`)},d8=e=>{let t=e.match(N6);if(!t){let t=e.match(W6);if(t){let n=e.lastIndexOf(t[1]);if(!(E6(e,n)||k6(e,n))&&s8(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return E6(e,r)||k6(e,r)||u8(e,n,r)?e:s8(e)%2==1?`${e}__`:e},f8=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`*`&&e[n-1]!==`*`&&e[n+1]!==`*`&&e[n-1]!==`\\`&&!X6(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
|
|
85923
85923
|
`)&&(!r||r===` `||r===` `||r===`
|
|
85924
|
-
`)||t&&r&&
|
|
85925
|
-
`;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},
|
|
85926
|
-
`)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,
|
|
85924
|
+
`)||t&&r&&q6(t)&&q6(r))continue;return n}}return-1},p8=e=>{if(!e.match(F6))return e;let t=f8(e);if(t===-1||E6(e,t)||k6(e,t))return e;let n=e.substring(t+1);return!n||z6.test(n)?e:n8(e)%2==1?`${e}*`:e},m8=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`_`&&e[n-1]!==`_`&&e[n+1]!==`_`&&e[n-1]!==`\\`&&!X6(e,n)&&!Q6(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&q6(t)&&q6(r))continue;return n}}return-1},h8=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
85925
|
+
`;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},g8=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(o8(t)%2!=1)return null;let n=t.indexOf(`**`),r=m8(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},_8=e=>{if(!e.match(I6))return e;let t=m8(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||z6.test(n)||E6(e,t)||k6(e,t))return e;if(i8(e)%2==1){let t=g8(e);return t===null?h8(e):t}return e},v8=e=>{let t=o8(e),n=n8(e);return t%2==0&&n%2==0},y8=(e,t,n)=>!t||z6.test(t)||E6(e,n)||k6(e,n)?!0:e8(e,n,`*`),b8=e=>{if(U6.test(e))return e;let t=e.match(P6);if(!t)return e;let n=t[2];return y8(e,n,e.lastIndexOf(t[1]))?e:a8(e)%2==1?v8(e)?e:`${e}***`:e},x8=/<[a-zA-Z/][^>]*$/,S8=e=>{let t=e.match(x8);return!t||t.index===void 0||E6(e,t.index)?e:e.substring(0,t.index).trimEnd()},C8=e=>!e.match(H6)||e.includes(`
|
|
85926
|
+
`)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,w8=e=>(e.match(/```/g)||[]).length%2==1,T8=e=>{let t=C8(e);if(t!==null)return t;let n=e.match(L6);if(n&&!w8(e)){let t=n[2];if(!t||z6.test(t))return e;if(O6(e)%2==1)return`${e}\``}return e},E8=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",D8=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!E8(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},O8=e=>{let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
|
|
85927
85927
|
`,t)!==-1&&!e.endsWith(`
|
|
85928
85928
|
`)?`${e}
|
|
85929
|
-
$$`:`${e}$$`},
|
|
85930
|
-
`);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(
|
|
85931
|
-
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(
|
|
85932
|
-
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},
|
|
85933
|
-
`;default:return r(U8(e))}}function q8(e,t,n=0,r=!1){switch(e.type){case`heading`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{bold:!0,color:e.depth<=2?t.primary:t.secondary,dimColor:e.depth>2,children:G8(e.tokens,t,r)})},`heading-${e.depth}`);case`paragraph`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{children:G8(e.tokens,t,r)})},`paragraph`);case`code`:return(0,Y.jsx)(H8,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,Y.jsx)(Z,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:t.border,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,r)=>(0,Y.jsx)(Z,{children:q8(e,t,n,!0)},r))},`blockquote`);case`list`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:e.items.map((i,a)=>{let o=e.ordered?(Number(e.start)||1)+a:null,s=i.task===!0,c=i.checked===!0,l=i.tokens?.filter(e=>e.type!==`checkbox`)||[];return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:t.secondary,dimColor:!0,children:s?c?`[✓] `:`[ ] `:o===null?`• `:`${o}. `}),(0,Y.jsx)(Z,{flexGrow:1,flexDirection:`column`,children:l.map((e,i)=>(0,Y.jsx)(Z,{children:q8(e,t,n+1,r)},i))})]},a)})},`list`);case`table`:{let n=e,i=n.header.map((e,t)=>{let r=U8(e).length;for(let e of n.rows)r=Math.max(r,U8(e[t]).length);return Math.max(r,3)});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:t.border,alignSelf:`flex-start`,children:n.header.map((e,a)=>{let o=n.align?.[a]||null;return(0,Y.jsx)(Z,{width:i[a]+2,paddingX:1,justifyContent:o===`center`?`center`:o===`right`?`flex-end`:`flex-start`,children:(0,Y.jsx)(Q,{bold:!0,color:t.primary,children:G8(e.tokens,t,r)})},a)})}),n.rows.map((e,a)=>(0,Y.jsx)(Z,{flexDirection:`row`,children:e.map((e,a)=>{let o=n.align?.[a]||null;return(0,Y.jsx)(Z,{width:i[a]+2,paddingX:1,justifyContent:o===`center`?`center`:o===`right`?`flex-end`:`flex-start`,children:(0,Y.jsx)(Q,{children:G8(e.tokens,t,r)})},a)})},a))]},`table`)}case`hr`:return(0,Y.jsx)(Z,{children:(0,Y.jsx)(Q,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{children:K8(e,t,r)})})}}function J8({children:e}){let{colors:t}=bz(),n=(0,X.useMemo)(()=>{try{let t=z8(e);return d6.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,X.useMemo)(()=>{let e=[],r=n.length;return n.forEach((n,i)=>{let a=i===r-1;if(n.type===`space`){e.push((0,Y.jsx)(Z,{height:1},`space-${i}`));return}e.push((0,Y.jsx)(Z,{flexDirection:`column`,children:q8(n,t)},i)),n.type===`heading`&&!a&&e.push((0,Y.jsx)(Z,{height:1},`heading-space-${i}`))}),e},[n,t])})}J8.displayName=`Markdown`;const Y8=`baking.beaming.booping.bouncing.brewing.bubbling.chasing.churning.coalescing.conjuring.cooking.crafting.crunching.cuddling.dancing.dazzling.discovering.doodling.dreaming.drifting.enchanting.exploring.finding.floating.fluttering.foraging.forging.frolicking.gathering.giggling.gliding.greeting.growing.hatching.herding.honking.hopping.hugging.humming.imagining.inventing.jingling.juggling.jumping.kindling.knitting.launching.leaping.mapping.marinating.meandering.mixing.moseying.munching.napping.nibbling.noodling.orbiting.painting.percolating.petting.plotting.pondering.popping.prancing.purring.puzzling.questing.riding.roaming.rolling.sauteeing.scribbling.seeking.shimmying.singing.skipping.sleeping.snacking.sniffing.snuggling.soaring.sparking.spinning.splashing.sprouting.squishing.stargazing.stirring.strolling.swimming.swinging.tickling.tinkering.toasting.tumbling.twirling.waddling.wandering.watching.weaving.whistling.wibbling.wiggling.wishing.wobbling.wondering.yawning.zooming.adventuring.assembling.ballooning.befriending.blinking.blossoming.browsing.burrowing.capering.cartwheeling.celebrating.charging.cheering.chuckling.clambering.clapping.climbing.confettifying.connecting.contemplating.cuddling.curating.dabbling.daydreaming.delighting.detecting.doodling.doodling.drizzling.echoing.edging.elucidating.fiddling.flapping.flickering.flipping.formulating.gallivanting.gamboling.gesticulating.harmonizing.hiding.hitchhiking.hopping.illuminating.investigating.jamming.kaleidoscoping.leapfrogging.levitating.listening.lounging.marveling.mimicking.murmuring.mystifying.narrating.nestling.nuzzling.orchestrating.peeking.perambulating.perusing.pirouetting.plopping.poking.prepping.processing.purring.questing.quipping.quizzing.rambling.relishing.reveling.romping.scampering.scanning.scheming.scribbling.shuffling.skedaddling.snoozing.snuggling.spinning.squeaking.squirming.stalking.star-jumping.strolling.swirling.tapping.tasting.tiptoeing.toddling.traversing.tripping.tuning.unfolding.unraveling.updating.vibing.wandering.whirling.whizzing.wiggling.winking.wobbling.wondering.yodeling.yondering.zipping.zizzling.zoning`.split(`.`);function X8(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z8(){return Y8[Math.floor(Math.random()*Y8.length)]}function Q8(e){let t=q$[e.name];if(!t)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsxs)(Q,{color:`red`,children:[`Unknown tool: `,e.name]})});let n;n=e.result?.rejected?(()=>{try{return JSON.parse(e.result.content)}catch{return{}}})().reason===`interrupted`?`interrupted`:`rejected`:e.result?`success`:e.parsedResult?.phase===`error`?`error`:`executing`;let r=e.input??{},i=``;try{i=t.getHeaderParams(r)}catch{}try{return t.renderUI(r,n,e.parsedResult,e.displayData)}catch(n){let r=n instanceof Error?n.message:String(n);return console.error(`Error rendering tool ${e.name}:`,r),(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:t.displayName,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error rendering tool`})]})}}const $8=(0,X.memo)(({char:e,color:t})=>{let[n,r]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{let e=setInterval(()=>{(0,X.startTransition)(()=>{r(e=>!e)})},500);return()=>clearInterval(e)},[]),(0,Y.jsx)(Q,{color:t,children:n?e:` `})});$8.displayName=`BlinkingIndicator`;const e5=(0,X.memo)(e=>{let{type:t,segment:n,isSpinny:r=!1,source:i}=e;if(t!==`text`)throw Error(`Can only render text segments, got ${t}`);let a=(0,X.useMemo)(()=>A1(n),[n]);return a?.trim()?i===`user`?(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`white`,children:`❯`}),(0,Y.jsx)(Q,{dimColor:!0,italic:!0,children:a})]}):r?(0,Y.jsx)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,Y.jsx)(v2,{text:a})}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`white`,children:`⏺`}),(0,Y.jsx)(J8,{children:a.trimStart()})]})}):null});e5.displayName=`TextSegment`;const t5=(0,X.memo)(e=>{let{segment:t,thinkingStartTime:n,thinkingEndTime:r}=e,{colors:i}=bz(),a=(0,X.useMemo)(()=>A1(t),[t]),o=(0,X.useMemo)(()=>n&&r?`thought for ${W0(r-n)}`:null,[n,r]);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,Y.jsx)(Q,{color:i.textSubtle,children:`✳`}),(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[o&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`(`,o,`)`]}),a&&(0,Y.jsx)(Q,{color:i.textSubtle,wrap:`wrap`,children:a})]})]})});t5.displayName=`ExpandedThinkingSegment`;const n5=5e3,r5=(0,X.memo)(e=>{let{isSpinny:t=!1,thinkingStartTime:n,thinkingEndTime:r}=e,[i,a]=(0,X.useState)(performance.now()),[o,s]=(0,X.useState)(!1);if((0,X.useEffect)(()=>{if(!t||!n)return;let e=setInterval(()=>{(0,X.startTransition)(()=>a(performance.now()))},1e3);return()=>clearInterval(e)},[t,n]),(0,X.useEffect)(()=>{if(t||!r)return;let e=setTimeout(()=>s(!0),2e3);return()=>clearTimeout(e)},[t,r]),o)return null;let c=(0,X.useMemo)(()=>{if(t){if(!n)return`thinking...`;let e=i-n;return e<n5?`thinking...`:`thinking for ${W0(e)}`}if(n&&r){let e=r-n;return e<n5?`thought`:`thought for ${W0(e)}`}return`thinking...`},[n,r,t,i]);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[t?(0,Y.jsx)($8,{char:`●`,color:`cyan`}):(0,Y.jsx)(Q,{color:`green`,children:`●`}),(0,Y.jsx)(Q,{dimColor:!0,children:c})]})});r5.displayName=`ThinkingSegment`;const i5=(0,X.memo)(e=>{let{toolUseRequest:t,toolUseResult:n,toolDisplayData:r,parsedResult:i}=e;return t?Array.isArray(t)?(0,Y.jsx)(Y.Fragment,{children:t.map((e,t)=>(0,Y.jsx)(Q8,{...e,result:n,displayData:r,parsedResult:i},e.id??t))}):(0,Y.jsx)(Q8,{...t,result:n,displayData:r,parsedResult:i}):null});i5.displayName=`ToolCallSegment`;const a5=(0,X.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,{colors:a}=bz(),o=(0,X.useRef)(Z8());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let s=(0,X.useMemo)(()=>A1(n),[n]);if(!s&&!r)throw Error(`Collapsible component segment must have content or title`);let c=r||X8(o.current);return(0,Y.jsxs)(Z,{borderStyle:s?`single`:void 0,borderColor:a.border,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[c&&(0,Y.jsx)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(v2,{text:`${c}...`}),(0,Y.jsx)(Q,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(Q,{color:a.textMuted,children:c})]})}),s&&(0,Y.jsx)(J8,{children:s})]})});a5.displayName=`CollapsibleComponentSegment`;const o5=(0,X.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e,{colors:o}=bz();if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(a);if((0,X.useEffect)(()=>{if(a!==l.current&&a!=null){l.current=a,c(!0);let e=setTimeout(()=>c(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let u=(0,X.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),d=(0,X.useMemo)(()=>{switch(u){case`info`:return o.info;case`success`:return o.success;case`warning`:return o.warning;case`error`:return o.error;default:return o.info}},[u,o]),f=e=>e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().split(` `).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `),p=(0,X.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:d,children:s?`◉`:`●`}),(0,Y.jsx)(Q,{color:d,bold:s,inverse:s,children:s?` ${n} `:n})]}),p.length>0&&(0,Y.jsx)(Z,{marginLeft:2,flexDirection:`row`,gap:1,children:p.map((e,t)=>(0,Y.jsxs)(X.Fragment,{children:[t>0&&(0,Y.jsx)(Q,{children:` | `}),(0,Y.jsx)(Q,{color:`cyan`,underline:!0,children:f(e.type)})]},t))})]})});o5.displayName=`NotificationSegment`;const s5=(0,X.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,Y.jsx)(e5,{...e});case`thinking`:return(0,Y.jsx)(r5,{...e});case`code_llm_tool_call`:return(0,Y.jsx)(i5,{...e});case`collapsible_component`:return(0,Y.jsx)(a5,{...e});case`code_llm_agent_tool_request`:return(0,Y.jsx)(i5,{...e});case`code_llm_notification`:return(0,Y.jsx)(o5,{...e});default:return null}});s5.displayName=`SegmentBase`;function c5(e,t){return(0,Y.jsx)(o5,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function l5({segment:e}){return(0,Y.jsx)(j4,{fallback:c5,children:(0,Y.jsx)(s5,{segment:e})})}const u5=(0,X.memo)(({snapshot:e,onClose:t})=>{let{colors:n}=bz();HL((e,n)=>{(n.ctrl||n.super)&&e===`o`&&t(),n.escape&&t()});let r=(0,X.useMemo)(()=>e.filter(e=>!e.temp&&!e.isSpinny),[e]);return(0,Y.jsx)(JJ.Provider,{value:!0,children:(0,Y.jsxs)(Z,{flexDirection:`column`,gap:1,children:[(0,Y.jsx)(Z,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:r.map(e=>(0,Y.jsx)(d5,{segment:e},e.id))}),(0,Y.jsxs)(Z,{borderStyle:`single`,borderColor:n.border,paddingLeft:1,paddingRight:1,flexDirection:`row`,gap:2,children:[(0,Y.jsx)(Q,{color:n.textMuted,children:`expanded view`}),(0,Y.jsx)(Q,{dimColor:!0,children:`ctrl+o or esc to collapse`})]})]})})});u5.displayName=`ExpandedView`;const d5=(0,X.memo)(({segment:e})=>e.type===`thinking`?(0,Y.jsx)(t5,{...e}):(0,Y.jsx)(l5,{segment:e}));d5.displayName=`ExpandedSegment`;var f5=H(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.tinycolor=r())})(e,(function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}var t=/^\s+/,n=/\s+$/;function r(e,t){if(e||=``,t||={},e instanceof r)return e;if(!(this instanceof r))return new r(e,t);var n=i(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=O(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=c(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=c(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=o(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=o(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return u(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return d(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(k(this._r,255)*100)+`%`,g:Math.round(k(this._g,255)*100)+`%`,b:Math.round(k(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(k(this._r,255)*100)+`%, `+Math.round(k(this._g,255)*100)+`%, `+Math.round(k(this._b,255)*100)+`%)`:`rgba(`+Math.round(k(this._r,255)*100)+`%, `+Math.round(k(this._g,255)*100)+`%, `+Math.round(k(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:E[u(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+f(this._r,this._g,this._b,this._a),n=t,i=this._gradientType?`GradientType = 1, `:``;if(e){var a=r(e);n=`#`+f(a._r,a._g,a._b,a._a)}return`progid:DXImageTransform.Microsoft.gradient(`+i+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return r(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(_,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(m,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(C,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(w,arguments)},splitcomplement:function(){return this._applyCombination(S,arguments)},triad:function(){return this._applyCombination(x,[3])},tetrad:function(){return this._applyCombination(x,[4])}},r.fromRatio=function(t,n){if(e(t)==`object`){var i={};for(var a in t)t.hasOwnProperty(a)&&(a===`a`?i[a]=t[a]:i[a]=F(t[a]));t=i}return r(t,n)};function i(t){var n={r:0,g:0,b:0},r=1,i=null,o=null,c=null,u=!1,d=!1;return typeof t==`string`&&(t=z(t)),e(t)==`object`&&(R(t.r)&&R(t.g)&&R(t.b)?(n=a(t.r,t.g,t.b),u=!0,d=String(t.r).substr(-1)===`%`?`prgb`:`rgb`):R(t.h)&&R(t.s)&&R(t.v)?(i=F(t.s),o=F(t.v),n=l(t.h,i,o),u=!0,d=`hsv`):R(t.h)&&R(t.s)&&R(t.l)&&(i=F(t.s),c=F(t.l),n=s(t.h,i,c),u=!0,d=`hsl`),t.hasOwnProperty(`a`)&&(r=t.a)),r=O(r),{ok:u,format:t.format||d,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:r}}function a(e,t,n){return{r:k(e,255)*255,g:k(t,255)*255,b:k(n,255)*255}}function o(e,t,n){e=k(e,255),t=k(t,255),n=k(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,l:s}}function s(e,t,n){var r,i,a;e=k(e,360),t=k(t,100),n=k(n,100);function o(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function c(e,t,n){e=k(e,255),t=k(t,255),n=k(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,v:s}}function l(e,t,n){e=k(e,360)*6,t=k(t,100),n=k(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),c=r%6,l=[n,o,a,a,s,n][c],u=[s,n,n,o,a,a][c],d=[a,a,s,n,n,o][c];return{r:l*255,g:u*255,b:d*255}}function u(e,t,n,r){var i=[P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join(``)}function d(e,t,n,r,i){var a=[P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16)),P(I(r))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join(``)}function f(e,t,n,r){return[P(I(r)),P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16))].join(``)}r.equals=function(e,t){return!e||!t?!1:r(e).toRgbString()==r(t).toRgbString()},r.random=function(){return r.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function p(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.s-=t/100,n.s=A(n.s),r(n)}function m(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.s+=t/100,n.s=A(n.s),r(n)}function h(e){return r(e).desaturate(100)}function g(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.l+=t/100,n.l=A(n.l),r(n)}function _(e,t){t=t===0?0:t||10;var n=r(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),r(n)}function v(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.l-=t/100,n.l=A(n.l),r(n)}function y(e,t){var n=r(e).toHsl(),i=(n.h+t)%360;return n.h=i<0?360+i:i,r(n)}function b(e){var t=r(e).toHsl();return t.h=(t.h+180)%360,r(t)}function x(e,t){if(isNaN(t)||t<=0)throw Error(`Argument to polyad must be a positive number`);for(var n=r(e).toHsl(),i=[r(e)],a=360/t,o=1;o<t;o++)i.push(r({h:(n.h+o*a)%360,s:n.s,l:n.l}));return i}function S(e){var t=r(e).toHsl(),n=t.h;return[r(e),r({h:(n+72)%360,s:t.s,l:t.l}),r({h:(n+216)%360,s:t.s,l:t.l})]}function C(e,t,n){t||=6,n||=30;var i=r(e).toHsl(),a=360/n,o=[r(e)];for(i.h=(i.h-(a*t>>1)+720)%360;--t;)i.h=(i.h+a)%360,o.push(r(i));return o}function w(e,t){t||=6;for(var n=r(e).toHsv(),i=n.h,a=n.s,o=n.v,s=[],c=1/t;t--;)s.push(r({h:i,s:a,v:o})),o=(o+c)%1;return s}r.mix=function(e,t,n){n=n===0?0:n||50;var i=r(e).toRgb(),a=r(t).toRgb(),o=n/100;return r({r:(a.r-i.r)*o+i.r,g:(a.g-i.g)*o+i.g,b:(a.b-i.b)*o+i.b,a:(a.a-i.a)*o+i.a})},r.readability=function(e,t){var n=r(e),i=r(t);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},r.isReadable=function(e,t,n){var i=r.readability(e,t),a,o=!1;switch(a=B(n),a.level+a.size){case`AAsmall`:case`AAAlarge`:o=i>=4.5;break;case`AAlarge`:o=i>=3;break;case`AAAsmall`:o=i>=7;break}return o},r.mostReadable=function(e,t,n){var i=null,a=0,o,s,c,l;n||={},s=n.includeFallbackColors,c=n.level,l=n.size;for(var u=0;u<t.length;u++)o=r.readability(e,t[u]),o>a&&(a=o,i=r(t[u]));return r.isReadable(e,i,{level:c,size:l})||!s?i:(n.includeFallbackColors=!1,r.mostReadable(e,[`#fff`,`#000`],n))};var T=r.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},E=r.hexNames=D(T);function D(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function O(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function k(e,t){M(e)&&(e=`100%`);var n=N(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function A(e){return Math.min(1,Math.max(0,e))}function j(e){return parseInt(e,16)}function M(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function N(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function P(e){return e.length==1?`0`+e:``+e}function F(e){return e<=1&&(e=e*100+`%`),e}function I(e){return Math.round(parseFloat(e)*255).toString(16)}function ee(e){return j(e)/255}var L=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function R(e){return!!L.CSS_UNIT.exec(e)}function z(e){e=e.replace(t,``).replace(n,``).toLowerCase();var r=!1;if(T[e])e=T[e],r=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var i;return(i=L.rgb.exec(e))?{r:i[1],g:i[2],b:i[3]}:(i=L.rgba.exec(e))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=L.hsl.exec(e))?{h:i[1],s:i[2],l:i[3]}:(i=L.hsla.exec(e))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=L.hsv.exec(e))?{h:i[1],s:i[2],v:i[3]}:(i=L.hsva.exec(e))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=L.hex8.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),a:ee(i[4]),format:r?`name`:`hex8`}:(i=L.hex6.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),format:r?`name`:`hex`}:(i=L.hex4.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),a:ee(i[4]+``+i[4]),format:r?`name`:`hex8`}:(i=L.hex3.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),format:r?`name`:`hex`}:!1}function B(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}return r}))})),p5=H(((e,t)=>{let n=f5(),r={r:256,g:256,b:256,a:1},i={h:360,s:1,v:1,a:1};function a(e,t,n){let r={};for(let i in e)e.hasOwnProperty(i)&&(r[i]=n===0?0:(t[i]-e[i])/n);return r}function o(e,t,n,r){let i={};for(let a in t)t.hasOwnProperty(a)&&(i[a]=e[a]*n+t[a],i[a]=i[a]<0?i[a]+r[a]:r[a]===1?i[a]:i[a]%r[a]);return i}function s(e,t,i){let s=e.color.toRgb(),c=a(s,t.color.toRgb(),i),l=[e.color];for(let e=1;e<i;e++){let t=o(c,s,e,r);l.push(n(t))}return l}function c(e,t,r,c){let l=e.color.toHsv(),u=t.color.toHsv();if(l.s===0||u.s===0)return s(e,t,r);let d;if(typeof c==`boolean`)d=c;else{let e=l.h<u.h&&u.h-l.h<180||l.h>u.h&&l.h-u.h>180;d=c===`long`&&e||c===`short`&&!e}let f=a(l,u,r),p=[e.color],m;m=l.h<=u.h&&!d||l.h>=u.h&&d?u.h-l.h:d?360-u.h+l.h:360-l.h+u.h,f.h=(-1)**(d?1:0)*Math.abs(m)/r;for(let e=1;e<r;e++){let t=o(f,l,e,i);p.push(n(t))}return p}function l(e,t){let n=e.length;if(t=parseInt(t,10),isNaN(t)||t<2)throw Error(`Invalid number of steps (< 2)`);if(t<n)throw Error(`Number of steps cannot be inferior to number of stops`);let r=[];for(let i=1;i<n;i++){let n=(t-1)*(e[i].pos-e[i-1].pos);r.push(Math.max(1,Math.round(n)))}let i=1;for(let e=n-1;e--;)i+=r[e];for(;i!==t;)if(i<t){let e=Math.min.apply(null,r);r[r.indexOf(e)]++,i++}else{let e=Math.max.apply(null,r);r[r.indexOf(e)]--,i--}return r}function u(e,t,r,i){if(t<0||t>1)throw Error(`Position must be between 0 and 1`);let s,c;for(let n=0,r=e.length;n<r-1;n++)if(t>=e[n].pos&&t<e[n+1].pos){s=e[n],c=e[n+1];break}return s||=c=e[e.length-1],n(o(a(s.color[r](),c.color[r](),(c.pos-s.pos)*100),s.color[r](),(t-s.pos)*100,i))}var d=class e{constructor(e){if(e.length<2)throw Error(`Invalid number of stops (< 2)`);let t=e[0].pos!==void 0,r=e.length,i=-1,a=!1;this.stops=e.map((e,o)=>{let s=e.pos!==void 0;if(t^s)throw Error(`Cannot mix positionned and not posionned color stops`);if(s){let t=e.color!==void 0;if(!t&&(a||o===0||o===r-1))throw Error(`Cannot define two consecutive position-only stops`);if(a=!t,e={color:t?n(e.color):null,colorLess:!t,pos:e.pos},e.pos<0||e.pos>1)throw Error(`Color stops positions must be between 0 and 1`);if(e.pos<i)throw Error(`Color stops positions are not ordered`);i=e.pos}else e={color:n(e.color===void 0?e:e.color),pos:o/(r-1)};return e}),this.stops[0].pos!==0&&(this.stops.unshift({color:this.stops[0].color,pos:0}),r++),this.stops[r-1].pos!==1&&this.stops.push({color:this.stops[r-1].color,pos:1})}reverse(){let t=[];return this.stops.forEach(function(e){t.push({color:e.color,pos:1-e.pos})}),new e(t.reverse())}loop(){let t=[],n=[];return this.stops.forEach(e=>{t.push({color:e.color,pos:e.pos/2})}),this.stops.slice(0,-1).forEach(e=>{n.push({color:e.color,pos:1-e.pos/2})}),new e(t.concat(n.reverse()))}rgb(e){let t=l(this.stops,e),n=[];this.stops.forEach((e,t)=>{e.colorLess&&(e.color=s(this.stops[t-1],this.stops[t+1],2)[1])});for(let e=0,r=this.stops.length;e<r-1;e++){let r=s(this.stops[e],this.stops[e+1],t[e]);n.splice(n.length,0,...r)}return n.push(this.stops[this.stops.length-1].color),n}hsv(e,t){let n=l(this.stops,e),r=[];this.stops.forEach((e,n)=>{e.colorLess&&(e.color=c(this.stops[n-1],this.stops[n+1],2,t)[1])});for(let e=0,i=this.stops.length;e<i-1;e++){let i=c(this.stops[e],this.stops[e+1],n[e],t);r.splice(r.length,0,...i)}return r.push(this.stops[this.stops.length-1].color),r}css(e,t){e||=`linear`,t||=e===`linear`?`to right`:`ellipse at center`;let n=e+`-gradient(`+t;return this.stops.forEach(function(e){n+=`, `+(e.colorLess?``:e.color.toRgbString()+` `)+e.pos*100+`%`}),n+=`)`,n}rgbAt(e){return u(this.stops,e,`toRgb`,r)}hsvAt(e){return u(this.stops,e,`toHsv`,i)}};t.exports=function(e){if(arguments.length===1){if(!Array.isArray(arguments[0]))throw Error(`"stops" is not an array`);e=arguments[0]}else e=Array.prototype.slice.call(arguments);return new d(e)}})),m5=Ee({atlas:()=>C5,cristal:()=>w5,default:()=>g5,fruit:()=>A5,instagram:()=>j5,mind:()=>E5,morning:()=>D5,multiline:()=>y5,passion:()=>k5,pastel:()=>F5,rainbow:()=>P5,retro:()=>M5,summer:()=>N5,teen:()=>T5,vice:()=>O5}),h5=Oe(p5(),1);const g5=(...e)=>{let t,n;if(e.length===0)throw Error(`Missing gradient colors`);if(Array.isArray(e[0]))t=(0,h5.default)(e[0]),n=b5(e[1]);else{if(e.length===1)throw Error(`Expected an array of colors, received ${JSON.stringify(e[0])}`);t=(0,h5.default)(...e)}let r=(e,r)=>v5(e?e.toString():``,t,r??n);return r.multiline=(e,r)=>y5(e?e.toString():``,t,r??n),r},_5=(e,t,n)=>t.interpolation?.toLowerCase()===`hsv`?e.hsv(n,t.hsvSpin?.toLowerCase()||!1):e.rgb(n);function v5(e,t,n){let r=_5(t,b5(n),Math.max(e.replace(/\s/g,``).length,t.stops.length)),i=``;for(let t of e)i+=t.match(/\s/g)?t:pj.hex(r.shift()?.toHex()||`#000`)(t);return i}function y5(e,t,n){let r=b5(n),i=e.split(`
|
|
85934
|
-
`),a=
|
|
85935
|
-
`)}function
|
|
85929
|
+
$$`:`${e}$$`},k8=e=>D8(e)%2==0?e:O8(e),A8=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=J6(e,t);if(r===-1||E6(e,r))return null;let i=r>0&&e[r-1]===`!`,a=i?r-1:r,o=e.substring(0,a);if(i)return o;let s=e.substring(r+1,t);return n===`text-only`?`${o}${s}`:`${o}[${s}](streamdown:incomplete-link)`},j8=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!E6(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=Y6(e,n);if(t===-1)return n;if(t+1<e.length&&e[t+1]===`(`){let r=e.indexOf(`)`,t+2);r!==-1&&(n=r)}}return t},M8=(e,t,n)=>{let r=t>0&&e[t-1]===`!`,i=r?t-1:t;if(!e.substring(t+1).includes(`]`)){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=j8(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(Y6(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=j8(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},N8=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!E6(e,n)){let r=A8(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!E6(e,n)){let r=M8(e,n,t);if(r!==null)return r}return e},P8=/^-{1,2}$/,F8=/^[\s]*-{1,2}[\s]+$/,I8=/^={1,2}$/,L8=/^[\s]*={1,2}[\s]+$/,R8=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
|
|
85930
|
+
`);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(P8.test(i)&&!n.match(F8)){let t=r.split(`
|
|
85931
|
+
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(I8.test(i)&&!n.match(L8)){let t=r.split(`
|
|
85932
|
+
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},z8=e=>{let t=e.match(R6);if(t){let n=t[2];if(!n||z6.test(n))return e;let r=e.lastIndexOf(t[1]);if(E6(e,r)||k6(e,r))return e;if(e.match(K6)?.length%2==1)return`${e}~~`}else{let t=e.match(G6);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(E6(e,n)||k6(e,n))return e;if(e.match(K6)?.length%2==1)return`${e}~`}}return e},B8=e=>e!==!1,V8={COMPARISON_OPERATORS:-10,HTML_TAGS:-5,SETEXT_HEADINGS:0,LINKS:10,BOLD_ITALIC:20,BOLD:30,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,DEFAULT:100},H8=[{handler:{name:`comparisonOperators`,handle:j6,priority:V8.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:S8,priority:V8.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:R8,priority:V8.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:N8,priority:V8.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:b8,priority:V8.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:l8,priority:V8.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:d8,priority:V8.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:p8,priority:V8.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:_8,priority:V8.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:T8,priority:V8.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:z8,priority:V8.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:k8,priority:V8.KATEX},optionKey:`katex`}],U8=e=>{let t=e?.linkMode??`protocol`;return H8.filter(({handler:t,optionKey:n})=>t.name===`links`?B8(e?.links)||B8(e?.images):B8(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:T6(w6({},e),{handle:e=>N8(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},W8=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=U8(t),i=(t?.handlers??[]).map(e=>({handler:T6(w6({},e),{priority:e.priority??V8.DEFAULT}),earlyReturn:void 0})),a=[...r,...i].sort((e,t)=>(e.handler.priority??0)-(t.handler.priority??0));for(let{handler:e,earlyReturn:t}of a)if(n=e.handle(n),t!=null&&t(n))return n;return n};function G8(e){if(!e)return!1;let t=e.toLowerCase().trim();return t===`mermaid`||t===`mmd`}function K8(e){try{return Uq(e)}catch{return null}}function q8({children:e,language:t}){let{colors:n}=bz(),r=(0,X.useMemo)(()=>LU(n),[n]);if(G8(t)){let t=K8(e||``);if(t!==null)return(0,Y.jsx)(Z,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,Y.jsx)(Q,{children:t})})}let i=e;if(t&&(0,FU.supportsLanguage)(t))try{i=(0,FU.highlight)(e||``,{language:t,theme:r})}catch{}return(0,Y.jsx)(Z,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,Y.jsx)(Q,{children:i})})}q8.displayName=`CodeBlock`;function J8(e){return`text`in e&&typeof e.text==`string`?e.text:`tokens`in e&&Array.isArray(e.tokens)?e.tokens.map(e=>J8(e)).join(``):``}function Y8(e){return`checked`in e&&typeof e.checked==`boolean`}function X8(e,t,n=!1){return e?e.map((e,r)=>(0,Y.jsx)(X.Fragment,{children:Z8(e,t,n)},r)):null}function Z8(e,t,n=!1){let r=e=>n?(0,Y.jsx)(Q,{dimColor:!0,italic:!0,children:e}):e;switch(e.type){case`strong`:return(0,Y.jsx)(Q,{bold:!0,children:X8(e.tokens,t,n)});case`em`:return(0,Y.jsx)(Q,{italic:!0,children:X8(e.tokens,t,n)});case`del`:return(0,Y.jsx)(Q,{strikethrough:!0,children:X8(e.tokens,t,n)});case`codespan`:return r((0,Y.jsx)(Q,{color:t.primary,dimColor:!0,children:e.text}));case`link`:return r((0,Y.jsx)(c4,{href:e.href,children:J8(e)}));case`image`:{let t=e,n=t.text||t.href;return r((0,Y.jsxs)(Q,{dimColor:!0,children:[n,` `,t.href!==n&&`(${t.href})`]}))}case`checkbox`:{let n=Y8(e)&&e.checked===!0;return r((0,Y.jsx)(Q,{color:t.secondary,children:n?`[✓]`:`[ ]`}))}case`text`:return e.tokens?X8(e.tokens,t,n):r(e.text);case`br`:return`
|
|
85933
|
+
`;default:return r(J8(e))}}function Q8(e,t,n=0,r=!1){switch(e.type){case`heading`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{bold:!0,color:e.depth<=2?t.primary:t.secondary,dimColor:e.depth>2,children:X8(e.tokens,t,r)})},`heading-${e.depth}`);case`paragraph`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{children:X8(e.tokens,t,r)})},`paragraph`);case`code`:return(0,Y.jsx)(q8,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,Y.jsx)(Z,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:t.border,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,r)=>(0,Y.jsx)(Z,{children:Q8(e,t,n,!0)},r))},`blockquote`);case`list`:return(0,Y.jsx)(Z,{flexDirection:`column`,children:e.items.map((i,a)=>{let o=e.ordered?(Number(e.start)||1)+a:null,s=i.task===!0,c=i.checked===!0,l=i.tokens?.filter(e=>e.type!==`checkbox`)||[];return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:t.secondary,dimColor:!0,children:s?c?`[✓] `:`[ ] `:o===null?`• `:`${o}. `}),(0,Y.jsx)(Z,{flexGrow:1,flexDirection:`column`,children:l.map((e,i)=>(0,Y.jsx)(Z,{children:Q8(e,t,n+1,r)},i))})]},a)})},`list`);case`table`:{let n=e,i=n.header.map((e,t)=>{let r=J8(e).length;for(let e of n.rows)r=Math.max(r,J8(e[t]).length);return Math.max(r,3)});return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(Z,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:t.border,alignSelf:`flex-start`,children:n.header.map((e,a)=>{let o=n.align?.[a]||null;return(0,Y.jsx)(Z,{width:i[a]+2,paddingX:1,justifyContent:o===`center`?`center`:o===`right`?`flex-end`:`flex-start`,children:(0,Y.jsx)(Q,{bold:!0,color:t.primary,children:X8(e.tokens,t,r)})},a)})}),n.rows.map((e,a)=>(0,Y.jsx)(Z,{flexDirection:`row`,children:e.map((e,a)=>{let o=n.align?.[a]||null;return(0,Y.jsx)(Z,{width:i[a]+2,paddingX:1,justifyContent:o===`center`?`center`:o===`right`?`flex-end`:`flex-start`,children:(0,Y.jsx)(Q,{children:X8(e.tokens,t,r)})},a)})},a))]},`table`)}case`hr`:return(0,Y.jsx)(Z,{children:(0,Y.jsx)(Q,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsx)(Q,{children:Z8(e,t,r)})})}}function $8({children:e}){let{colors:t}=bz(),n=(0,X.useMemo)(()=>{try{let t=W8(e);return g6.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,X.useMemo)(()=>{let e=[],r=n.length;return n.forEach((n,i)=>{let a=i===r-1;if(n.type===`space`){e.push((0,Y.jsx)(Z,{height:1},`space-${i}`));return}e.push((0,Y.jsx)(Z,{flexDirection:`column`,children:Q8(n,t)},i)),n.type===`heading`&&!a&&e.push((0,Y.jsx)(Z,{height:1},`heading-space-${i}`))}),e},[n,t])})}$8.displayName=`Markdown`;const e5=`baking.beaming.booping.bouncing.brewing.bubbling.chasing.churning.coalescing.conjuring.cooking.crafting.crunching.cuddling.dancing.dazzling.discovering.doodling.dreaming.drifting.enchanting.exploring.finding.floating.fluttering.foraging.forging.frolicking.gathering.giggling.gliding.greeting.growing.hatching.herding.honking.hopping.hugging.humming.imagining.inventing.jingling.juggling.jumping.kindling.knitting.launching.leaping.mapping.marinating.meandering.mixing.moseying.munching.napping.nibbling.noodling.orbiting.painting.percolating.petting.plotting.pondering.popping.prancing.purring.puzzling.questing.riding.roaming.rolling.sauteeing.scribbling.seeking.shimmying.singing.skipping.sleeping.snacking.sniffing.snuggling.soaring.sparking.spinning.splashing.sprouting.squishing.stargazing.stirring.strolling.swimming.swinging.tickling.tinkering.toasting.tumbling.twirling.waddling.wandering.watching.weaving.whistling.wibbling.wiggling.wishing.wobbling.wondering.yawning.zooming.adventuring.assembling.ballooning.befriending.blinking.blossoming.browsing.burrowing.capering.cartwheeling.celebrating.charging.cheering.chuckling.clambering.clapping.climbing.confettifying.connecting.contemplating.cuddling.curating.dabbling.daydreaming.delighting.detecting.doodling.doodling.drizzling.echoing.edging.elucidating.fiddling.flapping.flickering.flipping.formulating.gallivanting.gamboling.gesticulating.harmonizing.hiding.hitchhiking.hopping.illuminating.investigating.jamming.kaleidoscoping.leapfrogging.levitating.listening.lounging.marveling.mimicking.murmuring.mystifying.narrating.nestling.nuzzling.orchestrating.peeking.perambulating.perusing.pirouetting.plopping.poking.prepping.processing.purring.questing.quipping.quizzing.rambling.relishing.reveling.romping.scampering.scanning.scheming.scribbling.shuffling.skedaddling.snoozing.snuggling.spinning.squeaking.squirming.stalking.star-jumping.strolling.swirling.tapping.tasting.tiptoeing.toddling.traversing.tripping.tuning.unfolding.unraveling.updating.vibing.wandering.whirling.whizzing.wiggling.winking.wobbling.wondering.yodeling.yondering.zipping.zizzling.zoning`.split(`.`);function t5(e){return e.charAt(0).toUpperCase()+e.slice(1)}function n5(){return e5[Math.floor(Math.random()*e5.length)]}function r5(e){let t=x1[e.name];if(!t)return(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsxs)(Q,{color:`red`,children:[`Unknown tool: `,e.name]})});let n;n=e.result?.rejected?(()=>{try{return JSON.parse(e.result.content)}catch{return{}}})().reason===`interrupted`?`interrupted`:`rejected`:e.result?`success`:e.parsedResult?.phase===`error`?`error`:`executing`;let r=e.input??{},i=``;try{i=t.getHeaderParams(r)}catch{}try{return t.renderUI(r,n,e.parsedResult,e.displayData)}catch(n){let r=n instanceof Error?n.message:String(n);return console.error(`Error rendering tool ${e.name}:`,r),(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(gJ,{name:t.displayName,params:i,status:`error`}),(0,Y.jsx)(_J,{color:`red`,children:`Error rendering tool`})]})}}const i5=(0,X.memo)(({char:e,color:t})=>{let[n,r]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{let e=setInterval(()=>{(0,X.startTransition)(()=>{r(e=>!e)})},500);return()=>clearInterval(e)},[]),(0,Y.jsx)(Q,{color:t,children:n?e:` `})});i5.displayName=`BlinkingIndicator`;const a5=(0,X.memo)(e=>{let{type:t,segment:n,isSpinny:r=!1,source:i}=e;if(t!==`text`)throw Error(`Can only render text segments, got ${t}`);let a=(0,X.useMemo)(()=>F1(n),[n]);return a?.trim()?i===`user`?(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`white`,children:`❯`}),(0,Y.jsx)(Q,{dimColor:!0,italic:!0,children:a})]}):r?(0,Y.jsx)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,Y.jsx)(C2,{text:a})}):(0,Y.jsx)(Z,{flexDirection:`column`,children:(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`white`,children:`⏺`}),(0,Y.jsx)($8,{children:a.trimStart()})]})}):null});a5.displayName=`TextSegment`;const o5=(0,X.memo)(e=>{let{segment:t,thinkingStartTime:n,thinkingEndTime:r}=e,{colors:i}=bz(),a=(0,X.useMemo)(()=>F1(t),[t]),o=(0,X.useMemo)(()=>n&&r?`thought for ${Y0(r-n)}`:null,[n,r]);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,Y.jsx)(Q,{color:i.textSubtle,children:`✳`}),(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[o&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`(`,o,`)`]}),a&&(0,Y.jsx)(Q,{color:i.textSubtle,wrap:`wrap`,children:a})]})]})});o5.displayName=`ExpandedThinkingSegment`;const s5=5e3,c5=(0,X.memo)(e=>{let{isSpinny:t=!1,thinkingStartTime:n,thinkingEndTime:r}=e,[i,a]=(0,X.useState)(performance.now()),[o,s]=(0,X.useState)(!1);if((0,X.useEffect)(()=>{if(!t||!n)return;let e=setInterval(()=>{(0,X.startTransition)(()=>a(performance.now()))},1e3);return()=>clearInterval(e)},[t,n]),(0,X.useEffect)(()=>{if(t||!r)return;let e=setTimeout(()=>s(!0),2e3);return()=>clearTimeout(e)},[t,r]),o)return null;let c=(0,X.useMemo)(()=>{if(t){if(!n)return`thinking...`;let e=i-n;return e<s5?`thinking...`:`thinking for ${Y0(e)}`}if(n&&r){let e=r-n;return e<s5?`thought`:`thought for ${Y0(e)}`}return`thinking...`},[n,r,t,i]);return(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[t?(0,Y.jsx)(i5,{char:`●`,color:`cyan`}):(0,Y.jsx)(Q,{color:`green`,children:`●`}),(0,Y.jsx)(Q,{dimColor:!0,children:c})]})});c5.displayName=`ThinkingSegment`;const l5=(0,X.memo)(e=>{let{toolUseRequest:t,toolUseResult:n,toolDisplayData:r,parsedResult:i}=e;return t?Array.isArray(t)?(0,Y.jsx)(Y.Fragment,{children:t.map((e,t)=>(0,Y.jsx)(r5,{...e,result:n,displayData:r,parsedResult:i},e.id??t))}):(0,Y.jsx)(r5,{...t,result:n,displayData:r,parsedResult:i}):null});l5.displayName=`ToolCallSegment`;const u5=(0,X.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,{colors:a}=bz(),o=(0,X.useRef)(n5());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let s=(0,X.useMemo)(()=>F1(n),[n]);if(!s&&!r)throw Error(`Collapsible component segment must have content or title`);let c=r||t5(o.current);return(0,Y.jsxs)(Z,{borderStyle:s?`single`:void 0,borderColor:a.border,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[c&&(0,Y.jsx)(Z,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(C2,{text:`${c}...`}),(0,Y.jsx)(Q,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{children:` `}),(0,Y.jsx)(Q,{color:a.textMuted,children:c})]})}),s&&(0,Y.jsx)($8,{children:s})]})});u5.displayName=`CollapsibleComponentSegment`;const d5=(0,X.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e,{colors:o}=bz();if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(a);if((0,X.useEffect)(()=>{if(a!==l.current&&a!=null){l.current=a,c(!0);let e=setTimeout(()=>c(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let u=(0,X.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),d=(0,X.useMemo)(()=>{switch(u){case`info`:return o.info;case`success`:return o.success;case`warning`:return o.warning;case`error`:return o.error;default:return o.info}},[u,o]),f=e=>e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().split(` `).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `),p=(0,X.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,Y.jsxs)(Z,{flexDirection:`column`,gap:0,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:d,children:s?`◉`:`●`}),(0,Y.jsx)(Q,{color:d,bold:s,inverse:s,children:s?` ${n} `:n})]}),p.length>0&&(0,Y.jsx)(Z,{marginLeft:2,flexDirection:`row`,gap:1,children:p.map((e,t)=>(0,Y.jsxs)(X.Fragment,{children:[t>0&&(0,Y.jsx)(Q,{children:` | `}),(0,Y.jsx)(Q,{color:`cyan`,underline:!0,children:f(e.type)})]},t))})]})});d5.displayName=`NotificationSegment`;const f5=(0,X.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,Y.jsx)(a5,{...e});case`thinking`:return(0,Y.jsx)(c5,{...e});case`code_llm_tool_call`:return(0,Y.jsx)(l5,{...e});case`collapsible_component`:return(0,Y.jsx)(u5,{...e});case`code_llm_agent_tool_request`:return(0,Y.jsx)(l5,{...e});case`code_llm_notification`:return(0,Y.jsx)(d5,{...e});default:return null}});f5.displayName=`SegmentBase`;function p5(e,t){return(0,Y.jsx)(d5,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function m5({segment:e}){return(0,Y.jsx)(I4,{fallback:p5,children:(0,Y.jsx)(f5,{segment:e})})}const h5=(0,X.memo)(({snapshot:e,onClose:t})=>{let{colors:n}=bz();HL((e,n)=>{(n.ctrl||n.super)&&e===`o`&&t(),n.escape&&t()});let r=(0,X.useMemo)(()=>e.filter(e=>!e.temp&&!e.isSpinny),[e]);return(0,Y.jsx)(JJ.Provider,{value:!0,children:(0,Y.jsxs)(Z,{flexDirection:`column`,gap:1,children:[(0,Y.jsx)(Z,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:r.map(e=>(0,Y.jsx)(g5,{segment:e},e.id))}),(0,Y.jsxs)(Z,{borderStyle:`single`,borderColor:n.border,paddingLeft:1,paddingRight:1,flexDirection:`row`,gap:2,children:[(0,Y.jsx)(Q,{color:n.textMuted,children:`expanded view`}),(0,Y.jsx)(Q,{dimColor:!0,children:`ctrl+o or esc to collapse`})]})]})})});h5.displayName=`ExpandedView`;const g5=(0,X.memo)(({segment:e})=>e.type===`thinking`?(0,Y.jsx)(o5,{...e}):(0,Y.jsx)(m5,{segment:e}));g5.displayName=`ExpandedSegment`;var _5=H(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.tinycolor=r())})(e,(function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}var t=/^\s+/,n=/\s+$/;function r(e,t){if(e||=``,t||={},e instanceof r)return e;if(!(this instanceof r))return new r(e,t);var n=i(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=O(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=c(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=c(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=o(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=o(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return u(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return d(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(k(this._r,255)*100)+`%`,g:Math.round(k(this._g,255)*100)+`%`,b:Math.round(k(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(k(this._r,255)*100)+`%, `+Math.round(k(this._g,255)*100)+`%, `+Math.round(k(this._b,255)*100)+`%)`:`rgba(`+Math.round(k(this._r,255)*100)+`%, `+Math.round(k(this._g,255)*100)+`%, `+Math.round(k(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:E[u(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+f(this._r,this._g,this._b,this._a),n=t,i=this._gradientType?`GradientType = 1, `:``;if(e){var a=r(e);n=`#`+f(a._r,a._g,a._b,a._a)}return`progid:DXImageTransform.Microsoft.gradient(`+i+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return r(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(_,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(p,arguments)},saturate:function(){return this._applyModification(m,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(C,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(w,arguments)},splitcomplement:function(){return this._applyCombination(S,arguments)},triad:function(){return this._applyCombination(x,[3])},tetrad:function(){return this._applyCombination(x,[4])}},r.fromRatio=function(t,n){if(e(t)==`object`){var i={};for(var a in t)t.hasOwnProperty(a)&&(a===`a`?i[a]=t[a]:i[a]=F(t[a]));t=i}return r(t,n)};function i(t){var n={r:0,g:0,b:0},r=1,i=null,o=null,c=null,u=!1,d=!1;return typeof t==`string`&&(t=z(t)),e(t)==`object`&&(R(t.r)&&R(t.g)&&R(t.b)?(n=a(t.r,t.g,t.b),u=!0,d=String(t.r).substr(-1)===`%`?`prgb`:`rgb`):R(t.h)&&R(t.s)&&R(t.v)?(i=F(t.s),o=F(t.v),n=l(t.h,i,o),u=!0,d=`hsv`):R(t.h)&&R(t.s)&&R(t.l)&&(i=F(t.s),c=F(t.l),n=s(t.h,i,c),u=!0,d=`hsl`),t.hasOwnProperty(`a`)&&(r=t.a)),r=O(r),{ok:u,format:t.format||d,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:r}}function a(e,t,n){return{r:k(e,255)*255,g:k(t,255)*255,b:k(n,255)*255}}function o(e,t,n){e=k(e,255),t=k(t,255),n=k(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,l:s}}function s(e,t,n){var r,i,a;e=k(e,360),t=k(t,100),n=k(n,100);function o(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function c(e,t,n){e=k(e,255),t=k(t,255),n=k(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,v:s}}function l(e,t,n){e=k(e,360)*6,t=k(t,100),n=k(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),c=r%6,l=[n,o,a,a,s,n][c],u=[s,n,n,o,a,a][c],d=[a,a,s,n,n,o][c];return{r:l*255,g:u*255,b:d*255}}function u(e,t,n,r){var i=[P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join(``)}function d(e,t,n,r,i){var a=[P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16)),P(I(r))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join(``)}function f(e,t,n,r){return[P(I(r)),P(Math.round(e).toString(16)),P(Math.round(t).toString(16)),P(Math.round(n).toString(16))].join(``)}r.equals=function(e,t){return!e||!t?!1:r(e).toRgbString()==r(t).toRgbString()},r.random=function(){return r.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function p(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.s-=t/100,n.s=A(n.s),r(n)}function m(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.s+=t/100,n.s=A(n.s),r(n)}function h(e){return r(e).desaturate(100)}function g(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.l+=t/100,n.l=A(n.l),r(n)}function _(e,t){t=t===0?0:t||10;var n=r(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),r(n)}function v(e,t){t=t===0?0:t||10;var n=r(e).toHsl();return n.l-=t/100,n.l=A(n.l),r(n)}function y(e,t){var n=r(e).toHsl(),i=(n.h+t)%360;return n.h=i<0?360+i:i,r(n)}function b(e){var t=r(e).toHsl();return t.h=(t.h+180)%360,r(t)}function x(e,t){if(isNaN(t)||t<=0)throw Error(`Argument to polyad must be a positive number`);for(var n=r(e).toHsl(),i=[r(e)],a=360/t,o=1;o<t;o++)i.push(r({h:(n.h+o*a)%360,s:n.s,l:n.l}));return i}function S(e){var t=r(e).toHsl(),n=t.h;return[r(e),r({h:(n+72)%360,s:t.s,l:t.l}),r({h:(n+216)%360,s:t.s,l:t.l})]}function C(e,t,n){t||=6,n||=30;var i=r(e).toHsl(),a=360/n,o=[r(e)];for(i.h=(i.h-(a*t>>1)+720)%360;--t;)i.h=(i.h+a)%360,o.push(r(i));return o}function w(e,t){t||=6;for(var n=r(e).toHsv(),i=n.h,a=n.s,o=n.v,s=[],c=1/t;t--;)s.push(r({h:i,s:a,v:o})),o=(o+c)%1;return s}r.mix=function(e,t,n){n=n===0?0:n||50;var i=r(e).toRgb(),a=r(t).toRgb(),o=n/100;return r({r:(a.r-i.r)*o+i.r,g:(a.g-i.g)*o+i.g,b:(a.b-i.b)*o+i.b,a:(a.a-i.a)*o+i.a})},r.readability=function(e,t){var n=r(e),i=r(t);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},r.isReadable=function(e,t,n){var i=r.readability(e,t),a,o=!1;switch(a=B(n),a.level+a.size){case`AAsmall`:case`AAAlarge`:o=i>=4.5;break;case`AAlarge`:o=i>=3;break;case`AAAsmall`:o=i>=7;break}return o},r.mostReadable=function(e,t,n){var i=null,a=0,o,s,c,l;n||={},s=n.includeFallbackColors,c=n.level,l=n.size;for(var u=0;u<t.length;u++)o=r.readability(e,t[u]),o>a&&(a=o,i=r(t[u]));return r.isReadable(e,i,{level:c,size:l})||!s?i:(n.includeFallbackColors=!1,r.mostReadable(e,[`#fff`,`#000`],n))};var T=r.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},E=r.hexNames=D(T);function D(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function O(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function k(e,t){M(e)&&(e=`100%`);var n=N(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function A(e){return Math.min(1,Math.max(0,e))}function j(e){return parseInt(e,16)}function M(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function N(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function P(e){return e.length==1?`0`+e:``+e}function F(e){return e<=1&&(e=e*100+`%`),e}function I(e){return Math.round(parseFloat(e)*255).toString(16)}function ee(e){return j(e)/255}var L=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function R(e){return!!L.CSS_UNIT.exec(e)}function z(e){e=e.replace(t,``).replace(n,``).toLowerCase();var r=!1;if(T[e])e=T[e],r=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var i;return(i=L.rgb.exec(e))?{r:i[1],g:i[2],b:i[3]}:(i=L.rgba.exec(e))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=L.hsl.exec(e))?{h:i[1],s:i[2],l:i[3]}:(i=L.hsla.exec(e))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=L.hsv.exec(e))?{h:i[1],s:i[2],v:i[3]}:(i=L.hsva.exec(e))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=L.hex8.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),a:ee(i[4]),format:r?`name`:`hex8`}:(i=L.hex6.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),format:r?`name`:`hex`}:(i=L.hex4.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),a:ee(i[4]+``+i[4]),format:r?`name`:`hex8`}:(i=L.hex3.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),format:r?`name`:`hex`}:!1}function B(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}return r}))})),v5=H(((e,t)=>{let n=_5(),r={r:256,g:256,b:256,a:1},i={h:360,s:1,v:1,a:1};function a(e,t,n){let r={};for(let i in e)e.hasOwnProperty(i)&&(r[i]=n===0?0:(t[i]-e[i])/n);return r}function o(e,t,n,r){let i={};for(let a in t)t.hasOwnProperty(a)&&(i[a]=e[a]*n+t[a],i[a]=i[a]<0?i[a]+r[a]:r[a]===1?i[a]:i[a]%r[a]);return i}function s(e,t,i){let s=e.color.toRgb(),c=a(s,t.color.toRgb(),i),l=[e.color];for(let e=1;e<i;e++){let t=o(c,s,e,r);l.push(n(t))}return l}function c(e,t,r,c){let l=e.color.toHsv(),u=t.color.toHsv();if(l.s===0||u.s===0)return s(e,t,r);let d;if(typeof c==`boolean`)d=c;else{let e=l.h<u.h&&u.h-l.h<180||l.h>u.h&&l.h-u.h>180;d=c===`long`&&e||c===`short`&&!e}let f=a(l,u,r),p=[e.color],m;m=l.h<=u.h&&!d||l.h>=u.h&&d?u.h-l.h:d?360-u.h+l.h:360-l.h+u.h,f.h=(-1)**(d?1:0)*Math.abs(m)/r;for(let e=1;e<r;e++){let t=o(f,l,e,i);p.push(n(t))}return p}function l(e,t){let n=e.length;if(t=parseInt(t,10),isNaN(t)||t<2)throw Error(`Invalid number of steps (< 2)`);if(t<n)throw Error(`Number of steps cannot be inferior to number of stops`);let r=[];for(let i=1;i<n;i++){let n=(t-1)*(e[i].pos-e[i-1].pos);r.push(Math.max(1,Math.round(n)))}let i=1;for(let e=n-1;e--;)i+=r[e];for(;i!==t;)if(i<t){let e=Math.min.apply(null,r);r[r.indexOf(e)]++,i++}else{let e=Math.max.apply(null,r);r[r.indexOf(e)]--,i--}return r}function u(e,t,r,i){if(t<0||t>1)throw Error(`Position must be between 0 and 1`);let s,c;for(let n=0,r=e.length;n<r-1;n++)if(t>=e[n].pos&&t<e[n+1].pos){s=e[n],c=e[n+1];break}return s||=c=e[e.length-1],n(o(a(s.color[r](),c.color[r](),(c.pos-s.pos)*100),s.color[r](),(t-s.pos)*100,i))}var d=class e{constructor(e){if(e.length<2)throw Error(`Invalid number of stops (< 2)`);let t=e[0].pos!==void 0,r=e.length,i=-1,a=!1;this.stops=e.map((e,o)=>{let s=e.pos!==void 0;if(t^s)throw Error(`Cannot mix positionned and not posionned color stops`);if(s){let t=e.color!==void 0;if(!t&&(a||o===0||o===r-1))throw Error(`Cannot define two consecutive position-only stops`);if(a=!t,e={color:t?n(e.color):null,colorLess:!t,pos:e.pos},e.pos<0||e.pos>1)throw Error(`Color stops positions must be between 0 and 1`);if(e.pos<i)throw Error(`Color stops positions are not ordered`);i=e.pos}else e={color:n(e.color===void 0?e:e.color),pos:o/(r-1)};return e}),this.stops[0].pos!==0&&(this.stops.unshift({color:this.stops[0].color,pos:0}),r++),this.stops[r-1].pos!==1&&this.stops.push({color:this.stops[r-1].color,pos:1})}reverse(){let t=[];return this.stops.forEach(function(e){t.push({color:e.color,pos:1-e.pos})}),new e(t.reverse())}loop(){let t=[],n=[];return this.stops.forEach(e=>{t.push({color:e.color,pos:e.pos/2})}),this.stops.slice(0,-1).forEach(e=>{n.push({color:e.color,pos:1-e.pos/2})}),new e(t.concat(n.reverse()))}rgb(e){let t=l(this.stops,e),n=[];this.stops.forEach((e,t)=>{e.colorLess&&(e.color=s(this.stops[t-1],this.stops[t+1],2)[1])});for(let e=0,r=this.stops.length;e<r-1;e++){let r=s(this.stops[e],this.stops[e+1],t[e]);n.splice(n.length,0,...r)}return n.push(this.stops[this.stops.length-1].color),n}hsv(e,t){let n=l(this.stops,e),r=[];this.stops.forEach((e,n)=>{e.colorLess&&(e.color=c(this.stops[n-1],this.stops[n+1],2,t)[1])});for(let e=0,i=this.stops.length;e<i-1;e++){let i=c(this.stops[e],this.stops[e+1],n[e],t);r.splice(r.length,0,...i)}return r.push(this.stops[this.stops.length-1].color),r}css(e,t){e||=`linear`,t||=e===`linear`?`to right`:`ellipse at center`;let n=e+`-gradient(`+t;return this.stops.forEach(function(e){n+=`, `+(e.colorLess?``:e.color.toRgbString()+` `)+e.pos*100+`%`}),n+=`)`,n}rgbAt(e){return u(this.stops,e,`toRgb`,r)}hsvAt(e){return u(this.stops,e,`toHsv`,i)}};t.exports=function(e){if(arguments.length===1){if(!Array.isArray(arguments[0]))throw Error(`"stops" is not an array`);e=arguments[0]}else e=Array.prototype.slice.call(arguments);return new d(e)}})),y5=Ee({atlas:()=>O5,cristal:()=>k5,default:()=>x5,fruit:()=>F5,instagram:()=>I5,mind:()=>j5,morning:()=>M5,multiline:()=>w5,passion:()=>P5,pastel:()=>B5,rainbow:()=>z5,retro:()=>L5,summer:()=>R5,teen:()=>A5,vice:()=>N5}),b5=Oe(v5(),1);const x5=(...e)=>{let t,n;if(e.length===0)throw Error(`Missing gradient colors`);if(Array.isArray(e[0]))t=(0,b5.default)(e[0]),n=T5(e[1]);else{if(e.length===1)throw Error(`Expected an array of colors, received ${JSON.stringify(e[0])}`);t=(0,b5.default)(...e)}let r=(e,r)=>C5(e?e.toString():``,t,r??n);return r.multiline=(e,r)=>w5(e?e.toString():``,t,r??n),r},S5=(e,t,n)=>t.interpolation?.toLowerCase()===`hsv`?e.hsv(n,t.hsvSpin?.toLowerCase()||!1):e.rgb(n);function C5(e,t,n){let r=S5(t,T5(n),Math.max(e.replace(/\s/g,``).length,t.stops.length)),i=``;for(let t of e)i+=t.match(/\s/g)?t:pj.hex(r.shift()?.toHex()||`#000`)(t);return i}function w5(e,t,n){let r=T5(n),i=e.split(`
|
|
85934
|
+
`),a=S5(t,r,Math.max(...i.map(e=>e.length),t.stops.length)),o=[];for(let e of i){let t=a.slice(0),n=``;for(let r of e)n+=pj.hex(t.shift()?.toHex()||`#000`)(r);o.push(n)}return o.join(`
|
|
85935
|
+
`)}function T5(e){let t={interpolation:`rgb`,hsvSpin:`short`,...e};if(e!==void 0&&typeof e!=`object`)throw TypeError(`Expected \`options\` to be an \`object\`, got \`${typeof e}\``);if(typeof t.interpolation!=`string`)throw TypeError(`Expected \`options.interpolation\` to be \`rgb\` or \`hsv\`, got \`${typeof t.interpolation}\``);if(t.interpolation.toLowerCase()===`hsv`&&typeof t.hsvSpin!=`string`)throw TypeError(`Expected \`options.hsvSpin\` to be a \`short\` or \`long\`, got \`${typeof t.hsvSpin}\``);return t}const E5={atlas:{colors:[`#feac5e`,`#c779d0`,`#4bc0c8`],options:{}},cristal:{colors:[`#bdfff3`,`#4ac29a`],options:{}},teen:{colors:[`#77a1d3`,`#79cbca`,`#e684ae`],options:{}},mind:{colors:[`#473b7b`,`#3584a7`,`#30d2be`],options:{}},morning:{colors:[`#ff5f6d`,`#ffc371`],options:{interpolation:`hsv`}},vice:{colors:[`#5ee7df`,`#b490ca`],options:{interpolation:`hsv`}},passion:{colors:[`#f43b47`,`#453a94`],options:{}},fruit:{colors:[`#ff4e50`,`#f9d423`],options:{}},instagram:{colors:[`#833ab4`,`#fd1d1d`,`#fcb045`],options:{}},retro:{colors:[`#3f51b1`,`#5a55ae`,`#7b5fac`,`#8f6aae`,`#a86aa4`,`#cc6b8e`,`#f18271`,`#f3a469`,`#f7c978`],options:{}},summer:{colors:[`#fdbb2d`,`#22c1c3`],options:{}},rainbow:{colors:[`#ff0000`,`#ff0100`],options:{interpolation:`hsv`,hsvSpin:`long`}},pastel:{colors:[`#74ebd5`,`#74ecd5`],options:{interpolation:`hsv`,hsvSpin:`long`}}};function D5(e){let t=t=>x5(...e.colors)(t,e.options);return t.multiline=(t=``)=>x5(...e.colors).multiline(t,e.options),t}const O5=D5(E5.atlas),k5=D5(E5.cristal),A5=D5(E5.teen),j5=D5(E5.mind),M5=D5(E5.morning),N5=D5(E5.vice),P5=D5(E5.passion),F5=D5(E5.fruit),I5=D5(E5.instagram),L5=D5(E5.retro),R5=D5(E5.summer),z5=D5(E5.rainbow),B5=D5(E5.pastel);x5.atlas=O5,x5.cristal=k5,x5.teen=A5,x5.mind=j5,x5.morning=M5,x5.vice=N5,x5.passion=P5,x5.fruit=F5,x5.instagram=I5,x5.retro=L5,x5.summer=R5,x5.rainbow=z5,x5.pastel=B5;const V5=(0,X.memo)(e=>{let t=(0,X.useMemo)(()=>e.name?y5[e.name]:x5(...e.colors),[e.name,e.colors]);return(0,Y.jsx)(Q,{transform:e=>t.multiline(B1(e)),children:e.children})});V5.displayName=`Gradient`;const H5=(0,X.memo)(()=>{let{width:e}=k1(),{colors:t}=bz(),n=(0,X.useMemo)(()=>[t.gradientStart,t.gradientMid,t.gradientEnd],[t]);return e<=50?(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,flexWrap:`wrap`,children:[(0,Y.jsx)(V5,{colors:n,children:(0,Y.jsx)(Q,{children:`Abacus AI`})}),(0,Y.jsxs)(Q,{color:t.textMuted,children:[`v`,hj.default.version]})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(V5,{colors:n,children:(0,Y.jsx)(Q,{children:` ▗▄▖ ▗▄▄▖ ▗▄▖ ▗▄▄▖▗▖ ▗▖ ▗▄▄▖ ▗▄▖ ▗▄▄▄▖ ▗▄▄▖▗▖ ▗▄▄▄▖
|
|
85936
85936
|
▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ ▐▌▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
|
|
85937
85937
|
▐▛▀▜▌▐▛▀▚▖▐▛▀▜▌▐▌ ▐▌ ▐▌ ▝▀▚▖▐▛▀▜▌ █ ▐▌ ▐▌ █
|
|
85938
|
-
▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `})}),(0,Y.jsxs)(Q,{color:t.textMuted,children:[`v`,hj.default.version]})]})});L5.displayName=`Header`;const R5=`baking.beaming.booping.bouncing.brewing.bubbling.chasing.churning.coalescing.conjuring.cooking.crafting.crunching.cuddling.dancing.dazzling.discovering.doodling.dreaming.drifting.enchanting.exploring.finding.floating.fluttering.foraging.forging.frolicking.gathering.giggling.gliding.greeting.growing.hatching.herding.honking.hopping.hugging.humming.imagining.inventing.jingling.juggling.jumping.kindling.knitting.launching.leaping.mapping.marinating.meandering.mixing.moseying.munching.napping.nibbling.noodling.orbiting.painting.percolating.petting.plotting.pondering.popping.prancing.purring.puzzling.questing.riding.roaming.rolling.sauteeing.scribbling.seeking.shimmying.singing.skipping.sleeping.snacking.sniffing.snuggling.soaring.sparking.spinning.splashing.sprouting.squishing.stargazing.stirring.strolling.swimming.swinging.tickling.tinkering.toasting.tumbling.twirling.waddling.wandering.watching.weaving.whistling.wibbling.wiggling.wishing.wobbling.wondering.yawning.zooming`.split(`.`);function z5(e){return e.charAt(0).toUpperCase()+e.slice(1)}function B5(){return R5[Math.floor(Math.random()*R5.length)]}function V5(e,t){let[n,r]=(0,X.useState)(0),i=(0,X.useRef)(null);if((0,X.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{r(e=>e+1)},500);return()=>clearInterval(t)},[e]),!e)return null;let a=Date.now();if(t){if(i.current===null&&(i.current=t+5e3),a>i.current)return null;let n=t-e;return n<5e3?`thought`:`thought for ${W0(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${W0(o)}`}function H5(e){let[,t]=(0,X.useState)(0);if((0,X.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e]),!e)return null;let n=Date.now()-e;return n<5e3?null:W0(n)}const U5=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=NQ(),[a,o]=(0,X.useState)(()=>B5()),s=(0,X.useRef)(Cl.Idle);(0,X.useEffect)(()=>{s.current===Cl.Idle&&e!==Cl.Idle&&o(B5()),s.current=e},[e]);let c=V5(t,n),l=H5(r);if(!(e!==Cl.Idle&&e!==Cl.WaitingForToolPermission))return null;let u=e===Cl.LoadingConversation?`Resuming`:z5(a);return(0,Y.jsxs)(Z,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,Y.jsx)(v2,{text:`${u}...`}),c&&(0,Y.jsxs)(Q,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,Y.jsx)(Q,{dimColor:!0,children:l}),e!==Cl.LoadingConversation&&(0,Y.jsx)(Q,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})},W5=new Set([`read_file`,`list_dir`,`grep`,`file_search`,`semantic_search_server`,`web_search`,`web_fetch`,`get_tab_content`,`bash_output`,`kill_shell`,`get_interactive_elements`,`navigate_to`,`new_tab`,`switch_active_tab`,`close_tab`,`refresh_tab`,`get_diagnostics`]);function G5(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function K5(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function q5(e){let t=G5(e),n=K5(e),r=q$[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function J5(e){switch(e){case`read_file`:return`read`;case`list_dir`:return`list`;case`grep`:case`file_search`:case`semantic_search_server`:return`search`;case`web_search`:return`web`;case`web_fetch`:return`fetch`;case`navigate_to`:case`new_tab`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:return`browser`;case`bash_output`:return`terminal`;case`kill_shell`:return`terminal`;case`get_diagnostics`:return`diag`;default:return`other`}}function Y5(e){let t=[];function n(e,n,r){let i=n+r;if(i===0)return;let a;if(r>0)switch(e){case`search`:a=i===1?`searching for 1 pattern`:`searching for ${i} patterns`;break;case`read`:a=i===1?`reading 1 file`:`reading ${i} files`;break;case`list`:a=i===1?`listing 1 directory`:`listing ${i} directories`;break;case`web`:a=i===1?`searching the web`:`searching the web ${i} times`;break;case`fetch`:a=i===1?`fetching 1 URL`:`fetching ${i} URLs`;break;case`browser`:a=i===1?`navigating browser`:`navigating browser ${i} times`;break;case`terminal`:a=`getting terminal output`;break;case`diag`:a=`checking diagnostics`;break;default:a=i===1?`1 operation`:`${i} operations`;break}else switch(e){case`search`:a=n===1?`searched for 1 pattern`:`searched for ${n} patterns`;break;case`read`:a=n===1?`read 1 file`:`read ${n} files`;break;case`list`:a=n===1?`listed 1 directory`:`listed ${n} directories`;break;case`web`:a=n===1?`searched the web`:`searched the web ${n} times`;break;case`fetch`:a=n===1?`fetched 1 URL`:`fetched ${n} URLs`;break;case`browser`:a=n===1?`navigated browser`:`navigated browser ${n} times`;break;case`terminal`:a=`got terminal output`;break;case`diag`:a=`checked diagnostics`;break;default:a=n===1?`1 operation`:`${n} operations`;break}t.push(a)}for(let t of[`search`,`read`,`list`,`web`,`fetch`,`browser`,`terminal`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const X5=(0,X.memo)(({segments:e})=>{let{colors:t}=bz(),n={},r=null,i=!1,a=!1;for(let t of e){let e=J5(G5(t)),o=!t.toolUseResult;if(n[e]||(n[e]={completed:0,executing:0}),o)n[e].executing++,r=t,i=!0;else{n[e].completed++;let r=t.toolUseResult;(r?.rejected||r?.content?.startsWith(`Error:`))&&(a=!0)}}let o=Y5(n),s=o.charAt(0).toUpperCase()+o.slice(1),c=r?q5(r):null;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`center`,children:[i?(0,Y.jsx)(hJ,{}):(0,Y.jsx)(Q,{color:a?`red`:i?`white`:`green`,children:`⏺`}),(0,Y.jsxs)(Q,{children:[s,i?`…`:``]}),(0,Y.jsx)(Q,{color:t.textMuted,dimColor:!0,children:`(ctrl+o to expand)`})]}),c&&(0,Y.jsxs)(Z,{flexDirection:`row`,paddingLeft:2,children:[(0,Y.jsxs)(Q,{color:t.textSubtle,dimColor:!0,children:[`⎿`,` `]}),(0,Y.jsx)(Q,{color:t.textSubtle,children:c})]})]})});X5.displayName=`ToolGroupSummary`;const Z5=(0,X.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,X.useState)(0),[i,a]=(0,X.useState)(0),[o,s]=(0,X.useState)(()=>new Map),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>new Map),f=(0,X.useRef)(null),p=(0,X.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,X.useRef)(i);g.current=i;let _=(0,X.useRef)(n);_.current=n;let v=(0,X.useRef)(c);v.current=c;let y=(0,X.useRef)(e);y.current=e;let b=(0,X.useRef)(o);b.current=o;let x=(0,X.useRef)(u);x.current=u;let S=(0,X.useCallback)((e,t)=>{let n={};for(let r=0;r<y.current.length;r++){let i=y.current[r];if(!i)continue;let a=e.get(r);if(!a||a.size===0)continue;let o=[...a].sort((e,t)=>e-t).map(e=>i.options[e]?.label??``).filter(Boolean),s=t.get(r);n[`question_${r}`]=s?`${o.join(`, `)} — ${s}`:o.join(`, `)}return n},[]),C=(0,X.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,X.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,X.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,X.useRef)(T);E.current=T;let D=(0,X.useCallback)(e=>{if(e.key.return){let t=p(f.current?.text?.trim()??``),n=_.current,r=new Map(x.current);t?r.set(n,t):r.delete(n),d(r),l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.escape){l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.tab){l(!1),f.current?.setText(``),e.preventDefault();return}},[p]),O=(0,X.useCallback)(e=>{let t=_.current,n=new Map(x.current),r=p(e.trim());r?n.set(t,r):n.delete(t),d(n),l(!1),f.current?.setText(``)},[p]);if(HL((0,X.useCallback)((e,t)=>{if(v.current)return;let n=_.current,i=y.current[n];if(!i)return;let o=i.options.length;if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o-1,e+1));return}if(t.leftArrow){n>0&&(r(n-1),a(0),l(!1));return}if(t.rightArrow){n<y.current.length-1&&(r(n+1),a(0),l(!1));return}if(e===` `){let e=g.current,t=new Map(b.current),r=new Set(t.get(n)??[]);i.multiSelect?r.has(e)?r.delete(e):r.add(e):(r.clear(),r.add(e)),t.set(n,r),s(t);return}if(t.return){if((b.current.get(n)??new Set).size===0&&!i.multiSelect){let e=g.current,t=new Map(b.current),r=new Set([e]);t.set(n,r),s(t),w(n+1,t,x.current)}else E.current();return}if(t.tab){l(!0),setTimeout(()=>{let e=x.current.get(n)??``;f.current&&e&&f.current.setText(e)},0);return}if(t.escape){C(b.current,x.current);return}},[w,C]),{isActive:!c}),!m)return null;let k=u.get(n);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{children:m.question})}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:m.options.map((e,t)=>{let n=t===i,r=h.has(t),a=m.multiSelect?r?`[x] `:`[ ] `:r?`◉ `:`○ `;return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,Y.jsxs)(Q,{color:r?`green`:n?void 0:`gray`,children:[a,e.label]}),e.description?(0,Y.jsxs)(Q,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:`cyan`,children:`❯ `}),(0,Y.jsx)(Q,{dimColor:!0,children:`Note: `}),(0,Y.jsx)(L0,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`Note: `,(0,Y.jsx)(Q,{italic:!0,children:k})]})}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`enter save note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc discard note`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`↑↓ option`}),(0,Y.jsx)(Q,{dimColor:!0,children:`space select`}),(0,Y.jsx)(Q,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,Y.jsx)(Q,{dimColor:!0,children:`←→ navigate`}),(0,Y.jsx)(Q,{dimColor:!0,children:`tab add note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc skip`})]})})]})});Z5.displayName=`AskUserQuestionPermissionUI`;const Q5=(0,X.memo)(({option:e,index:t,isSelected:n,showAsInput:r,inputPlaceholder:i,inputPrefix:a,inputBufferRef:o,onInputSubmit:s,onInputKeyDown:c})=>r?(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:`cyan`,children:`❯ `}),(0,Y.jsx)(Q,{children:`${t+1}. ${a||``}`}),(0,Y.jsx)(L0,{ref:o,flexGrow:1,maxWidth:`90%`,placeholder:i,onSubmit:s,onKeyDown:c})]}):(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,Y.jsxs)(Q,{color:n?void 0:`gray`,children:[`${t+1}. ${e.label}`,e.hint&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));Q5.displayName=`PermissionOptionItem`;const $5=(0,X.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,X.useState)(0),[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useCallback)(e=>l.current?.getExpandedText(e)??e,[]),d=(0,X.useCallback)(()=>{},[]),f=(0,X.useRef)(``),p=(0,X.useRef)(``),m=(0,X.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),h=s,g=(0,X.useRef)(a);g.current=a;let _=(0,X.useRef)(m.length);_.current=m.length;let v=(0,X.useRef)(h);v.current=h;let y=(0,X.useRef)(t);y.current=t;let b=(0,X.useRef)(r);b.current=r;let x=(0,X.useRef)(m);x.current=m;let S=(0,X.useCallback)(()=>{let e=x.current[g.current];if(e)if(v.current){let t=l.current?.text?.trim();if(t){let n=u(t),r=e.value===`accept`?`accept`:`reject`;y.current({decision:r,userMessage:n,rule:e.hint}),d()}}else e.value!==`input`&&y.current({decision:e.value,rule:e.hint})},[u,d]),C=(0,X.useRef)(S);C.current=S;let w=(0,X.useCallback)(e=>{if(e.trim()){let t=x.current[g.current],n=u(e.trim()),r=t?.value===`accept`?`accept`:`reject`;y.current({decision:r,userMessage:n}),d()}},[u,d]),T=(0,X.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=x.current[g.current],n=l.current?.text||``;t?.value===`accept`?f.current=n:t?.value===`reject`&&(p.current=n),c(!1),e.key.upArrow?o(e=>Math.max(0,e-1)):o(e=>Math.min(_.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=x.current[g.current];t?.value===`accept`?f.current=``:t?.value===`reject`&&(p.current=``),d(),c(!1),e.preventDefault();return}if(e.key.escape){d(),c(!1),y.current({decision:`reject`}),e.preventDefault();return}},[d]);HL((0,X.useCallback)((e,t)=>{if(!v.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(_.current-1,e+1));return}if(t.escape){y.current({decision:`reject`});return}if(t.tab&&t.shift){if(b.current){b.current();return}let e=x.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{y.current({decision:`allowAlways`})},0));return}if(t.tab){let e=x.current[g.current];if(e&&(e.value===`accept`||e.value===`reject`)){c(!0);let t=e.value===`accept`?f.current:p.current;setTimeout(()=>{l.current&&t&&l.current.setText(t)},0)}return}if(t.return){C.current();return}}},[]),{isActive:!0}),(0,X.useEffect)(()=>{let e=m[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?f.current:p.current)&&!s&&c(!0))},[a,m,s]);let E=(0,X.useRef)(!1);(0,X.useEffect)(()=>{s&&(E.current=!0)},[s]),(0,X.useEffect)(()=>{if(!s||!E.current)return;let e=m[a];if(!e)return;let t=e.value===`accept`?f.current:e.value===`reject`?p.current:``;t?setTimeout(()=>{l.current&&l.current.text===``&&l.current.setText(t),E.current=!1},0):E.current=!1},[s,a,m]);let D=m[a],O=s&&D,k=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,A=!s&&D&&(D.value===`accept`||D.value===`reject`),j=m.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[m.map((e,t)=>{let r=t===a,i=O&&r,o=e.value===`accept`?f.current:e.value===`reject`?p.current:``;return(0,Y.jsx)(Q5,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,inputPrefix:k(e),inputPlaceholder:n,inputBufferRef:l,onInputSubmit:w,onInputKeyDown:T},t)}),(0,Y.jsx)(Z,{flexDirection:`row`,marginTop:1,gap:2,children:s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`enter submit`}),(0,Y.jsx)(Q,{dimColor:!0,children:`tab discard note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc reject`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`↑↓ navigate`}),(0,Y.jsx)(Q,{dimColor:!0,children:`enter select`}),A&&(0,Y.jsx)(Q,{dimColor:!0,children:`tab add note`}),i&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`shift+tab `,i]}),!i&&j&&(0,Y.jsx)(Q,{dimColor:!0,children:`shift+tab don't ask again`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc reject`})]})})]})});$5.displayName=`PermissionOptions`;function e7(e){return e.decision===`accept`&&e.userMessage?{type:`accept_with_message`,message:e.userMessage}:e.decision===`reject`&&e.userMessage?{type:`reject_with_message`,message:e.userMessage}:e.decision===`allowAlwaysWithRule`?e.rule?{type:`allow_always_with_rule`,rule:e.rule}:`accept`:e.decision===`allowAlwaysWithRules`?e.rules?{type:`allow_always_with_rules`,rules:e.rules}:`accept`:e.decision}const t7=(0,X.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=FJ(),s=o===Sl.PlanMode,c=HD(e,process.cwd()),l=[{label:`Yes, apply changes`,value:`accept`},...s?[]:[{label:`Yes, and always allow Edit(${c})`,value:`allowAlwaysWithRule`}],{label:`No, reject changes`,value:`reject`}],u=e=>{if(e.decision===`allowAlwaysWithRule`){i({type:`allow_always_with_rule`,rule:`Edit(${c})`});return}i(e7(e))};return r?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:l,onSelect:u,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`${a?`Create`:`Update`} file ${e}`}),a?(0,Y.jsx)(xJ,{filePath:e,content:n,maxLines:100}):(0,Y.jsx)(bY,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:l,onSelect:u,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});t7.displayName=`EditFilePermissionUI`;const n7=(0,X.memo)(({filePath:e,onResolve:t})=>(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Delete file ${e}`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{color:`red`,children:e})}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:[{label:`Yes, delete file`,value:`accept`},{label:`No, keep file`,value:`reject`}],onSelect:e=>{t(e7(e))}})})]}));n7.displayName=`DeleteFilePermissionUI`;const r7=(0,X.memo)(({description:e,url:t,displayName:n,onResolve:r})=>{let i=[{label:`Yes, allow action`,value:`accept`},{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`},{label:`No, deny action`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Browser action: ${e}`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:e}),t&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`URL: `,t]})]}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:i,onSelect:e=>{if(e.decision===`allowAlwaysWithRule`){r({type:`allow_always_with_rule`,rule:n});return}r(e7(e))}})})]})});r7.displayName=`BrowserActionPermissionUI`;const i7=(0,X.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let{colors:i}=bz(),a=(0,X.useMemo)(()=>LU(i),[i]),o=od(e),s=(0,X.useMemo)(()=>{let e=[{label:`Yes, run command`,value:`accept`}];if(n.length>1){e.push({label:`Yes, and always allow all: ${n.map(e=>`Bash(${e})`).join(`, `)}`,value:`allowAlwaysWithRules`});for(let t of n)e.push({label:`Yes, and always allow Bash(${t})`,value:`allowAlwaysWithRule`,hint:t})}else n.length===1?e.push({label:`Yes, and always allow Bash(${n[0]})`,value:`allowAlwaysWithRule`,hint:n[0]}):e.push({label:`Yes, and always allow Bash(${o})`,value:`allowAlwaysWithRule`});return e.push({label:`No, skip command`,value:`reject`}),e},[n,o]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Bash command`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:(0,FU.supportsLanguage)(`bash`)?(()=>{try{return(0,FU.highlight)(e,{language:`bash`,theme:a})}catch{return e}})():e}),t&&(0,Y.jsx)(Z,{paddingTop:1,children:(0,Y.jsx)(Q,{dimColor:!0,children:`(Running in background)`})})]}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:s,onSelect:e=>{if(e.decision===`allowAlwaysWithRules`){r({type:`allow_always_with_rules`,rules:n.map(e=>`Bash(${e})`)});return}if(e.decision===`allowAlwaysWithRule`){r({type:`allow_always_with_rule`,rule:e.rule?`Bash(${e.rule})`:`Bash(${n[0]??o})`});return}r(e7(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});i7.displayName=`RunTerminalPermissionUI`;const a7=(0,X.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let{colors:i}=bz(),a=(0,X.useMemo)(()=>LU(i),[i]),o=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`}]:[],{label:`No, deny`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:e}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{children:(0,FU.supportsLanguage)(`json`)?(()=>{try{return(0,FU.highlight)(t,{language:`json`,theme:a})}catch{return t}})():t})}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:o,onSelect:e=>{if(e.decision===`allowAlwaysWithRule`&&n){r({type:`allow_always_with_rule`,rule:n});return}r(e7(e))}})})]})});a7.displayName=`GenericPermissionUI`;const o7=(0,X.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,Y.jsx)(J8,{children:t})]}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:[{label:`Yes, implement the plan (approve each edit)`,value:`accept`},{label:`Yes, implement the plan (auto-accept all edits)`,value:`allowAlways`,hint:`shift+tab`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(e7(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));o7.displayName=`ExitPlanModePermissionUI`;const s7=(0,X.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow read`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny read`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Read file outside workspace`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:e}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Directory: `,t]})]}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:r,onSelect:e=>{n(e7(e))}})})]})});s7.displayName=`ReadOutsideDirectoryPermissionUI`;const c7=(0,X.memo)(({notebookPath:e,cellId:t,editMode:n,cellType:r,originalContent:i,newContent:a,onResolve:o})=>{let s=n??`replace`,c=``;c=s===`delete`?`Delete cell${t?` ${t}`:``}`:s===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${r??`code`})`:`Replace cell contents for cell ${t??`unknown`}`;let l=HD(e,process.cwd()),u=[{label:`Yes, apply changes`,value:`accept`},{label:`Yes, and always allow Edit(${l})`,value:`allowAlwaysWithRule`},{label:`No, reject changes`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(a2,{title:`Edit notebook`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:e}),(0,Y.jsx)(Q,{dimColor:!0,children:c})]}),s===`delete`?(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,Y.jsx)(xJ,{filePath:e,content:a,maxLines:100}):(0,Y.jsx)(bY,{filePath:e,originalContent:i,newContent:a,paddingLeft:1}),(0,Y.jsx)(Z,{borderStyle:i2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)($5,{options:u,onSelect:e=>{if(e.decision===`allowAlwaysWithRule`){o({type:`allow_always_with_rule`,rule:`Edit(${l})`});return}o(e7(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});c7.displayName=`NotebookEditPermissionUI`;const l7=(0,X.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,Y.jsx)(t7,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`delete_file`:return(0,Y.jsx)(n7,{filePath:t.filePath,onResolve:n});case`run_terminal`:return(0,Y.jsx)(i7,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,Y.jsx)(r7,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,Y.jsx)(a7,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,Y.jsx)(s7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,Y.jsx)(o7,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,Y.jsx)(Z5,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,Y.jsx)(c7,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});l7.displayName=`ToolPermissionUI`;function u7(e){let t=(0,X.useRef)(!1),n=(0,X.useRef)(e);(0,X.useEffect)(()=>{n.current=e},[e]),(0,X.useEffect)(()=>{let e=()=>{t.current||(t.current=!0,n.current())};return process.on(`exit`,e),process.on(`SIGINT`,e),process.on(`SIGTERM`,e),()=>{e(),process.off(`exit`,e),process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[])}const d7=(0,X.createContext)(null),f7=()=>{let e=(0,X.use)(d7);if(!e)throw Error(`${f7.name} must be used within a ${p7.name}`);return e};function p7({children:e}){let t=(0,X.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(`${PQ.SET_TITLE}${t}${PQ.BEL}`)},[]);u7(()=>{process.stdout.write(`${PQ.SET_TITLE}${PQ.BEL}`)});let n=(0,X.useMemo)(()=>({setTitle:t}),[t]);return(0,Y.jsx)(d7.Provider,{value:n,children:e})}const m7=2e3;function h7(e,t,n){return e===Cl.ExecutingTool?`tool-executing`:e===Cl.Submitted||e===Cl.Streaming?`streaming`:e===Cl.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function g7(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueOne:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),y=(0,X.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,X.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,X.useCallback)(()=>{y(),b()},[y,b]),S=h7(t,n,i),C=(0,X.useRef)(S);return(0,X.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),HL((0,X.useEffectEvent)((e,S)=>{if(S.ctrl&&e===`z`){process.platform!==`win32`&&process.kill(process.pid,`SIGTSTP`);return}let C=S.escape,w=S.ctrl&&e===`c`,T=S.ctrl&&e===`d`;if(!C&&!w&&!T||C&&r)return;let E=h7(t,n,i);if(E===`tool-executing`||E===`streaming`){x(),o();return}if(E===`permission-ui`){x(),s();return}if(E===`idle-with-text`){if(C){p?(l(),x()):(b(),m(!0),_.current=setTimeout(()=>{m(!1),_.current=null},m7));return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},m7);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},m7);return}if(E===`idle-empty`){if(C){a()&&u();return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},m7);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},m7)}}),{isActive:!0}),(0,X.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}function _7(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function v7(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function y7(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function b7(e){let t={toolUses:0,responses:0};for(let n of e)switch(n.type){case`code_llm_tool_call`:case`code_llm_agent_tool_request`:t.toolUses+=Array.isArray(n.toolUseRequest)?n.toolUseRequest.length:1;break;case`text`:n.source===`bot`&&t.responses++;break}return t}function x7(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function S7(e){let t={toolUses:0,responses:0},n=[],r=[],i=0,a=[];for(let a=0;a<e.length;a++){let o=e[a];if(y7(o)){let e=b7(n);t=x7(t,e),r.push(...n),n=[],i++;continue}n.push(o)}i>0&&a.push({kind:`compacted`,id:`compacted-${i}`,counts:t,segments:r});let o=C7(n);return a.push(...o),a}function C7(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`thinking`){t.push({kind:`segment`,segment:r}),n++;continue}if(_7(r)&&W5.has(w7(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(v7(i[i.length-1]))break;if(_7(t)&&W5.has(w7(t)))i.push(t),a++;else break}i.length===1?t.push({kind:`segment`,segment:i[0]}):t.push({kind:`tool-group`,id:i[0].id,segments:i}),n=a;continue}t.push({kind:`segment`,segment:r}),n++}return t}function w7(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function T7(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`thinking`)return{thinkingStartTime:n.thinkingStartTime??null,thinkingEndTime:n.thinkingEndTime??null}}return{thinkingStartTime:null,thinkingEndTime:null}}function E7({timing:e}){let{setTitle:t}=f7(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,removeFirstFromQueue:u,clearQueue:d}=T$(),f=(0,X.useRef)(null),{authExpired:p,clearAuthExpired:m,apiClient:h}=c$();(0,X.useEffect)(()=>{p&&(s(`Session expired — use /login to authenticate again.`,`error`),m())},[p,s,m]);let[g,_]=(0,X.useState)(null),v=(0,X.useCallback)(()=>{_(e=>e===null?n.filter(e=>!e.temp&&!e.isSpinny):null)},[n]);HL((0,X.useCallback)((e,t)=>{(t.ctrl||t.super)&&e===`o`&&v()},[v]),{isActive:g===null});let{lastItem:y,prevItems:b}=(0,X.useMemo)(()=>{let e=S7(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:x,thinkingEndTime:S}=(0,X.useMemo)(()=>T7(n),[n]),C=(0,X.useRef)(Cl.Idle),[w,T]=(0,X.useState)(null);(0,X.useEffect)(()=>{let e=C.current===Cl.Idle,t=r!==Cl.Idle&&r!==Cl.WaitingForToolPermission;e&&t?T(Date.now()):r===Cl.Idle&&T(null),C.current=r},[r]);let E=r===Cl.WaitingForToolPermission&&i!==null,[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(`0`),[j,M]=(0,X.useState)(0);(0,X.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,X.useEffect)(()=>Kj(async()=>{let t=e.getFormattedDuration(),n=0;if(o)try{n=await _1(h,o)}catch{}M(n),A(t),O(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,o,h]);let N=g7({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:g!==null,composerHasText:()=>f.current?.hasText()??!1,hasQueuedMessages:()=>f.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>f.current?.saveAndClear(),clearComposer:()=>f.current?.clear(),dequeueOne:u,clearQueue:d,exitApp:()=>qj(0)}),P=r!==Cl.Idle&&r!==Cl.WaitingForToolPermission,F=i?.request.tool.id??null;return g===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,Y.jsx)(L5,{}),(0,Y.jsxs)(dJ.Provider,{value:F,children:[b.map(e=>e.kind===`compacted`?(0,Y.jsx)(X$,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,Y.jsx)(l5,{segment:e.segment},e.segment.id):(0,Y.jsx)(X5,{segments:e.segments},e.id)),y&&(y.kind===`compacted`?(0,Y.jsx)(X$,{counts:y.counts,segments:y.segments},y.id):y.kind===`segment`?(0,Y.jsx)(l5,{segment:y.segment},y.segment.id):(0,Y.jsx)(X5,{segments:y.segments},y.id))]}),P&&(0,Y.jsx)(j4,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(U5,{status:r,thinkingStartTime:x,thinkingEndTime:S,runStartTime:w})})]}),D?(0,Y.jsx)(M4,{duration:k,credits:j,conversationId:o}):(0,Y.jsxs)(Y.Fragment,{children:[E&&(0,Y.jsx)(j4,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(l7,{pendingTool:i})}),(0,Y.jsx)(X.Activity,{mode:E?`hidden`:`visible`,children:(0,Y.jsx)(j4,{fallback:e=>(0,Y.jsxs)(Z,{flexDirection:`column`,paddingX:1,children:[(0,Y.jsx)(Q,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,Y.jsx)(Q,{color:`yellow`,children:e.message}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,Le.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(A4,{hints:N,composerRef:f})})})]})]}):(0,Y.jsx)(u5,{snapshot:g,onClose:()=>_(null)})}async function D7({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Sl.Yolo;break;case`accept-edits`:i=Sl.AcceptEdits;break;case`plan`:i=Sl.PlanMode;break;default:i=Sl.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Sl.Yolo:r?.[`auto-accept-edits`]?i=Sl.AcceptEdits:r?.[`plan-mode`]&&(i=Sl.PlanMode);let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(PQ.HIDE_CURSOR),l=()=>s(PQ.SHOW_CURSOR),u=!1;for(;;){u=!1;let a=new ZR,o=new U0,s=null,d=()=>{u=!0,s?.unmount()};c();let f=RL((0,Y.jsx)(xz,{children:(0,Y.jsx)(l$,{client:e,authManager:t,onAuthExpired:d,children:(0,Y.jsx)(ez,{client:a,children:(0,Y.jsx)(n1,{children:(0,Y.jsx)(p7,{children:(0,Y.jsx)(o$,{children:(0,Y.jsx)($$,{configService:n,children:(0,Y.jsx)(AQ,{children:(0,Y.jsx)(RJ,{initialMode:i,children:(0,Y.jsx)(MQ,{children:(0,Y.jsx)(w$,{apiClient:e,configService:n,agentArgs:r,children:(0,Y.jsx)(E7,{timing:o})})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
|
|
85938
|
+
▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `})}),(0,Y.jsxs)(Q,{color:t.textMuted,children:[`v`,hj.default.version]})]})});H5.displayName=`Header`;const U5=`baking.beaming.booping.bouncing.brewing.bubbling.chasing.churning.coalescing.conjuring.cooking.crafting.crunching.cuddling.dancing.dazzling.discovering.doodling.dreaming.drifting.enchanting.exploring.finding.floating.fluttering.foraging.forging.frolicking.gathering.giggling.gliding.greeting.growing.hatching.herding.honking.hopping.hugging.humming.imagining.inventing.jingling.juggling.jumping.kindling.knitting.launching.leaping.mapping.marinating.meandering.mixing.moseying.munching.napping.nibbling.noodling.orbiting.painting.percolating.petting.plotting.pondering.popping.prancing.purring.puzzling.questing.riding.roaming.rolling.sauteeing.scribbling.seeking.shimmying.singing.skipping.sleeping.snacking.sniffing.snuggling.soaring.sparking.spinning.splashing.sprouting.squishing.stargazing.stirring.strolling.swimming.swinging.tickling.tinkering.toasting.tumbling.twirling.waddling.wandering.watching.weaving.whistling.wibbling.wiggling.wishing.wobbling.wondering.yawning.zooming`.split(`.`);function W5(e){return e.charAt(0).toUpperCase()+e.slice(1)}function G5(){return U5[Math.floor(Math.random()*U5.length)]}function K5(e,t){let[n,r]=(0,X.useState)(0),i=(0,X.useRef)(null);if((0,X.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{r(e=>e+1)},500);return()=>clearInterval(t)},[e]),!e)return null;let a=Date.now();if(t){if(i.current===null&&(i.current=t+5e3),a>i.current)return null;let n=t-e;return n<5e3?`thought`:`thought for ${Y0(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${Y0(o)}`}function q5(e){let[,t]=(0,X.useState)(0);if((0,X.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e]),!e)return null;let n=Date.now()-e;return n<5e3?null:Y0(n)}const J5=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=s$(),[a,o]=(0,X.useState)(()=>G5()),s=(0,X.useRef)(Cl.Idle);(0,X.useEffect)(()=>{s.current===Cl.Idle&&e!==Cl.Idle&&o(G5()),s.current=e},[e]);let c=K5(t,n),l=q5(r);if(!(e!==Cl.Idle&&e!==Cl.WaitingForToolPermission))return null;let u=e===Cl.LoadingConversation?`Resuming`:W5(a);return(0,Y.jsxs)(Z,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,Y.jsx)(Q,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,Y.jsx)(C2,{text:`${u}...`}),c&&(0,Y.jsxs)(Q,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,Y.jsx)(Q,{dimColor:!0,children:l}),e!==Cl.LoadingConversation&&(0,Y.jsx)(Q,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})},Y5=new Set([`read_file`,`list_dir`,`grep`,`file_search`,`semantic_search_server`,`web_search`,`web_fetch`,`get_tab_content`,`bash_output`,`kill_shell`,`get_interactive_elements`,`navigate_to`,`new_tab`,`switch_active_tab`,`close_tab`,`refresh_tab`,`get_diagnostics`]);function X5(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function Z5(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function Q5(e){let t=X5(e),n=Z5(e),r=x1[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function $5(e){switch(e){case`read_file`:return`read`;case`list_dir`:return`list`;case`grep`:case`file_search`:case`semantic_search_server`:return`search`;case`web_search`:return`web`;case`web_fetch`:return`fetch`;case`navigate_to`:case`new_tab`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:return`browser`;case`bash_output`:return`terminal`;case`kill_shell`:return`terminal`;case`get_diagnostics`:return`diag`;default:return`other`}}function e7(e){let t=[];function n(e,n,r){let i=n+r;if(i===0)return;let a;if(r>0)switch(e){case`search`:a=i===1?`searching for 1 pattern`:`searching for ${i} patterns`;break;case`read`:a=i===1?`reading 1 file`:`reading ${i} files`;break;case`list`:a=i===1?`listing 1 directory`:`listing ${i} directories`;break;case`web`:a=i===1?`searching the web`:`searching the web ${i} times`;break;case`fetch`:a=i===1?`fetching 1 URL`:`fetching ${i} URLs`;break;case`browser`:a=i===1?`navigating browser`:`navigating browser ${i} times`;break;case`terminal`:a=`getting terminal output`;break;case`diag`:a=`checking diagnostics`;break;default:a=i===1?`1 operation`:`${i} operations`;break}else switch(e){case`search`:a=n===1?`searched for 1 pattern`:`searched for ${n} patterns`;break;case`read`:a=n===1?`read 1 file`:`read ${n} files`;break;case`list`:a=n===1?`listed 1 directory`:`listed ${n} directories`;break;case`web`:a=n===1?`searched the web`:`searched the web ${n} times`;break;case`fetch`:a=n===1?`fetched 1 URL`:`fetched ${n} URLs`;break;case`browser`:a=n===1?`navigated browser`:`navigated browser ${n} times`;break;case`terminal`:a=`got terminal output`;break;case`diag`:a=`checked diagnostics`;break;default:a=n===1?`1 operation`:`${n} operations`;break}t.push(a)}for(let t of[`search`,`read`,`list`,`web`,`fetch`,`browser`,`terminal`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const t7=(0,X.memo)(({segments:e})=>{let{colors:t}=bz(),n={},r=null,i=!1,a=!1;for(let t of e){let e=$5(X5(t)),o=!t.toolUseResult;if(n[e]||(n[e]={completed:0,executing:0}),o)n[e].executing++,r=t,i=!0;else{n[e].completed++;let r=t.toolUseResult;(r?.rejected||r?.content?.startsWith(`Error:`))&&(a=!0)}}let o=e7(n),s=o.charAt(0).toUpperCase()+o.slice(1),c=r?Q5(r):null;return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsxs)(Z,{flexDirection:`row`,gap:1,alignItems:`center`,children:[i?(0,Y.jsx)(hJ,{}):(0,Y.jsx)(Q,{color:a?`red`:i?`white`:`green`,children:`⏺`}),(0,Y.jsxs)(Q,{children:[s,i?`…`:``]}),(0,Y.jsx)(Q,{color:t.textMuted,dimColor:!0,children:`(ctrl+o to expand)`})]}),c&&(0,Y.jsxs)(Z,{flexDirection:`row`,paddingLeft:2,children:[(0,Y.jsxs)(Q,{color:t.textSubtle,dimColor:!0,children:[`⎿`,` `]}),(0,Y.jsx)(Q,{color:t.textSubtle,children:c})]})]})});t7.displayName=`ToolGroupSummary`;const n7=(0,X.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,X.useState)(0),[i,a]=(0,X.useState)(0),[o,s]=(0,X.useState)(()=>new Map),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>new Map),f=(0,X.useRef)(null),p=(0,X.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,X.useRef)(i);g.current=i;let _=(0,X.useRef)(n);_.current=n;let v=(0,X.useRef)(c);v.current=c;let y=(0,X.useRef)(e);y.current=e;let b=(0,X.useRef)(o);b.current=o;let x=(0,X.useRef)(u);x.current=u;let S=(0,X.useCallback)((e,t)=>{let n={};for(let r=0;r<y.current.length;r++){let i=y.current[r];if(!i)continue;let a=e.get(r);if(!a||a.size===0)continue;let o=[...a].sort((e,t)=>e-t).map(e=>i.options[e]?.label??``).filter(Boolean),s=t.get(r);n[`question_${r}`]=s?`${o.join(`, `)} — ${s}`:o.join(`, `)}return n},[]),C=(0,X.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,X.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,X.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,X.useRef)(T);E.current=T;let D=(0,X.useCallback)(e=>{if(e.key.return){let t=p(f.current?.text?.trim()??``),n=_.current,r=new Map(x.current);t?r.set(n,t):r.delete(n),d(r),l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.escape){l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.tab){l(!1),f.current?.setText(``),e.preventDefault();return}},[p]),O=(0,X.useCallback)(e=>{let t=_.current,n=new Map(x.current),r=p(e.trim());r?n.set(t,r):n.delete(t),d(n),l(!1),f.current?.setText(``)},[p]);if(HL((0,X.useCallback)((e,t)=>{if(v.current)return;let n=_.current,i=y.current[n];if(!i)return;let o=i.options.length;if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o-1,e+1));return}if(t.leftArrow){n>0&&(r(n-1),a(0),l(!1));return}if(t.rightArrow){n<y.current.length-1&&(r(n+1),a(0),l(!1));return}if(e===` `){let e=g.current,t=new Map(b.current),r=new Set(t.get(n)??[]);i.multiSelect?r.has(e)?r.delete(e):r.add(e):(r.clear(),r.add(e)),t.set(n,r),s(t);return}if(t.return){if((b.current.get(n)??new Set).size===0&&!i.multiSelect){let e=g.current,t=new Map(b.current),r=new Set([e]);t.set(n,r),s(t),w(n+1,t,x.current)}else E.current();return}if(t.tab){l(!0),setTimeout(()=>{let e=x.current.get(n)??``;f.current&&e&&f.current.setText(e)},0);return}if(t.escape){C(b.current,x.current);return}},[w,C]),{isActive:!c}),!m)return null;let k=u.get(n);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{children:m.question})}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:m.options.map((e,t)=>{let n=t===i,r=h.has(t),a=m.multiSelect?r?`[x] `:`[ ] `:r?`◉ `:`○ `;return(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,Y.jsxs)(Q,{color:r?`green`:n?void 0:`gray`,children:[a,e.label]}),e.description?(0,Y.jsxs)(Q,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:`cyan`,children:`❯ `}),(0,Y.jsx)(Q,{dimColor:!0,children:`Note: `}),(0,Y.jsx)(H0,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`Note: `,(0,Y.jsx)(Q,{italic:!0,children:k})]})}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`enter save note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc discard note`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`↑↓ option`}),(0,Y.jsx)(Q,{dimColor:!0,children:`space select`}),(0,Y.jsx)(Q,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,Y.jsx)(Q,{dimColor:!0,children:`←→ navigate`}),(0,Y.jsx)(Q,{dimColor:!0,children:`tab add note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc skip`})]})})]})});n7.displayName=`AskUserQuestionPermissionUI`;const r7=(0,X.memo)(({option:e,index:t,isSelected:n,showAsInput:r,showAsEdit:i,inputPlaceholder:a,inputPrefix:o,inputBufferRef:s,editBufferRef:c,onInputSubmit:l,onInputKeyDown:u,onEditSubmit:d,onEditKeyDown:f})=>i?(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:`cyan`,children:`❯ `}),(0,Y.jsx)(Q,{children:`${t+1}. `}),(0,Y.jsx)(H0,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:`cyan`,children:`❯ `}),(0,Y.jsx)(Q,{children:`${t+1}. ${o||``}`}),(0,Y.jsx)(H0,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,Y.jsxs)(Z,{flexDirection:`row`,children:[(0,Y.jsx)(Q,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,Y.jsxs)(Q,{color:n?void 0:`gray`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,Y.jsxs)(Q,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));r7.displayName=`PermissionOptionItem`;const i7=(0,X.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,X.useState)(0),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,X.useCallback)(()=>{},[]),h=(0,X.useRef)(``),g=(0,X.useRef)(``),_=(0,X.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),v=s,y=(0,X.useRef)(a);y.current=a;let b=(0,X.useRef)(_.length);b.current=_.length;let x=(0,X.useRef)(v);x.current=v;let S=(0,X.useRef)(l);S.current=l;let C=(0,X.useRef)(t);C.current=t;let w=(0,X.useRef)(r);w.current=r;let T=(0,X.useRef)(_);T.current=_;let E=(0,X.useCallback)(()=>{let e=T.current[y.current];if(e)if(x.current){let t=d.current?.text?.trim();if(t){let n=p(t),r=e.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:e.rules}),m()}}else e.value!==`input`&&C.current({decision:e.value,rules:e.rules})},[p,m]),D=(0,X.useRef)(E);D.current=E;let O=(0,X.useCallback)(e=>{if(e.trim()){let t=T.current[y.current],n=p(e.trim()),r=t?.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:t?.rules}),m()}},[p,m]),k=(0,X.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=T.current[y.current],n=d.current?.text||``;t?.value===`accept`?h.current=n:t?.value===`reject`&&(g.current=n),c(!1),e.key.upArrow?o(e=>Math.max(0,e-1)):o(e=>Math.min(b.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=T.current[y.current];t?.value===`accept`?h.current=``:t?.value===`reject`&&(g.current=``),m(),c(!1),e.preventDefault();return}if(e.key.escape){m(),c(!1),C.current({decision:`reject`}),e.preventDefault();return}},[m]),A=(0,X.useCallback)(e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);t.length!==0&&T.current[y.current]&&(t.length===1?C.current({decision:`allowAlwaysWithRule`,rules:t}):C.current({decision:`allowAlwaysWithRules`,rules:t}),u(!1))},[]),j=(0,X.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);HL((0,X.useCallback)((e,t)=>{if(!x.current&&!S.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(b.current-1,e+1));return}if(t.escape){C.current({decision:`reject`});return}if(t.tab&&t.shift){if(w.current){w.current();return}let e=T.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{C.current({decision:`allowAlways`})},0));return}if(t.tab){let e=T.current[y.current];if(e&&(e.value===`accept`||e.value===`reject`)){c(!0);let t=e.value===`accept`?h.current:g.current;setTimeout(()=>{d.current&&t&&d.current.setText(t)},0)}return}if(e===`e`||e===`E`){let e=T.current[y.current];if(e?.rules?.length){u(!0),setTimeout(()=>{f.current?.setText(e.rules.join(`, `))},0);return}}if(t.return){D.current();return}}},[]),{isActive:!0}),(0,X.useEffect)(()=>{let e=_[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?h.current:g.current)&&!s&&c(!0))},[a,_,s]);let M=(0,X.useRef)(!1);(0,X.useEffect)(()=>{s&&(M.current=!0)},[s]),(0,X.useEffect)(()=>{if(!s||!M.current)return;let e=_[a];if(!e)return;let t=e.value===`accept`?h.current:e.value===`reject`?g.current:``;t?setTimeout(()=>{d.current&&d.current.text===``&&d.current.setText(t),M.current=!1},0):M.current=!1},[s,a,_]);let N=_[a],P=s&&N,F=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,I=!s&&!l&&N&&(N.value===`accept`||N.value===`reject`),ee=!s&&!l&&!!N?.rules?.length,L=_.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[_.map((e,t)=>{let r=t===a,i=P&&r,o=e.value===`accept`?h.current:e.value===`reject`?g.current:``;return(0,Y.jsx)(r7,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,showAsEdit:l&&r,editBufferRef:f,onEditSubmit:A,onEditKeyDown:j,inputPrefix:F(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:O,onInputKeyDown:k},t)}),(0,Y.jsx)(Z,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`enter confirm`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc cancel`})]}):s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`enter submit`}),(0,Y.jsx)(Q,{dimColor:!0,children:`tab discard note`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc reject`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{dimColor:!0,children:`↑↓ navigate`}),(0,Y.jsx)(Q,{dimColor:!0,children:`enter select`}),I&&(0,Y.jsx)(Q,{dimColor:!0,children:`tab add note`}),ee&&(0,Y.jsx)(Q,{dimColor:!0,children:`e edit rule`}),i&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`shift+tab `,i]}),!i&&L&&(0,Y.jsx)(Q,{dimColor:!0,children:`shift+tab don't ask again`}),(0,Y.jsx)(Q,{dimColor:!0,children:`esc reject`})]})})]})});i7.displayName=`PermissionOptions`;function a7(e){return e.decision===`accept`&&e.userMessage?{type:`accept_with_message`,message:e.userMessage}:e.decision===`reject`&&e.userMessage?{type:`reject_with_message`,message:e.userMessage}:e.decision===`allowAlwaysWithRule`?e.rules?.length?{type:`allow_always_with_rule`,rule:e.rules[0]}:`accept`:e.decision===`allowAlwaysWithRules`?e.rules?.length?{type:`allow_always_with_rules`,rules:e.rules}:`accept`:e.decision}const o7=(0,X.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=FJ(),s=o===Sl.PlanMode,c=HD(e,process.cwd()),l=[{label:`Yes, apply changes`,value:`accept`},...s?[]:[{label:`Yes, and always allow Edit(${c})`,value:`allowAlwaysWithRule`,rules:[`Edit(${c})`]}],{label:`No, reject changes`,value:`reject`}],u=e=>{i(a7(e))};return r?(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:l,onSelect:u,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`${a?`Create`:`Update`} file ${e}`}),a?(0,Y.jsx)(xJ,{filePath:e,content:n,maxLines:100}):(0,Y.jsx)(bY,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:l,onSelect:u,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});o7.displayName=`EditFilePermissionUI`;const s7=(0,X.memo)(({filePath:e,onResolve:t})=>(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Delete file ${e}`}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{color:`red`,children:e})}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:[{label:`Yes, delete file`,value:`accept`},{label:`No, keep file`,value:`reject`}],onSelect:e=>{t(a7(e))}})})]}));s7.displayName=`DeleteFilePermissionUI`;const c7=(0,X.memo)(({description:e,url:t,displayName:n,onResolve:r})=>{let i=[{label:`Yes, allow action`,value:`accept`},{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]},{label:`No, deny action`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Browser action: ${e}`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:e}),t&&(0,Y.jsxs)(Q,{dimColor:!0,children:[`URL: `,t]})]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:i,onSelect:e=>{r(a7(e))}})})]})});c7.displayName=`BrowserActionPermissionUI`;const l7=(0,X.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let{colors:i}=bz(),a=(0,X.useMemo)(()=>LU(i),[i]),o=od(e),s=(0,X.useMemo)(()=>{let e=[{label:`Yes, run command`,value:`accept`}];if(n.length>1){e.push({label:`Yes, and always allow all: ${n.map(e=>`Bash(${e})`).join(`, `)}`,value:`allowAlwaysWithRules`,rules:n.map(e=>`Bash(${e})`)});for(let t of n)e.push({label:`Yes, and always allow Bash(${t})`,value:`allowAlwaysWithRule`,rules:[`Bash(${t})`]})}else n.length===1?e.push({label:`Yes, and always allow Bash(${n[0]})`,value:`allowAlwaysWithRule`,rules:[`Bash(${n[0]})`]}):e.push({label:`Yes, and always allow Bash(${o})`,value:`allowAlwaysWithRule`,rules:[`Bash(${o})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,o]);return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Bash command`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:(0,FU.supportsLanguage)(`bash`)?(()=>{try{return(0,FU.highlight)(e,{language:`bash`,theme:a})}catch{return e}})():e}),t&&(0,Y.jsx)(Z,{paddingTop:1,children:(0,Y.jsx)(Q,{dimColor:!0,children:`(Running in background)`})})]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:s,onSelect:e=>{r(a7(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});l7.displayName=`RunTerminalPermissionUI`;const u7=(0,X.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let{colors:i}=bz(),a=(0,X.useMemo)(()=>LU(i),[i]),o=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:e}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{children:(0,FU.supportsLanguage)(`json`)?(()=>{try{return(0,FU.highlight)(t,{language:`json`,theme:a})}catch{return t}})():t})}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:o,onSelect:e=>{r(a7(e))}})})]})});u7.displayName=`GenericPermissionUI`;const d7=(0,X.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,Y.jsx)($8,{children:t})]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:[{label:`Yes, implement the plan (approve each edit)`,value:`accept`},{label:`Yes, implement the plan (auto-accept all edits)`,value:`allowAlways`,hint:`shift+tab`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(a7(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));d7.displayName=`ExitPlanModePermissionUI`;const f7=(0,X.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow read`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny read`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Read file outside workspace`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,Y.jsx)(Q,{children:e}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Directory: `,t]})]}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:r,onSelect:e=>{n(a7(e))}})})]})});f7.displayName=`ReadOutsideDirectoryPermissionUI`;const p7=(0,X.memo)(({notebookPath:e,cellId:t,editMode:n,cellType:r,originalContent:i,newContent:a,onResolve:o})=>{let s=n??`replace`,c=``;c=s===`delete`?`Delete cell${t?` ${t}`:``}`:s===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${r??`code`})`:`Replace cell contents for cell ${t??`unknown`}`;let l=HD(e,process.cwd()),u=[{label:`Yes, apply changes`,value:`accept`},{label:`Yes, and always allow Edit(${l})`,value:`allowAlwaysWithRule`,rules:[`Edit(${l})`]},{label:`No, reject changes`,value:`reject`}];return(0,Y.jsxs)(Z,{flexDirection:`column`,children:[(0,Y.jsx)(u2,{title:`Edit notebook`}),(0,Y.jsxs)(Z,{flexDirection:`column`,paddingLeft:1,children:[(0,Y.jsx)(Q,{dimColor:!0,children:e}),(0,Y.jsx)(Q,{dimColor:!0,children:c})]}),s===`delete`?(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,Y.jsx)(Q,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,Y.jsx)(xJ,{filePath:e,content:a,maxLines:100}):(0,Y.jsx)(bY,{filePath:e,originalContent:i,newContent:a,paddingLeft:1}),(0,Y.jsx)(Z,{borderStyle:l2,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,Y.jsx)(Z,{flexDirection:`column`,paddingLeft:1,children:(0,Y.jsx)(i7,{options:u,onSelect:e=>{o(a7(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});p7.displayName=`NotebookEditPermissionUI`;const m7=(0,X.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,Y.jsx)(o7,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`delete_file`:return(0,Y.jsx)(s7,{filePath:t.filePath,onResolve:n});case`run_terminal`:return(0,Y.jsx)(l7,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,Y.jsx)(c7,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,Y.jsx)(u7,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,Y.jsx)(f7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,Y.jsx)(d7,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,Y.jsx)(n7,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,Y.jsx)(p7,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});m7.displayName=`ToolPermissionUI`;function h7(e){let t=(0,X.useRef)(!1),n=(0,X.useRef)(e);(0,X.useEffect)(()=>{n.current=e},[e]),(0,X.useEffect)(()=>{let e=()=>{t.current||(t.current=!0,n.current())};return process.on(`exit`,e),process.on(`SIGINT`,e),process.on(`SIGTERM`,e),()=>{e(),process.off(`exit`,e),process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[])}const g7=(0,X.createContext)(null),_7=()=>{let e=(0,X.use)(g7);if(!e)throw Error(`${_7.name} must be used within a ${v7.name}`);return e};function v7({children:e}){let t=(0,X.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(`${c$.SET_TITLE}${t}${c$.BEL}`)},[]);h7(()=>{process.stdout.write(`${c$.SET_TITLE}${c$.BEL}`)});let n=(0,X.useMemo)(()=>({setTitle:t}),[t]);return(0,Y.jsx)(g7.Provider,{value:n,children:e})}const y7=2e3;function b7(e,t,n){return e===Cl.ExecutingTool?`tool-executing`:e===Cl.Submitted||e===Cl.Streaming?`streaming`:e===Cl.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function x7(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueOne:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),y=(0,X.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,X.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,X.useCallback)(()=>{y(),b()},[y,b]),S=b7(t,n,i),C=(0,X.useRef)(S);return(0,X.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),HL((0,X.useEffectEvent)((e,S)=>{if(S.ctrl&&e===`z`){process.platform!==`win32`&&process.kill(process.pid,`SIGTSTP`);return}let C=S.escape,w=S.ctrl&&e===`c`,T=S.ctrl&&e===`d`;if(!C&&!w&&!T||C&&r)return;let E=b7(t,n,i);if(E===`tool-executing`||E===`streaming`){x(),o();return}if(E===`permission-ui`){x(),s();return}if(E===`idle-with-text`){if(C){p?(l(),x()):(b(),m(!0),_.current=setTimeout(()=>{m(!1),_.current=null},y7));return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},y7);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},y7);return}if(E===`idle-empty`){if(C){a()&&u();return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},y7);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},y7)}}),{isActive:!0}),(0,X.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}function S7(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function C7(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function w7(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function T7(e){let t={toolUses:0,responses:0};for(let n of e)switch(n.type){case`code_llm_tool_call`:case`code_llm_agent_tool_request`:t.toolUses+=Array.isArray(n.toolUseRequest)?n.toolUseRequest.length:1;break;case`text`:n.source===`bot`&&t.responses++;break}return t}function E7(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function D7(e){let t={toolUses:0,responses:0},n=[],r=[],i=0,a=[];for(let a=0;a<e.length;a++){let o=e[a];if(w7(o)){let e=T7(n);t=E7(t,e),r.push(...n),n=[],i++;continue}n.push(o)}i>0&&a.push({kind:`compacted`,id:`compacted-${i}`,counts:t,segments:r});let o=O7(n);return a.push(...o),a}function O7(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`thinking`){t.push({kind:`segment`,segment:r}),n++;continue}if(S7(r)&&Y5.has(k7(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(C7(i[i.length-1]))break;if(S7(t)&&Y5.has(k7(t)))i.push(t),a++;else break}i.length===1?t.push({kind:`segment`,segment:i[0]}):t.push({kind:`tool-group`,id:i[0].id,segments:i}),n=a;continue}t.push({kind:`segment`,segment:r}),n++}return t}function k7(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function A7(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`thinking`)return{thinkingStartTime:n.thinkingStartTime??null,thinkingEndTime:n.thinkingEndTime??null}}return{thinkingStartTime:null,thinkingEndTime:null}}function j7({timing:e}){let{setTitle:t}=_7(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,removeFirstFromQueue:u,clearQueue:d}=$$(),f=(0,X.useRef)(null),{authExpired:p,clearAuthExpired:m,apiClient:h}=I$();(0,X.useEffect)(()=>{p&&(s(`Session expired — use /login to authenticate again.`,`error`),m())},[p,s,m]);let[g,_]=(0,X.useState)(null),v=(0,X.useCallback)(()=>{_(e=>e===null?n.filter(e=>!e.temp&&!e.isSpinny):null)},[n]);HL((0,X.useCallback)((e,t)=>{(t.ctrl||t.super)&&e===`o`&&v()},[v]),{isActive:g===null});let{lastItem:y,prevItems:b}=(0,X.useMemo)(()=>{let e=D7(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:x,thinkingEndTime:S}=(0,X.useMemo)(()=>A7(n),[n]),C=(0,X.useRef)(Cl.Idle),[w,T]=(0,X.useState)(null);(0,X.useEffect)(()=>{let e=C.current===Cl.Idle,t=r!==Cl.Idle&&r!==Cl.WaitingForToolPermission;e&&t?T(Date.now()):r===Cl.Idle&&T(null),C.current=r},[r]);let E=r===Cl.WaitingForToolPermission&&i!==null,[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(`0`),[j,M]=(0,X.useState)(0);(0,X.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,X.useEffect)(()=>Kj(async()=>{let t=e.getFormattedDuration(),n=0;if(o)try{n=await P1(h,o)}catch{}M(n),A(t),O(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,o,h]);let N=x7({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:g!==null,composerHasText:()=>f.current?.hasText()??!1,hasQueuedMessages:()=>f.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>f.current?.saveAndClear(),clearComposer:()=>f.current?.clear(),dequeueOne:u,clearQueue:d,exitApp:()=>qj(0)}),P=r!==Cl.Idle&&r!==Cl.WaitingForToolPermission,F=i?.request.tool.id??null;return g===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Z,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,Y.jsx)(H5,{}),(0,Y.jsxs)(dJ.Provider,{value:F,children:[b.map(e=>e.kind===`compacted`?(0,Y.jsx)(w1,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,Y.jsx)(m5,{segment:e.segment},e.segment.id):(0,Y.jsx)(t7,{segments:e.segments},e.id)),y&&(y.kind===`compacted`?(0,Y.jsx)(w1,{counts:y.counts,segments:y.segments},y.id):y.kind===`segment`?(0,Y.jsx)(m5,{segment:y.segment},y.segment.id):(0,Y.jsx)(t7,{segments:y.segments},y.id))]}),P&&(0,Y.jsx)(I4,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(J5,{status:r,thinkingStartTime:x,thinkingEndTime:S,runStartTime:w})})]}),D?(0,Y.jsx)(L4,{duration:k,credits:j,conversationId:o}):(0,Y.jsxs)(Y.Fragment,{children:[E&&(0,Y.jsx)(I4,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(m7,{pendingTool:i})}),(0,Y.jsx)(X.Activity,{mode:E?`hidden`:`visible`,children:(0,Y.jsx)(I4,{fallback:e=>(0,Y.jsxs)(Z,{flexDirection:`column`,paddingX:1,children:[(0,Y.jsx)(Q,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,Y.jsx)(Q,{color:`yellow`,children:e.message}),(0,Y.jsxs)(Q,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,Le.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,Y.jsx)(F4,{hints:N,composerRef:f})})})]})]}):(0,Y.jsx)(h5,{snapshot:g,onClose:()=>_(null)})}async function M7({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Sl.Yolo;break;case`accept-edits`:i=Sl.AcceptEdits;break;case`plan`:i=Sl.PlanMode;break;default:i=Sl.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Sl.Yolo:r?.[`auto-accept-edits`]?i=Sl.AcceptEdits:r?.[`plan-mode`]&&(i=Sl.PlanMode);let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(c$.HIDE_CURSOR),l=()=>s(c$.SHOW_CURSOR),u=!1;for(;;){u=!1;let a=new ZR,o=new J0,s=null,d=()=>{u=!0,s?.unmount()};c();let f=RL((0,Y.jsx)(xz,{children:(0,Y.jsx)(L$,{client:e,authManager:t,onAuthExpired:d,children:(0,Y.jsx)(ez,{client:a,children:(0,Y.jsx)(A1,{children:(0,Y.jsx)(v7,{children:(0,Y.jsx)(P$,{children:(0,Y.jsx)(D1,{configService:n,children:(0,Y.jsx)(i$,{children:(0,Y.jsx)(RJ,{initialMode:i,children:(0,Y.jsx)(o$,{children:(0,Y.jsx)(Q$,{apiClient:e,configService:n,agentArgs:r,children:(0,Y.jsx)(j7,{timing:o})})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
|
|
85939
85939
|
Abacus.AI has been suspended. Run \`fg\` to bring Abacus back.
|
|
85940
|
-
`)}});s=f;let p=!1,m=()=>{p||(p=!0,l())},h=()=>{p||(p=!0,f.cleanupTerminal())};if(process.once(`exit`,h),await f.waitUntilExit(),process.off(`exit`,h),m(),!u||!(await PN({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Oe(mj()))).default.version})).success)break}}async function
|
|
85941
|
-
`)[0]?.trim();if(e)return e}catch{}return Le.binName}function
|
|
85940
|
+
`)}});s=f;let p=!1,m=()=>{p||(p=!0,l())},h=()=>{p||(p=!0,f.cleanupTerminal())};if(process.once(`exit`,h),await f.waitUntilExit(),process.off(`exit`,h),m(),!u||!(await PN({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Oe(mj()))).default.version})).success)break}}async function N7(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0}=e;if(!n&&yj()||!n&&vj()||!n&&!r)return{action:`skipped`};let i;try{i=await Sj(t)}catch{return n?(ON.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!i)return n&&ON.success(`Already up to date (${t})`),{action:`skipped`};let a=wj(i);EN(`Update available: ${i.currentVersion} → ${i.latestVersion}`),wN(a,`Install command`);let o=await SN({message:`Would you like to update now?`,initialValue:!0});if(PM(o))return TN(`Update cancelled`),{action:`exit`};if(o){let e=jN();e.start(`Updating... (${a})`);let{ok:t,output:n}=await Ej(i,t=>{e.message(`Updating... ${t}`)});if(t)return e.stop(`Updated to ${i.latestVersion}`),n&&wN(n,`Install output`),DN(`Restarting...`),{action:`updated`,version:i.latestVersion};{e.stop(`Update failed`),n&&wN(n,`Error output`),ON.error(`Update failed. You can try manually running the command above.`);let t=await SN({message:`Continue using v${i.currentVersion}?`,initialValue:!0});return PM(t)||!t?(TN(`Exiting`),{action:`exit`}):(DN(`Continuing with v${i.currentVersion}`),{action:`continue`})}}let s=await SN({message:`Continue using v${i.currentVersion}?`,initialValue:!0});return PM(s)||!s?(TN(`Exiting`),{action:`exit`}):(DN(`Continuing with v${i.currentVersion}`),{action:`continue`})}function P7(e,t=1){throw console.error(pj.red(e)),qj(t),Error(e)}function F7(e){try{return new URL(e)}catch{P7(`Invalid ${Le.envPrefix}BASE_URL: ${e}`)}}function I7(e){(e?.[`output-format`]||e?.[`input-format`])&&!e?.print&&P7(`--output-format and --input-format flags can only be used with --print mode`)}async function L7(){let e=process.stdin;e.isTTY&&P7(`No prompt provided and no piped input detected. Either provide a prompt or pipe input.`);let t=``;for await(let n of e)t+=n;let n=t.trim();return n||P7(`No input provided`),n}async function R7(e){return e?.prompt?e.prompt:L7()}async function z7(e,t){let n=t.get(`baseUrl`);n&&(F7(n),e.setUrl(n),e.resetEndpoints(),await e.getApiEndpoint())}async function B7(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(Le.agentType))?.result??[]).sort((e,t)=>{let n=e.lastEventCreatedAt?new Date(e.lastEventCreatedAt).getTime():0;return(t.lastEventCreatedAt?new Date(t.lastEventCreatedAt).getTime():0)-n})[0]?.deploymentConversationId}catch{}}async function V7(e,t){if(t?.version){console.log(`Abacus.AI CLI version ${hj.default.version}`),qj(0);return}if(I7(t),t?.[`desktop-host`]){await Xj({agentArgs:t});return}else if(t?.print){let e=await R7(t);await VN({agentArgs:{...t,prompt:e}})}else{let n=await MA.create(),r=new Ie(n,{error:(e,...t)=>Fj.error(e,...t),debug:(...e)=>Fj.debug(...e),warn:(e,...t)=>Fj.warn(e,...t)});if(await z7(r,e),!n.isAuthenticated()&&!n.isEnvAuth()&&((!process.stdin.isTTY||!process.stdout.isTTY)&&P7(`Not authenticated. Set ${Le.envPrefix}API_KEY environment variable or run interactively to log in.`),!(await PN({authManager:n,apiClient:r,reason:`welcome`,version:hj.default.version})).success)){qj(0);return}let i=await B7(t,r);await M7({apiClient:r,authManager:n,configService:e,agentArgs:{...t,...i&&{conversationId:i}}})}}function H7(){try{let e=d(`${process.platform===`win32`?`where`:`which`} ${Le.binName}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim().split(`
|
|
85941
|
+
`)[0]?.trim();if(e)return e}catch{}return Le.binName}function U7(e){let t=H7();return new Promise(n=>{let r=f(t,e,{stdio:`inherit`,env:{...process.env}});r.on(`error`,e=>{process.stderr.write(`Failed to relaunch CLI: ${e.message}\n`),process.stderr.write(`Please run "${Le.binName}" manually.\n`),n(1)}),r.on(`exit`,e=>n(e??0))})}async function W7(){let e=await N7({currentVersion:hj.default.version,explicit:!0});if(e.action===`updated`){let e=await U7(process.argv.slice(3));process.exit(e)}process.exit(e.action===`exit`?1:0)}async function G7(e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let t=await N7({currentVersion:hj.default.version,autoUpdate:e.get(`autoUpdate`)!==!1});if(t.action===`updated`){let e=await U7(process.argv.slice(2));process.exit(e)}t.action===`exit`&&process.exit(0)}if(process.argv[2]===`upgrade`)await W7();else{let{values:e,positionals:t}=A({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`},model:{type:`string`,short:`m`},print:{type:`boolean`,short:`p`},resume:{type:`string`},continue:{type:`boolean`,short:`c`},"output-format":{type:`string`},"input-format":{type:`string`},"allow-editing":{type:`string`},"auto-accept-edits":{type:`boolean`},"dangerously-skip-permissions":{type:`boolean`},"plan-mode":{type:`boolean`},"permission-mode":{type:`string`},"allowed-tools":{type:`string`,multiple:!0},"disallowed-tools":{type:`string`,multiple:!0},"add-dir":{type:`string`,multiple:!0},"desktop-host":{type:`boolean`}},allowPositionals:!0,strict:!0});e.help&&(console.log(`Usage: abacus [options] [prompt]
|
|
85942
85942
|
|
|
85943
85943
|
Commands:
|
|
85944
85944
|
upgrade Check for updates and install the latest version
|
|
@@ -85957,4 +85957,4 @@ Options:
|
|
|
85957
85957
|
--permission-mode <mode> Permission mode: normal, accept-edits, yolo, plan
|
|
85958
85958
|
--allowed-tools <pattern> Auto-allow tool patterns (can repeat)
|
|
85959
85959
|
--disallowed-tools <pattern> Auto-deny tool patterns (can repeat)
|
|
85960
|
-
--add-dir <path> Additional allowed directory (can repeat)`),process.exit(0));let n=new BD({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await n.load(),await
|
|
85960
|
+
--add-dir <path> Additional allowed directory (can repeat)`),process.exit(0));let n=new BD({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await n.load(),await G7(n),await V7(n,{...e,prompt:t.length>0?t.join(` `):null}).catch(e=>{console.error(e),process.exit(1)})}export{};
|