@abacus-ai/cli 2.4.9-canary.0 → 2.4.9-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +127 -126
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import{createRequire as e}from"node:module";import*as t from"node:util";import n
3
3
  `;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function yt(e,t){if(typeof t==`string`)return _t(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function bt(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=vt(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=yt(n,i),n===void 0)return}return n}function xt(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&gt(u)&&(l=bt(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function St(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const Ct=Symbol.for(`logtape.categoryPrefix`);function wt(){let e=pt.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[Ct];return Array.isArray(t)?t:[]}function Tt(){let e=pt.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var Et=Xe({inspect:()=>Dt});function Dt(e,t){return n.inspect(e,t)}const Ot={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},kt=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):Et!=null&&`inspect`in Et&&typeof Dt==`function`?(e,t)=>Dt(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function At(e){return e<10?`0${e}`:`${e}`}function jt(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const Mt={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${At(t.getUTCMonth()+1)}-${At(t.getUTCDate())} ${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${At(t.getUTCMonth()+1)}-${At(t.getUTCDate())} ${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${At(t.getUTCMonth()+1)}-${At(t.getUTCDate())} ${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${At(t.getUTCHours())}:${At(t.getUTCMinutes())}:${At(t.getUTCSeconds())}.${jt(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${At(t.getUTCMonth()+1)}-${At(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},Nt={ABBR:Ot,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function Pt(e){return e===`crlf`?`\r
4
4
  `:`
5
5
  `}function Ft(e,t){if(!(t instanceof Error))return t;let n={name:t.name,message:t.message};typeof t.stack==`string`&&(n.stack=t.stack);let r=t.cause;r!==void 0&&(n.cause=r),typeof AggregateError<`u`&&t instanceof AggregateError&&(n.errors=t.errors);for(let e of Object.keys(t))e in n||(n[e]=t[e]);return n}function It(e={}){let t=(()=>{let t=e.timestamp;return t==null?Mt[`date-time-timezone`]:t===`disabled`?Mt.none:typeof t==`string`&&t in Mt?Mt[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,kt):kt,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>Nt.ABBR[e]:t===`abbr`?e=>Nt.abbr[e]:t===`FULL`?e=>Nt.FULL[e]:t===`full`?e=>Nt.full[e]:t===`L`?e=>Nt.L[e]:t===`l`?e=>Nt.l[e]:t})(),a=Pt(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=e.message,c=s.length,l;if(c===1)l=s[0];else if(c<=6){l=``;for(let e=0;e<c;e++)l+=e%2==0?s[e]:r(s[e])}else{let e=Array(c);for(let t=0;t<c;t++)e[t]=t%2==0?s[t]:r(s[t]);l=e.join(``)}return`${o({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:l,record:e})}${a}`}}const Lt=It(),Rt=`\x1B[0m`,zt={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},Bt={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},Vt={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function Ht(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:Bt[n]}${r==null?``:zt[r]}`,a=n==null&&r==null?``:Rt,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??Vt,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:Bt[c]}${l==null?``:zt[l]}`,d=c==null&&l==null?``:Rt;return It({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:Bt[o]}${f==null?``:zt[f]}${n}${o==null&&f==null?``:Rt}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}Ht();function Ut(e={}){let t=Pt(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties},Ft)+t;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties},Ft)+t;let n=e.message[0];for(let t=1;t<e.message.length;t++)n+=t&1?JSON.stringify(e.message[t]):e.message[t];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:n,logger:e.category.join(`.`),properties:e.properties},Ft)+t};let n=e.message===`template`,r=e.properties??`nest:properties`,i;if(typeof e.categorySeparator==`function`)i=e.categorySeparator;else{let t=e.categorySeparator??`.`;i=e=>e.join(t)}let a;if(r===`flatten`)a=e=>e;else if(r.startsWith(`prepend:`)){let e=r.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);a=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(r.startsWith(`nest:`)){let e=r.substring(5);a=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let o;return o=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:o(e),logger:i(e.category),...a(e.properties)},Ft)+t}Ut();const Wt={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function Gt(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${Ot[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,Wt[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function Kt(e={}){let t=e.formatter??Gt,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let qt=null;const Jt=new Set,Yt=new Set,Xt=new Set;function Zt(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function Qt(e){let t=e?rn:an;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t);return}}let n=globalThis.addEventListener;typeof n==`function`&&(`Deno`in globalThis?n.call(globalThis,`unload`,t):n.call(globalThis,`pagehide`,t))}async function $t(e){if(qt!=null&&!e.reset)throw new on(`Already configured; if you want to reset, turn on the reset flag.`);await tn();try{en(e,!0)}catch(e){throw e instanceof on&&await tn(),e}}function en(e,t){qt=e;let n=!1,r=new Set;for(let t of e.loggers){Zt(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new on(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=pt.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new on(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new on(`Filter not found: ${n}.`);a.filters.push(it(t))}Jt.add(a)}pt.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)Xt.add(n);else throw new on(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Yt.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)Xt.add(n);else throw new on(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Yt.add(n)}Qt(t);let i=pt.getLogger([`logtape`,`meta`]);n||i.sinks.push(Kt()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}async function tn(){await rn(),nn()}function nn(){let e=pt.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,Jt.clear(),qt=null}async function rn(){an();let e=[];for(let t of Xt)e.push(t[Symbol.asyncDispose]()),Xt.delete(t);await Promise.all(e)}function an(){for(let e of Yt)e[Symbol.dispose]();Yt.clear()}var on=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};let sn=``;function cn(){let e=new Date,t=(e,t=2)=>String(e).padStart(t,`0`);return`${[e.getFullYear(),t(e.getMonth()+1),t(e.getDate()),`T`,t(e.getHours()),t(e.getMinutes()),t(e.getSeconds())].join(``)}-${Math.random().toString(36).substring(2,8)}`}function ln(){return sn||=cn(),sn}function un(e){sn=e}function dn(e,t){let n=t.formatter??Lt,r=t.encoder??new TextEncoder,i=t.maxSize??1024*1024,a=t.maxFiles??5,o=t.bufferSize??1024*8,s=t.flushInterval??5e3,c=0;try{c=t.statSync(e).size}catch{}let l=t.openSync(e),u=Date.now(),d=``;function f(e){return c+e.length>i}function p(){t.closeSync(l);for(let n=a-1;n>0;n--){let r=`${e}.${n}`,i=`${e}.${n+1}`;try{t.renameSync(r,i)}catch{}}t.renameSync(e,`${e}.1`),c=0,l=t.openSync(e)}if(!t.nonBlocking){function e(){if(d.length>0){let e=r.encode(d);d=``,f(e)&&p(),t.writeSync(l,e),t.flushSync(l),c+=e.length,u=Date.now()}}let i=t=>{d+=n(t);let r=d.length>=o,i=s>0&&t.timestamp-u>=s;(r||i)&&e()};return i[Symbol.dispose]=()=>{e(),t.closeSync(l)},i}let m=t,h=!1,g=null,_=null;async function v(){if(d.length===0)return;let e=d;d=``;try{let t=r.encode(e);f(t)&&p(),m.writeSync(l,t),await m.flush(l),c+=t.length,u=Date.now()}catch{}}function y(){g||h||(g=v().finally(()=>{g=null}))}function b(){_!==null||h||(_=setInterval(()=>{y()},s))}let x=e=>{if(h)return;d+=n(e);let t=d.length>=o,r=s>0&&e.timestamp-u>=s;t||r?y():_===null&&s>0&&b()};return x[Symbol.asyncDispose]=async()=>{h=!0,_!==null&&(clearInterval(_),_=null),await v();try{await m.close(l)}catch{}},x}const fn={openSync(e){return c.openSync(e,`a`)},writeSync:c.writeSync,writeManySync(e,t){if(t.length!==0){if(t.length===1){c.writeSync(e,t[0]);return}c.writevSync(e,t)}},flushSync:c.fsyncSync,closeSync:c.closeSync,statSync:c.statSync,renameSync:c.renameSync},pn={...fn,async writeMany(e,t){if(t.length!==0){if(t.length===1){await a(c.write)(e,t[0]);return}await a(c.writev)(e,t)}},flush:a(c.fsync),close:a(c.close)};({...fn}),c.readdirSync,c.unlinkSync,c.mkdirSync,{...pn},c.readdirSync,c.unlinkSync,c.mkdirSync;function mn(e,t={}){return t.nonBlocking?dn(e,{...t,...pn}):dn(e,{...t,...fn})}const hn={name:`abacusai`,fullName:`Abacus.AI`,longName:`Abacus.AI CLI`,description:`AI coding assistant`,binName:`abacusai`,binAliases:[`abacus`],configDirName:`.abacusai`,logsDirName:`logs`,configFileName:`config.json`,localConfigDirName:`.abacusai`,ideDirName:`ide`,envPrefix:`ABACUS_`,internalEnvPrefix:`CODELLM_`,socketEnvVar:`CODELLM_SOCKET_PATH`,keychainService:`abacusai`,mcpClientName:`abacusai-agent`,mcpOAuthClientName:`Abacus.AI Agent`,mcpConfigSourceType:`abacusai-user`,reactIdentifierPrefix:`abacusai-`,agentType:`CODE_LLM_AGENT`,sentryDsn:`https://bd1c87d300ab740912022757ddda4ad2@o270508.ingest.us.sentry.io/4511013419024384`},gn={publishName:`@abacus-ai/cli`,userAgentNames:{cli:`codellm-cli`,desktop:`codellm-desktop`,print:`codellm-non-interactive`},runtimeDeps:[`koffi`,`@vscode/ripgrep`,`trash`]};function _n(){return O.join(te(),hn.configDirName,hn.logsDirName)}function vn(e,t=20){try{let n=v(e).filter(e=>e.endsWith(`.log`)).map(t=>({name:t,mtime:b(O.join(e,t)).mtimeMs})).sort((e,t)=>t.mtime-e.mtime);for(let r of n.slice(t))try{x(O.join(e,r.name))}catch{}}catch{}}function yn(e){try{p(e,{recursive:!0})}catch{}}function bn(e,t){return yn(e),vn(e),mn(O.join(e,`${t}.log`),{maxSize:5*1024*1024,maxFiles:20})}async function xn(e={}){let t=e.sessionId??ln(),n=e.logDir??_n(),r=e.logLevel??(e.dev?`debug`:`info`),i={file:bn(n,t)};e.dev&&(i.console=Kt()),await $t({sinks:i,loggers:[{category:[`codellm`],lowestLevel:r,sinks:Object.keys(i)},{category:[`logtape`,`meta`],lowestLevel:`warning`,sinks:[]}]})}function Sn(){let e=dt([`codellm`,`api`]);return{error(t,...n){t instanceof Error?e.error(t):e.error`${t} ${n}`},warn(t,...n){e.warn`${t} ${n}`},debug(...t){e.debug`${t}`}}}const Cn=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,wn=globalThis,Tn=`10.46.0`;function En(){return Dn(wn),wn}function Dn(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.46.0`,t[Tn]=t[`10.46.0`]||{}}function On(e,t,n=wn){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[Tn]=r[`10.46.0`]||{};return i[e]||(i[e]=t())}const kn=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],An={};function jn(e){if(!(`console`in wn))return e();let t=wn.console,n={},r=Object.keys(An);r.forEach(e=>{let r=An[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Mn(){zn().enabled=!0}function Nn(){zn().enabled=!1}function Pn(){return zn().enabled}function Fn(...e){Rn(`log`,...e)}function In(...e){Rn(`warn`,...e)}function Ln(...e){Rn(`error`,...e)}function Rn(e,...t){Cn&&Pn()&&jn(()=>{wn.console[e](`Sentry Logger [${e}]:`,...t)})}function zn(){return Cn?On(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}const Bn={enable:Mn,disable:Nn,isEnabled:Pn,log:Fn,warn:In,error:Ln},Vn=/\(error: (.*)\)/,Hn=/captureMessage|captureException/;function Un(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
6
- `);for(let e=n;e<a.length;e++){let n=a[e];n.length>1024&&(n=n.slice(0,1024));let o=Vn.test(n)?n.replace(Vn,`$1`):n;if(!o.match(/\S*Error: /)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=50+r)break}}return Gn(i.slice(r))}}function Wn(e){return Array.isArray(e)?Un(...e):e}function Gn(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(Kn(t).function||``)&&t.pop(),t.reverse(),Hn.test(Kn(t).function||``)&&(t.pop(),Hn.test(Kn(t).function||``)&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||Kn(t).filename,function:e.function||`?`}))}function Kn(e){return e[e.length-1]||{}}const qn=`<anonymous>`;function Jn(e){try{return!e||typeof e!=`function`?qn:e.name||qn}catch{return qn}}function Yn(e){return`__v_isVNode`in e&&e.__v_isVNode?`[VueVNode]`:`[VueViewModel]`}function Xn(e){let t=e?.startsWith(`file://`)?e.slice(7):e;return t?.match(/\/[A-Z]:/)&&(t=t.slice(1)),t}const Zn={},Qn={};function $n(e,t){Zn[e]=Zn[e]||[],Zn[e].push(t)}function er(e,t){if(!Qn[e]){Qn[e]=!0;try{t()}catch(t){Cn&&Bn.error(`Error while instrumenting ${e}`,t)}}}function tr(e,t){let n=e&&Zn[e];if(n)for(let r of n)try{r(t)}catch(t){Cn&&Bn.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${Jn(r)}\nError:`,t)}}let nr=null;function rr(e){let t=`error`;$n(t,e),er(t,ir)}function ir(){nr=wn.onerror,wn.onerror=function(e,t,n,r,i){return tr(`error`,{column:r,error:i,line:n,msg:e,url:t}),nr?nr.apply(this,arguments):!1},wn.onerror.__SENTRY_INSTRUMENTED__=!0}let ar=null;function or(e){let t=`unhandledrejection`;$n(t,e),er(t,sr)}function sr(){ar=wn.onunhandledrejection,wn.onunhandledrejection=function(e){return tr(`unhandledrejection`,e),ar?ar.apply(this,arguments):!0},wn.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const cr=Object.prototype.toString;function lr(e){switch(cr.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object WebAssembly.Exception]`:return!0;default:return xr(e,Error)}}function ur(e,t){return cr.call(e)===`[object ${t}]`}function dr(e){return ur(e,`ErrorEvent`)}function fr(e){return ur(e,`String`)}function pr(e){return typeof e==`object`&&!!e&&`__sentry_template_string__`in e&&`__sentry_template_values__`in e}function mr(e){return e===null||pr(e)||typeof e!=`object`&&typeof e!=`function`}function hr(e){return ur(e,`Object`)}function gr(e){return typeof Event<`u`&&xr(e,Event)}function _r(e){return typeof Element<`u`&&xr(e,Element)}function vr(e){return ur(e,`RegExp`)}function yr(e){return!!(e?.then&&typeof e.then==`function`)}function br(e){return hr(e)&&`nativeEvent`in e&&`preventDefault`in e&&`stopPropagation`in e}function xr(e,t){try{return e instanceof t}catch{return!1}}function Sr(e){return!!(typeof e==`object`&&e&&(e.__isVue||e._isVue||e.__v_isVNode))}const Cr=wn;function wr(e,t={}){if(!e)return`<unknown>`;try{let n=e,r=[],i=0,a=0,o,s=Array.isArray(t)?t:t.keyAttrs,c=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&i++<5&&(o=Tr(n,s),!(o===`html`||i>1&&a+r.length*3+o.length>=c));)r.push(o),a+=o.length,n=n.parentNode;return r.reverse().join(` > `)}catch{return`<unknown>`}}function Tr(e,t){let n=e,r=[];if(!n?.tagName)return``;if(Cr.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());let i=t?.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(i?.length)i.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{n.id&&r.push(`#${n.id}`);let e=n.className;if(e&&fr(e)){let t=e.split(/\s+/);for(let e of t)r.push(`.${e}`)}}for(let e of[`aria-label`,`type`,`name`,`title`,`alt`]){let t=n.getAttribute(e);t&&r.push(`[${e}="${t}"]`)}return r.join(``)}function Er(e,t,n){if(!(t in e))return;let r=e[t];if(typeof r!=`function`)return;let i=n(r);typeof i==`function`&&Or(i,r);try{e[t]=i}catch{Cn&&Bn.log(`Failed to replace method "${t}" in object`,e)}}function Dr(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{Cn&&Bn.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function Or(e,t){try{e.prototype=t.prototype=t.prototype||{},Dr(e,`__sentry_original__`,t)}catch{}}function kr(e){return e.__sentry_original__}function Ar(e){if(lr(e))return{message:e.message,name:e.name,stack:e.stack,...Mr(e)};if(gr(e)){let t={type:e.type,target:jr(e.target),currentTarget:jr(e.currentTarget),...Mr(e)};return typeof CustomEvent<`u`&&xr(e,CustomEvent)&&(t.detail=e.detail),t}else return e}function jr(e){try{return _r(e)?wr(e):Object.prototype.toString.call(e)}catch{return`<unknown>`}}function Mr(e){return typeof e==`object`&&e?Object.fromEntries(Object.entries(e)):{}}function Nr(e){let t=Object.keys(Ar(e));return t.sort(),t[0]?t.join(`, `):`[object has no keys]`}let Pr;function Fr(e){if(Pr!==void 0)return Pr?Pr(e):e();let t=Symbol.for(`__SENTRY_SAFE_RANDOM_ID_WRAPPER__`),n=wn;return t in n&&typeof n[t]==`function`?(Pr=n[t],Pr(e)):(Pr=null,e())}function Ir(){return Fr(()=>Math.random())}function Lr(){return Fr(()=>Date.now())}function Rr(e,t=0){return typeof e!=`string`||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function zr(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`'{snip} ${n}`),a<r&&(n+=` {snip}`),n}function Br(e,t){if(!Array.isArray(e))return``;let n=[];for(let t=0;t<e.length;t++){let r=e[t];try{Sr(r)?n.push(Yn(r)):n.push(String(r))}catch{n.push(`[value cannot be serialized]`)}}return n.join(t)}function Vr(e,t,n=!1){return fr(e)?vr(t)?t.test(e):fr(t)?n?e===t:e.includes(t):!1:!1}function Hr(e,t=[],n=!1){return t.some(t=>Vr(e,t,n))}function Ur(){let e=wn;return e.crypto||e.msCrypto}let Wr;function Gr(){return Ir()*16}function Kr(e=Ur()){try{if(e?.randomUUID)return Fr(()=>e.randomUUID()).replace(/-/g,``)}catch{}return Wr||=`10000000100040008000100000000000`,Wr.replace(/[018]/g,e=>(e^(Gr()&15)>>e/4).toString(16))}function qr(e){return e.exception?.values?.[0]}function Jr(e){let{message:t,event_id:n}=e;if(t)return t;let r=qr(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||`<unknown>`:n||`<unknown>`}function Yr(e,t,n){let r=e.exception=e.exception||{},i=r.values=r.values||[],a=i[0]=i[0]||{};a.value||=t||``,a.type||=n||`Error`}function Xr(e,t){let n=qr(e);if(!n)return;let r={type:`generic`,handled:!0},i=n.mechanism;if(n.mechanism={...r,...i,...t},t&&`data`in t){let e={...i?.data,...t.data};n.mechanism.data=e}}const Zr=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function Qr(e){return parseInt(e||``,10)}function $r(e){let t=e.match(Zr)||[],n=Qr(t[1]),r=Qr(t[2]),i=Qr(t[3]);return{buildmetadata:t[5],major:isNaN(n)?void 0:n,minor:isNaN(r)?void 0:r,patch:isNaN(i)?void 0:i,prerelease:t[4]}}function ei(e){if(ti(e))return!0;try{Dr(e,`__sentry_captured__`,!0)}catch{}return!1}function ti(e){try{return e.__sentry_captured__}catch{}}const ni=1e3;function ri(){return Lr()/ni}function ii(){let{performance:e}=wn;if(!e?.now||!e.timeOrigin)return ri;let t=e.timeOrigin;return()=>(t+Fr(()=>e.now()))/ni}let ai;function oi(){return(ai??=ii())()}function si(e){let t=oi(),n={sid:Kr(),init:!0,timestamp:t,started:t,duration:0,status:`ok`,errors:0,ignoreDuration:!1,toJSON:()=>ui(n)};return e&&ci(n,e),n}function ci(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),!e.did&&!t.did&&(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||oi(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=t.sid.length===32?t.sid:Kr()),t.init!==void 0&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),typeof t.started==`number`&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if(typeof t.duration==`number`)e.duration=t.duration;else{let t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),typeof t.errors==`number`&&(e.errors=t.errors),t.status&&(e.status=t.status)}function li(e,t){let n={};t?n={status:t}:e.status===`ok`&&(n={status:`exited`}),ci(e,n)}function ui(e){return{sid:`${e.sid}`,init:e.init,started:new Date(e.started*1e3).toISOString(),timestamp:new Date(e.timestamp*1e3).toISOString(),status:e.status,errors:e.errors,did:typeof e.did==`number`||typeof e.did==`string`?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}function di(e,t,n=2){if(!t||typeof t!=`object`||n<=0)return t;if(e&&Object.keys(t).length===0)return e;let r={...e};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=di(r[e],t[e],n-1));return r}function fi(){return Kr()}function pi(){return Kr().substring(16)}const mi=`_sentrySpan`;function hi(e,t){t?Dr(e,mi,t):delete e[mi]}function gi(e){return e[mi]}var _i=class e{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:fi(),sampleRand:Ir()}}clone(){let t=new e;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._attributes={...this._attributes},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,t._conversationId=this._conversationId,hi(t,gi(this)),t}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&ci(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return t===null?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;let n=typeof t==`function`?t(this):t,{tags:r,attributes:i,extra:a,user:o,contexts:s,level:c,fingerprint:l=[],propagationContext:u,conversationId:d}=(n instanceof e?n.getScopeData():hr(n)?t:void 0)||{};return this._tags={...this._tags,...r},this._attributes={...this._attributes,...i},this._extra={...this._extra,...a},this._contexts={...this._contexts,...s},o&&Object.keys(o).length&&(this._user=o),c&&(this._level=c),l.length&&(this._fingerprint=l),u&&(this._propagationContext=u),d&&(this._conversationId=d),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,hi(this,void 0),this._attachments=[],this.setPropagationContext({traceId:fi(),sampleRand:Ir()}),this._notifyScopeListeners(),this}addBreadcrumb(e,t){let n=typeof t==`number`?t:100;if(n<=0)return this;let r={timestamp:ri(),...e,message:e.message?Rr(e.message,2048):e.message};return this._breadcrumbs.push(r),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n),this._client?.recordDroppedEvent(`buffer_overflow`,`log_item`)),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:gi(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=di(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){let n=t?.event_id||Kr();if(!this._client)return Cn&&Bn.warn(`No client configured on scope - will not capture exception!`),n;let r=Error(`Sentry syntheticException`);return this._client.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){let r=n?.event_id||Kr();if(!this._client)return Cn&&Bn.warn(`No client configured on scope - will not capture message!`),r;let i=n?.syntheticException??Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){let n=e.event_id||t?.event_id||Kr();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(Cn&&Bn.warn(`No client configured on scope - will not capture event!`),n)}_notifyScopeListeners(){this._notifyingListeners||=(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),!1)}};function vi(){return On(`defaultCurrentScope`,()=>new _i)}function yi(){return On(`defaultIsolationScope`,()=>new _i)}const bi=e=>e instanceof Promise&&!e[xi],xi=Symbol(`chained PromiseLike`),Si=(e,t,n)=>{let r=e.then(e=>(t(e),e),e=>{throw n(e),e});return bi(r)&&bi(e)?r:Ci(e,r)},Ci=(e,t)=>{let n=!1;for(let r in e){if(r in t)continue;n=!0;let i=e[r];typeof i==`function`?Object.defineProperty(t,r,{value:(...t)=>i.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[r]=i}return n&&Object.assign(t,{[xi]:!0}),t};var wi=class{constructor(e,t){let n;n=e||new _i;let r;r=t||new _i,this._stack=[{scope:n}],this._isolationScope=r}withScope(e){let t=this._pushScope(),n;try{n=e(t)}catch(e){throw this._popScope(),e}return yr(n)?Si(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}};function Ti(){let e=Dn(En());return e.stack=e.stack||new wi(vi(),yi())}function Ei(e){return Ti().withScope(e)}function Di(e,t){let n=Ti();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function Oi(e){return Ti().withScope(()=>e(Ti().getIsolationScope()))}function ki(){return{withIsolationScope:Oi,withScope:Ei,withSetScope:Di,withSetIsolationScope:(e,t)=>Oi(t),getCurrentScope:()=>Ti().getScope(),getIsolationScope:()=>Ti().getIsolationScope()}}function Ai(e){let t=Dn(En());t.acs=e}function ji(e){let t=Dn(e);return t.acs?t.acs:ki()}function Mi(){return ji(En()).getCurrentScope()}function Ni(){return ji(En()).getIsolationScope()}function Pi(){return On(`globalScope`,()=>new _i)}function Fi(...e){let t=ji(En());if(e.length===2){let[n,r]=e;return n?t.withSetScope(n,r):t.withScope(r)}return t.withScope(e[0])}function Ii(...e){let t=ji(En());if(e.length===2){let[n,r]=e;return n?t.withSetIsolationScope(n,r):t.withIsolationScope(r)}return t.withIsolationScope(e[0])}function Li(){return Mi().getClient()}function Ri(e){let{traceId:t,parentSpanId:n,propagationSpanId:r}=e.getPropagationContext(),i={trace_id:t,span_id:r||pi()};return n&&(i.parent_span_id=n),i}function zi(e){if(e){if(typeof e==`object`&&`deref`in e&&typeof e.deref==`function`)try{return e.deref()}catch{return}return e}}function Bi(e){let t=e;return{scope:t._sentryScope,isolationScope:zi(t._sentryIsolationScope)}}function Vi(e){let t=Ui(e);if(!t)return;let n=Object.entries(t).reduce((e,[t,n])=>{if(t.startsWith(`sentry-`)){let r=t.slice(7);e[r]=n}return e},{});if(Object.keys(n).length>0)return n}function Hi(e){if(e)return Gi(Object.entries(e).reduce((e,[t,n])=>(n&&(e[`sentry-${t}`]=n),e),{}))}function Ui(e){if(!(!e||!fr(e)&&!Array.isArray(e)))return Array.isArray(e)?e.reduce((e,t)=>{let n=Wi(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{}):Wi(e)}function Wi(e){return e.split(`,`).map(e=>{let t=e.indexOf(`=`);return t===-1?[]:[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}function Gi(e){if(Object.keys(e).length!==0)return Object.entries(e).reduce((e,[t,n],r)=>{let i=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`,a=r===0?i:`${e},${i}`;return a.length>8192?(Cn&&Bn.warn(`Not adding key: ${t} with val: ${n} to baggage header due to exceeding baggage size limits.`),e):a},``)}const Ki=/^o(\d+)\./,qi=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Ji(e){return e===`http`||e===`https`}function Yi(e,t=!1){let{host:n,path:r,pass:i,port:a,projectId:o,protocol:s,publicKey:c}=e;return`${s}://${c}${t&&i?`:${i}`:``}@${n}${a?`:${a}`:``}/${r&&`${r}/`}${o}`}function Xi(e){let t=qi.exec(e);if(!t){jn(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});return}let[n,r,i=``,a=``,o=``,s=``]=t.slice(1),c=``,l=s,u=l.split(`/`);if(u.length>1&&(c=u.slice(0,-1).join(`/`),l=u.pop()),l){let e=l.match(/^\d+/);e&&(l=e[0])}return Zi({host:a,pass:i,path:c,projectId:l,port:o,protocol:n,publicKey:r})}function Zi(e){return{protocol:e.protocol,publicKey:e.publicKey||``,pass:e.pass||``,host:e.host,port:e.port||``,path:e.path||``,projectId:e.projectId}}function Qi(e){if(!Cn)return!0;let{port:t,projectId:n,protocol:r}=e;return[`protocol`,`publicKey`,`host`,`projectId`].find(t=>e[t]?!1:(Bn.error(`Invalid Sentry Dsn: ${t} missing`),!0))?!1:n.match(/^\d+$/)?Ji(r)?t&&isNaN(parseInt(t,10))?(Bn.error(`Invalid Sentry Dsn: Invalid port ${t}`),!1):!0:(Bn.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(Bn.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function $i(e){return e.match(Ki)?.[1]}function ea(e){let t=e.getOptions(),{host:n}=e.getDsn()||{},r;return t.orgId?r=String(t.orgId):n&&(r=$i(n)),r}function ta(e){let t=typeof e==`string`?Xi(e):Zi(e);if(!(!t||!Qi(t)))return t}function na(e){if(typeof e==`boolean`)return Number(e);let t=typeof e==`string`?parseFloat(e):e;if(!(typeof t!=`number`||isNaN(t)||t<0||t>1))return t}const ra=RegExp(`^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$`);function ia(e){if(!e)return;let t=e.match(ra);if(!t)return;let n;return t[3]===`1`?n=!0:t[3]===`0`&&(n=!1),{traceId:t[1],parentSampled:n,parentSpanId:t[2]}}function aa(e,t){let n=ia(e),r=Vi(t);if(!n?.traceId)return{traceId:fi(),sampleRand:Ir()};let i=ca(n,r);r&&(r.sample_rand=i.toString());let{traceId:a,parentSpanId:o,parentSampled:s}=n;return{traceId:a,parentSpanId:o,sampled:s,dsc:r||{},sampleRand:i}}function oa(e=fi(),t=pi(),n){let r=``;return n!==void 0&&(r=n?`-1`:`-0`),`${e}-${t}${r}`}function sa(e=fi(),t=pi(),n){return`00-${e}-${t}-${n?`01`:`00`}`}function ca(e,t){let n=na(t?.sample_rand);if(n!==void 0)return n;let r=na(t?.sample_rate);return r&&e?.parentSampled!==void 0?e.parentSampled?Ir()*r:r+Ir()*(1-r):Ir()}function la(e,t){let n=ea(e);return t&&n&&t!==n?(Bn.log(`Won't continue trace because org IDs don't match (incoming baggage: ${t}, SDK options: ${n})`),!1):e.getOptions().strictTraceContinuation&&(t&&!n||!t&&n)?(Bn.log(`Starting a new trace because strict trace continuation is enabled but one org ID is missing (incoming baggage: ${t}, Sentry client: ${n})`),!1):!0}let ua=!1;function da(e){let{spanId:t,traceId:n,isRemote:r}=e.spanContext(),i=r?t:_a(e).parent_span_id,a=Bi(e).scope;return{parent_span_id:i,span_id:r?a?.getPropagationContext().propagationSpanId||pi():t,trace_id:n}}function fa(e){let{traceId:t,spanId:n}=e.spanContext();return oa(t,n,ba(e))}function pa(e){let{traceId:t,spanId:n}=e.spanContext();return sa(t,n,ba(e))}function ma(e){if(e&&e.length>0)return e.map(({context:{spanId:e,traceId:t,traceFlags:n,...r},attributes:i})=>({span_id:e,trace_id:t,sampled:n===1,attributes:i,...r}))}function ha(e){return typeof e==`number`?ga(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?ga(e.getTime()):oi()}function ga(e){return e>9999999999?e/1e3:e}function _a(e){if(ya(e))return e.getSpanJSON();let{spanId:t,traceId:n}=e.spanContext();if(va(e)){let{attributes:r,startTime:i,name:a,endTime:o,status:s,links:c}=e;return{span_id:t,trace_id:n,data:r,description:a,parent_span_id:`parentSpanId`in e?e.parentSpanId:`parentSpanContext`in e?e.parentSpanContext?.spanId:void 0,start_timestamp:ha(i),timestamp:ha(o)||void 0,status:xa(s),op:r[`sentry.op`],origin:r[`sentry.origin`],links:ma(c)}}return{span_id:t,trace_id:n,start_timestamp:0,data:{}}}function va(e){let t=e;return!!t.attributes&&!!t.startTime&&!!t.name&&!!t.endTime&&!!t.status}function ya(e){return typeof e.getSpanJSON==`function`}function ba(e){let{traceFlags:t}=e.spanContext();return t===1}function xa(e){if(!(!e||e.code===0))return e.code===1?`ok`:e.message||`internal_error`}function Sa(e){return e._sentryRootSpan||e}function Ca(){let e=ji(En());return e.getActiveSpan?e.getActiveSpan():gi(Mi())}function wa(){ua||=(jn(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),!0)}let Ta=!1;function Ea(){if(Ta)return;function e(){let e=Ca(),t=e&&Sa(e);if(t){let e=`internal_error`;Cn&&Bn.log(`[Tracing] Root span: ${e} -> Global error occurred`),t.setStatus({code:2,message:e})}}e.tag=`sentry_tracingErrorCallback`,Ta=!0,rr(e),or(e)}function Da(e){if(typeof __SENTRY_TRACING__==`boolean`&&!__SENTRY_TRACING__)return!1;let t=e||Li()?.getOptions();return!!t&&(t.tracesSampleRate!=null||!!t.tracesSampler)}function Oa(e){Bn.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function ka(e,t){if(!t?.length||!e.description)return!1;for(let n of t){if(ja(n)){if(Vr(e.description,n))return Cn&&Oa(e),!0;continue}if(!n.name&&!n.op)continue;let t=n.name?Vr(e.description,n.name):!0,r=n.op?e.op&&Vr(e.op,n.op):!0;if(t&&r)return Cn&&Oa(e),!0}return!1}function Aa(e,t){let n=t.parent_span_id,r=t.span_id;if(n)for(let t of e)t.parent_span_id===r&&(t.parent_span_id=n)}function ja(e){return typeof e==`string`||e instanceof RegExp}function Ma(e,t){let n=t.getOptions(),{publicKey:r}=t.getDsn()||{},i={environment:n.environment||`production`,release:n.release,public_key:r,trace_id:e,org_id:ea(t)};return t.emit(`createDsc`,i),i}function Na(e,t){let n=t.getPropagationContext();return n.dsc||Ma(n.traceId,e)}function Pa(e){let t=Li();if(!t)return{};let n=Sa(e),r=_a(n),i=r.data,a=n.spanContext().traceState,o=a?.get(`sentry.sample_rate`)??i[`sentry.sample_rate`]??i[`sentry.previous_trace_sample_rate`];function s(e){return(typeof o==`number`||typeof o==`string`)&&(e.sample_rate=`${o}`),e}let c=n._frozenDsc;if(c)return s(c);let l=a?.get(`sentry.dsc`),u=l&&Vi(l);if(u)return s(u);let d=Ma(e.spanContext().traceId,t),f=i[`sentry.source`],p=r.description;return f!==`url`&&p&&(d.transaction=p),Da()&&(d.sampled=String(ba(n)),d.sample_rand=a?.get(`sentry.sample_rand`)??Bi(n).scope?.getPropagationContext().sampleRand.toString()),s(d),t.emit(`createDsc`,d,n),d}function Fa(e,t=100,n=1/0){try{return La(``,e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function Ia(e,t=3,n=100*1024){let r=Fa(e,t);return Va(r)>n?Ia(e,t-1,n):r}function La(e,t,n=1/0,r=1/0,i=Ha()){let[a,o]=i;if(t==null||[`boolean`,`string`].includes(typeof t)||typeof t==`number`&&Number.isFinite(t))return t;let s=Ra(e,t);if(!s.startsWith(`[object `))return s;if(t.__sentry_skip_normalization__)return t;let c=typeof t.__sentry_override_normalization_depth__==`number`?t.__sentry_override_normalization_depth__:n;if(c===0)return s.replace(`object `,``);if(a(t))return`[Circular ~]`;let l=t;if(l&&typeof l.toJSON==`function`)try{return La(``,l.toJSON(),c-1,r,i)}catch{}let u=Array.isArray(t)?[]:{},d=0,f=Ar(t);for(let e in f){if(!Object.prototype.hasOwnProperty.call(f,e))continue;if(d>=r){u[e]=`[MaxProperties ~]`;break}let t=f[e];u[e]=La(e,t,c-1,r,i),d++}return o(t),u}function Ra(e,t){try{if(e===`domain`&&t&&typeof t==`object`&&t._events)return`[Domain]`;if(e===`domainEmitter`)return`[DomainEmitter]`;if(typeof global<`u`&&t===global)return`[Global]`;if(typeof window<`u`&&t===window)return`[Window]`;if(typeof document<`u`&&t===document)return`[Document]`;if(Sr(t))return Yn(t);if(br(t))return`[SyntheticEvent]`;if(typeof t==`number`&&!Number.isFinite(t))return`[${t}]`;if(typeof t==`function`)return`[Function: ${Jn(t)}]`;if(typeof t==`symbol`)return`[${String(t)}]`;if(typeof t==`bigint`)return`[BigInt: ${String(t)}]`;let n=za(t);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(e){return`**non-serializable** (${e})`}}function za(e){let t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:`null prototype`}function Ba(e){return~-encodeURI(e).split(/%..|./).length}function Va(e){return Ba(JSON.stringify(e))}function Ha(){let e=new WeakSet;function t(t){return e.has(t)?!0:(e.add(t),!1)}function n(t){e.delete(t)}return[t,n]}function Ua(e,t=[]){return[e,t]}function Wa(e,t){let[n,r]=e;return[n,[...r,t]]}function Ga(e,t){let n=e[1];for(let e of n){let n=e[0].type;if(t(e,n))return!0}return!1}function Ka(e,t){return Ga(e,(e,n)=>t.includes(n))}function qa(e){let t=Dn(wn);return t.encodePolyfill?t.encodePolyfill(e):new TextEncoder().encode(e)}function Ja(e){let[t,n]=e,r=JSON.stringify(t);function i(e){typeof r==`string`?r=typeof e==`string`?r+e:[qa(r),e]:r.push(typeof e==`string`?qa(e):e)}for(let e of n){let[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),typeof n==`string`||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Fa(n))}i(e)}}return typeof r==`string`?r:Ya(r)}function Ya(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Xa(e){let t=typeof e.data==`string`?qa(e.data):e.data;return[{type:`attachment`,length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const Za={sessions:`session`,event:`error`,client_report:`internal`,user_report:`default`,profile_chunk:`profile`,replay_event:`replay`,replay_recording:`replay`,check_in:`monitor`,raw_security:`security`,log:`log_item`,trace_metric:`metric`};function Qa(e){return e in Za}function $a(e){return Qa(e)?Za[e]:e}function eo(e){if(!e?.sdk)return;let{name:t,version:n}=e.sdk;return{name:t,version:n}}function to(e,t,n,r){let i=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date().toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:Yi(r)},...i&&{trace:i}}}function no(e,t){if(!t)return e;let n=e.sdk||{};return e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0},e}function ro(e,t,n,r){let i=eo(n);return Ua({sent_at:new Date().toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:Yi(t)}},[`aggregates`in e?[{type:`sessions`},e]:[{type:`session`},e.toJSON()]])}function io(e,t,n,r){let i=eo(n),a=e.type&&e.type!==`replay_event`?e.type:`event`;no(e,n?.sdk);let o=to(e,i,r,t);return delete e.sdkProcessingMetadata,Ua(o,[[{type:a},e]])}const ao=`__SENTRY_SUPPRESS_TRACING__`,oo=(e,t)=>{let n=ji(En());if(n.continueTrace)return n.continueTrace(e,t);let{sentryTrace:r,baggage:i}=e,a=Li(),o=Vi(i);return a&&!la(a,o?.org_id)?lo(t):Fi(e=>{let n=aa(r,i);return e.setPropagationContext(n),hi(e,void 0),t()})};function so(e,t){let n=uo();return n.withActiveSpan?n.withActiveSpan(e,t):Fi(n=>(hi(n,e||void 0),t(n)))}function co(e){let t=uo();return t.suppressTracing?t.suppressTracing(e):Fi(t=>{t.setSDKProcessingMetadata({[ao]:!0});let n=e();return t.setSDKProcessingMetadata({[ao]:void 0}),n})}function lo(e){return Fi(t=>(t.setPropagationContext({traceId:fi(),sampleRand:Ir()}),Cn&&Bn.log(`Starting a new trace with id ${t.getPropagationContext().traceId}`),so(null,e)))}function uo(){return ji(En())}function fo(e){return new mo(t=>{t(e)})}function po(e){return new mo((t,n)=>{n(e)})}var mo=class e{constructor(e){this._state=0,this._handlers=[],this._runExecutor(e)}then(t,n){return new e((e,r)=>{this._handlers.push([!1,n=>{if(!t)e(n);else try{e(t(n))}catch(e){r(e)}},t=>{if(!n)r(t);else try{e(n(t))}catch(e){r(e)}}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(t){return new e((e,n)=>{let r,i;return this.then(e=>{i=!1,r=e,t&&t()},e=>{i=!0,r=e,t&&t()}).then(()=>{if(i){n(r);return}e(r)})})}_executeHandlers(){if(this._state===0)return;let e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||=(this._state===1&&e[1](this._value),this._state===2&&e[2](this._value),!0)})}_runExecutor(e){let t=(e,t)=>{if(this._state===0){if(yr(t)){t.then(n,r);return}this._state=e,this._value=t,this._executeHandlers()}},n=e=>{t(1,e)},r=e=>{t(2,e)};try{e(n,r)}catch(e){r(e)}}};function ho(e,t,n,r=0){try{let i=go(t,n,e,r);return yr(i)?i:fo(i)}catch(e){return po(e)}}function go(e,t,n,r){let i=n[r];if(!e||!i)return e;let a=i({...e},t);return Cn&&a===null&&Bn.log(`Event processor "${i.id||`?`}" dropped event`),yr(a)?a.then(e=>go(e,t,n,r+1)):go(a,t,n,r+1)}let _o,vo,yo,bo;function xo(e){let t=wn._sentryDebugIds,n=wn._debugIds;if(!t&&!n)return{};let r=t?Object.keys(t):[],i=n?Object.keys(n):[];if(bo&&r.length===vo&&i.length===yo)return bo;vo=r.length,yo=i.length,bo={},_o||={};let a=(t,n)=>{for(let r of t){let t=n[r],i=_o?.[r];if(i&&bo&&t)bo[i[0]]=t,_o&&(_o[r]=[i[0],t]);else if(t){let n=e(r);for(let e=n.length-1;e>=0;e--){let i=n[e]?.filename;if(i&&bo&&_o){bo[i]=t,_o[r]=[i,t];break}}}}};return t&&a(r,t),n&&a(i,n),bo}function So(e,t){let{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:a}=t;Eo(e,t),r&&ko(e,r),Ao(e,n),Do(e,i),Oo(e,a)}function Co(e,t){let{extra:n,tags:r,attributes:i,user:a,contexts:o,level:s,sdkProcessingMetadata:c,breadcrumbs:l,fingerprint:u,eventProcessors:d,attachments:f,propagationContext:p,transactionName:m,span:h}=t;wo(e,`extra`,n),wo(e,`tags`,r),wo(e,`attributes`,i),wo(e,`user`,a),wo(e,`contexts`,o),e.sdkProcessingMetadata=di(e.sdkProcessingMetadata,c,2),s&&(e.level=s),m&&(e.transactionName=m),h&&(e.span=h),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),u.length&&(e.fingerprint=[...e.fingerprint,...u]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),f.length&&(e.attachments=[...e.attachments,...f]),e.propagationContext={...e.propagationContext,...p}}function wo(e,t,n){e[t]=di(e[t],n,1)}function To(e,t){let n=Pi().getScopeData();return e&&Co(n,e.getScopeData()),t&&Co(n,t.getScopeData()),n}function Eo(e,t){let{extra:n,tags:r,user:i,contexts:a,level:o,transactionName:s}=t;Object.keys(n).length&&(e.extra={...n,...e.extra}),Object.keys(r).length&&(e.tags={...r,...e.tags}),Object.keys(i).length&&(e.user={...i,...e.user}),Object.keys(a).length&&(e.contexts={...a,...e.contexts}),o&&(e.level=o),s&&e.type!==`transaction`&&(e.transaction=s)}function Do(e,t){let n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}function Oo(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}function ko(e,t){e.contexts={trace:da(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Pa(t),...e.sdkProcessingMetadata};let n=_a(Sa(t)).description;n&&!e.transaction&&e.type===`transaction`&&(e.transaction=n)}function Ao(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint.length||delete e.fingerprint}function jo(e,t,n,r,i,a){let{normalizeDepth:o=3,normalizeMaxBreadth:s=1e3}=e,c={...t,event_id:t.event_id||n.event_id||Kr(),timestamp:t.timestamp||ri()},l=n.integrations||e.integrations.map(e=>e.name);Mo(c,e),Fo(c,l),i&&i.emit(`applyFrameMetadata`,t),t.type===void 0&&No(c,e.stackParser);let u=Lo(r,n.captureContext);n.mechanism&&Xr(c,n.mechanism);let d=i?i.getEventProcessors():[],f=To(a,u),p=[...n.attachments||[],...f.attachments];p.length&&(n.attachments=p),So(c,f);let m=[...d,...f.eventProcessors];return(n.data&&n.data.__sentry__===!0?fo(c):ho(m,c,n)).then(e=>(e&&Po(e),typeof o==`number`&&o>0?Io(e,o,s):e))}function Mo(e,t){let{environment:n,release:r,dist:i,maxValueLength:a}=t;e.environment=e.environment||n||`production`,!e.release&&r&&(e.release=r),!e.dist&&i&&(e.dist=i);let o=e.request;o?.url&&a&&(o.url=Rr(o.url,a)),a&&e.exception?.values?.forEach(e=>{e.value&&=Rr(e.value,a)})}function No(e,t){let n=xo(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}function Po(e){let t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),Object.keys(t).length===0)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];let n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:`sourcemap`,code_file:e,debug_id:t})})}function Fo(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}function Io(e,t,n){if(!e)return null;let r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Fa(e.data,t,n)}}))},...e.user&&{user:Fa(e.user,t,n)},...e.contexts&&{contexts:Fa(e.contexts,t,n)},...e.extra&&{extra:Fa(e.extra,t,n)}};return e.contexts?.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=Fa(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>({...e,...e.data&&{data:Fa(e.data,t,n)}}))),e.contexts?.flags&&r.contexts&&(r.contexts.flags=Fa(e.contexts.flags,3,n)),r}function Lo(e,t){if(!t)return e;let n=e?e.clone():new _i;return n.update(t),n}function Ro(e){if(e)return zo(e)||Vo(e)?{captureContext:e}:e}function zo(e){return e instanceof _i||typeof e==`function`}const Bo=[`user`,`level`,`extra`,`contexts`,`tags`,`fingerprint`,`propagationContext`];function Vo(e){return Object.keys(e).some(e=>Bo.includes(e))}function Ho(e,t){return Mi().captureException(e,Ro(t))}function Uo(e,t){let n=typeof t==`string`?t:void 0,r=typeof t==`string`?void 0:{captureContext:t};return Mi().captureMessage(e,n,r)}function Wo(e,t){Ni().setTag(e,t)}function Go(){let e=Li();return e?.getOptions().enabled!==!1&&!!e?.getTransport()}function Ko(e){let t=Ni(),{user:n}=To(t,Mi()),{userAgent:r}=wn.navigator||{},i=si({user:n,...r&&{userAgent:r},...e}),a=t.getSession();return a?.status===`ok`&&ci(a,{status:`exited`}),qo(),t.setSession(i),i}function qo(){let e=Ni(),t=Mi().getSession()||e.getSession();t&&li(t),Jo(),e.setSession()}function Jo(){let e=Ni(),t=Li(),n=e.getSession();n&&t&&t.captureSession(n)}function Yo(e){let t=e.protocol?`${e.protocol}:`:``,n=e.port?`:${e.port}`:``;return`${t}//${e.host}${n}${e.path?`/${e.path}`:``}/api/`}function Xo(e){return`${Yo(e)}${e.projectId}/envelope/`}function Zo(e,t){let n={sentry_version:`7`};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}function Qo(e,t,n){return t||`${Xo(e)}?${Zo(e,n)}`}const $o=[];function es(e){let t={};return e.forEach(e=>{let{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.values(t)}function ts(e){let t=e.defaultIntegrations||[],n=e.integrations;t.forEach(e=>{e.isDefaultInstance=!0});let r;if(Array.isArray(n))r=[...t,...n];else if(typeof n==`function`){let e=n(t);r=Array.isArray(e)?e:[e]}else r=t;return es(r)}function ns(e,t){let n={};return t.forEach(t=>{t&&is(e,t,n)}),n}function rs(e,t){for(let n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function is(e,t,n){if(n[t.name]){Cn&&Bn.log(`Integration skipped because it was already installed: ${t.name}`);return}if(n[t.name]=t,!$o.includes(t.name)&&typeof t.setupOnce==`function`&&(t.setupOnce(),$o.push(t.name)),t.setup&&typeof t.setup==`function`&&t.setup(e),typeof t.preprocessEvent==`function`){let n=t.preprocessEvent.bind(t);e.on(`preprocessEvent`,(t,r)=>n(t,r,e))}if(typeof t.processEvent==`function`){let n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}Cn&&Bn.log(`Integration installed: ${t.name}`)}function as(e){return e}function os(e,t){return t?Fi(t,()=>{let n=Ca(),r=n?da(n):Ri(t);return[n?Pa(n):Na(e,t),r]}):[void 0,void 0]}function ss(e){return[{type:`log`,item_count:e.length,content_type:`application/vnd.sentry.items.log+json`},{items:e}]}function cs(e,t,n,r){let i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Yi(r)),Ua(i,[ss(e)])}function ls(e,t){let n=t??us(e)??[];if(n.length===0)return;let r=e.getOptions(),i=cs(n,r._metadata,r.tunnel,e.getDsn());ds().set(e,[]),e.emit(`flushLogs`),e.sendEnvelope(i)}function us(e){return ds().get(e)}function ds(){return On(`clientToLogBufferMap`,()=>new WeakMap)}function fs(e){return[{type:`trace_metric`,item_count:e.length,content_type:`application/vnd.sentry.items.trace-metric+json`},{items:e}]}function ps(e,t,n,r){let i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Yi(r)),Ua(i,[fs(e)])}function ms(e,t){let n=t??hs(e)??[];if(n.length===0)return;let r=e.getOptions(),i=ps(n,r._metadata,r.tunnel,e.getDsn());gs().set(e,[]),e.emit(`flushMetrics`),e.sendEnvelope(i)}function hs(e){return gs().get(e)}function gs(){return On(`clientToMetricBufferMap`,()=>new WeakMap)}function _s(e){return typeof e==`object`&&typeof e.unref==`function`&&e.unref(),e}const vs=Symbol.for(`SentryBufferFullError`);function ys(e=100){let t=new Set;function n(){return t.size<e}function r(e){t.delete(e)}function i(e){if(!n())return po(vs);let i=e();return t.add(i),i.then(()=>r(i),()=>r(i)),i}function a(e){if(!t.size)return fo(!0);let n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;let r=[n,new Promise(t=>_s(setTimeout(()=>t(!1),e)))];return Promise.race(r)}return{get $(){return Array.from(t)},add:i,drain:a}}function bs(e,t=Lr()){let n=parseInt(`${e}`,10);if(!isNaN(n))return n*1e3;let r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}function xs(e,t){return e[t]||e.all||0}function Ss(e,t,n=Lr()){return xs(e,t)>n}function Cs(e,{statusCode:t,headers:n},r=Lr()){let i={...e},a=n?.[`x-sentry-rate-limits`],o=n?.[`retry-after`];if(a)for(let e of a.trim().split(`,`)){let[t,n,,,a]=e.split(`:`,5),o=parseInt(t,10),s=(isNaN(o)?60:o)*1e3;if(!n)i.all=r+s;else for(let e of n.split(`;`))e===`metric_bucket`?(!a||a.split(`;`).includes(`custom`))&&(i[e]=r+s):i[e]=r+s}else o?i.all=r+bs(o,r):t===429&&(i.all=r+60*1e3);return i}function ws(e,t,n=ys(e.bufferSize||64)){let r={},i=e=>n.drain(e);function a(i){let a=[];if(Ga(i,(t,n)=>{let i=$a(n);Ss(r,i)?e.recordDroppedEvent(`ratelimit_backoff`,i):a.push(t)}),a.length===0)return Promise.resolve({});let o=Ua(i[0],a),s=t=>{if(Ka(o,[`client_report`])){Cn&&Bn.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`);return}Ga(o,(n,r)=>{e.recordDroppedEvent(t,$a(r))})};return n.add(()=>t({body:Ja(o)}).then(e=>e.statusCode===413?(Cn&&Bn.error(`Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.`),s(`send_error`),e):(Cn&&e.statusCode!==void 0&&(e.statusCode<200||e.statusCode>=300)&&Bn.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),r=Cs(r,e),e),e=>{throw s(`network_error`),Cn&&Bn.error(`Encountered error running transport request:`,e),e})).then(e=>e,e=>{if(e===vs)return Cn&&Bn.error(`Skipped sending event because buffer is full.`),s(`queue_overflow`),Promise.resolve({});throw e})}return{send:a,flush:i}}function Ts(e,t,n){let r=[{type:`client_report`},{timestamp:n||ri(),discarded_events:e}];return Ua(t?{dsn:t}:{},[r])}function Es(e){let t=[];e.message&&t.push(e.message);try{let n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}function Ds(e){let{trace_id:t,parent_span_id:n,span_id:r,status:i,origin:a,data:o,op:s}=e.contexts?.trace??{};return{data:o??{},description:e.transaction,op:s,parent_span_id:n,span_id:r??``,start_timestamp:e.start_timestamp??0,status:i,timestamp:e.timestamp,trace_id:t??``,origin:a,profile_id:o?.[`sentry.profile_id`],exclusive_time:o?.[`sentry.exclusive_time`],measurements:e.measurements,is_segment:!0}}function Os(e){return{type:`transaction`,timestamp:e.timestamp,start_timestamp:e.start_timestamp,transaction:e.description,contexts:{trace:{trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,op:e.op,status:e.status,origin:e.origin,data:{...e.data,...e.profile_id&&{"sentry.profile_id":e.profile_id},...e.exclusive_time&&{"sentry.exclusive_time":e.exclusive_time}}}},measurements:e.measurements}}const ks=`Not capturing exception because it's already been captured.`,As=`Discarded session because of missing or non-string release`,js=Symbol.for(`SentryInternalError`),Ms=Symbol.for(`SentryDoNotSendEventError`);function Ns(e){return{message:e,[js]:!0}}function Ps(e){return{message:e,[Ms]:!0}}function Fs(e){return!!e&&typeof e==`object`&&js in e}function Is(e){return!!e&&typeof e==`object`&&Ms in e}function Ls(e,t,n,r,i){let a=0,o,s=!1;e.on(n,()=>{a=0,clearTimeout(o),s=!1}),e.on(t,t=>{a+=r(t),a>=8e5?i(e):s||(s=!0,o=_s(setTimeout(()=>{i(e)},5e3)))}),e.on(`flush`,()=>{i(e)})}var Rs=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=ys(e.transportOptions?.bufferSize??64),e.dsn?this._dsn=ta(e.dsn):Cn&&Bn.warn(`No DSN provided, client will not send events.`),this._dsn){let t=Qo(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}this._options.enableLogs=this._options.enableLogs??this._options._experiments?.enableLogs,this._options.enableLogs&&Ls(this,`afterCaptureLog`,`flushLogs`,Gs,ls),(this._options.enableMetrics??this._options._experiments?.enableMetrics??!0)&&Ls(this,`afterCaptureMetric`,`flushMetrics`,Ws,ms)}captureException(e,t,n){let r=Kr();if(ei(e))return Cn&&Bn.log(ks),r;let i={event_id:r,...t};return this._process(()=>this.eventFromException(e,i).then(e=>this._captureEvent(e,i,n)).then(e=>e),`error`),i.event_id}captureMessage(e,t,n,r){let i={event_id:Kr(),...n},a=pr(e)?e:String(e),o=mr(e),s=o?this.eventFromMessage(a,t,i):this.eventFromException(e,i);return this._process(()=>s.then(e=>this._captureEvent(e,i,r)),o?`unknown`:`error`),i.event_id}captureEvent(e,t,n){let r=Kr();if(t?.originalException&&ei(t.originalException))return Cn&&Bn.log(ks),r;let i={event_id:r,...t},a=e.sdkProcessingMetadata||{},o=a.capturedSpanScope,s=a.capturedSpanIsolationScope,c=zs(e.type);return this._process(()=>this._captureEvent(e,i,o||n,s),c),i.event_id}captureSession(e){this.sendSession(e),ci(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){let t=this._transport;if(!t)return!0;this.emit(`flush`);let n=await this._isClientDoneProcessing(e),r=await t.flush(e);return n&&r}async close(e){ls(this);let t=await this.flush(e);return this.getOptions().enabled=!1,this.emit(`close`),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith(`Spotlight`)))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){let t=this._integrations[e.name];is(this,e,this._integrations),t||rs(this,[e])}sendEvent(e,t={}){this.emit(`beforeSendEvent`,e,t);let n=io(e,this._dsn,this._options._metadata,this._options.tunnel);for(let e of t.attachments||[])n=Wa(n,Xa(e));this.sendEnvelope(n).then(t=>this.emit(`afterSendEvent`,e,t))}sendSession(e){let{release:t,environment:n=`production`}=this._options;if(`aggregates`in e){let r=e.attrs||{};if(!r.release&&!t){Cn&&Bn.warn(As);return}r.release=r.release||t,r.environment=r.environment||n,e.attrs=r}else{if(!e.release&&!t){Cn&&Bn.warn(As);return}e.release=e.release||t,e.environment=e.environment||n}this.emit(`beforeSendSession`,e);let r=ro(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(r)}recordDroppedEvent(e,t,n=1){if(this._options.sendClientReports){let r=`${e}:${t}`;Cn&&Bn.log(`Recording outcome: "${r}"${n>1?` (${n} times)`:``}`),this._outcomes[r]=(this._outcomes[r]||0)+n}}on(e,t){let n=this._hooks[e]=this._hooks[e]||new Set,r=(...e)=>t(...e);return n.add(r),()=>{n.delete(r)}}emit(e,...t){let n=this._hooks[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit(`beforeEnvelope`,e),this._isEnabled()&&this._transport)try{return await this._transport.send(e)}catch(e){return Cn&&Bn.error(`Error while sending envelope:`,e),{}}return Cn&&Bn.error(`Transport disabled`),{}}dispose(){}_setupIntegrations(){let{integrations:e}=this._options;this._integrations=ns(this,e),rs(this,e)}_updateSessionFromEvent(e,t){let n=t.level===`fatal`,r=!1,i=t.exception?.values;if(i){r=!0,n=!1;for(let e of i)if(e.mechanism?.handled===!1){n=!0;break}}let a=e.status===`ok`;(a&&e.errors===0||a&&n)&&(ci(e,{...n&&{status:`crashed`},errors:e.errors||Number(r||n)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,t,n,r){let i=this.getOptions(),a=Object.keys(this._integrations);return!t.integrations&&a?.length&&(t.integrations=a),this.emit(`preprocessEvent`,e,t),e.type||r.setLastEventId(e.event_id||t.event_id),jo(i,e,t,n,this,r).then(e=>e===null?e:(this.emit(`postprocessEvent`,e,t),e.contexts={trace:{...e.contexts?.trace,...Ri(n)},...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Na(this,n),...e.sdkProcessingMetadata},e))}_captureEvent(e,t={},n=Mi(),r=Ni()){return Cn&&Hs(e)&&Bn.log(`Captured error event \`${Es(e)[0]||`<unknown>`}\``),this._processEvent(e,t,n,r).then(e=>e.event_id,e=>{Cn&&(Is(e)?Bn.log(e.message):Fs(e)?Bn.warn(e.message):Bn.warn(e))})}_processEvent(e,t,n,r){let i=this.getOptions(),{sampleRate:a}=i,o=Us(e),s=Hs(e),c=`before send for type \`${e.type||`error`}\``,l=a===void 0?void 0:na(a);if(s&&typeof l==`number`&&Ir()>l)return this.recordDroppedEvent(`sample_rate`,`error`),po(Ps(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));let u=zs(e.type);return this._prepareEvent(e,t,n,r).then(e=>{if(e===null)throw this.recordDroppedEvent(`event_processor`,u),Ps("An event processor returned `null`, will not send event.");return t.data?.__sentry__===!0?e:Bs(Vs(this,i,e,t),c)}).then(i=>{if(i===null){if(this.recordDroppedEvent(`before_send`,u),o){let t=1+(e.spans||[]).length;this.recordDroppedEvent(`before_send`,`span`,t)}throw Ps(`${c} returned \`null\`, will not send event.`)}let a=n.getSession()||r.getSession();if(s&&a&&this._updateSessionFromEvent(a,i),o){let e=(i.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(i.spans?i.spans.length:0);e>0&&this.recordDroppedEvent(`before_send`,`span`,e)}let l=i.transaction_info;return o&&l&&i.transaction!==e.transaction&&(i.transaction_info={...l,source:`custom`}),this.sendEvent(i,t),i}).then(null,e=>{throw Is(e)||Fs(e)?e:(this.captureException(e,{mechanism:{handled:!1,type:`internal`},data:{__sentry__:!0},originalException:e}),Ns(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`))})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===vs&&this.recordDroppedEvent(`queue_overflow`,t),e))}_clearOutcomes(){let e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{let[n,r]=e.split(`:`);return{reason:n,category:r,quantity:t}})}_flushOutcomes(){Cn&&Bn.log(`Flushing outcomes...`);let e=this._clearOutcomes();if(e.length===0){Cn&&Bn.log(`No outcomes to send`);return}if(!this._dsn){Cn&&Bn.log(`No dsn provided, will not send outcomes`);return}Cn&&Bn.log(`Sending outcomes:`,e);let t=Ts(e,this._options.tunnel&&Yi(this._dsn));this.sendEnvelope(t)}};function zs(e){return e===`replay_event`?`replay`:e||`error`}function Bs(e,t){let n=`${t} must return \`null\` or a valid event.`;if(yr(e))return e.then(e=>{if(!hr(e)&&e!==null)throw Ns(n);return e},e=>{throw Ns(`${t} rejected with ${e}`)});if(!hr(e)&&e!==null)throw Ns(n);return e}function Vs(e,t,n,r){let{beforeSend:i,beforeSendTransaction:a,beforeSendSpan:o,ignoreSpans:s}=t,c=n;if(Hs(c)&&i)return i(c,r);if(Us(c)){if(o||s){let t=Ds(c);if(s?.length&&ka(t,s))return null;if(o){let e=o(t);e?c=di(n,Os(e)):wa()}if(c.spans){let t=[],n=c.spans;for(let e of n){if(s?.length&&ka(e,s)){Aa(n,e);continue}if(o){let n=o(e);n?t.push(n):(wa(),t.push(e))}else t.push(e)}let r=c.spans.length-t.length;r&&e.recordDroppedEvent(`before_send`,`span`,r),c.spans=t}}if(a){if(c.spans){let e=c.spans.length;c.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return a(c,r)}}return c}function Hs(e){return e.type===void 0}function Us(e){return e.type===`transaction`}function Ws(e){let t=0;return e.name&&(t+=e.name.length*2),t+=8,t+Ks(e.attributes)}function Gs(e){let t=0;return e.message&&(t+=e.message.length*2),t+Ks(e.attributes)}function Ks(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*qs(e[0]):mr(e)?t+=qs(e):t+=100}),t}function qs(e){return typeof e==`string`?e.length*2:typeof e==`number`?8:typeof e==`boolean`?4:0}function Js(e,t,n,r,i){let a={sent_at:new Date().toISOString()};return n?.sdk&&(a.sdk={name:n.sdk.name,version:n.sdk.version}),r&&i&&(a.dsn=Yi(i)),t&&(a.trace=t),Ua(a,[Ys(e)])}function Ys(e){return[{type:`check_in`},e]}function Xs(e){let t=e._metadata?.sdk,n=t?.name&&t?.version?`${t?.name}/${t?.version}`:void 0;e.transportOptions={...e.transportOptions,headers:{...n&&{"user-agent":n},...e.transportOptions?.headers}}}function Zs(e,t){return e(t.stack||``,1)}function Qs(e){return lr(e)&&`__sentry_fetch_url_host__`in e&&typeof e.__sentry_fetch_url_host__==`string`}function $s(e){return Qs(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}function ec(e,t){let n={type:t.name||t.constructor.name,value:$s(t)},r=Zs(e,t);return r.length&&(n.stacktrace={frames:r}),n}function tc(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(n instanceof Error)return n}}function nc(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message '${e.message}'`),t}else if(`message`in e&&typeof e.message==`string`)return e.message;let t=Nr(e);if(dr(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let n=rc(e);return`${n&&n!==`Object`?`'${n}'`:`Object`} captured as exception with keys: ${t}`}function rc(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function ic(e,t,n,r){if(lr(n))return[n,void 0];if(t.synthetic=!0,hr(n)){let t=e?.getOptions().normalizeDepth,i={__serialized__:Ia(n,t)},a=tc(n);if(a)return[a,i];let o=nc(n),s=r?.syntheticException||Error(o);return s.message=o,[s,i]}let i=r?.syntheticException||Error(n);return i.message=`${n}`,[i,void 0]}function ac(e,t,n,r){let i=r?.data&&r.data.mechanism||{handled:!0,type:`generic`},[a,o]=ic(e,i,n,r),s={exception:{values:[ec(t,a)]}};return o&&(s.extra=o),Yr(s,void 0,void 0),Xr(s,i),{...s,event_id:r?.event_id}}function oc(e,t,n=`info`,r,i){let a={event_id:r?.event_id,level:n};if(i&&r?.syntheticException){let n=Zs(e,r.syntheticException);n.length&&(a.exception={values:[{value:t,stacktrace:{frames:n}}]},Xr(a,{synthetic:!0}))}if(pr(t)){let{__sentry_template_string__:e,__sentry_template_values__:n}=t;return a.logentry={message:e,params:n},a}return a.message=t,a}var sc=class extends Rs{constructor(e){Ea(),Xs(e),super(e),this._setUpMetricsProcessing()}eventFromException(e,t){let n=ac(this,this._options.stackParser,e,t);return n.level=`error`,fo(n)}eventFromMessage(e,t=`info`,n){return fo(oc(this._options.stackParser,e,t,n,this._options.attachStacktrace))}captureException(e,t,n){return cc(t),super.captureException(e,t,n)}captureEvent(e,t,n){return!e.type&&e.exception?.values&&e.exception.values.length>0&&cc(t),super.captureEvent(e,t,n)}captureCheckIn(e,t,n){let r=`checkInId`in e&&e.checkInId?e.checkInId:Kr();if(!this._isEnabled())return Cn&&Bn.warn(`SDK not enabled, will not capture check-in.`),r;let{release:i,environment:a,tunnel:o}=this.getOptions(),s={check_in_id:r,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:a};`duration`in e&&(s.duration=e.duration),t&&(s.monitor_config={schedule:t.schedule,checkin_margin:t.checkinMargin,max_runtime:t.maxRuntime,timezone:t.timezone,failure_issue_threshold:t.failureIssueThreshold,recovery_threshold:t.recoveryThreshold});let[c,l]=os(this,n);l&&(s.contexts={trace:l});let u=Js(s,c,this.getSdkMetadata(),o,this.getDsn());return Cn&&Bn.log(`Sending checkin:`,e.monitorSlug,e.status),this.sendEnvelope(u),r}dispose(){Cn&&Bn.log(`Disposing client...`);for(let e of Object.keys(this._hooks))this._hooks[e]?.clear();this._hooks={},this._eventProcessors.length=0,this._integrations={},this._outcomes={},this._transport=void 0,this._promiseBuffer=ys(64)}_prepareEvent(e,t,n,r){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:e.contexts?.runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,t,n,r)}_setUpMetricsProcessing(){this.on(`processMetric`,e=>{this._options.serverName&&(e.attributes={"server.address":this._options.serverName,...e.attributes})})}};function cc(e){let t=Ni().getScopeData().sdkProcessingMetadata.requestSession;if(t){let n=e?.mechanism?.handled??!0;n&&t.status!==`crashed`?t.status=`errored`:n||(t.status=`crashed`)}}const lc=new Set([`false`,`f`,`n`,`no`,`off`,`0`]),uc=new Set([`true`,`t`,`y`,`yes`,`on`,`1`]);function dc(e,t){let n=String(e).toLowerCase();return lc.has(n)?!1:uc.has(n)?!0:t?.strict?null:!!e}function fc(e){if(!e)return{};let t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};let n=t[6]||``,r=t[8]||``;return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}function pc(e){return e.split(/[?#]/,1)[0]}function mc(e){let{protocol:t,host:n,path:r}=e,i=n?.replace(/^.*@/,`[filtered]:[filtered]@`).replace(/(:80)$/,``).replace(/(:443)$/,``)||``;return`${t?`${t}://`:``}${i}${r}`}function hc(e,t,n=[t],r=`npm`){let i=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};i.name||(i.name=`sentry.javascript.${t}`,i.packages=n.map(e=>({name:`${r}:@sentry/${e}`,version:Tn})),i.version=Tn)}function gc(e={}){let t=e.client||Li();if(!Go()||!t)return{};let n=ji(En());if(n.getTraceData)return n.getTraceData(e);let r=e.scope||Mi(),i=e.span||Ca(),a=i?fa(i):_c(r),o=Hi(i?Pa(i):Na(t,r));if(!ra.test(a))return Bn.warn(`Invalid sentry-trace data. Cannot generate trace data`),{};let s={"sentry-trace":a,baggage:o};return e.propagateTraceparent&&(s.traceparent=i?pa(i):vc(r)),s}function _c(e){let{traceId:t,sampled:n,propagationSpanId:r}=e.getPropagationContext();return oa(t,r,n)}function vc(e){let{traceId:t,sampled:n,propagationSpanId:r}=e.getPropagationContext();return sa(t,r,n)}const yc=`[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:`;function bc(e,t,n){if(typeof e!=`string`||!t)return!0;let r=n?.get(e);if(r!==void 0)return Cn&&!r&&Bn.log(yc,e),r;let i=Hr(e,t);return n?.set(e,i),Cn&&!i&&Bn.log(yc,e),i}function xc(e){let t=Object.create(null);try{Object.entries(e).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}catch{}return t}function Sc(e){let t=e.headers||{},n=(typeof t[`x-forwarded-host`]==`string`?t[`x-forwarded-host`]:void 0)||(typeof t.host==`string`?t.host:void 0),r=(typeof t[`x-forwarded-proto`]==`string`?t[`x-forwarded-proto`]:void 0)||e.protocol||(e.socket?.encrypted?`https`:`http`),i=e.url||``,a=Cc({url:i,host:n,protocol:r}),o=e.body||void 0,s=e.cookies;return{url:a,method:e.method,query_string:wc(i),headers:xc(t),cookies:s,data:o}}function Cc({url:e,protocol:t,host:n}){if(e?.startsWith(`http`))return e;if(e&&n)return`${t}://${n}${e}`}function wc(e){if(e)try{let t=new URL(e,`http://s.io`).search.slice(1);return t.length?t:void 0}catch{return}}function Tc(e,t){let n=Li(),r=Ni();if(!n)return;let{beforeBreadcrumb:i=null,maxBreadcrumbs:a=100}=n.getOptions();if(a<=0)return;let o={timestamp:ri(),...e},s=i?jn(()=>i(o,t)):o;s!==null&&(n.emit&&n.emit(`beforeAddBreadcrumb`,s,t),r.addBreadcrumb(s,a))}let Ec;const Dc=new WeakMap,Oc=as((()=>({name:`FunctionToString`,setupOnce(){Ec=Function.prototype.toString;try{Function.prototype.toString=function(...e){let t=kr(this),n=Dc.has(Li())&&t!==void 0?t:this;return Ec.apply(n,e)}}catch{}},setup(e){Dc.set(e,!0)}}))),kc=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],Ac=as((e={})=>{let t;return{name:`EventFilters`,setup(n){t=jc(e,n.getOptions())},processEvent(n,r,i){return t||=jc(e,i.getOptions()),Mc(n,t)?null:n}}});function jc(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:kc],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function Mc(e,t){if(!e.type){if(Nc(e,t.ignoreErrors))return Cn&&Bn.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${Jr(e)}`),!0;if(zc(e))return Cn&&Bn.warn(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${Jr(e)}`),!0;if(Fc(e,t.denyUrls))return Cn&&Bn.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${Jr(e)}.\nUrl: ${Rc(e)}`),!0;if(!Ic(e,t.allowUrls))return Cn&&Bn.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${Jr(e)}.\nUrl: ${Rc(e)}`),!0}else if(e.type===`transaction`&&Pc(e,t.ignoreTransactions))return Cn&&Bn.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${Jr(e)}`),!0;return!1}function Nc(e,t){return t?.length?Es(e).some(e=>Hr(e,t)):!1}function Pc(e,t){if(!t?.length)return!1;let n=e.transaction;return n?Hr(n,t):!1}function Fc(e,t){if(!t?.length)return!1;let n=Rc(e);return n?Hr(n,t):!1}function Ic(e,t){if(!t?.length)return!0;let n=Rc(e);return n?Hr(n,t):!0}function Lc(e=[]){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.filename!==`<anonymous>`&&n.filename!==`[native code]`)return n.filename||null}return null}function Rc(e){try{let t=[...e.exception?.values??[]].reverse().find(e=>e.mechanism?.parent_id===void 0&&e.stacktrace?.frames?.length)?.stacktrace?.frames;return t?Lc(t):null}catch{return Cn&&Bn.error(`Cannot extract url for event ${Jr(e)}`),null}}function zc(e){return e.exception?.values?.length?!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&e.type!==`Error`||e.value):!1}function Bc(e,t,n,r,i,a){if(!i.exception?.values||!a||!xr(a.originalException,Error))return;let o=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;o&&(i.exception.values=Vc(e,t,r,a.originalException,n,i.exception.values,o,0))}function Vc(e,t,n,r,i,a,o,s){if(a.length>=n+1)return a;let c=[...a];if(xr(r[i],Error)){Uc(o,s,r);let a=e(t,r[i]),l=c.length;Wc(a,i,l,s),c=Vc(e,t,n,r[i],i,[a,...c],a,l)}return Hc(r)&&r.errors.forEach((a,l)=>{if(xr(a,Error)){Uc(o,s,r);let u=e(t,a),d=c.length;Wc(u,`errors[${l}]`,d,s),c=Vc(e,t,n,a,i,[u,...c],u,d)}}),c}function Hc(e){return Array.isArray(e.errors)}function Uc(e,t,n){e.mechanism={handled:!0,type:`auto.core.linked_errors`,...Hc(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Wc(e,t,n,r){e.mechanism={handled:!0,...e.mechanism,type:`chained`,source:t,exception_id:n,parent_id:r}}const Gc=as(((e={})=>{let t=e.limit||5,n=e.key||`cause`;return{name:`LinkedErrors`,preprocessEvent(e,r,i){Bc(ec,i.getOptions().stackParser,n,t,e,r)}}}));function Kc(e){let t={},n=0;for(;n<e.length;){let r=e.indexOf(`=`,n);if(r===-1)break;let i=e.indexOf(`;`,n);if(i===-1)i=e.length;else if(i<r){n=e.lastIndexOf(`;`,r-1)+1;continue}let a=e.slice(n,r).trim();if(t[a]===void 0){let n=e.slice(r+1,i).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));try{t[a]=n.indexOf(`%`)===-1?n:decodeURIComponent(n)}catch{t[a]=n}}n=i+1}return t}const qc=[`X-Client-IP`,`X-Forwarded-For`,`Fly-Client-IP`,`CF-Connecting-IP`,`Fastly-Client-Ip`,`True-Client-Ip`,`X-Real-IP`,`X-Cluster-Client-IP`,`X-Forwarded`,`Forwarded-For`,`Forwarded`,`X-Vercel-Forwarded-For`];function Jc(e){let t={};for(let n of Object.keys(e))t[n.toLowerCase()]=e[n];return qc.map(e=>{let n=t[e.toLowerCase()],r=Array.isArray(n)?n.join(`;`):n;return e===`Forwarded`?Yc(r):r?.split(`,`).map(e=>e.trim())}).reduce((e,t)=>t?e.concat(t):e,[]).find(e=>e!==null&&Xc(e))||null}function Yc(e){if(!e)return null;for(let t of e.split(`;`))if(t.startsWith(`for=`))return t.slice(4);return null}function Xc(e){return/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)/.test(e)}const Zc={cookies:!0,data:!0,headers:!0,query_string:!0,url:!0},Qc=as(((e={})=>{let t={...Zc,...e.include};return{name:`RequestData`,processEvent(e,n,r){let{sdkProcessingMetadata:i={}}=e,{normalizedRequest:a,ipAddress:o}=i,s={...t,ip:t.ip??r.getOptions().sendDefaultPii};return a&&$c(e,a,{ipAddress:o},s),e}}}));function $c(e,t,n,r){if(e.request={...e.request,...el(t,r)},r.ip){let r=t.headers&&Jc(t.headers)||n.ipAddress;r&&(e.user={...e.user,ip_address:r})}}function el(e,t){let n={},r={...e.headers};return t.headers&&(n.headers=r,t.cookies||delete r.cookie,t.ip||qc.forEach(e=>{delete r[e]})),n.method=e.method,t.url&&(n.url=e.url),t.cookies&&(n.cookies=e.cookies||(r?.cookie?Kc(r.cookie):void 0)||{}),t.query_string&&(n.query_string=e.query_string),t.data&&(n.data=e.data),n}function tl(e){let t=`console`;$n(t,e),er(t,nl)}function nl(){`console`in wn&&kn.forEach(function(e){e in wn.console&&Er(wn.console,e,function(t){return An[e]=t,function(...t){tr(`console`,{args:t,level:e}),An[e]?.apply(wn.console,t)}})})}function rl(e){return e===`warn`?`warning`:[`fatal`,`error`,`warning`,`log`,`info`,`debug`].includes(e)?e:`log`}const il=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function al(e){let t=e.length>1024?`<truncated>${e.slice(-1024)}`:e,n=il.exec(t);return n?n.slice(1):[]}function ol(e){let t=al(e),n=t[0]||``,r=t[1];return!n&&!r?`.`:(r&&=r.slice(0,r.length-1),n+r)}const sl=as((e={})=>{let t=new Set(e.levels||kn);return{name:`Console`,setup(e){tl(({args:n,level:r})=>{Li()!==e||!t.has(r)||cl(r,n)})}}});function cl(e,t){let n={category:`console`,data:{arguments:t,logger:`console`},level:rl(e),message:ll(t)};if(e===`assert`)if(t[0]===!1){let e=t.slice(1);n.message=e.length>0?`Assertion failed: ${ll(e)}`:`Assertion failed`,n.data.arguments=e}else return;Tc(n,{input:t,level:e})}function ll(e){return`util`in wn&&typeof wn.util.format==`function`?wn.util.format(...e):Br(e,` `)}function ul(e){if(e!==void 0){if(e>=400&&e<500)return`warning`;if(e>=500)return`error`}}function dl(e,t=!1){return!(t||e&&!e.startsWith(`/`)&&!e.match(/^[A-Z]:/)&&!e.startsWith(`.`)&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes(`node_modules/`)}function fl(e){let t=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,r=/at (?:async )?(.+?) \(data:(.*?),/;return i=>{let a=i.match(r);if(a)return{filename:`<data:${a[2]}>`,function:a[1]};let o=i.match(n);if(o){let t,n,r,i,a;if(o[1]){r=o[1];let e=r.lastIndexOf(`.`);if(r[e-1]===`.`&&e--,e>0){t=r.slice(0,e),n=r.slice(e+1);let i=t.indexOf(`.Module`);i>0&&(r=r.slice(i+1),t=t.slice(0,i))}i=void 0}n&&(i=t,a=n),n===`<anonymous>`&&(a=void 0,r=void 0),r===void 0&&(a||=`?`,r=i?`${i}.${a}`:a);let s=Xn(o[2]),c=o[5]===`native`;!s&&o[5]&&!c&&(s=o[5]);let l=s?hl(s):void 0;return{filename:l??s,module:l&&e?.(l),function:r,lineno:ml(o[3]),colno:ml(o[4]),in_app:dl(s||``,c)}}if(i.match(t))return{filename:i}}}function pl(e){return[90,fl(e)]}function ml(e){return parseInt(e||``,10)||void 0}function hl(e){try{return decodeURI(e)}catch{return}}var gl=class{constructor(e){this._maxSize=e,this._cache=new Map}get size(){return this._cache.size}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){if(this._cache.size>=this._maxSize){let e=this._cache.keys().next().value;this._cache.delete(e)}this._cache.set(e,t)}remove(e){let t=this._cache.get(e);return t&&this._cache.delete(e),t}clear(){this._cache.clear()}keys(){return Array.from(this._cache.keys())}values(){let e=[];return this._cache.forEach(t=>e.push(t)),e}};let _l=!1,vl=``,yl=0,bl=0;const xl=6e4,Sl=new Map,Cl=new Set([`OnUncaughtException`,`OnUnhandledRejection`]);function wl(e,t){_l=!0,vl=e,Wo(`session_id`,ln()),Wo(`runtime`,e),t&&Wo(`client_kind`,t)}function Tl(e){return vl=e.runtime,{dsn:hn.sentryDsn,environment:e.environment??(typeof process<`u`?`production`:void 0)??`production`,release:e.version,tracesSampleRate:0,sampleRate:1,maxBreadcrumbs:30,sendDefaultPii:!1,...e.disableGlobalUnhandledErrors?{integrations(e){return e.filter(e=>!Cl.has(e.name))}}:{},beforeSend(e){return jl(e)||Nl(e)||!Pl()||Il(Fl(e))?null:El(e)}}}function El(e){return e}function Dl(e,t){_l&&(t?Fi(n=>{n.setExtras(t),Ho(e)}):Ho(e))}function Ol(e,t,n){_l&&(n?Fi(r=>{r.setExtras(n),Uo(e,t)}):Uo(e,t))}function kl(e,t){_l&&Wo(e,t)}function Al(e,t,n=`info`){_l&&Tc({message:e,category:t,level:n})}function jl(e){for(let t of e.exception?.values??[]){let e=t.type??``,n=t.value??``;if(e===`AbortError`||e===`CreditLimitError`||n===`interrupted`||n===`This operation was aborted`||vl===`cli`&&/\bE(?:IO|PIPE|NOTCONN)\b/.test(n))return!0}return(e.message??e.logentry?.message??``)===`Credit limit reached`}const Ml=/codellm|abacusai/;function Nl(e){if(vl!==`extension-host`)return!1;let t=e.exception?.values;if(!t||t.length===0)return!1;let n=t.flatMap(e=>e.stacktrace?.frames??[]);return n.length===0?!1:!n.some(e=>{let t=e.filename??e.abs_path??e.module??``;return Ml.test(t)})}function Pl(){let e=Date.now();return e-bl>xl&&(yl=0,bl=e),yl++,yl<=10}function Fl(e){let t=e.exception?.values?.[0];if(t)return`${t.type??``}:${t.value??``}`;let n=e.message??e.logentry?.message;return n?`msg:${n}`:Math.random().toString()}function Il(e){let t=Date.now(),n=Sl.get(e);if(n&&t-n<xl)return!0;if(Sl.set(e,t),Sl.size>100){let e=Sl.keys().next().value;e&&Sl.delete(e)}return!1}var Ll=class extends Error{code=`AUTH_EXPIRED`;constructor(){super(`Session expired — please log in again.`),this.name=`AuthExpiredError`}},Rl=class extends Error{cause;code=`NETWORK_ERROR`;constructor(e,t){super(e??`Network unavailable — check your connection.`),this.cause=t,this.name=`NetworkError`}};const zl=[`User not logged in`,`Invalid API Key`,`Invalid session token`];function Bl(e){return zl.includes(e)}function Vl(e){if(!(e instanceof Error))return!1;if(e instanceof Rl)return!0;let t=e.message.toLowerCase();return e.name===`TypeError`&&t.includes(`fetch failed`)||t.includes(`econnrefused`)||t.includes(`econnreset`)||t.includes(`etimedout`)||t.includes(`enotfound`)||t.includes(`enetunreach`)||t.includes(`ehostunreach`)||t.includes(`epipe`)||t.includes(`socket hang up`)}const Hl=`codellm.endpoints`;var Ul=class e{headers;logger;clientName;clientVersion;static apiPrefixUrl=`https://apps.abacus.ai`;static abacusDomain=`https://abacus.ai`;chatWebDomainOverride=null;cache=new Map;userAgentHeaders;constructor(e,t,n,r){this.headers=e,this.logger=t,this.clientName=n,this.clientVersion=r,this.userAgentHeaders=n&&r?{"User-Agent":`${n}/${r}`}:{};let i=this.cache.get(`codellm.endpoints`)??null;if(i)try{this.endpoints=JSON.parse(i)}catch(e){this.logger?.error(`Failed to parse stored endpoints:`,e)}}throwAuthExpired(){throw Ol(`Auth expired mid-session`,`warning`,{context:`api-client`}),new Ll}setUrl(t){e.apiPrefixUrl=t,e.abacusDomain=t.includes(`-apps.abacus.ai`)?t.replace(`-apps.abacus.ai`,`.abacus.ai`):t.replace(`apps.`,``)}setChatWebDomain(e){this.chatWebDomainOverride=e,e?this.cache.set(`codellm.chatWebDomain`,e):this.cache.delete(`codellm.chatWebDomain`)}getChatWebDomain(){return this.chatWebDomainOverride}endpoints=null;getAbacusDomain(){return this.isDevpodEnvironment()?e.apiPrefixUrl:e.abacusDomain}async getConversationsList(e,t){return this._customCall(`/api/listDeploymentConversations`,{conversationType:e,...t&&{chatllmProjectId:t}},{isClusterProxy:!0,method:`GET`})}async searchConversations(e,t){return this._customCall(`/api/_searchConversations`,{query:e,...t&&{conversationType:t}},{isClusterProxy:!0,method:`POST`})}getDeploymentConversation(e){return this._customCall(`/api/getDeploymentConversation`,{...e,skipDocumentBoundingBoxes:!0,filterIntermediateConversationEvents:!0,getUnusedDocumentUploads:!1},{isClusterProxy:!0,method:`POST`})}clearDeploymentConversation(e){return this._customCall(`/api/clearDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}getCodeEdit({fileContents:e,fileSelection:t,rules:n,...r}){return this._customCall(`/api/_getCodeEdit`,{...r,fileContents:e===void 0?void 0:JSON.stringify(e),fileSelection:t===void 0?void 0:JSON.stringify(t),rules:n===void 0?void 0:JSON.stringify(n)},{isClusterProxy:!0,method:`POST`})}listLLMModels(){return this._customCall(`/api/_listCodeBots`,{supportsThoughtStreaming:!0},{isClusterProxy:!0,method:`POST`})}getConstantsAutocomplete(){return this._customCall(`/api/_getConstantsAutocomplete`,{},{isClusterProxy:!0,method:`POST`,suppressNotifications:!0})}getCodeAutocompleteResponse({signal:e,...t}){return this._customCall(`/api/_getCodeAutocompleteResponse`,t,{isClusterProxy:!0,method:`POST`,signal:e})}getAutocompleteEditPrediction({signal:e,...t}){return this._customCall(`/api/_getAutocompleteEditPrediction`,t,{isClusterProxy:!0,method:`POST`,signal:e})}async getUserInfo(){return!this.endpoints&&!this.chatWebDomainOverride&&await this.getApiEndpoint(),await this._customCall(`/api/_getUserInfo`,{},{method:`POST`,useDirect:!0,suppressNotifications:!0})}async getApiEndpoint(){let e=await this._customCall(`/api/v0/getApiEndpoint`,{reqScheme:`https`},{method:`POST`,useDirect:!0});return e?.success&&e?.result&&(this.endpoints=e,this.cache.set(Hl,JSON.stringify(e))),e}resetEndpoints(){this.endpoints=null,this.cache.delete(Hl),this.chatWebDomainOverride=null}async*streamChatMessage({requestId:e,fileContents:t,filePositions:n,terminalSelections:r,rules:i,signal:a,...o}){yield*this.fetchSSE(`/api/_codeLLMSendMessageSSE`,{...o,fileContents:t===null?void 0:JSON.stringify(t),filePositions:n===null?void 0:JSON.stringify(n),terminalSelections:r===null?void 0:JSON.stringify(r),rules:i===void 0?void 0:JSON.stringify(i),requestId:e},{isClusterProxy:!0,signal:a})}async*streamAgentMessage({requestId:e,folderPaths:t,terminalSelections:n,mcpTools:r,availableSkills:i,activeSkills:a,supportedSubAgents:o,reconnect:s,signal:c,...l}){yield*this.fetchSSE(`/api/_codeLLMSendAgentMessageSSE`,{...l,folderPaths:t===void 0?void 0:JSON.stringify(t),terminalSelections:n===null?void 0:JSON.stringify(n),mcpTools:r===void 0?void 0:JSON.stringify(r),requestId:e,availableSkills:i===void 0?void 0:JSON.stringify(i),activeSkills:a===void 0?void 0:JSON.stringify(a),supportedSubAgents:o===void 0?void 0:JSON.stringify(o),supportsParallelToolUse:!0,...s&&{reconnect:!0}},{isClusterProxy:!0,signal:c})}stopResponseSSE(e){return this._customCall(`/api/_stopResponseSSE`,{requestId:e},{isClusterProxy:!0,method:`POST`})}getPendingRequestIdForConversation(e){return this._customCall(`/api/_getPendingRequestIdForConversation`,{deploymentConversationId:e},{isClusterProxy:!0,method:`GET`})}async _customCall(t,n,r={method:`POST`}){try{let i,a=this.isDevpodEnvironment();a&&!t?.includes(`/api/v0/`)&&!t?.includes(`_codeLLMSendMessageSSE`)&&!t?.includes(`_getCodeAutocompleteResponse`)&&!t?.includes(`_getAutocompleteEditPrediction`)&&!t?.includes(`_codeLLMSendAgentMessageSSE`)&&!t?.includes(`createUploadDataToChatllmRequest`)&&!t?.includes(`getUploadDataToChatllmStatus`)&&!t?.includes(`_stopResponseSSE`)&&!t?.includes(`_getPendingRequestIdForConversation`)&&!t?.includes(`_getCodeSummary`)&&!t?.includes(`_getIndividualSummary`)&&!t?.includes(`_getCodeEdit`)&&!t?.includes(`_getCodeChatEdits`)&&!t?.includes(`_getCodeLLMCodeEmbeddings`)&&!t?.includes(`_getCodeLLMChangedFiles`)&&!t?.includes(`_updateCodeLLMWorkspaceState`)&&(t=t?.replace(`/api/`,`/api/v0/`)),i=r.useDirect?t?.includes(`_getUserInfo`)?this.getAbacusDomain():this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.getAbacusDomain():r.isClusterProxy?this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.endpoints?.result?a&&this.endpoints.result.proxyEndpoint?this.endpoints.result.proxyEndpoint:this.endpoints.result.externalChatEndpoint?this.endpoints.result.externalChatEndpoint:e.apiPrefixUrl:e.apiPrefixUrl:t?.includes(`listExternalApplications`)||t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?this.getAbacusDomain():e.apiPrefixUrl;let o=i.indexOf(`/chatllm`);i=o===-1?i:i.substring(0,o);let s=new URL(`${i}${t}`),c=t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?{}:await this.headers.getHeaders(),l,u={"REAI-UI":`1`,...this.userAgentHeaders,...c};if(r.method===`GET`){if(n!==void 0)for(let e of Object.keys(n))s.searchParams.append(e,String(n[e]))}else if(r.formData)l=r.formData;else if(l=JSON.stringify(n),u[`Content-Type`]=`application/json`,r.gzip){u[`Content-Encoding`]=`gzip`;let e=new Blob([l]).stream().pipeThrough(new CompressionStream(`gzip`)),t=await new Response(e).arrayBuffer();l=btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(t))))}let d=await fetch(s,{method:r.method,body:l,headers:u,signal:r.signal});if(!d.ok){let e=await d.text(),t=`API request failed with status ${d.status}`;try{let n=JSON.parse(e);if(n&&typeof n==`object`&&`error`in n){let e=String(n.error);Bl(e)&&this.throwAuthExpired(),t=e}}catch(n){if(n instanceof Ll)throw n;t+=`: ${e}`}throw Error(t)}let f=await d.json();if(f&&typeof f==`object`&&`success`in f&&`error`in f){let e=f;e.success===!1&&e.error&&Bl(e.error)&&this.throwAuthExpired()}return f}catch(e){if(e instanceof Ll)throw e;if(e instanceof Error&&e.name===`AbortError`)return null;throw e instanceof Error&&Vl(e)?new Rl(e.message,e):(Dl(e,{context:`api-client`}),e)}}async createCodellmDeploymentConversation(e=rt.CODE_LLM,t){return await this._customCall(`/api/_createCodellmDeploymentConversation`,{conversationType:e.toString(),...t&&{clientType:t},codeAgentV2:!0},{isClusterProxy:!0,method:`POST`})}_createChatLLMProject(e){return this._customCall(`/api/_createChatLLMProject`,e,{isClusterProxy:!0,method:`POST`})}_attachConverstationToChatLLMProject(e){return this._customCall(`/api/_attachConverstationToChatLLMProject`,e,{isClusterProxy:!0,method:`POST`})}async createUploadDataToChatllmRequest({deploymentConversationId:e,deploymentId:t,files:n,startPage:r,endPage:i}){let a=new globalThis.FormData;for(let e of n){let t=e.name.lastIndexOf(`.`),n=e.name.substring(0,t===-1?e.name.length:t);a.append(n,e)}a.append(`deploymentConversationId`,e),a.append(`deploymentId`,t),r!==void 0&&a.append(`startPage`,String(r)),i!==void 0&&a.append(`endPage`,String(i));let o=await this._customCall(`/api/createUploadDataToChatllmRequest`,{},{isClusterProxy:!0,method:`POST`,formData:a});if(!o)throw Error(`Upload failed`);return o}getUploadStatus(e){return this._customCall(`/api/getUploadDataToChatllmStatus?request_id=${e}`,void 0,{isClusterProxy:!0,method:`GET`})}deleteDeploymentConversation(e){return this._customCall(`/api/deleteDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}getCodeChatEdits(e){return this._customCall(`/api/_getCodeChatEdits`,e,{isClusterProxy:!0,method:`POST`})}listExternalApplications(){return this._customCall(`/api/listExternalApplications`,{includeSearchLlm:!1},{isClusterProxy:!1,method:`POST`})}detachDocumentsFromDeploymentConversation(e){return this._customCall(`/api/_detachDocumentsFromDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}authenticateDeviceForCodeLlm(e,t){return this._customCall(`/api/_authenticateDeviceForCodeLlm`,{email:e,deviceId:t},{isClusterProxy:!1,method:`POST`})}pollDeviceCode(e){return this._customCall(`/api/_pollDeviceCode`,{userCode:e},{isClusterProxy:!1,method:`POST`})}recordUserAction(e){return this._customCall(`/api/_recordUserAction`,{actionType:e},{isClusterProxy:!0,method:`POST`})}listOrganizations(){return this._customCall(`/api/v0/_listOrganizations`,{},{method:`GET`,useDirect:!0})}updateApiKeyOrganization(e){return this._customCall(`/api/v0/_updateApiKeyOrganization`,{organizationId:e},{method:`POST`,useDirect:!0})}selectActiveOrganization(e){return this._customCall(`/api/v0/_selectActiveOrganization`,{organizationId:e},{method:`POST`,useDirect:!0})}async switchOrganization(e){if(!(await this.updateApiKeyOrganization(e))?.success||!(await this.selectActiveOrganization(e))?.success)return!1;this.resetEndpoints();let t=(await this.getUserInfo())?.result?.organization,n=null;if(t){let e=t.externalChatOrgHost;if(typeof e==`string`&&e.trim()!==``)n=e.trim();else if(typeof t.externalChatEndpoint==`string`&&t.externalChatEndpoint.trim()!==``){let e=t.externalChatEndpoint.trim(),r=null;try{r=new URL(e)}catch{try{/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(e)||(r=new URL(`https://${e}`))}catch{r=null}}r?.host&&(n=r.host)}}return this.setChatWebDomain(n),!0}isDevpodEnvironment(){let e=this.endpoints?.result?.apiEndpoint||``;return e.includes(`-dev.internalreai.com`)||e.includes(`-dev.mumbai.internalreai.com`)}async*fetchSSE(e,t,n={}){let r=(await this._fetchRaw(e,t,{...n,isSSE:!0,method:`POST`})).body?.getReader();if(!r)return;let i=new TextDecoder,a=``;try{for(;;){let e,{value:t,done:n}=await Promise.race([r.read(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`SSE read timeout — connection may be lost`)),3e4)})]).finally(()=>clearTimeout(e));if(n){if(a.trim()){let e=this.parseNDJSON(a);for(let t of e.parsed){if(t.end||t.cancelled)return;yield t}}return}a+=i.decode(t,{stream:!0});let{parsed:o,remainder:s}=this.parseNDJSON(a);a=s;for(let e of o){if(e.error){yield e;return}if(e.end||e.cancelled)return;e.ping||(yield e)}}}catch(e){if(this.logger?.error(`Streaming error`,e),e instanceof Ll)throw e;if(e instanceof Error&&e.name===`AbortError`)return;throw e instanceof Error&&(Vl(e)||e.message.includes(`SSE read timeout`))?new Rl(e.message,e):e}finally{r.releaseLock()}}async _fetchRaw(t,n,r){let i,a=this.isDevpodEnvironment();i=r.useDirect?t?.includes(`_getUserInfo`)?this.getAbacusDomain():this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.getAbacusDomain():r.isClusterProxy?this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.endpoints?.result?a&&this.endpoints.result.proxyEndpoint?this.endpoints.result.proxyEndpoint:this.endpoints.result.externalChatEndpoint?this.endpoints.result.externalChatEndpoint:e.apiPrefixUrl:e.apiPrefixUrl:t?.includes(`listExternalApplications`)||t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?this.getAbacusDomain():e.apiPrefixUrl,a&&!t?.includes(`/api/v0/`)&&!t?.includes(`_codeLLMSendMessageSSE`)&&!t?.includes(`_getCodeAutocompleteResponse`)&&!t?.includes(`_getAutocompleteEditPrediction`)&&!t?.includes(`_codeLLMSendAgentMessageSSE`)&&!t?.includes(`createUploadDataToChatllmRequest`)&&!t?.includes(`getUploadDataToChatllmStatus`)&&!t?.includes(`_stopResponseSSE`)&&!t?.includes(`_getPendingRequestIdForConversation`)&&!t?.includes(`_getCodeSummary`)&&!t?.includes(`_getIndividualSummary`)&&!t?.includes(`_getCodeEdit`)&&!t?.includes(`_getCodeChatEdits`)&&!t?.includes(`_getCodeLLMCodeEmbeddings`)&&!t?.includes(`_getCodeLLMChangedFiles`)&&!t?.includes(`_updateCodeLLMWorkspaceState`)&&(t=t?.replace(`/api/`,`/api/v0/`));let o=i.indexOf(`/chatllm`);i=o===-1?i:i.substring(0,o);let s=new URL(`${i}${t}`),c=await this.headers.getHeaders(),l={"REAI-UI":`1`,...this.userAgentHeaders,...c,...r.isSSE?{Accept:`text/event-stream`,Connection:`keep-alive`}:{}},u;if(r.method===`GET`){if(n)for(let e of Object.keys(n))s.searchParams.append(e,String(n[e]))}else if(r.formData)u=r.formData;else if(u=JSON.stringify(n),l[`Content-Type`]=`application/json`,r.gzip){l[`Content-Encoding`]=`gzip`;let e=new Blob([u]).stream().pipeThrough(new CompressionStream(`gzip`)),t=await new Response(e).arrayBuffer();u=btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(t))))}let d=await fetch(s,{method:r.method,body:u,headers:l,signal:r.signal});if(!d.ok){let e=await d.text(),t=`API request failed with status ${d.status}`;try{let n=JSON.parse(e);if(n&&typeof n==`object`&&`error`in n){let e=String(n.error);Bl(e)&&this.throwAuthExpired(),t=e}}catch(n){if(n instanceof Ll)throw n;t+=`: ${e}`}throw Error(t)}return d}parseNDJSON(e){let t=[],n=0,r=e.indexOf(`
6
+ `);for(let e=n;e<a.length;e++){let n=a[e];n.length>1024&&(n=n.slice(0,1024));let o=Vn.test(n)?n.replace(Vn,`$1`):n;if(!o.match(/\S*Error: /)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=50+r)break}}return Gn(i.slice(r))}}function Wn(e){return Array.isArray(e)?Un(...e):e}function Gn(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(Kn(t).function||``)&&t.pop(),t.reverse(),Hn.test(Kn(t).function||``)&&(t.pop(),Hn.test(Kn(t).function||``)&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||Kn(t).filename,function:e.function||`?`}))}function Kn(e){return e[e.length-1]||{}}const qn=`<anonymous>`;function Jn(e){try{return!e||typeof e!=`function`?qn:e.name||qn}catch{return qn}}function Yn(e){return`__v_isVNode`in e&&e.__v_isVNode?`[VueVNode]`:`[VueViewModel]`}function Xn(e){let t=e?.startsWith(`file://`)?e.slice(7):e;return t?.match(/\/[A-Z]:/)&&(t=t.slice(1)),t}const Zn={},Qn={};function $n(e,t){Zn[e]=Zn[e]||[],Zn[e].push(t)}function er(e,t){if(!Qn[e]){Qn[e]=!0;try{t()}catch(t){Cn&&Bn.error(`Error while instrumenting ${e}`,t)}}}function tr(e,t){let n=e&&Zn[e];if(n)for(let r of n)try{r(t)}catch(t){Cn&&Bn.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${Jn(r)}\nError:`,t)}}let nr=null;function rr(e){let t=`error`;$n(t,e),er(t,ir)}function ir(){nr=wn.onerror,wn.onerror=function(e,t,n,r,i){return tr(`error`,{column:r,error:i,line:n,msg:e,url:t}),nr?nr.apply(this,arguments):!1},wn.onerror.__SENTRY_INSTRUMENTED__=!0}let ar=null;function or(e){let t=`unhandledrejection`;$n(t,e),er(t,sr)}function sr(){ar=wn.onunhandledrejection,wn.onunhandledrejection=function(e){return tr(`unhandledrejection`,e),ar?ar.apply(this,arguments):!0},wn.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const cr=Object.prototype.toString;function lr(e){switch(cr.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object WebAssembly.Exception]`:return!0;default:return xr(e,Error)}}function ur(e,t){return cr.call(e)===`[object ${t}]`}function dr(e){return ur(e,`ErrorEvent`)}function fr(e){return ur(e,`String`)}function pr(e){return typeof e==`object`&&!!e&&`__sentry_template_string__`in e&&`__sentry_template_values__`in e}function mr(e){return e===null||pr(e)||typeof e!=`object`&&typeof e!=`function`}function hr(e){return ur(e,`Object`)}function gr(e){return typeof Event<`u`&&xr(e,Event)}function _r(e){return typeof Element<`u`&&xr(e,Element)}function vr(e){return ur(e,`RegExp`)}function yr(e){return!!(e?.then&&typeof e.then==`function`)}function br(e){return hr(e)&&`nativeEvent`in e&&`preventDefault`in e&&`stopPropagation`in e}function xr(e,t){try{return e instanceof t}catch{return!1}}function Sr(e){return!!(typeof e==`object`&&e&&(e.__isVue||e._isVue||e.__v_isVNode))}const Cr=wn;function wr(e,t={}){if(!e)return`<unknown>`;try{let n=e,r=[],i=0,a=0,o,s=Array.isArray(t)?t:t.keyAttrs,c=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&i++<5&&(o=Tr(n,s),!(o===`html`||i>1&&a+r.length*3+o.length>=c));)r.push(o),a+=o.length,n=n.parentNode;return r.reverse().join(` > `)}catch{return`<unknown>`}}function Tr(e,t){let n=e,r=[];if(!n?.tagName)return``;if(Cr.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());let i=t?.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(i?.length)i.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{n.id&&r.push(`#${n.id}`);let e=n.className;if(e&&fr(e)){let t=e.split(/\s+/);for(let e of t)r.push(`.${e}`)}}for(let e of[`aria-label`,`type`,`name`,`title`,`alt`]){let t=n.getAttribute(e);t&&r.push(`[${e}="${t}"]`)}return r.join(``)}function Er(e,t,n){if(!(t in e))return;let r=e[t];if(typeof r!=`function`)return;let i=n(r);typeof i==`function`&&Or(i,r);try{e[t]=i}catch{Cn&&Bn.log(`Failed to replace method "${t}" in object`,e)}}function Dr(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{Cn&&Bn.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function Or(e,t){try{e.prototype=t.prototype=t.prototype||{},Dr(e,`__sentry_original__`,t)}catch{}}function kr(e){return e.__sentry_original__}function Ar(e){if(lr(e))return{message:e.message,name:e.name,stack:e.stack,...Mr(e)};if(gr(e)){let t={type:e.type,target:jr(e.target),currentTarget:jr(e.currentTarget),...Mr(e)};return typeof CustomEvent<`u`&&xr(e,CustomEvent)&&(t.detail=e.detail),t}else return e}function jr(e){try{return _r(e)?wr(e):Object.prototype.toString.call(e)}catch{return`<unknown>`}}function Mr(e){return typeof e==`object`&&e?Object.fromEntries(Object.entries(e)):{}}function Nr(e){let t=Object.keys(Ar(e));return t.sort(),t[0]?t.join(`, `):`[object has no keys]`}let Pr;function Fr(e){if(Pr!==void 0)return Pr?Pr(e):e();let t=Symbol.for(`__SENTRY_SAFE_RANDOM_ID_WRAPPER__`),n=wn;return t in n&&typeof n[t]==`function`?(Pr=n[t],Pr(e)):(Pr=null,e())}function Ir(){return Fr(()=>Math.random())}function Lr(){return Fr(()=>Date.now())}function Rr(e,t=0){return typeof e!=`string`||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function zr(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`'{snip} ${n}`),a<r&&(n+=` {snip}`),n}function Br(e,t){if(!Array.isArray(e))return``;let n=[];for(let t=0;t<e.length;t++){let r=e[t];try{Sr(r)?n.push(Yn(r)):n.push(String(r))}catch{n.push(`[value cannot be serialized]`)}}return n.join(t)}function Vr(e,t,n=!1){return fr(e)?vr(t)?t.test(e):fr(t)?n?e===t:e.includes(t):!1:!1}function Hr(e,t=[],n=!1){return t.some(t=>Vr(e,t,n))}function Ur(){let e=wn;return e.crypto||e.msCrypto}let Wr;function Gr(){return Ir()*16}function Kr(e=Ur()){try{if(e?.randomUUID)return Fr(()=>e.randomUUID()).replace(/-/g,``)}catch{}return Wr||=`10000000100040008000100000000000`,Wr.replace(/[018]/g,e=>(e^(Gr()&15)>>e/4).toString(16))}function qr(e){return e.exception?.values?.[0]}function Jr(e){let{message:t,event_id:n}=e;if(t)return t;let r=qr(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||`<unknown>`:n||`<unknown>`}function Yr(e,t,n){let r=e.exception=e.exception||{},i=r.values=r.values||[],a=i[0]=i[0]||{};a.value||=t||``,a.type||=n||`Error`}function Xr(e,t){let n=qr(e);if(!n)return;let r={type:`generic`,handled:!0},i=n.mechanism;if(n.mechanism={...r,...i,...t},t&&`data`in t){let e={...i?.data,...t.data};n.mechanism.data=e}}const Zr=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function Qr(e){return parseInt(e||``,10)}function $r(e){let t=e.match(Zr)||[],n=Qr(t[1]),r=Qr(t[2]),i=Qr(t[3]);return{buildmetadata:t[5],major:isNaN(n)?void 0:n,minor:isNaN(r)?void 0:r,patch:isNaN(i)?void 0:i,prerelease:t[4]}}function ei(e){if(ti(e))return!0;try{Dr(e,`__sentry_captured__`,!0)}catch{}return!1}function ti(e){try{return e.__sentry_captured__}catch{}}const ni=1e3;function ri(){return Lr()/ni}function ii(){let{performance:e}=wn;if(!e?.now||!e.timeOrigin)return ri;let t=e.timeOrigin;return()=>(t+Fr(()=>e.now()))/ni}let ai;function oi(){return(ai??=ii())()}function si(e){let t=oi(),n={sid:Kr(),init:!0,timestamp:t,started:t,duration:0,status:`ok`,errors:0,ignoreDuration:!1,toJSON:()=>ui(n)};return e&&ci(n,e),n}function ci(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),!e.did&&!t.did&&(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||oi(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=t.sid.length===32?t.sid:Kr()),t.init!==void 0&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),typeof t.started==`number`&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if(typeof t.duration==`number`)e.duration=t.duration;else{let t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),typeof t.errors==`number`&&(e.errors=t.errors),t.status&&(e.status=t.status)}function li(e,t){let n={};t?n={status:t}:e.status===`ok`&&(n={status:`exited`}),ci(e,n)}function ui(e){return{sid:`${e.sid}`,init:e.init,started:new Date(e.started*1e3).toISOString(),timestamp:new Date(e.timestamp*1e3).toISOString(),status:e.status,errors:e.errors,did:typeof e.did==`number`||typeof e.did==`string`?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}function di(e,t,n=2){if(!t||typeof t!=`object`||n<=0)return t;if(e&&Object.keys(t).length===0)return e;let r={...e};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=di(r[e],t[e],n-1));return r}function fi(){return Kr()}function pi(){return Kr().substring(16)}const mi=`_sentrySpan`;function hi(e,t){t?Dr(e,mi,t):delete e[mi]}function gi(e){return e[mi]}var _i=class e{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:fi(),sampleRand:Ir()}}clone(){let t=new e;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._attributes={...this._attributes},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,t._conversationId=this._conversationId,hi(t,gi(this)),t}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&ci(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return t===null?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;let n=typeof t==`function`?t(this):t,{tags:r,attributes:i,extra:a,user:o,contexts:s,level:c,fingerprint:l=[],propagationContext:u,conversationId:d}=(n instanceof e?n.getScopeData():hr(n)?t:void 0)||{};return this._tags={...this._tags,...r},this._attributes={...this._attributes,...i},this._extra={...this._extra,...a},this._contexts={...this._contexts,...s},o&&Object.keys(o).length&&(this._user=o),c&&(this._level=c),l.length&&(this._fingerprint=l),u&&(this._propagationContext=u),d&&(this._conversationId=d),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,hi(this,void 0),this._attachments=[],this.setPropagationContext({traceId:fi(),sampleRand:Ir()}),this._notifyScopeListeners(),this}addBreadcrumb(e,t){let n=typeof t==`number`?t:100;if(n<=0)return this;let r={timestamp:ri(),...e,message:e.message?Rr(e.message,2048):e.message};return this._breadcrumbs.push(r),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n),this._client?.recordDroppedEvent(`buffer_overflow`,`log_item`)),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:gi(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=di(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){let n=t?.event_id||Kr();if(!this._client)return Cn&&Bn.warn(`No client configured on scope - will not capture exception!`),n;let r=Error(`Sentry syntheticException`);return this._client.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){let r=n?.event_id||Kr();if(!this._client)return Cn&&Bn.warn(`No client configured on scope - will not capture message!`),r;let i=n?.syntheticException??Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){let n=e.event_id||t?.event_id||Kr();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(Cn&&Bn.warn(`No client configured on scope - will not capture event!`),n)}_notifyScopeListeners(){this._notifyingListeners||=(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),!1)}};function vi(){return On(`defaultCurrentScope`,()=>new _i)}function yi(){return On(`defaultIsolationScope`,()=>new _i)}const bi=e=>e instanceof Promise&&!e[xi],xi=Symbol(`chained PromiseLike`),Si=(e,t,n)=>{let r=e.then(e=>(t(e),e),e=>{throw n(e),e});return bi(r)&&bi(e)?r:Ci(e,r)},Ci=(e,t)=>{let n=!1;for(let r in e){if(r in t)continue;n=!0;let i=e[r];typeof i==`function`?Object.defineProperty(t,r,{value:(...t)=>i.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[r]=i}return n&&Object.assign(t,{[xi]:!0}),t};var wi=class{constructor(e,t){let n;n=e||new _i;let r;r=t||new _i,this._stack=[{scope:n}],this._isolationScope=r}withScope(e){let t=this._pushScope(),n;try{n=e(t)}catch(e){throw this._popScope(),e}return yr(n)?Si(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}};function Ti(){let e=Dn(En());return e.stack=e.stack||new wi(vi(),yi())}function Ei(e){return Ti().withScope(e)}function Di(e,t){let n=Ti();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function Oi(e){return Ti().withScope(()=>e(Ti().getIsolationScope()))}function ki(){return{withIsolationScope:Oi,withScope:Ei,withSetScope:Di,withSetIsolationScope:(e,t)=>Oi(t),getCurrentScope:()=>Ti().getScope(),getIsolationScope:()=>Ti().getIsolationScope()}}function Ai(e){let t=Dn(En());t.acs=e}function ji(e){let t=Dn(e);return t.acs?t.acs:ki()}function Mi(){return ji(En()).getCurrentScope()}function Ni(){return ji(En()).getIsolationScope()}function Pi(){return On(`globalScope`,()=>new _i)}function Fi(...e){let t=ji(En());if(e.length===2){let[n,r]=e;return n?t.withSetScope(n,r):t.withScope(r)}return t.withScope(e[0])}function Ii(...e){let t=ji(En());if(e.length===2){let[n,r]=e;return n?t.withSetIsolationScope(n,r):t.withIsolationScope(r)}return t.withIsolationScope(e[0])}function Li(){return Mi().getClient()}function Ri(e){let{traceId:t,parentSpanId:n,propagationSpanId:r}=e.getPropagationContext(),i={trace_id:t,span_id:r||pi()};return n&&(i.parent_span_id=n),i}function zi(e){if(e){if(typeof e==`object`&&`deref`in e&&typeof e.deref==`function`)try{return e.deref()}catch{return}return e}}function Bi(e){let t=e;return{scope:t._sentryScope,isolationScope:zi(t._sentryIsolationScope)}}function Vi(e){let t=Ui(e);if(!t)return;let n=Object.entries(t).reduce((e,[t,n])=>{if(t.startsWith(`sentry-`)){let r=t.slice(7);e[r]=n}return e},{});if(Object.keys(n).length>0)return n}function Hi(e){if(e)return Gi(Object.entries(e).reduce((e,[t,n])=>(n&&(e[`sentry-${t}`]=n),e),{}))}function Ui(e){if(!(!e||!fr(e)&&!Array.isArray(e)))return Array.isArray(e)?e.reduce((e,t)=>{let n=Wi(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{}):Wi(e)}function Wi(e){return e.split(`,`).map(e=>{let t=e.indexOf(`=`);return t===-1?[]:[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}function Gi(e){if(Object.keys(e).length!==0)return Object.entries(e).reduce((e,[t,n],r)=>{let i=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`,a=r===0?i:`${e},${i}`;return a.length>8192?(Cn&&Bn.warn(`Not adding key: ${t} with val: ${n} to baggage header due to exceeding baggage size limits.`),e):a},``)}const Ki=/^o(\d+)\./,qi=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Ji(e){return e===`http`||e===`https`}function Yi(e,t=!1){let{host:n,path:r,pass:i,port:a,projectId:o,protocol:s,publicKey:c}=e;return`${s}://${c}${t&&i?`:${i}`:``}@${n}${a?`:${a}`:``}/${r&&`${r}/`}${o}`}function Xi(e){let t=qi.exec(e);if(!t){jn(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});return}let[n,r,i=``,a=``,o=``,s=``]=t.slice(1),c=``,l=s,u=l.split(`/`);if(u.length>1&&(c=u.slice(0,-1).join(`/`),l=u.pop()),l){let e=l.match(/^\d+/);e&&(l=e[0])}return Zi({host:a,pass:i,path:c,projectId:l,port:o,protocol:n,publicKey:r})}function Zi(e){return{protocol:e.protocol,publicKey:e.publicKey||``,pass:e.pass||``,host:e.host,port:e.port||``,path:e.path||``,projectId:e.projectId}}function Qi(e){if(!Cn)return!0;let{port:t,projectId:n,protocol:r}=e;return[`protocol`,`publicKey`,`host`,`projectId`].find(t=>e[t]?!1:(Bn.error(`Invalid Sentry Dsn: ${t} missing`),!0))?!1:n.match(/^\d+$/)?Ji(r)?t&&isNaN(parseInt(t,10))?(Bn.error(`Invalid Sentry Dsn: Invalid port ${t}`),!1):!0:(Bn.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(Bn.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function $i(e){return e.match(Ki)?.[1]}function ea(e){let t=e.getOptions(),{host:n}=e.getDsn()||{},r;return t.orgId?r=String(t.orgId):n&&(r=$i(n)),r}function ta(e){let t=typeof e==`string`?Xi(e):Zi(e);if(!(!t||!Qi(t)))return t}function na(e){if(typeof e==`boolean`)return Number(e);let t=typeof e==`string`?parseFloat(e):e;if(!(typeof t!=`number`||isNaN(t)||t<0||t>1))return t}const ra=RegExp(`^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$`);function ia(e){if(!e)return;let t=e.match(ra);if(!t)return;let n;return t[3]===`1`?n=!0:t[3]===`0`&&(n=!1),{traceId:t[1],parentSampled:n,parentSpanId:t[2]}}function aa(e,t){let n=ia(e),r=Vi(t);if(!n?.traceId)return{traceId:fi(),sampleRand:Ir()};let i=ca(n,r);r&&(r.sample_rand=i.toString());let{traceId:a,parentSpanId:o,parentSampled:s}=n;return{traceId:a,parentSpanId:o,sampled:s,dsc:r||{},sampleRand:i}}function oa(e=fi(),t=pi(),n){let r=``;return n!==void 0&&(r=n?`-1`:`-0`),`${e}-${t}${r}`}function sa(e=fi(),t=pi(),n){return`00-${e}-${t}-${n?`01`:`00`}`}function ca(e,t){let n=na(t?.sample_rand);if(n!==void 0)return n;let r=na(t?.sample_rate);return r&&e?.parentSampled!==void 0?e.parentSampled?Ir()*r:r+Ir()*(1-r):Ir()}function la(e,t){let n=ea(e);return t&&n&&t!==n?(Bn.log(`Won't continue trace because org IDs don't match (incoming baggage: ${t}, SDK options: ${n})`),!1):e.getOptions().strictTraceContinuation&&(t&&!n||!t&&n)?(Bn.log(`Starting a new trace because strict trace continuation is enabled but one org ID is missing (incoming baggage: ${t}, Sentry client: ${n})`),!1):!0}let ua=!1;function da(e){let{spanId:t,traceId:n,isRemote:r}=e.spanContext(),i=r?t:_a(e).parent_span_id,a=Bi(e).scope;return{parent_span_id:i,span_id:r?a?.getPropagationContext().propagationSpanId||pi():t,trace_id:n}}function fa(e){let{traceId:t,spanId:n}=e.spanContext();return oa(t,n,ba(e))}function pa(e){let{traceId:t,spanId:n}=e.spanContext();return sa(t,n,ba(e))}function ma(e){if(e&&e.length>0)return e.map(({context:{spanId:e,traceId:t,traceFlags:n,...r},attributes:i})=>({span_id:e,trace_id:t,sampled:n===1,attributes:i,...r}))}function ha(e){return typeof e==`number`?ga(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?ga(e.getTime()):oi()}function ga(e){return e>9999999999?e/1e3:e}function _a(e){if(ya(e))return e.getSpanJSON();let{spanId:t,traceId:n}=e.spanContext();if(va(e)){let{attributes:r,startTime:i,name:a,endTime:o,status:s,links:c}=e;return{span_id:t,trace_id:n,data:r,description:a,parent_span_id:`parentSpanId`in e?e.parentSpanId:`parentSpanContext`in e?e.parentSpanContext?.spanId:void 0,start_timestamp:ha(i),timestamp:ha(o)||void 0,status:xa(s),op:r[`sentry.op`],origin:r[`sentry.origin`],links:ma(c)}}return{span_id:t,trace_id:n,start_timestamp:0,data:{}}}function va(e){let t=e;return!!t.attributes&&!!t.startTime&&!!t.name&&!!t.endTime&&!!t.status}function ya(e){return typeof e.getSpanJSON==`function`}function ba(e){let{traceFlags:t}=e.spanContext();return t===1}function xa(e){if(!(!e||e.code===0))return e.code===1?`ok`:e.message||`internal_error`}function Sa(e){return e._sentryRootSpan||e}function Ca(){let e=ji(En());return e.getActiveSpan?e.getActiveSpan():gi(Mi())}function wa(){ua||=(jn(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),!0)}let Ta=!1;function Ea(){if(Ta)return;function e(){let e=Ca(),t=e&&Sa(e);if(t){let e=`internal_error`;Cn&&Bn.log(`[Tracing] Root span: ${e} -> Global error occurred`),t.setStatus({code:2,message:e})}}e.tag=`sentry_tracingErrorCallback`,Ta=!0,rr(e),or(e)}function Da(e){if(typeof __SENTRY_TRACING__==`boolean`&&!__SENTRY_TRACING__)return!1;let t=e||Li()?.getOptions();return!!t&&(t.tracesSampleRate!=null||!!t.tracesSampler)}function Oa(e){Bn.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function ka(e,t){if(!t?.length||!e.description)return!1;for(let n of t){if(ja(n)){if(Vr(e.description,n))return Cn&&Oa(e),!0;continue}if(!n.name&&!n.op)continue;let t=n.name?Vr(e.description,n.name):!0,r=n.op?e.op&&Vr(e.op,n.op):!0;if(t&&r)return Cn&&Oa(e),!0}return!1}function Aa(e,t){let n=t.parent_span_id,r=t.span_id;if(n)for(let t of e)t.parent_span_id===r&&(t.parent_span_id=n)}function ja(e){return typeof e==`string`||e instanceof RegExp}function Ma(e,t){let n=t.getOptions(),{publicKey:r}=t.getDsn()||{},i={environment:n.environment||`production`,release:n.release,public_key:r,trace_id:e,org_id:ea(t)};return t.emit(`createDsc`,i),i}function Na(e,t){let n=t.getPropagationContext();return n.dsc||Ma(n.traceId,e)}function Pa(e){let t=Li();if(!t)return{};let n=Sa(e),r=_a(n),i=r.data,a=n.spanContext().traceState,o=a?.get(`sentry.sample_rate`)??i[`sentry.sample_rate`]??i[`sentry.previous_trace_sample_rate`];function s(e){return(typeof o==`number`||typeof o==`string`)&&(e.sample_rate=`${o}`),e}let c=n._frozenDsc;if(c)return s(c);let l=a?.get(`sentry.dsc`),u=l&&Vi(l);if(u)return s(u);let d=Ma(e.spanContext().traceId,t),f=i[`sentry.source`],p=r.description;return f!==`url`&&p&&(d.transaction=p),Da()&&(d.sampled=String(ba(n)),d.sample_rand=a?.get(`sentry.sample_rand`)??Bi(n).scope?.getPropagationContext().sampleRand.toString()),s(d),t.emit(`createDsc`,d,n),d}function Fa(e,t=100,n=1/0){try{return La(``,e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function Ia(e,t=3,n=100*1024){let r=Fa(e,t);return Va(r)>n?Ia(e,t-1,n):r}function La(e,t,n=1/0,r=1/0,i=Ha()){let[a,o]=i;if(t==null||[`boolean`,`string`].includes(typeof t)||typeof t==`number`&&Number.isFinite(t))return t;let s=Ra(e,t);if(!s.startsWith(`[object `))return s;if(t.__sentry_skip_normalization__)return t;let c=typeof t.__sentry_override_normalization_depth__==`number`?t.__sentry_override_normalization_depth__:n;if(c===0)return s.replace(`object `,``);if(a(t))return`[Circular ~]`;let l=t;if(l&&typeof l.toJSON==`function`)try{return La(``,l.toJSON(),c-1,r,i)}catch{}let u=Array.isArray(t)?[]:{},d=0,f=Ar(t);for(let e in f){if(!Object.prototype.hasOwnProperty.call(f,e))continue;if(d>=r){u[e]=`[MaxProperties ~]`;break}let t=f[e];u[e]=La(e,t,c-1,r,i),d++}return o(t),u}function Ra(e,t){try{if(e===`domain`&&t&&typeof t==`object`&&t._events)return`[Domain]`;if(e===`domainEmitter`)return`[DomainEmitter]`;if(typeof global<`u`&&t===global)return`[Global]`;if(typeof window<`u`&&t===window)return`[Window]`;if(typeof document<`u`&&t===document)return`[Document]`;if(Sr(t))return Yn(t);if(br(t))return`[SyntheticEvent]`;if(typeof t==`number`&&!Number.isFinite(t))return`[${t}]`;if(typeof t==`function`)return`[Function: ${Jn(t)}]`;if(typeof t==`symbol`)return`[${String(t)}]`;if(typeof t==`bigint`)return`[BigInt: ${String(t)}]`;let n=za(t);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(e){return`**non-serializable** (${e})`}}function za(e){let t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:`null prototype`}function Ba(e){return~-encodeURI(e).split(/%..|./).length}function Va(e){return Ba(JSON.stringify(e))}function Ha(){let e=new WeakSet;function t(t){return e.has(t)?!0:(e.add(t),!1)}function n(t){e.delete(t)}return[t,n]}function Ua(e,t=[]){return[e,t]}function Wa(e,t){let[n,r]=e;return[n,[...r,t]]}function Ga(e,t){let n=e[1];for(let e of n){let n=e[0].type;if(t(e,n))return!0}return!1}function Ka(e,t){return Ga(e,(e,n)=>t.includes(n))}function qa(e){let t=Dn(wn);return t.encodePolyfill?t.encodePolyfill(e):new TextEncoder().encode(e)}function Ja(e){let[t,n]=e,r=JSON.stringify(t);function i(e){typeof r==`string`?r=typeof e==`string`?r+e:[qa(r),e]:r.push(typeof e==`string`?qa(e):e)}for(let e of n){let[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),typeof n==`string`||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Fa(n))}i(e)}}return typeof r==`string`?r:Ya(r)}function Ya(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Xa(e){let t=typeof e.data==`string`?qa(e.data):e.data;return[{type:`attachment`,length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const Za={sessions:`session`,event:`error`,client_report:`internal`,user_report:`default`,profile_chunk:`profile`,replay_event:`replay`,replay_recording:`replay`,check_in:`monitor`,raw_security:`security`,log:`log_item`,trace_metric:`metric`};function Qa(e){return e in Za}function $a(e){return Qa(e)?Za[e]:e}function eo(e){if(!e?.sdk)return;let{name:t,version:n}=e.sdk;return{name:t,version:n}}function to(e,t,n,r){let i=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date().toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:Yi(r)},...i&&{trace:i}}}function no(e,t){if(!t)return e;let n=e.sdk||{};return e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0},e}function ro(e,t,n,r){let i=eo(n);return Ua({sent_at:new Date().toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:Yi(t)}},[`aggregates`in e?[{type:`sessions`},e]:[{type:`session`},e.toJSON()]])}function io(e,t,n,r){let i=eo(n),a=e.type&&e.type!==`replay_event`?e.type:`event`;no(e,n?.sdk);let o=to(e,i,r,t);return delete e.sdkProcessingMetadata,Ua(o,[[{type:a},e]])}const ao=`__SENTRY_SUPPRESS_TRACING__`,oo=(e,t)=>{let n=ji(En());if(n.continueTrace)return n.continueTrace(e,t);let{sentryTrace:r,baggage:i}=e,a=Li(),o=Vi(i);return a&&!la(a,o?.org_id)?lo(t):Fi(e=>{let n=aa(r,i);return e.setPropagationContext(n),hi(e,void 0),t()})};function so(e,t){let n=uo();return n.withActiveSpan?n.withActiveSpan(e,t):Fi(n=>(hi(n,e||void 0),t(n)))}function co(e){let t=uo();return t.suppressTracing?t.suppressTracing(e):Fi(t=>{t.setSDKProcessingMetadata({[ao]:!0});let n=e();return t.setSDKProcessingMetadata({[ao]:void 0}),n})}function lo(e){return Fi(t=>(t.setPropagationContext({traceId:fi(),sampleRand:Ir()}),Cn&&Bn.log(`Starting a new trace with id ${t.getPropagationContext().traceId}`),so(null,e)))}function uo(){return ji(En())}function fo(e){return new mo(t=>{t(e)})}function po(e){return new mo((t,n)=>{n(e)})}var mo=class e{constructor(e){this._state=0,this._handlers=[],this._runExecutor(e)}then(t,n){return new e((e,r)=>{this._handlers.push([!1,n=>{if(!t)e(n);else try{e(t(n))}catch(e){r(e)}},t=>{if(!n)r(t);else try{e(n(t))}catch(e){r(e)}}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(t){return new e((e,n)=>{let r,i;return this.then(e=>{i=!1,r=e,t&&t()},e=>{i=!0,r=e,t&&t()}).then(()=>{if(i){n(r);return}e(r)})})}_executeHandlers(){if(this._state===0)return;let e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||=(this._state===1&&e[1](this._value),this._state===2&&e[2](this._value),!0)})}_runExecutor(e){let t=(e,t)=>{if(this._state===0){if(yr(t)){t.then(n,r);return}this._state=e,this._value=t,this._executeHandlers()}},n=e=>{t(1,e)},r=e=>{t(2,e)};try{e(n,r)}catch(e){r(e)}}};function ho(e,t,n,r=0){try{let i=go(t,n,e,r);return yr(i)?i:fo(i)}catch(e){return po(e)}}function go(e,t,n,r){let i=n[r];if(!e||!i)return e;let a=i({...e},t);return Cn&&a===null&&Bn.log(`Event processor "${i.id||`?`}" dropped event`),yr(a)?a.then(e=>go(e,t,n,r+1)):go(a,t,n,r+1)}let _o,vo,yo,bo;function xo(e){let t=wn._sentryDebugIds,n=wn._debugIds;if(!t&&!n)return{};let r=t?Object.keys(t):[],i=n?Object.keys(n):[];if(bo&&r.length===vo&&i.length===yo)return bo;vo=r.length,yo=i.length,bo={},_o||={};let a=(t,n)=>{for(let r of t){let t=n[r],i=_o?.[r];if(i&&bo&&t)bo[i[0]]=t,_o&&(_o[r]=[i[0],t]);else if(t){let n=e(r);for(let e=n.length-1;e>=0;e--){let i=n[e]?.filename;if(i&&bo&&_o){bo[i]=t,_o[r]=[i,t];break}}}}};return t&&a(r,t),n&&a(i,n),bo}function So(e,t){let{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:a}=t;Eo(e,t),r&&ko(e,r),Ao(e,n),Do(e,i),Oo(e,a)}function Co(e,t){let{extra:n,tags:r,attributes:i,user:a,contexts:o,level:s,sdkProcessingMetadata:c,breadcrumbs:l,fingerprint:u,eventProcessors:d,attachments:f,propagationContext:p,transactionName:m,span:h}=t;wo(e,`extra`,n),wo(e,`tags`,r),wo(e,`attributes`,i),wo(e,`user`,a),wo(e,`contexts`,o),e.sdkProcessingMetadata=di(e.sdkProcessingMetadata,c,2),s&&(e.level=s),m&&(e.transactionName=m),h&&(e.span=h),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),u.length&&(e.fingerprint=[...e.fingerprint,...u]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),f.length&&(e.attachments=[...e.attachments,...f]),e.propagationContext={...e.propagationContext,...p}}function wo(e,t,n){e[t]=di(e[t],n,1)}function To(e,t){let n=Pi().getScopeData();return e&&Co(n,e.getScopeData()),t&&Co(n,t.getScopeData()),n}function Eo(e,t){let{extra:n,tags:r,user:i,contexts:a,level:o,transactionName:s}=t;Object.keys(n).length&&(e.extra={...n,...e.extra}),Object.keys(r).length&&(e.tags={...r,...e.tags}),Object.keys(i).length&&(e.user={...i,...e.user}),Object.keys(a).length&&(e.contexts={...a,...e.contexts}),o&&(e.level=o),s&&e.type!==`transaction`&&(e.transaction=s)}function Do(e,t){let n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}function Oo(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}function ko(e,t){e.contexts={trace:da(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Pa(t),...e.sdkProcessingMetadata};let n=_a(Sa(t)).description;n&&!e.transaction&&e.type===`transaction`&&(e.transaction=n)}function Ao(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint.length||delete e.fingerprint}function jo(e,t,n,r,i,a){let{normalizeDepth:o=3,normalizeMaxBreadth:s=1e3}=e,c={...t,event_id:t.event_id||n.event_id||Kr(),timestamp:t.timestamp||ri()},l=n.integrations||e.integrations.map(e=>e.name);Mo(c,e),Fo(c,l),i&&i.emit(`applyFrameMetadata`,t),t.type===void 0&&No(c,e.stackParser);let u=Lo(r,n.captureContext);n.mechanism&&Xr(c,n.mechanism);let d=i?i.getEventProcessors():[],f=To(a,u),p=[...n.attachments||[],...f.attachments];p.length&&(n.attachments=p),So(c,f);let m=[...d,...f.eventProcessors];return(n.data&&n.data.__sentry__===!0?fo(c):ho(m,c,n)).then(e=>(e&&Po(e),typeof o==`number`&&o>0?Io(e,o,s):e))}function Mo(e,t){let{environment:n,release:r,dist:i,maxValueLength:a}=t;e.environment=e.environment||n||`production`,!e.release&&r&&(e.release=r),!e.dist&&i&&(e.dist=i);let o=e.request;o?.url&&a&&(o.url=Rr(o.url,a)),a&&e.exception?.values?.forEach(e=>{e.value&&=Rr(e.value,a)})}function No(e,t){let n=xo(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}function Po(e){let t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),Object.keys(t).length===0)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];let n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:`sourcemap`,code_file:e,debug_id:t})})}function Fo(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}function Io(e,t,n){if(!e)return null;let r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Fa(e.data,t,n)}}))},...e.user&&{user:Fa(e.user,t,n)},...e.contexts&&{contexts:Fa(e.contexts,t,n)},...e.extra&&{extra:Fa(e.extra,t,n)}};return e.contexts?.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=Fa(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>({...e,...e.data&&{data:Fa(e.data,t,n)}}))),e.contexts?.flags&&r.contexts&&(r.contexts.flags=Fa(e.contexts.flags,3,n)),r}function Lo(e,t){if(!t)return e;let n=e?e.clone():new _i;return n.update(t),n}function Ro(e){if(e)return zo(e)||Vo(e)?{captureContext:e}:e}function zo(e){return e instanceof _i||typeof e==`function`}const Bo=[`user`,`level`,`extra`,`contexts`,`tags`,`fingerprint`,`propagationContext`];function Vo(e){return Object.keys(e).some(e=>Bo.includes(e))}function Ho(e,t){return Mi().captureException(e,Ro(t))}function Uo(e,t){let n=typeof t==`string`?t:void 0,r=typeof t==`string`?void 0:{captureContext:t};return Mi().captureMessage(e,n,r)}function Wo(e,t){Ni().setTag(e,t)}function Go(){let e=Li();return e?.getOptions().enabled!==!1&&!!e?.getTransport()}function Ko(e){let t=Ni(),{user:n}=To(t,Mi()),{userAgent:r}=wn.navigator||{},i=si({user:n,...r&&{userAgent:r},...e}),a=t.getSession();return a?.status===`ok`&&ci(a,{status:`exited`}),qo(),t.setSession(i),i}function qo(){let e=Ni(),t=Mi().getSession()||e.getSession();t&&li(t),Jo(),e.setSession()}function Jo(){let e=Ni(),t=Li(),n=e.getSession();n&&t&&t.captureSession(n)}function Yo(e){let t=e.protocol?`${e.protocol}:`:``,n=e.port?`:${e.port}`:``;return`${t}//${e.host}${n}${e.path?`/${e.path}`:``}/api/`}function Xo(e){return`${Yo(e)}${e.projectId}/envelope/`}function Zo(e,t){let n={sentry_version:`7`};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}function Qo(e,t,n){return t||`${Xo(e)}?${Zo(e,n)}`}const $o=[];function es(e){let t={};return e.forEach(e=>{let{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.values(t)}function ts(e){let t=e.defaultIntegrations||[],n=e.integrations;t.forEach(e=>{e.isDefaultInstance=!0});let r;if(Array.isArray(n))r=[...t,...n];else if(typeof n==`function`){let e=n(t);r=Array.isArray(e)?e:[e]}else r=t;return es(r)}function ns(e,t){let n={};return t.forEach(t=>{t&&is(e,t,n)}),n}function rs(e,t){for(let n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function is(e,t,n){if(n[t.name]){Cn&&Bn.log(`Integration skipped because it was already installed: ${t.name}`);return}if(n[t.name]=t,!$o.includes(t.name)&&typeof t.setupOnce==`function`&&(t.setupOnce(),$o.push(t.name)),t.setup&&typeof t.setup==`function`&&t.setup(e),typeof t.preprocessEvent==`function`){let n=t.preprocessEvent.bind(t);e.on(`preprocessEvent`,(t,r)=>n(t,r,e))}if(typeof t.processEvent==`function`){let n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}Cn&&Bn.log(`Integration installed: ${t.name}`)}function as(e){return e}function os(e,t){return t?Fi(t,()=>{let n=Ca(),r=n?da(n):Ri(t);return[n?Pa(n):Na(e,t),r]}):[void 0,void 0]}function ss(e){return[{type:`log`,item_count:e.length,content_type:`application/vnd.sentry.items.log+json`},{items:e}]}function cs(e,t,n,r){let i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Yi(r)),Ua(i,[ss(e)])}function ls(e,t){let n=t??us(e)??[];if(n.length===0)return;let r=e.getOptions(),i=cs(n,r._metadata,r.tunnel,e.getDsn());ds().set(e,[]),e.emit(`flushLogs`),e.sendEnvelope(i)}function us(e){return ds().get(e)}function ds(){return On(`clientToLogBufferMap`,()=>new WeakMap)}function fs(e){return[{type:`trace_metric`,item_count:e.length,content_type:`application/vnd.sentry.items.trace-metric+json`},{items:e}]}function ps(e,t,n,r){let i={};return t?.sdk&&(i.sdk={name:t.sdk.name,version:t.sdk.version}),n&&r&&(i.dsn=Yi(r)),Ua(i,[fs(e)])}function ms(e,t){let n=t??hs(e)??[];if(n.length===0)return;let r=e.getOptions(),i=ps(n,r._metadata,r.tunnel,e.getDsn());gs().set(e,[]),e.emit(`flushMetrics`),e.sendEnvelope(i)}function hs(e){return gs().get(e)}function gs(){return On(`clientToMetricBufferMap`,()=>new WeakMap)}function _s(e){return typeof e==`object`&&typeof e.unref==`function`&&e.unref(),e}const vs=Symbol.for(`SentryBufferFullError`);function ys(e=100){let t=new Set;function n(){return t.size<e}function r(e){t.delete(e)}function i(e){if(!n())return po(vs);let i=e();return t.add(i),i.then(()=>r(i),()=>r(i)),i}function a(e){if(!t.size)return fo(!0);let n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;let r=[n,new Promise(t=>_s(setTimeout(()=>t(!1),e)))];return Promise.race(r)}return{get $(){return Array.from(t)},add:i,drain:a}}function bs(e,t=Lr()){let n=parseInt(`${e}`,10);if(!isNaN(n))return n*1e3;let r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}function xs(e,t){return e[t]||e.all||0}function Ss(e,t,n=Lr()){return xs(e,t)>n}function Cs(e,{statusCode:t,headers:n},r=Lr()){let i={...e},a=n?.[`x-sentry-rate-limits`],o=n?.[`retry-after`];if(a)for(let e of a.trim().split(`,`)){let[t,n,,,a]=e.split(`:`,5),o=parseInt(t,10),s=(isNaN(o)?60:o)*1e3;if(!n)i.all=r+s;else for(let e of n.split(`;`))e===`metric_bucket`?(!a||a.split(`;`).includes(`custom`))&&(i[e]=r+s):i[e]=r+s}else o?i.all=r+bs(o,r):t===429&&(i.all=r+60*1e3);return i}function ws(e,t,n=ys(e.bufferSize||64)){let r={},i=e=>n.drain(e);function a(i){let a=[];if(Ga(i,(t,n)=>{let i=$a(n);Ss(r,i)?e.recordDroppedEvent(`ratelimit_backoff`,i):a.push(t)}),a.length===0)return Promise.resolve({});let o=Ua(i[0],a),s=t=>{if(Ka(o,[`client_report`])){Cn&&Bn.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`);return}Ga(o,(n,r)=>{e.recordDroppedEvent(t,$a(r))})};return n.add(()=>t({body:Ja(o)}).then(e=>e.statusCode===413?(Cn&&Bn.error(`Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.`),s(`send_error`),e):(Cn&&e.statusCode!==void 0&&(e.statusCode<200||e.statusCode>=300)&&Bn.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),r=Cs(r,e),e),e=>{throw s(`network_error`),Cn&&Bn.error(`Encountered error running transport request:`,e),e})).then(e=>e,e=>{if(e===vs)return Cn&&Bn.error(`Skipped sending event because buffer is full.`),s(`queue_overflow`),Promise.resolve({});throw e})}return{send:a,flush:i}}function Ts(e,t,n){let r=[{type:`client_report`},{timestamp:n||ri(),discarded_events:e}];return Ua(t?{dsn:t}:{},[r])}function Es(e){let t=[];e.message&&t.push(e.message);try{let n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}function Ds(e){let{trace_id:t,parent_span_id:n,span_id:r,status:i,origin:a,data:o,op:s}=e.contexts?.trace??{};return{data:o??{},description:e.transaction,op:s,parent_span_id:n,span_id:r??``,start_timestamp:e.start_timestamp??0,status:i,timestamp:e.timestamp,trace_id:t??``,origin:a,profile_id:o?.[`sentry.profile_id`],exclusive_time:o?.[`sentry.exclusive_time`],measurements:e.measurements,is_segment:!0}}function Os(e){return{type:`transaction`,timestamp:e.timestamp,start_timestamp:e.start_timestamp,transaction:e.description,contexts:{trace:{trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,op:e.op,status:e.status,origin:e.origin,data:{...e.data,...e.profile_id&&{"sentry.profile_id":e.profile_id},...e.exclusive_time&&{"sentry.exclusive_time":e.exclusive_time}}}},measurements:e.measurements}}const ks=`Not capturing exception because it's already been captured.`,As=`Discarded session because of missing or non-string release`,js=Symbol.for(`SentryInternalError`),Ms=Symbol.for(`SentryDoNotSendEventError`);function Ns(e){return{message:e,[js]:!0}}function Ps(e){return{message:e,[Ms]:!0}}function Fs(e){return!!e&&typeof e==`object`&&js in e}function Is(e){return!!e&&typeof e==`object`&&Ms in e}function Ls(e,t,n,r,i){let a=0,o,s=!1;e.on(n,()=>{a=0,clearTimeout(o),s=!1}),e.on(t,t=>{a+=r(t),a>=8e5?i(e):s||(s=!0,o=_s(setTimeout(()=>{i(e)},5e3)))}),e.on(`flush`,()=>{i(e)})}var Rs=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=ys(e.transportOptions?.bufferSize??64),e.dsn?this._dsn=ta(e.dsn):Cn&&Bn.warn(`No DSN provided, client will not send events.`),this._dsn){let t=Qo(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}this._options.enableLogs=this._options.enableLogs??this._options._experiments?.enableLogs,this._options.enableLogs&&Ls(this,`afterCaptureLog`,`flushLogs`,Gs,ls),(this._options.enableMetrics??this._options._experiments?.enableMetrics??!0)&&Ls(this,`afterCaptureMetric`,`flushMetrics`,Ws,ms)}captureException(e,t,n){let r=Kr();if(ei(e))return Cn&&Bn.log(ks),r;let i={event_id:r,...t};return this._process(()=>this.eventFromException(e,i).then(e=>this._captureEvent(e,i,n)).then(e=>e),`error`),i.event_id}captureMessage(e,t,n,r){let i={event_id:Kr(),...n},a=pr(e)?e:String(e),o=mr(e),s=o?this.eventFromMessage(a,t,i):this.eventFromException(e,i);return this._process(()=>s.then(e=>this._captureEvent(e,i,r)),o?`unknown`:`error`),i.event_id}captureEvent(e,t,n){let r=Kr();if(t?.originalException&&ei(t.originalException))return Cn&&Bn.log(ks),r;let i={event_id:r,...t},a=e.sdkProcessingMetadata||{},o=a.capturedSpanScope,s=a.capturedSpanIsolationScope,c=zs(e.type);return this._process(()=>this._captureEvent(e,i,o||n,s),c),i.event_id}captureSession(e){this.sendSession(e),ci(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){let t=this._transport;if(!t)return!0;this.emit(`flush`);let n=await this._isClientDoneProcessing(e),r=await t.flush(e);return n&&r}async close(e){ls(this);let t=await this.flush(e);return this.getOptions().enabled=!1,this.emit(`close`),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith(`Spotlight`)))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){let t=this._integrations[e.name];is(this,e,this._integrations),t||rs(this,[e])}sendEvent(e,t={}){this.emit(`beforeSendEvent`,e,t);let n=io(e,this._dsn,this._options._metadata,this._options.tunnel);for(let e of t.attachments||[])n=Wa(n,Xa(e));this.sendEnvelope(n).then(t=>this.emit(`afterSendEvent`,e,t))}sendSession(e){let{release:t,environment:n=`production`}=this._options;if(`aggregates`in e){let r=e.attrs||{};if(!r.release&&!t){Cn&&Bn.warn(As);return}r.release=r.release||t,r.environment=r.environment||n,e.attrs=r}else{if(!e.release&&!t){Cn&&Bn.warn(As);return}e.release=e.release||t,e.environment=e.environment||n}this.emit(`beforeSendSession`,e);let r=ro(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(r)}recordDroppedEvent(e,t,n=1){if(this._options.sendClientReports){let r=`${e}:${t}`;Cn&&Bn.log(`Recording outcome: "${r}"${n>1?` (${n} times)`:``}`),this._outcomes[r]=(this._outcomes[r]||0)+n}}on(e,t){let n=this._hooks[e]=this._hooks[e]||new Set,r=(...e)=>t(...e);return n.add(r),()=>{n.delete(r)}}emit(e,...t){let n=this._hooks[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit(`beforeEnvelope`,e),this._isEnabled()&&this._transport)try{return await this._transport.send(e)}catch(e){return Cn&&Bn.error(`Error while sending envelope:`,e),{}}return Cn&&Bn.error(`Transport disabled`),{}}dispose(){}_setupIntegrations(){let{integrations:e}=this._options;this._integrations=ns(this,e),rs(this,e)}_updateSessionFromEvent(e,t){let n=t.level===`fatal`,r=!1,i=t.exception?.values;if(i){r=!0,n=!1;for(let e of i)if(e.mechanism?.handled===!1){n=!0;break}}let a=e.status===`ok`;(a&&e.errors===0||a&&n)&&(ci(e,{...n&&{status:`crashed`},errors:e.errors||Number(r||n)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,t,n,r){let i=this.getOptions(),a=Object.keys(this._integrations);return!t.integrations&&a?.length&&(t.integrations=a),this.emit(`preprocessEvent`,e,t),e.type||r.setLastEventId(e.event_id||t.event_id),jo(i,e,t,n,this,r).then(e=>e===null?e:(this.emit(`postprocessEvent`,e,t),e.contexts={trace:{...e.contexts?.trace,...Ri(n)},...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Na(this,n),...e.sdkProcessingMetadata},e))}_captureEvent(e,t={},n=Mi(),r=Ni()){return Cn&&Hs(e)&&Bn.log(`Captured error event \`${Es(e)[0]||`<unknown>`}\``),this._processEvent(e,t,n,r).then(e=>e.event_id,e=>{Cn&&(Is(e)?Bn.log(e.message):Fs(e)?Bn.warn(e.message):Bn.warn(e))})}_processEvent(e,t,n,r){let i=this.getOptions(),{sampleRate:a}=i,o=Us(e),s=Hs(e),c=`before send for type \`${e.type||`error`}\``,l=a===void 0?void 0:na(a);if(s&&typeof l==`number`&&Ir()>l)return this.recordDroppedEvent(`sample_rate`,`error`),po(Ps(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));let u=zs(e.type);return this._prepareEvent(e,t,n,r).then(e=>{if(e===null)throw this.recordDroppedEvent(`event_processor`,u),Ps("An event processor returned `null`, will not send event.");return t.data?.__sentry__===!0?e:Bs(Vs(this,i,e,t),c)}).then(i=>{if(i===null){if(this.recordDroppedEvent(`before_send`,u),o){let t=1+(e.spans||[]).length;this.recordDroppedEvent(`before_send`,`span`,t)}throw Ps(`${c} returned \`null\`, will not send event.`)}let a=n.getSession()||r.getSession();if(s&&a&&this._updateSessionFromEvent(a,i),o){let e=(i.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(i.spans?i.spans.length:0);e>0&&this.recordDroppedEvent(`before_send`,`span`,e)}let l=i.transaction_info;return o&&l&&i.transaction!==e.transaction&&(i.transaction_info={...l,source:`custom`}),this.sendEvent(i,t),i}).then(null,e=>{throw Is(e)||Fs(e)?e:(this.captureException(e,{mechanism:{handled:!1,type:`internal`},data:{__sentry__:!0},originalException:e}),Ns(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`))})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===vs&&this.recordDroppedEvent(`queue_overflow`,t),e))}_clearOutcomes(){let e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{let[n,r]=e.split(`:`);return{reason:n,category:r,quantity:t}})}_flushOutcomes(){Cn&&Bn.log(`Flushing outcomes...`);let e=this._clearOutcomes();if(e.length===0){Cn&&Bn.log(`No outcomes to send`);return}if(!this._dsn){Cn&&Bn.log(`No dsn provided, will not send outcomes`);return}Cn&&Bn.log(`Sending outcomes:`,e);let t=Ts(e,this._options.tunnel&&Yi(this._dsn));this.sendEnvelope(t)}};function zs(e){return e===`replay_event`?`replay`:e||`error`}function Bs(e,t){let n=`${t} must return \`null\` or a valid event.`;if(yr(e))return e.then(e=>{if(!hr(e)&&e!==null)throw Ns(n);return e},e=>{throw Ns(`${t} rejected with ${e}`)});if(!hr(e)&&e!==null)throw Ns(n);return e}function Vs(e,t,n,r){let{beforeSend:i,beforeSendTransaction:a,beforeSendSpan:o,ignoreSpans:s}=t,c=n;if(Hs(c)&&i)return i(c,r);if(Us(c)){if(o||s){let t=Ds(c);if(s?.length&&ka(t,s))return null;if(o){let e=o(t);e?c=di(n,Os(e)):wa()}if(c.spans){let t=[],n=c.spans;for(let e of n){if(s?.length&&ka(e,s)){Aa(n,e);continue}if(o){let n=o(e);n?t.push(n):(wa(),t.push(e))}else t.push(e)}let r=c.spans.length-t.length;r&&e.recordDroppedEvent(`before_send`,`span`,r),c.spans=t}}if(a){if(c.spans){let e=c.spans.length;c.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return a(c,r)}}return c}function Hs(e){return e.type===void 0}function Us(e){return e.type===`transaction`}function Ws(e){let t=0;return e.name&&(t+=e.name.length*2),t+=8,t+Ks(e.attributes)}function Gs(e){let t=0;return e.message&&(t+=e.message.length*2),t+Ks(e.attributes)}function Ks(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*qs(e[0]):mr(e)?t+=qs(e):t+=100}),t}function qs(e){return typeof e==`string`?e.length*2:typeof e==`number`?8:typeof e==`boolean`?4:0}function Js(e,t,n,r,i){let a={sent_at:new Date().toISOString()};return n?.sdk&&(a.sdk={name:n.sdk.name,version:n.sdk.version}),r&&i&&(a.dsn=Yi(i)),t&&(a.trace=t),Ua(a,[Ys(e)])}function Ys(e){return[{type:`check_in`},e]}function Xs(e){let t=e._metadata?.sdk,n=t?.name&&t?.version?`${t?.name}/${t?.version}`:void 0;e.transportOptions={...e.transportOptions,headers:{...n&&{"user-agent":n},...e.transportOptions?.headers}}}function Zs(e,t){return e(t.stack||``,1)}function Qs(e){return lr(e)&&`__sentry_fetch_url_host__`in e&&typeof e.__sentry_fetch_url_host__==`string`}function $s(e){return Qs(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}function ec(e,t){let n={type:t.name||t.constructor.name,value:$s(t)},r=Zs(e,t);return r.length&&(n.stacktrace={frames:r}),n}function tc(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(n instanceof Error)return n}}function nc(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message '${e.message}'`),t}else if(`message`in e&&typeof e.message==`string`)return e.message;let t=Nr(e);if(dr(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let n=rc(e);return`${n&&n!==`Object`?`'${n}'`:`Object`} captured as exception with keys: ${t}`}function rc(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function ic(e,t,n,r){if(lr(n))return[n,void 0];if(t.synthetic=!0,hr(n)){let t=e?.getOptions().normalizeDepth,i={__serialized__:Ia(n,t)},a=tc(n);if(a)return[a,i];let o=nc(n),s=r?.syntheticException||Error(o);return s.message=o,[s,i]}let i=r?.syntheticException||Error(n);return i.message=`${n}`,[i,void 0]}function ac(e,t,n,r){let i=r?.data&&r.data.mechanism||{handled:!0,type:`generic`},[a,o]=ic(e,i,n,r),s={exception:{values:[ec(t,a)]}};return o&&(s.extra=o),Yr(s,void 0,void 0),Xr(s,i),{...s,event_id:r?.event_id}}function oc(e,t,n=`info`,r,i){let a={event_id:r?.event_id,level:n};if(i&&r?.syntheticException){let n=Zs(e,r.syntheticException);n.length&&(a.exception={values:[{value:t,stacktrace:{frames:n}}]},Xr(a,{synthetic:!0}))}if(pr(t)){let{__sentry_template_string__:e,__sentry_template_values__:n}=t;return a.logentry={message:e,params:n},a}return a.message=t,a}var sc=class extends Rs{constructor(e){Ea(),Xs(e),super(e),this._setUpMetricsProcessing()}eventFromException(e,t){let n=ac(this,this._options.stackParser,e,t);return n.level=`error`,fo(n)}eventFromMessage(e,t=`info`,n){return fo(oc(this._options.stackParser,e,t,n,this._options.attachStacktrace))}captureException(e,t,n){return cc(t),super.captureException(e,t,n)}captureEvent(e,t,n){return!e.type&&e.exception?.values&&e.exception.values.length>0&&cc(t),super.captureEvent(e,t,n)}captureCheckIn(e,t,n){let r=`checkInId`in e&&e.checkInId?e.checkInId:Kr();if(!this._isEnabled())return Cn&&Bn.warn(`SDK not enabled, will not capture check-in.`),r;let{release:i,environment:a,tunnel:o}=this.getOptions(),s={check_in_id:r,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:a};`duration`in e&&(s.duration=e.duration),t&&(s.monitor_config={schedule:t.schedule,checkin_margin:t.checkinMargin,max_runtime:t.maxRuntime,timezone:t.timezone,failure_issue_threshold:t.failureIssueThreshold,recovery_threshold:t.recoveryThreshold});let[c,l]=os(this,n);l&&(s.contexts={trace:l});let u=Js(s,c,this.getSdkMetadata(),o,this.getDsn());return Cn&&Bn.log(`Sending checkin:`,e.monitorSlug,e.status),this.sendEnvelope(u),r}dispose(){Cn&&Bn.log(`Disposing client...`);for(let e of Object.keys(this._hooks))this._hooks[e]?.clear();this._hooks={},this._eventProcessors.length=0,this._integrations={},this._outcomes={},this._transport=void 0,this._promiseBuffer=ys(64)}_prepareEvent(e,t,n,r){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:e.contexts?.runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,t,n,r)}_setUpMetricsProcessing(){this.on(`processMetric`,e=>{this._options.serverName&&(e.attributes={"server.address":this._options.serverName,...e.attributes})})}};function cc(e){let t=Ni().getScopeData().sdkProcessingMetadata.requestSession;if(t){let n=e?.mechanism?.handled??!0;n&&t.status!==`crashed`?t.status=`errored`:n||(t.status=`crashed`)}}const lc=new Set([`false`,`f`,`n`,`no`,`off`,`0`]),uc=new Set([`true`,`t`,`y`,`yes`,`on`,`1`]);function dc(e,t){let n=String(e).toLowerCase();return lc.has(n)?!1:uc.has(n)?!0:t?.strict?null:!!e}function fc(e){if(!e)return{};let t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};let n=t[6]||``,r=t[8]||``;return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}function pc(e){return e.split(/[?#]/,1)[0]}function mc(e){let{protocol:t,host:n,path:r}=e,i=n?.replace(/^.*@/,`[filtered]:[filtered]@`).replace(/(:80)$/,``).replace(/(:443)$/,``)||``;return`${t?`${t}://`:``}${i}${r}`}function hc(e,t,n=[t],r=`npm`){let i=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};i.name||(i.name=`sentry.javascript.${t}`,i.packages=n.map(e=>({name:`${r}:@sentry/${e}`,version:Tn})),i.version=Tn)}function gc(e={}){let t=e.client||Li();if(!Go()||!t)return{};let n=ji(En());if(n.getTraceData)return n.getTraceData(e);let r=e.scope||Mi(),i=e.span||Ca(),a=i?fa(i):_c(r),o=Hi(i?Pa(i):Na(t,r));if(!ra.test(a))return Bn.warn(`Invalid sentry-trace data. Cannot generate trace data`),{};let s={"sentry-trace":a,baggage:o};return e.propagateTraceparent&&(s.traceparent=i?pa(i):vc(r)),s}function _c(e){let{traceId:t,sampled:n,propagationSpanId:r}=e.getPropagationContext();return oa(t,r,n)}function vc(e){let{traceId:t,sampled:n,propagationSpanId:r}=e.getPropagationContext();return sa(t,r,n)}const yc=`[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:`;function bc(e,t,n){if(typeof e!=`string`||!t)return!0;let r=n?.get(e);if(r!==void 0)return Cn&&!r&&Bn.log(yc,e),r;let i=Hr(e,t);return n?.set(e,i),Cn&&!i&&Bn.log(yc,e),i}function xc(e){let t=Object.create(null);try{Object.entries(e).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}catch{}return t}function Sc(e){let t=e.headers||{},n=(typeof t[`x-forwarded-host`]==`string`?t[`x-forwarded-host`]:void 0)||(typeof t.host==`string`?t.host:void 0),r=(typeof t[`x-forwarded-proto`]==`string`?t[`x-forwarded-proto`]:void 0)||e.protocol||(e.socket?.encrypted?`https`:`http`),i=e.url||``,a=Cc({url:i,host:n,protocol:r}),o=e.body||void 0,s=e.cookies;return{url:a,method:e.method,query_string:wc(i),headers:xc(t),cookies:s,data:o}}function Cc({url:e,protocol:t,host:n}){if(e?.startsWith(`http`))return e;if(e&&n)return`${t}://${n}${e}`}function wc(e){if(e)try{let t=new URL(e,`http://s.io`).search.slice(1);return t.length?t:void 0}catch{return}}function Tc(e,t){let n=Li(),r=Ni();if(!n)return;let{beforeBreadcrumb:i=null,maxBreadcrumbs:a=100}=n.getOptions();if(a<=0)return;let o={timestamp:ri(),...e},s=i?jn(()=>i(o,t)):o;s!==null&&(n.emit&&n.emit(`beforeAddBreadcrumb`,s,t),r.addBreadcrumb(s,a))}let Ec;const Dc=new WeakMap,Oc=as((()=>({name:`FunctionToString`,setupOnce(){Ec=Function.prototype.toString;try{Function.prototype.toString=function(...e){let t=kr(this),n=Dc.has(Li())&&t!==void 0?t:this;return Ec.apply(n,e)}}catch{}},setup(e){Dc.set(e,!0)}}))),kc=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],Ac=as((e={})=>{let t;return{name:`EventFilters`,setup(n){t=jc(e,n.getOptions())},processEvent(n,r,i){return t||=jc(e,i.getOptions()),Mc(n,t)?null:n}}});function jc(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:kc],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function Mc(e,t){if(!e.type){if(Nc(e,t.ignoreErrors))return Cn&&Bn.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${Jr(e)}`),!0;if(zc(e))return Cn&&Bn.warn(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${Jr(e)}`),!0;if(Fc(e,t.denyUrls))return Cn&&Bn.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${Jr(e)}.\nUrl: ${Rc(e)}`),!0;if(!Ic(e,t.allowUrls))return Cn&&Bn.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${Jr(e)}.\nUrl: ${Rc(e)}`),!0}else if(e.type===`transaction`&&Pc(e,t.ignoreTransactions))return Cn&&Bn.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${Jr(e)}`),!0;return!1}function Nc(e,t){return t?.length?Es(e).some(e=>Hr(e,t)):!1}function Pc(e,t){if(!t?.length)return!1;let n=e.transaction;return n?Hr(n,t):!1}function Fc(e,t){if(!t?.length)return!1;let n=Rc(e);return n?Hr(n,t):!1}function Ic(e,t){if(!t?.length)return!0;let n=Rc(e);return n?Hr(n,t):!0}function Lc(e=[]){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.filename!==`<anonymous>`&&n.filename!==`[native code]`)return n.filename||null}return null}function Rc(e){try{let t=[...e.exception?.values??[]].reverse().find(e=>e.mechanism?.parent_id===void 0&&e.stacktrace?.frames?.length)?.stacktrace?.frames;return t?Lc(t):null}catch{return Cn&&Bn.error(`Cannot extract url for event ${Jr(e)}`),null}}function zc(e){return e.exception?.values?.length?!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&e.type!==`Error`||e.value):!1}function Bc(e,t,n,r,i,a){if(!i.exception?.values||!a||!xr(a.originalException,Error))return;let o=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;o&&(i.exception.values=Vc(e,t,r,a.originalException,n,i.exception.values,o,0))}function Vc(e,t,n,r,i,a,o,s){if(a.length>=n+1)return a;let c=[...a];if(xr(r[i],Error)){Uc(o,s,r);let a=e(t,r[i]),l=c.length;Wc(a,i,l,s),c=Vc(e,t,n,r[i],i,[a,...c],a,l)}return Hc(r)&&r.errors.forEach((a,l)=>{if(xr(a,Error)){Uc(o,s,r);let u=e(t,a),d=c.length;Wc(u,`errors[${l}]`,d,s),c=Vc(e,t,n,a,i,[u,...c],u,d)}}),c}function Hc(e){return Array.isArray(e.errors)}function Uc(e,t,n){e.mechanism={handled:!0,type:`auto.core.linked_errors`,...Hc(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Wc(e,t,n,r){e.mechanism={handled:!0,...e.mechanism,type:`chained`,source:t,exception_id:n,parent_id:r}}const Gc=as(((e={})=>{let t=e.limit||5,n=e.key||`cause`;return{name:`LinkedErrors`,preprocessEvent(e,r,i){Bc(ec,i.getOptions().stackParser,n,t,e,r)}}}));function Kc(e){let t={},n=0;for(;n<e.length;){let r=e.indexOf(`=`,n);if(r===-1)break;let i=e.indexOf(`;`,n);if(i===-1)i=e.length;else if(i<r){n=e.lastIndexOf(`;`,r-1)+1;continue}let a=e.slice(n,r).trim();if(t[a]===void 0){let n=e.slice(r+1,i).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));try{t[a]=n.indexOf(`%`)===-1?n:decodeURIComponent(n)}catch{t[a]=n}}n=i+1}return t}const qc=[`X-Client-IP`,`X-Forwarded-For`,`Fly-Client-IP`,`CF-Connecting-IP`,`Fastly-Client-Ip`,`True-Client-Ip`,`X-Real-IP`,`X-Cluster-Client-IP`,`X-Forwarded`,`Forwarded-For`,`Forwarded`,`X-Vercel-Forwarded-For`];function Jc(e){let t={};for(let n of Object.keys(e))t[n.toLowerCase()]=e[n];return qc.map(e=>{let n=t[e.toLowerCase()],r=Array.isArray(n)?n.join(`;`):n;return e===`Forwarded`?Yc(r):r?.split(`,`).map(e=>e.trim())}).reduce((e,t)=>t?e.concat(t):e,[]).find(e=>e!==null&&Xc(e))||null}function Yc(e){if(!e)return null;for(let t of e.split(`;`))if(t.startsWith(`for=`))return t.slice(4);return null}function Xc(e){return/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)/.test(e)}const Zc={cookies:!0,data:!0,headers:!0,query_string:!0,url:!0},Qc=as(((e={})=>{let t={...Zc,...e.include};return{name:`RequestData`,processEvent(e,n,r){let{sdkProcessingMetadata:i={}}=e,{normalizedRequest:a,ipAddress:o}=i,s={...t,ip:t.ip??r.getOptions().sendDefaultPii};return a&&$c(e,a,{ipAddress:o},s),e}}}));function $c(e,t,n,r){if(e.request={...e.request,...el(t,r)},r.ip){let r=t.headers&&Jc(t.headers)||n.ipAddress;r&&(e.user={...e.user,ip_address:r})}}function el(e,t){let n={},r={...e.headers};return t.headers&&(n.headers=r,t.cookies||delete r.cookie,t.ip||qc.forEach(e=>{delete r[e]})),n.method=e.method,t.url&&(n.url=e.url),t.cookies&&(n.cookies=e.cookies||(r?.cookie?Kc(r.cookie):void 0)||{}),t.query_string&&(n.query_string=e.query_string),t.data&&(n.data=e.data),n}function tl(e){let t=`console`;$n(t,e),er(t,nl)}function nl(){`console`in wn&&kn.forEach(function(e){e in wn.console&&Er(wn.console,e,function(t){return An[e]=t,function(...t){tr(`console`,{args:t,level:e}),An[e]?.apply(wn.console,t)}})})}function rl(e){return e===`warn`?`warning`:[`fatal`,`error`,`warning`,`log`,`info`,`debug`].includes(e)?e:`log`}const il=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function al(e){let t=e.length>1024?`<truncated>${e.slice(-1024)}`:e,n=il.exec(t);return n?n.slice(1):[]}function ol(e){let t=al(e),n=t[0]||``,r=t[1];return!n&&!r?`.`:(r&&=r.slice(0,r.length-1),n+r)}const sl=as((e={})=>{let t=new Set(e.levels||kn);return{name:`Console`,setup(e){tl(({args:n,level:r})=>{Li()!==e||!t.has(r)||cl(r,n)})}}});function cl(e,t){let n={category:`console`,data:{arguments:t,logger:`console`},level:rl(e),message:ll(t)};if(e===`assert`)if(t[0]===!1){let e=t.slice(1);n.message=e.length>0?`Assertion failed: ${ll(e)}`:`Assertion failed`,n.data.arguments=e}else return;Tc(n,{input:t,level:e})}function ll(e){return`util`in wn&&typeof wn.util.format==`function`?wn.util.format(...e):Br(e,` `)}function ul(e){if(e!==void 0){if(e>=400&&e<500)return`warning`;if(e>=500)return`error`}}function dl(e,t=!1){return!(t||e&&!e.startsWith(`/`)&&!e.match(/^[A-Z]:/)&&!e.startsWith(`.`)&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes(`node_modules/`)}function fl(e){let t=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,r=/at (?:async )?(.+?) \(data:(.*?),/;return i=>{let a=i.match(r);if(a)return{filename:`<data:${a[2]}>`,function:a[1]};let o=i.match(n);if(o){let t,n,r,i,a;if(o[1]){r=o[1];let e=r.lastIndexOf(`.`);if(r[e-1]===`.`&&e--,e>0){t=r.slice(0,e),n=r.slice(e+1);let i=t.indexOf(`.Module`);i>0&&(r=r.slice(i+1),t=t.slice(0,i))}i=void 0}n&&(i=t,a=n),n===`<anonymous>`&&(a=void 0,r=void 0),r===void 0&&(a||=`?`,r=i?`${i}.${a}`:a);let s=Xn(o[2]),c=o[5]===`native`;!s&&o[5]&&!c&&(s=o[5]);let l=s?hl(s):void 0;return{filename:l??s,module:l&&e?.(l),function:r,lineno:ml(o[3]),colno:ml(o[4]),in_app:dl(s||``,c)}}if(i.match(t))return{filename:i}}}function pl(e){return[90,fl(e)]}function ml(e){return parseInt(e||``,10)||void 0}function hl(e){try{return decodeURI(e)}catch{return}}var gl=class{constructor(e){this._maxSize=e,this._cache=new Map}get size(){return this._cache.size}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){if(this._cache.size>=this._maxSize){let e=this._cache.keys().next().value;this._cache.delete(e)}this._cache.set(e,t)}remove(e){let t=this._cache.get(e);return t&&this._cache.delete(e),t}clear(){this._cache.clear()}keys(){return Array.from(this._cache.keys())}values(){let e=[];return this._cache.forEach(t=>e.push(t)),e}};let _l=!1,vl=``,yl=0,bl=0;const xl=6e4,Sl=new Map,Cl=new Set([`OnUncaughtException`,`OnUnhandledRejection`]);function wl(e,t){_l=!0,vl=e,Wo(`session_id`,ln()),Wo(`runtime`,e),t&&Wo(`client_kind`,t)}function Tl(e){return vl=e.runtime,{dsn:hn.sentryDsn,environment:e.environment??(typeof process<`u`?`production`:void 0)??`production`,release:e.version,tracesSampleRate:0,sampleRate:1,maxBreadcrumbs:30,sendDefaultPii:!1,...e.disableGlobalUnhandledErrors?{integrations(e){return e.filter(e=>!Cl.has(e.name))}}:{},beforeSend(e){return jl(e)||Nl(e)||!Pl()||Il(Fl(e))?null:El(e)}}}function El(e){return e}function Dl(e,t){_l&&(t?Fi(n=>{n.setExtras(t),Ho(e)}):Ho(e))}function Ol(e,t,n){_l&&(n?Fi(r=>{r.setExtras(n),Uo(e,t)}):Uo(e,t))}function kl(e,t){_l&&Wo(e,t)}function Al(e,t,n=`info`){_l&&Tc({message:e,category:t,level:n})}function jl(e){for(let t of e.exception?.values??[]){let e=t.type??``,n=t.value??``;if(e===`AbortError`||e===`CreditLimitError`||n===`interrupted`||n===`This operation was aborted`||vl===`cli`&&/\bE(?:IO|PIPE|NOTCONN)\b/.test(n))return!0}return(e.message??e.logentry?.message??``)===`Credit limit reached`}const Ml=/codellm|abacusai/;function Nl(e){if(vl!==`extension-host`)return!1;let t=e.exception?.values;if(!t||t.length===0)return!1;let n=t.flatMap(e=>e.stacktrace?.frames??[]);return n.length===0?!1:!n.some(e=>{let t=e.filename??e.abs_path??e.module??``;return Ml.test(t)})}function Pl(){let e=Date.now();return e-bl>xl&&(yl=0,bl=e),yl++,yl<=10}function Fl(e){let t=e.exception?.values?.[0];if(t)return`${t.type??``}:${t.value??``}`;let n=e.message??e.logentry?.message;return n?`msg:${n}`:Math.random().toString()}function Il(e){let t=Date.now(),n=Sl.get(e);if(n&&t-n<xl)return!0;if(Sl.set(e,t),Sl.size>100){let e=Sl.keys().next().value;e&&Sl.delete(e)}return!1}var Ll=class extends Error{code=`AUTH_EXPIRED`;constructor(){super(`Session expired — please log in again.`),this.name=`AuthExpiredError`}},Rl=class extends Error{cause;code=`NETWORK_ERROR`;constructor(e,t){super(e??`Network unavailable — check your connection.`),this.cause=t,this.name=`NetworkError`}};const zl=[`User not logged in`,`Invalid API Key`,`Invalid session token`];function Bl(e){return zl.includes(e)}function Vl(e){if(!(e instanceof Error))return!1;if(e instanceof Rl)return!0;let t=e.message.toLowerCase();return e.name===`TypeError`&&t.includes(`fetch failed`)||t.includes(`econnrefused`)||t.includes(`econnreset`)||t.includes(`etimedout`)||t.includes(`enotfound`)||t.includes(`enetunreach`)||t.includes(`ehostunreach`)||t.includes(`epipe`)||t.includes(`socket hang up`)}const Hl=`codellm.endpoints`;var Ul=class e{headers;logger;clientName;clientVersion;static apiPrefixUrl=`https://apps.abacus.ai`;static abacusDomain=`https://abacus.ai`;chatWebDomainOverride=null;cache=new Map;userAgentHeaders;constructor(e,t,n,r){this.headers=e,this.logger=t,this.clientName=n,this.clientVersion=r,this.userAgentHeaders=n&&r?{"User-Agent":`${n}/${r}`}:{};let i=this.cache.get(`codellm.endpoints`)??null;if(i)try{this.endpoints=JSON.parse(i)}catch(e){this.logger?.error(`Failed to parse stored endpoints:`,e)}}throwAuthExpired(){throw Ol(`Auth expired mid-session`,`warning`,{context:`api-client`}),new Ll}setUrl(t){e.apiPrefixUrl=t,e.abacusDomain=t.includes(`-apps.abacus.ai`)?t.replace(`-apps.abacus.ai`,`.abacus.ai`):t.replace(`apps.`,``)}setChatWebDomain(e){this.chatWebDomainOverride=e,e?this.cache.set(`codellm.chatWebDomain`,e):this.cache.delete(`codellm.chatWebDomain`)}getChatWebDomain(){return this.chatWebDomainOverride}endpoints=null;getAbacusDomain(){return this.isDevpodEnvironment()?e.apiPrefixUrl:e.abacusDomain}async getConversationsList(e,t){return this._customCall(`/api/listDeploymentConversations`,{conversationType:e,...t&&{chatllmProjectId:t}},{isClusterProxy:!0,method:`GET`})}async searchConversations(e,t){return this._customCall(`/api/_searchConversations`,{query:e,...t&&{conversationType:t}},{isClusterProxy:!0,method:`POST`})}getDeploymentConversation(e){return this._customCall(`/api/getDeploymentConversation`,{...e,skipDocumentBoundingBoxes:!0,filterIntermediateConversationEvents:!0,getUnusedDocumentUploads:!1},{isClusterProxy:!0,method:`POST`})}clearDeploymentConversation(e){return this._customCall(`/api/clearDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}getCodeEdit({fileContents:e,fileSelection:t,rules:n,...r}){return this._customCall(`/api/_getCodeEdit`,{...r,fileContents:e===void 0?void 0:JSON.stringify(e),fileSelection:t===void 0?void 0:JSON.stringify(t),rules:n===void 0?void 0:JSON.stringify(n)},{isClusterProxy:!0,method:`POST`})}listLLMModels(){return this._customCall(`/api/_listCodeBots`,{supportsThoughtStreaming:!0},{isClusterProxy:!0,method:`POST`})}getConstantsAutocomplete(){return this._customCall(`/api/_getConstantsAutocomplete`,{},{isClusterProxy:!0,method:`POST`,suppressNotifications:!0})}getCodeAutocompleteResponse({signal:e,...t}){return this._customCall(`/api/_getCodeAutocompleteResponse`,t,{isClusterProxy:!0,method:`POST`,signal:e})}getAutocompleteEditPrediction({signal:e,...t}){return this._customCall(`/api/_getAutocompleteEditPrediction`,t,{isClusterProxy:!0,method:`POST`,signal:e})}async getUserInfo(){return!this.endpoints&&!this.chatWebDomainOverride&&await this.getApiEndpoint(),await this._customCall(`/api/_getUserInfo`,{},{method:`POST`,useDirect:!0,suppressNotifications:!0})}async getApiEndpoint(){let e=await this._customCall(`/api/v0/getApiEndpoint`,{reqScheme:`https`},{method:`POST`,useDirect:!0});return e?.success&&e?.result&&(this.endpoints=e,this.cache.set(Hl,JSON.stringify(e))),e}resetEndpoints(){this.endpoints=null,this.cache.delete(Hl),this.chatWebDomainOverride=null}async*streamChatMessage({deploymentConversationId:e,requestId:t,fileContents:n,filePositions:r,terminalSelections:i,rules:a,signal:o,...s}){yield*this.fetchSSE(`/api/_codeLLMSendMessageSSE`,{...s,deploymentConversationId:e,fileContents:n===null?void 0:JSON.stringify(n),filePositions:r===null?void 0:JSON.stringify(r),terminalSelections:i===null?void 0:JSON.stringify(i),rules:a===void 0?void 0:JSON.stringify(a),requestId:t},{isClusterProxy:!0,signal:o})}async*streamAgentMessage({deploymentConversationId:e,requestId:t,folderPaths:n,terminalSelections:r,mcpTools:i,availableSkills:a,activeSkills:o,supportedSubAgents:s,reconnect:c,signal:l,...u}){if(!e)throw Error(`streamAgentMessage: deploymentConversationId is required but was not provided`);yield*this.fetchSSE(`/api/_codeLLMSendAgentMessageSSE`,{...u,deploymentConversationId:e,folderPaths:n===void 0?void 0:JSON.stringify(n),terminalSelections:r===null?void 0:JSON.stringify(r),mcpTools:i===void 0?void 0:JSON.stringify(i),requestId:t,availableSkills:a===void 0?void 0:JSON.stringify(a),activeSkills:o===void 0?void 0:JSON.stringify(o),supportedSubAgents:s===void 0?void 0:JSON.stringify(s),supportsParallelToolUse:!0,...c&&{reconnect:!0}},{isClusterProxy:!0,signal:l})}stopResponseSSE(e){return this._customCall(`/api/_stopResponseSSE`,{requestId:e},{isClusterProxy:!0,method:`POST`})}getPendingRequestIdForConversation(e){return this._customCall(`/api/_getPendingRequestIdForConversation`,{deploymentConversationId:e},{isClusterProxy:!0,method:`GET`})}async _customCall(t,n,r={method:`POST`}){try{let i,a=this.isDevpodEnvironment();a&&!t?.includes(`/api/v0/`)&&!t?.includes(`_codeLLMSendMessageSSE`)&&!t?.includes(`_getCodeAutocompleteResponse`)&&!t?.includes(`_getAutocompleteEditPrediction`)&&!t?.includes(`_codeLLMSendAgentMessageSSE`)&&!t?.includes(`createUploadDataToChatllmRequest`)&&!t?.includes(`getUploadDataToChatllmStatus`)&&!t?.includes(`_stopResponseSSE`)&&!t?.includes(`_getPendingRequestIdForConversation`)&&!t?.includes(`_getCodeSummary`)&&!t?.includes(`_getIndividualSummary`)&&!t?.includes(`_getCodeEdit`)&&!t?.includes(`_getCodeChatEdits`)&&!t?.includes(`_getCodeLLMCodeEmbeddings`)&&!t?.includes(`_getCodeLLMChangedFiles`)&&!t?.includes(`_updateCodeLLMWorkspaceState`)&&(t=t?.replace(`/api/`,`/api/v0/`)),i=r.useDirect?t?.includes(`_getUserInfo`)?this.getAbacusDomain():this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.getAbacusDomain():r.isClusterProxy?this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.endpoints?.result?a&&this.endpoints.result.proxyEndpoint?this.endpoints.result.proxyEndpoint:this.endpoints.result.externalChatEndpoint?this.endpoints.result.externalChatEndpoint:e.apiPrefixUrl:e.apiPrefixUrl:t?.includes(`listExternalApplications`)||t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?this.getAbacusDomain():e.apiPrefixUrl;let o=i.indexOf(`/chatllm`);i=o===-1?i:i.substring(0,o);let s=new URL(`${i}${t}`),c=t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?{}:await this.headers.getHeaders(),l,u={"REAI-UI":`1`,...this.userAgentHeaders,...c};if(r.method===`GET`){if(n!==void 0)for(let e of Object.keys(n))s.searchParams.append(e,String(n[e]))}else if(r.formData)l=r.formData;else if(l=JSON.stringify(n),u[`Content-Type`]=`application/json`,r.gzip){u[`Content-Encoding`]=`gzip`;let e=new Blob([l]).stream().pipeThrough(new CompressionStream(`gzip`)),t=await new Response(e).arrayBuffer();l=btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(t))))}let d=await fetch(s,{method:r.method,body:l,headers:u,signal:r.signal});if(!d.ok){let e=await d.text(),t=`API request failed with status ${d.status}`;try{let n=JSON.parse(e);if(n&&typeof n==`object`&&`error`in n){let e=String(n.error);Bl(e)&&this.throwAuthExpired(),t=e}}catch(n){if(n instanceof Ll)throw n;t+=`: ${e}`}throw Error(t)}let f=await d.json();if(f&&typeof f==`object`&&`success`in f&&`error`in f){let e=f;e.success===!1&&e.error&&Bl(e.error)&&this.throwAuthExpired()}return f}catch(e){if(e instanceof Ll)throw e;if(e instanceof Error&&e.name===`AbortError`)return null;throw e instanceof Error&&Vl(e)?new Rl(e.message,e):(Dl(e,{context:`api-client`}),e)}}async createCodellmDeploymentConversation(e=rt.CODE_LLM,t){return await this._customCall(`/api/_createCodellmDeploymentConversation`,{conversationType:e.toString(),...t&&{clientType:t},codeAgentV2:!0},{isClusterProxy:!0,method:`POST`})}_createChatLLMProject(e){return this._customCall(`/api/_createChatLLMProject`,e,{isClusterProxy:!0,method:`POST`})}_attachConverstationToChatLLMProject(e){return this._customCall(`/api/_attachConverstationToChatLLMProject`,e,{isClusterProxy:!0,method:`POST`})}async createUploadDataToChatllmRequest({deploymentConversationId:e,deploymentId:t,files:n,startPage:r,endPage:i}){let a=new globalThis.FormData;for(let e of n){let t=e.name.lastIndexOf(`.`),n=e.name.substring(0,t===-1?e.name.length:t);a.append(n,e)}a.append(`deploymentConversationId`,e),a.append(`deploymentId`,t),r!==void 0&&a.append(`startPage`,String(r)),i!==void 0&&a.append(`endPage`,String(i));let o=await this._customCall(`/api/createUploadDataToChatllmRequest`,{},{isClusterProxy:!0,method:`POST`,formData:a});if(!o)throw Error(`Upload failed`);return o}getUploadStatus(e){return this._customCall(`/api/getUploadDataToChatllmStatus?request_id=${e}`,void 0,{isClusterProxy:!0,method:`GET`})}deleteDeploymentConversation(e){return this._customCall(`/api/deleteDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}getCodeChatEdits(e){return this._customCall(`/api/_getCodeChatEdits`,e,{isClusterProxy:!0,method:`POST`})}listExternalApplications(){return this._customCall(`/api/listExternalApplications`,{includeSearchLlm:!1},{isClusterProxy:!1,method:`POST`})}detachDocumentsFromDeploymentConversation(e){return this._customCall(`/api/_detachDocumentsFromDeploymentConversation`,e,{isClusterProxy:!0,method:`POST`})}authenticateDeviceForCodeLlm(e,t){return this._customCall(`/api/_authenticateDeviceForCodeLlm`,{email:e,deviceId:t},{isClusterProxy:!1,method:`POST`})}pollDeviceCode(e){return this._customCall(`/api/_pollDeviceCode`,{userCode:e},{isClusterProxy:!1,method:`POST`})}recordUserAction(e){return this._customCall(`/api/_recordUserAction`,{actionType:e},{isClusterProxy:!0,method:`POST`})}listOrganizations(){return this._customCall(`/api/v0/_listOrganizations`,{},{method:`GET`,useDirect:!0})}updateApiKeyOrganization(e){return this._customCall(`/api/v0/_updateApiKeyOrganization`,{organizationId:e},{method:`POST`,useDirect:!0})}selectActiveOrganization(e){return this._customCall(`/api/v0/_selectActiveOrganization`,{organizationId:e},{method:`POST`,useDirect:!0})}async switchOrganization(e){if(!(await this.updateApiKeyOrganization(e))?.success||!(await this.selectActiveOrganization(e))?.success)return!1;this.resetEndpoints();let t=(await this.getUserInfo())?.result?.organization,n=null;if(t){let e=t.externalChatOrgHost;if(typeof e==`string`&&e.trim()!==``)n=e.trim();else if(typeof t.externalChatEndpoint==`string`&&t.externalChatEndpoint.trim()!==``){let e=t.externalChatEndpoint.trim(),r=null;try{r=new URL(e)}catch{try{/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(e)||(r=new URL(`https://${e}`))}catch{r=null}}r?.host&&(n=r.host)}}return this.setChatWebDomain(n),!0}isDevpodEnvironment(){let e=this.endpoints?.result?.apiEndpoint||``;return e.includes(`-dev.internalreai.com`)||e.includes(`-dev.mumbai.internalreai.com`)}async*fetchSSE(e,t,n={}){let r=(await this._fetchRaw(e,t,{...n,isSSE:!0,method:`POST`})).body?.getReader();if(!r)return;let i=new TextDecoder,a=``;try{for(;;){let e,{value:t,done:n}=await Promise.race([r.read(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`SSE read timeout — connection may be lost`)),3e4)})]).finally(()=>clearTimeout(e));if(n){if(a.trim()){let e=this.parseNDJSON(a);for(let t of e.parsed){if(t.end||t.cancelled)return;yield t}}return}a+=i.decode(t,{stream:!0});let{parsed:o,remainder:s}=this.parseNDJSON(a);a=s;for(let e of o){if(e.error){yield e;return}if(e.end||e.cancelled)return;e.ping||(yield e)}}}catch(e){if(this.logger?.error(`Streaming error`,e),e instanceof Ll)throw e;if(e instanceof Error&&e.name===`AbortError`)return;throw e instanceof Error&&(Vl(e)||e.message.includes(`SSE read timeout`))?new Rl(e.message,e):e}finally{r.releaseLock()}}async _fetchRaw(t,n,r){let i,a=this.isDevpodEnvironment();i=r.useDirect?t?.includes(`_getUserInfo`)?this.getAbacusDomain():this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.getAbacusDomain():r.isClusterProxy?this.chatWebDomainOverride?`https://${this.chatWebDomainOverride}`:this.endpoints?.result?a&&this.endpoints.result.proxyEndpoint?this.endpoints.result.proxyEndpoint:this.endpoints.result.externalChatEndpoint?this.endpoints.result.externalChatEndpoint:e.apiPrefixUrl:e.apiPrefixUrl:t?.includes(`listExternalApplications`)||t?.includes(`_authenticateDeviceForCodeLlm`)||t?.includes(`_pollDeviceCode`)?this.getAbacusDomain():e.apiPrefixUrl,a&&!t?.includes(`/api/v0/`)&&!t?.includes(`_codeLLMSendMessageSSE`)&&!t?.includes(`_getCodeAutocompleteResponse`)&&!t?.includes(`_getAutocompleteEditPrediction`)&&!t?.includes(`_codeLLMSendAgentMessageSSE`)&&!t?.includes(`createUploadDataToChatllmRequest`)&&!t?.includes(`getUploadDataToChatllmStatus`)&&!t?.includes(`_stopResponseSSE`)&&!t?.includes(`_getPendingRequestIdForConversation`)&&!t?.includes(`_getCodeSummary`)&&!t?.includes(`_getIndividualSummary`)&&!t?.includes(`_getCodeEdit`)&&!t?.includes(`_getCodeChatEdits`)&&!t?.includes(`_getCodeLLMCodeEmbeddings`)&&!t?.includes(`_getCodeLLMChangedFiles`)&&!t?.includes(`_updateCodeLLMWorkspaceState`)&&(t=t?.replace(`/api/`,`/api/v0/`));let o=i.indexOf(`/chatllm`);i=o===-1?i:i.substring(0,o);let s=new URL(`${i}${t}`),c=await this.headers.getHeaders(),l={"REAI-UI":`1`,...this.userAgentHeaders,...c,...r.isSSE?{Accept:`text/event-stream`,Connection:`keep-alive`}:{}},u;if(r.method===`GET`){if(n)for(let e of Object.keys(n))s.searchParams.append(e,String(n[e]))}else if(r.formData)u=r.formData;else if(u=JSON.stringify(n),l[`Content-Type`]=`application/json`,r.gzip){l[`Content-Encoding`]=`gzip`;let e=new Blob([u]).stream().pipeThrough(new CompressionStream(`gzip`)),t=await new Response(e).arrayBuffer();u=btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(t))))}let d=await fetch(s,{method:r.method,body:u,headers:l,signal:r.signal});if(!d.ok){let e=await d.text(),t=`API request failed with status ${d.status}`;try{let n=JSON.parse(e);if(n&&typeof n==`object`&&`error`in n){let e=String(n.error);Bl(e)&&this.throwAuthExpired(),t=e}}catch(n){if(n instanceof Ll)throw n;t+=`: ${e}`}throw Error(t)}return d}parseNDJSON(e){let t=[],n=0,r=e.indexOf(`
7
7
  `,n);for(;r!==-1;){let i=e.substring(n,r).trim();if(n=r+1,r=e.indexOf(`
8
8
  `,n),i!==``)try{t.push(JSON.parse(i))}catch(r){if(r instanceof SyntaxError)return{parsed:t,remainder:e.substring(n-i.length-1)}}}return{parsed:t,remainder:e.substring(n)}}getCodeSummary(e){return this._customCall(`/api/_getCodeSummary`,e,{isClusterProxy:!0,method:`POST`,suppressNotifications:!0})}getIndividualSummary(e){return this._customCall(`/api/_getIndividualSummary`,e,{isClusterProxy:!0,method:`POST`,suppressNotifications:!0})}getCodeEmbedding(e){return this._customCall(`/api/_getCodeLLMCodeEmbeddings`,e,{isClusterProxy:!0,method:`POST`})}getCodeLLMChangedFiles(e){return this._customCall(`/api/_getCodeLLMChangedFiles`,e,{isClusterProxy:!0,method:`POST`,gzip:!1})}updateWorkspaceState(e){return this._customCall(`/api/_updateCodeLLMWorkspaceState`,e,{isClusterProxy:!0,method:`POST`,gzip:!1})}};const Wl=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__;var Gl=class extends sc{constructor(e){let t=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||P.hostname(),n={...e,platform:`node`,runtime:{name:`node`,version:global.process.version},serverName:t};hc(n,`node-light`,[`node-core`]),Bn.log(`Initializing Sentry: process: ${process.pid}, thread: ${z?`main`:`worker-${ne}`}.`),super(n),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{ls(this)},t&&this.on(`beforeCaptureLog`,e=>{e.attributes={...e.attributes,"server.address":t}}),process.on(`beforeExit`,this._logOnExitFlushListener))}async flush(e){return this.getOptions().sendClientReports&&this._flushOutcomes(),super.flush(e)}async close(e){return this._clientReportInterval&&clearInterval(this._clientReportInterval),this._clientReportOnExitFlushListener&&process.off(`beforeExit`,this._clientReportOnExitFlushListener),this._logOnExitFlushListener&&process.off(`beforeExit`,this._logOnExitFlushListener),super.close(e)}startClientReportTracking(){let e=this.getOptions();e.sendClientReports&&(this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{Wl&&Bn.log(`Flushing client reports based on interval.`),this._flushOutcomes()},e.clientReportFlushInterval??6e4).unref(),process.on(`beforeExit`,this._clientReportOnExitFlushListener))}};const Kl=as((e={})=>({name:`ChildProcess`,setup(){re.channel(`child_process`).subscribe(t=>{t&&typeof t==`object`&&`process`in t&&ql(t.process,e)}),re.channel(`worker_threads`).subscribe(t=>{t&&typeof t==`object`&&`worker`in t&&Jl(t.worker,e)})}}));function ql(e,t){let n=!1,r;e.on(`spawn`,()=>{if(e.spawnfile===`/usr/bin/sw_vers`){n=!0;return}r={spawnfile:e.spawnfile},t.includeChildProcessArgs&&(r.spawnargs=e.spawnargs)}).on(`exit`,e=>{n||(n=!0,e!==null&&e!==0&&Tc({category:`child_process`,message:`Child process exited with code '${e}'`,level:e===0?`info`:`warning`,data:r}))}).on(`error`,e=>{n||(n=!0,Tc({category:`child_process`,message:`Child process errored with '${e.message}'`,level:`error`,data:r}))})}function Jl(e,t){let n;e.on(`online`,()=>{n=e.threadId}).on(`error`,e=>{t.captureWorkerErrors===!1?Tc({category:`worker_thread`,message:`Worker thread errored with '${e.message}'`,level:`error`,data:{threadId:n}}):Ho(e,{mechanism:{type:`auto.child_process.worker_thread`,handled:!1,data:{threadId:String(n)}}})})}const Yl=a(h),Xl=a(_),Zl=as(((e={})=>{let t,n={app:!0,os:!0,device:!0,culture:!0,cloudResource:!0,...e};async function r(e){t===void 0&&(t=i());let n=Ql(await t);return e.contexts={...e.contexts,app:{...n.app,...e.contexts?.app},os:{...n.os,...e.contexts?.os},device:{...n.device,...e.contexts?.device},culture:{...n.culture,...e.contexts?.culture},cloud_resource:{...n.cloud_resource,...e.contexts?.cloud_resource}},e}async function i(){let e={};if(n.os&&(e.os=await $l()),n.app&&(e.app=tu()),n.device&&(e.device=nu(n.device)),n.culture){let t=eu();t&&(e.culture=t)}return n.cloudResource&&(e.cloud_resource=uu()),e}return{name:`Context`,processEvent(e){return r(e)}}}));function Ql(e){if(e.app?.app_memory&&(e.app.app_memory=process.memoryUsage().rss),e.app?.free_memory&&typeof process.availableMemory==`function`){let t=process.availableMemory?.();t!=null&&(e.app.free_memory=t)}return e.device?.free_memory&&(e.device.free_memory=P.freemem()),e}async function $l(){let e=P.platform();switch(e){case`darwin`:return su();case`linux`:return lu();default:return{name:ru[e]||e,version:P.release()}}}function eu(){try{if(typeof process.versions.icu!=`string`)return;let e=new Date(9e8);if(new Intl.DateTimeFormat(`es`,{month:`long`}).format(e)===`enero`){let e=Intl.DateTimeFormat().resolvedOptions();return{locale:e.locale,timezone:e.timeZone}}}catch{}}function tu(){let e=process.memoryUsage().rss,t={app_start_time:new Date(Date.now()-process.uptime()*1e3).toISOString(),app_memory:e};if(typeof process.availableMemory==`function`){let e=process.availableMemory?.();e!=null&&(t.free_memory=e)}return t}function nu(e){let t={},n;try{n=P.uptime()}catch{}if(typeof n==`number`&&(t.boot_time=new Date(Date.now()-n*1e3).toISOString()),t.arch=P.arch(),(e===!0||e.memory)&&(t.memory_size=P.totalmem(),t.free_memory=P.freemem()),e===!0||e.cpu){let e=P.cpus(),n=e?.[0];n&&(t.processor_count=e.length,t.cpu_description=n.model,t.processor_frequency=n.speed)}return t}const ru={aix:`IBM AIX`,freebsd:`FreeBSD`,openbsd:`OpenBSD`,sunos:`SunOS`,win32:`Windows`,ohos:`OpenHarmony`,android:`Android`},iu=[{name:`fedora-release`,distros:[`Fedora`]},{name:`redhat-release`,distros:[`Red Hat Linux`,`Centos`]},{name:`redhat_version`,distros:[`Red Hat Linux`]},{name:`SuSE-release`,distros:[`SUSE Linux`]},{name:`lsb-release`,distros:[`Ubuntu Linux`,`Arch Linux`]},{name:`debian_version`,distros:[`Debian`]},{name:`debian_release`,distros:[`Debian`]},{name:`arch-release`,distros:[`Arch Linux`]},{name:`gentoo-release`,distros:[`Gentoo Linux`]},{name:`novell-release`,distros:[`SUSE Linux`]},{name:`alpine-release`,distros:[`Alpine Linux`]}],au={alpine:e=>e,arch:e=>ou(/distrib_release=(.*)/,e),centos:e=>ou(/release ([^ ]+)/,e),debian:e=>e,fedora:e=>ou(/release (..)/,e),mint:e=>ou(/distrib_release=(.*)/,e),red:e=>ou(/release ([^ ]+)/,e),suse:e=>ou(/VERSION = (.*)\n/,e),ubuntu:e=>ou(/distrib_release=(.*)/,e)};function ou(e,t){let n=e.exec(t);return n?n[1]:void 0}async function su(){let e={kernel_version:P.release(),name:`Mac OS X`,version:`10.${Number(P.release().split(`.`)[0])-4}`};try{let t=await new Promise((e,t)=>{se(`/usr/bin/sw_vers`,(n,r)=>{if(n){t(n);return}e(r)})});e.name=ou(/^ProductName:\s+(.*)$/m,t),e.version=ou(/^ProductVersion:\s+(.*)$/m,t),e.build=ou(/^BuildVersion:\s+(.*)$/m,t)}catch{}return e}function cu(e){return e.split(` `)[0].toLowerCase()}async function lu(){let e={kernel_version:P.release(),name:`Linux`};try{let t=await Xl(`/etc`),n=iu.find(e=>t.includes(e.name));if(!n)return e;let r=(await Yl(A(`/etc`,n.name),{encoding:`utf-8`})).toLowerCase(),{distros:i}=n;e.name=i.find(e=>r.indexOf(cu(e))>=0)||i[0],e.version=au[cu(e.name)]?.(r)}catch{}return e}function uu(){if(process.env.VERCEL)return{"cloud.provider":`vercel`,"cloud.region":process.env.VERCEL_REGION};if(process.env.AWS_REGION)return{"cloud.provider":`aws`,"cloud.region":process.env.AWS_REGION,"cloud.platform":process.env.AWS_EXECUTION_ENV};if(process.env.GCP_PROJECT)return{"cloud.provider":`gcp`};if(process.env.ALIYUN_REGION_ID)return{"cloud.provider":`alibaba_cloud`,"cloud.region":process.env.ALIYUN_REGION_ID};if(process.env.WEBSITE_SITE_NAME&&process.env.REGION_NAME)return{"cloud.provider":`azure`,"cloud.region":process.env.REGION_NAME};if(process.env.IBM_CLOUD_REGION)return{"cloud.provider":`ibm_cloud`,"cloud.region":process.env.IBM_CLOUD_REGION};if(process.env.TENCENTCLOUD_REGION)return{"cloud.provider":`tencent_cloud`,"cloud.region":process.env.TENCENTCLOUD_REGION,"cloud.account.id":process.env.TENCENTCLOUD_APPID,"cloud.availability_zone":process.env.TENCENTCLOUD_ZONE};if(process.env.NETLIFY)return{"cloud.provider":`netlify`};if(process.env.FLY_REGION)return{"cloud.provider":`fly.io`,"cloud.region":process.env.FLY_REGION};if(process.env.DYNO)return{"cloud.provider":`heroku`}}const du=new gl(10),fu=new gl(20);function pu(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function mu(e){return!!(e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`))}function hu(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function gu(e,t){let n=du.get(e);if(n===void 0)return!1;for(let e=t[0];e<=t[1];e++)if(n[e]===void 0)return!1;return!0}function _u(e,t){if(!e.length)return[];let n=0,r=e[0];if(typeof r!=`number`)return[];let i=Tu(r,t),a=[];for(;;){if(n===e.length-1){a.push(i);break}let r=e[n+1];if(typeof r!=`number`)break;r<=i[1]?i[1]=r+t:(a.push(i),i=Tu(r,t)),n++}return a}function vu(e,t,n){return new Promise((r,i)=>{let a=u(e),o=pe({input:a});function s(){a.destroy(),r()}let c=0,l=0,d=t[l];if(d===void 0){s();return}let f=d[0],p=d[1];function m(t){fu.set(e,1),Wl&&Bn.error(`Failed to read file: ${e}. Error: ${t}`),o.close(),o.removeAllListeners(),s()}a.on(`error`,m),o.on(`error`,m),o.on(`close`,s),o.on(`line`,e=>{if(c++,!(c<f)&&(n[c]=zr(e,0),c>=p)){if(l===t.length-1){o.close(),o.removeAllListeners();return}l++;let e=t[l];if(e===void 0){o.close(),o.removeAllListeners();return}f=e[0],p=e[1]}})})}async function yu(e,t){let n={};if(t>0&&e.exception?.values){for(let t of e.exception.values)if(t.stacktrace?.frames?.length)for(let e=t.stacktrace.frames.length-1;e>=0;e--){let r=t.stacktrace.frames[e],i=r?.filename;!r||typeof i!=`string`||typeof r.lineno!=`number`||mu(i)||hu(r)||(n[i]||(n[i]=[]),n[i].push(r.lineno))}}let r=Object.keys(n);if(r.length==0)return e;let i=[];for(let e of r){if(fu.get(e))continue;let r=n[e];if(!r)continue;r.sort((e,t)=>e-t);let a=_u(r,t);if(a.every(t=>gu(e,t)))continue;let o=pu(du,e,{});i.push(vu(e,a,o))}if(await Promise.all(i).catch(()=>{Wl&&Bn.log(`Failed to read one or more source files and resolve context lines`)}),t>0&&e.exception?.values)for(let n of e.exception.values)n.stacktrace?.frames&&n.stacktrace.frames.length>0&&bu(n.stacktrace.frames,t,du);return e}function bu(e,t,n){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno==`number`){let e=n.get(r.filename);if(e===void 0)continue;Su(r.lineno,r,t,e)}}function xu(e){delete e.pre_context,delete e.context_line,delete e.post_context}function Su(e,t,n,r){if(t.lineno===void 0||r===void 0){Wl&&Bn.error(`Cannot resolve context for frame with no lineno or file contents`);return}t.pre_context=[];for(let i=Cu(e,n);i<e;i++){let e=r[i];if(e===void 0){xu(t),Wl&&Bn.error(`Could not find line ${i} in file ${t.filename}`);return}t.pre_context.push(e)}if(r[e]===void 0){xu(t),Wl&&Bn.error(`Could not find line ${e} in file ${t.filename}`);return}t.context_line=r[e];let i=wu(e,n);t.post_context=[];for(let n=e+1;n<=i;n++){let e=r[n];if(e===void 0)break;t.post_context.push(e)}}function Cu(e,t){return Math.max(1,e-t)}function wu(e,t){return e+t}function Tu(e,t){return[Cu(e,t),wu(e,t)]}const Eu=as(((e={})=>{let t=e.frameContextLines===void 0?7:e.frameContextLines;return{name:`ContextLines`,processEvent(e){return yu(e,t)}}})),Du=$r(process.versions.node),Ou=Du.major;Du.minor;let ku;async function Au(){if(ku===void 0)try{ku=!!(await import(`node:inspector`)).url()}catch{ku=!1}return ku}const ju=`__SENTRY_ERROR_LOCAL_VARIABLES__`;function Mu(e,t,n){let r=0,i=5,a=0;return setInterval(()=>{a===0?r>e&&(i*=2,n(i),i>86400&&(i=86400),a=i):(--a,a===0&&t()),r=0},1e3).unref(),()=>{r+=1}}function Nu(e){return e!==void 0&&(e.length===0||e===`?`||e===`<anonymous>`)}function Pu(e,t){return e===t||`Object.${e}`===t||e===`Object.${t}`||Nu(e)&&Nu(t)}function Fu(...e){Bn.log(`[LocalVariables]`,...e)}const Iu=as(((e={})=>{function t(t,n){let r=(t.stacktrace?.frames||[]).filter(e=>e.function!==`new Promise`);for(let t=0;t<r.length;t++){let i=r.length-t-1,a=n[t],o=r[i];if(!o||!a)break;a.vars===void 0||o.in_app===!1&&e.includeOutOfAppFrames!==!0||!Pu(o.function,a.function)||(o.vars=a.vars)}}function n(e,n){if(n.originalException&&typeof n.originalException==`object`&&`__SENTRY_ERROR_LOCAL_VARIABLES__`in n.originalException&&Array.isArray(n.originalException.__SENTRY_ERROR_LOCAL_VARIABLES__)){for(let r of e.exception?.values||[])t(r,n.originalException[ju]);n.originalException[ju]=void 0}return e}async function r(){let e=await import(`node:inspector`);e.url()||e.open(0)}function i(e){let t=new R(new URL(`data:application/javascript;base64,LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjQ2LjAgKGU1ZmRjOWQpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=`),{workerData:e,execArgv:[],env:{...process.env,NODE_OPTIONS:void 0}});process.on(`exit`,()=>{t.terminate()}),t.once(`error`,e=>{Fu(`Worker error`,e)}),t.once(`exit`,e=>{Fu(`Worker exit`,e)}),t.unref()}return{name:`LocalVariablesAsync`,async setup(t){if(!t.getOptions().includeLocalVariables)return;if(await Au()){Bn.warn(`Local variables capture has been disabled because the debugger was already enabled`);return}let n={...e,debug:Bn.isEnabled()};r().then(()=>{try{i(n)}catch(e){Bn.error(`Failed to start worker`,e)}},e=>{Bn.error(`Failed to start inspector`,e)})},processEvent(e,t){return n(e,t)}}}));function Lu(e){if(e!==void 0)return e.slice(-10).reduce((e,t)=>`${e},${t.function},${t.lineno},${t.colno}`,``)}function Ru(e,t){if(t!==void 0)return Lu(e(t,1))}function zu(e){let t=[],n=!1;function r(r){t=[],!n&&(n=!0,e(r))}t.push(r);function i(e){t.push(e)}function a(e){let n=t.pop()||r;try{n(e)}catch{r(e)}}return{add:i,next:a}}var Bu=class e{constructor(e){this._session=e}static async create(t){return t||new e(new(await(import(`node:inspector`))).Session)}configureAndConnect(e,t){this._session.connect(),this._session.on(`Debugger.paused`,t=>{e(t,()=>{this._session.post(`Debugger.resume`)})}),this._session.post(`Debugger.enable`),this._session.post(`Debugger.setPauseOnExceptions`,{state:t?`all`:`uncaught`})}setPauseOnExceptions(e){this._session.post(`Debugger.setPauseOnExceptions`,{state:e?`all`:`uncaught`})}getLocalVariables(e,t){this._getProperties(e,e=>{let{add:n,next:r}=zu(t);for(let t of e)if(t.value?.objectId&&t.value.className===`Array`){let e=t.value.objectId;n(n=>this._unrollArray(e,t.name,n,r))}else if(t.value?.objectId&&t.value.className===`Object`){let e=t.value.objectId;n(n=>this._unrollObject(e,t.name,n,r))}else t.value&&n(e=>this._unrollOther(t,e,r));r({})})}_getProperties(e,t){this._session.post(`Runtime.getProperties`,{objectId:e,ownProperties:!0},(e,n)=>{t(e?[]:n.result)})}_unrollArray(e,t,n,r){this._getProperties(e,e=>{n[t]=e.filter(e=>e.name!==`length`&&!isNaN(parseInt(e.name,10))).sort((e,t)=>parseInt(e.name,10)-parseInt(t.name,10)).map(e=>e.value?.value),r(n)})}_unrollObject(e,t,n,r){this._getProperties(e,e=>{n[t]=e.map(e=>[e.name,e.value?.value]).reduce((e,[t,n])=>(e[t]=n,e),{}),r(n)})}_unrollOther(e,t,n){e.value&&(`value`in e.value?e.value.value===void 0||e.value.value===null?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:`description`in e.value&&e.value.type!==`function`?t[e.name]=`<${e.value.description}>`:e.value.type===`undefined`&&(t[e.name]=`<undefined>`)),n(t)}};const Vu=as(((e={},t)=>{let n=new gl(20),r,i=!1;function a(t){let r=Lu(t.stacktrace?.frames);if(r===void 0)return;let i=n.remove(r);if(i===void 0)return;let a=(t.stacktrace?.frames||[]).filter(e=>e.function!==`new Promise`);for(let t=0;t<a.length;t++){let n=a.length-t-1,r=i[t],o=a[n];if(!o||!r)break;r.vars===void 0||o.in_app===!1&&e.includeOutOfAppFrames!==!0||!Pu(o.function,r.function)||(o.vars=r.vars)}}function o(e){for(let t of e.exception?.values||[])a(t);return e}let s;async function c(){let a=Li()?.getOptions();if(a?.includeLocalVariables){if(Ou<18){Bn.log("The `LocalVariables` integration is only supported on Node >= v18.");return}if(await Au()){Bn.warn(`Local variables capture has been disabled because the debugger was already enabled`);return}try{let o=await Bu.create(t),s=(e,{params:{reason:t,data:i,callFrames:a}},s)=>{if(t!==`exception`&&t!==`promiseRejection`){s();return}r?.();let c=Ru(e,i.description);if(c==null){s();return}let{add:l,next:u}=zu(e=>{n.set(c,e),s()});for(let e=0;e<Math.min(a.length,5);e++){let{scopeChain:t,functionName:n,this:r}=a[e],i=t.find(e=>e.type===`local`),s=r.className===`global`||!r.className?n:`${r.className}.${n}`;if(i?.object.objectId===void 0)l(t=>{t[e]={function:s},u(t)});else{let t=i.object.objectId;l(n=>o.getLocalVariables(t,t=>{n[e]={function:s,vars:t},u(n)}))}}u([])},c=e.captureAllExceptions!==!1;o.configureAndConnect((e,t)=>s(a.stackParser,e,t),c),c&&(r=Mu(e.maxExceptionsPerSecond||50,()=>{Bn.log(`Local variables rate-limit lifted.`),o.setPauseOnExceptions(!0)},e=>{Bn.log(`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),o.setPauseOnExceptions(!1)})),i=!0}catch(e){Bn.log("The `LocalVariables` integration failed to start.",e)}}}return{name:`LocalVariables`,setupOnce(){s=c()},async processEvent(e){return await s,i?o(e):e},_getCachedFramesCount(){return n.size},_getFirstCachedFrame(){return n.values()[0]}}})),Hu=(e={})=>Du.major<19?Vu(e):Iu(e);function Uu(){try{return typeof module<`u`&&module.exports!==void 0}catch{return!1}}let Wu;const Gu=typeof __SENTRY_SERVER_MODULES__>`u`?{}:__SENTRY_SERVER_MODULES__,Ku=(()=>({name:`Modules`,processEvent(e){return e.modules={...e.modules,...Xu()},e},getModules:Xu}));function qu(){try{return et.cache?Object.keys(et.cache):[]}catch{return[]}}function Ju(){return{...Gu,...Qu(),...Uu()?Yu():{}}}function Yu(){let e=et.main?.paths||[],t=qu(),n={},r=new Set;return t.forEach(t=>{let i=t,a=()=>{let t=i;if(i=k(t),!i||t===i||r.has(t))return;if(e.indexOf(i)<0)return a();let o=A(t,`package.json`);if(r.add(t),!f(o))return a();try{let e=JSON.parse(g(o,`utf8`));n[e.name]=e.version}catch{}};a()}),n}function Xu(){return Wu||=Ju(),Wu}function Zu(){try{let e=A(process.cwd(),`package.json`);return JSON.parse(g(e,`utf8`))}catch{return{}}}function Qu(){let e=Zu();return{...e.dependencies,...e.devDependencies}}function $u(e){jn(()=>{console.error(e)});let t=Li();if(t===void 0){Wl&&Bn.warn(`No NodeClient was defined, we are exiting the process now.`),global.process.exit(1);return}let n=t.getOptions(),r=n?.shutdownTimeout&&n.shutdownTimeout>0?n.shutdownTimeout:2e3;t.close(r).then(e=>{e||Wl&&Bn.warn(`We reached the timeout for emptying the request buffer, still exiting now!`),global.process.exit(1)},e=>{Wl&&Bn.error(e)})}const ed=as((e={})=>{let t={exitEvenIfOtherHandlersAreRegistered:!1,...e};return{name:`OnUncaughtException`,setup(e){z&&global.process.on(`uncaughtException`,td(e,t))}}});function td(e,t){let n=!1,r=!1,i=!1,a,o=e.getOptions();return Object.assign(s=>{let c=$u;t.onFatalError?c=t.onFatalError:o.onFatalError&&(c=o.onFatalError);let l=global.process.listeners(`uncaughtException`).filter(e=>e.name!==`domainUncaughtExceptionClear`&&e.tag!==`sentry_tracingErrorCallback`&&e._errorHandler!==!0).length===0,u=t.exitEvenIfOtherHandlersAreRegistered||l;n?u&&(i?(Wl&&Bn.warn(`uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown`),$u(s)):r||(r=!0,setTimeout(()=>{i||(i=!0,c(a,s))},2e3))):(a=s,n=!0,Li()===e&&Ho(s,{originalException:s,captureContext:{level:`fatal`},mechanism:{handled:!1,type:`auto.node.onuncaughtexception`}}),!i&&u&&(i=!0,c(s)))},{_errorHandler:!0})}const nd=[{name:`AI_NoOutputGeneratedError`},{name:`AbortError`}],rd=as(((e={})=>{let t={mode:e.mode??`warn`,ignore:[...nd,...e.ignore??[]]};return{name:`OnUnhandledRejection`,setup(e){global.process.on(`unhandledRejection`,ree(e,t))}}}));function eee(e){if(typeof e!=`object`||!e)return{name:``,message:String(e??``)};let t=e;return{name:typeof t.name==`string`?t.name:``,message:typeof t.message==`string`?t.message:String(e)}}function tee(e,t){let n=e.name===void 0||Vr(t.name,e.name,!0),r=e.message===void 0||Vr(t.message,e.message);return n&&r}function nee(e,t){let n=eee(t);return e.some(e=>tee(e,n))}function ree(e,t){return function(n,r){if(Li()!==e||nee(t.ignore??[],n))return;let i=t.mode===`strict`?`fatal`:`error`,a=n&&typeof n==`object`?n._sentry_active_span:void 0;(a?e=>so(a,e):e=>e())(()=>{Ho(n,{originalException:r,captureContext:{extra:{unhandledPromiseRejection:!0},level:i},mechanism:{handled:!1,type:`auto.node.onunhandledrejection`}})}),iee(n,t.mode)}}function iee(e,t){let n=`This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:`;t===`warn`?jn(()=>{console.warn(n),console.error(e&&typeof e==`object`&&`stack`in e?e.stack:e)}):t===`strict`&&(jn(()=>{console.warn(n)}),$u(e))}const aee=as(()=>({name:`ProcessSession`,setupOnce(){Ko(),process.on(`beforeExit`,()=>{Ni().getSession()?.status!==`ok`&&qo()})}})),oee=as(((e={})=>{let t={sidecarUrl:e.sidecarUrl||`http://localhost:8969/stream`};return{name:`Spotlight`,setup(e){try{Bn.warn(`[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?`)}catch{}see(e,t)}}}));function see(e,t){let n=cee(t.sidecarUrl);if(!n)return;let r=0;e.on(`beforeEnvelope`,e=>{if(r>3){Bn.warn(`[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests`);return}let t=Ja(e);co(()=>{let e=me.request({method:`POST`,path:n.pathname,hostname:n.hostname,port:n.port,headers:{"Content-Type":`application/x-sentry-envelope`}},e=>{e.statusCode&&e.statusCode>=200&&e.statusCode<400&&(r=0),e.on(`data`,()=>{}),e.on(`end`,()=>{}),e.setEncoding(`utf8`)});e.on(`error`,()=>{r++,Bn.warn(`[Spotlight] Failed to send envelope to Spotlight Sidecar`)}),e.write(t),e.end()})})}function cee(e){try{return new URL(`${e}`)}catch{Bn.warn(`[Spotlight] Invalid sidecar URL: ${e}`);return}}function lee(e){return!(e instanceof Error)||!(`errno`in e)||typeof e.errno!=`number`?!1:t.getSystemErrorMap().has(e.errno)}const uee=as((e={})=>({name:`NodeSystemError`,processEvent:(t,n,r)=>{if(!lee(n.originalException))return t;let i=n.originalException,a={...i};!r.getOptions().sendDefaultPii&&e.includePaths!==!0&&(delete a.path,delete a.dest),t.contexts={...t.contexts,node_system_error:a};for(let e of t.exception?.values||[])e.value&&(i.path&&e.value.includes(i.path)&&(e.value=e.value.replace(`'${i.path}'`,``).trim()),i.dest&&e.value.includes(i.dest)&&(e.value=e.value.replace(`'${i.dest}'`,``).trim()));return t}}));function id(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}function dee(e=process.argv[1]?ol(process.argv[1]):process.cwd(),t=N===`\\`){let n=t?id(e):e;return e=>{if(!e)return;let r=t?id(e):e,{dir:i,base:a,ext:o}=j.parse(r);(o===`.js`||o===`.mjs`||o===`.cjs`)&&(a=a.slice(0,o.length*-1));let s=decodeURIComponent(a);i||=`.`;let c=i.lastIndexOf(`/node_modules`);if(c>-1)return`${i.slice(c+14).replace(/\//g,`.`)}:${s}`;if(i.startsWith(n)){let e=i.slice(n.length+1).replace(/\//g,`.`);return e?`${e}:${s}`:s}return s}}function fee(e){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(wn.SENTRY_RELEASE?.id)return wn.SENTRY_RELEASE.id;let t=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,n=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_BUILD_COMMIT||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,r=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return t||n||r||e}const pee=Un(pl(dee())),ad=Symbol(`AgentBaseInternalState`);var mee=class extends me.Agent{constructor(e){super(e),this[ad]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==`boolean`)return e.secureEndpoint;if(typeof e.protocol==`string`)return e.protocol===`https:`}let{stack:t}=Error();return typeof t==`string`?t.split(`
9
9
  `).some(e=>e.indexOf(`(https.js:`)!==-1||e.indexOf(`node:https:`)!==-1):!1}createSocket(e,t,n){let r={...t,secureEndpoint:this.isSecureEndpoint(t)};Promise.resolve().then(()=>this.connect(e,r)).then(i=>{if(i instanceof me.Agent)return i.addRequest(e,r);this[ad].currentSocket=i,super.createSocket(e,t,n)},n)}createConnection(){let e=this[ad].currentSocket;if(this[ad].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[ad].defaultPort??(this.protocol===`https:`?443:80)}set defaultPort(e){this[ad]&&(this[ad].defaultPort=e)}get protocol(){return this[ad].protocol??(this.isSecureEndpoint()?`https:`:`http:`)}set protocol(e){this[ad]&&(this[ad].protocol=e)}};function od(...e){Bn.log(`[https-proxy-agent:parse-proxy-response]`,...e)}function hee(e){return new Promise((t,n)=>{let r=0,i=[];function a(){let t=e.read();t?l(t):e.once(`readable`,a)}function o(){e.removeListener(`end`,s),e.removeListener(`error`,c),e.removeListener(`readable`,a)}function s(){o(),od(`onend`),n(Error(`Proxy connection ended before receiving CONNECT response`))}function c(e){o(),od(`onerror %o`,e),n(e)}function l(s){i.push(s),r+=s.length;let c=Buffer.concat(i,r),l=c.indexOf(`\r
@@ -1868,7 +1868,7 @@ ${e.terminator}`}function cme(e){return`(${LP(e.body)})${IP(e.redirections)}`}fu
1868
1868
 
1869
1869
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=QF,s=!zF.jitless,c=s&&Ohe.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?WI([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function GI(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!aI(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>cI(e,r,BF())))}),t)}const KI=IF(`$ZodUnion`,(e,t)=>{FI.init(e,t),qF(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),qF(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),qF(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),qF(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>GF(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>GI(t,i,e,a)):GI(s,i,e,a)}});function qI(e,t,n,r){let i=e.filter(e=>e.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>cI(e,r,BF())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1}),t)}const j_e=IF(`$ZodXor`,(e,t)=>{KI.init(e,t),t.inclusive=!1;let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);t instanceof Promise?(s.push(t),o=!0):s.push(t)}return o?Promise.all(s).then(t=>qI(t,i,e,a)):qI(s,i,e,a)}}),M_e=IF(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,KI.init(e,t);let n=e._zod.parse;qF(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=UF(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!QF(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),N_e=IF(`$ZodIntersection`,(e,t)=>{FI.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>YI(e,t,n)):YI(e,i,a)}});function JI(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if($F(e)&&$F(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=JI(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=JI(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function YI(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),aI(e))return e;let o=JI(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const XI=IF(`$ZodTuple`,(e,t)=>{FI.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=[...n].reverse().findIndex(e=>e._zod.optin!==`optional`),c=s===-1?0:n.length-s;if(!t.rest){let t=a.length>n.length,i=a.length<c-1;if(t||i)return r.issues.push({...t?{code:`too_big`,maximum:n.length,inclusive:!0}:{code:`too_small`,minimum:n.length},input:a,inst:e,origin:`array`}),r}let l=-1;for(let e of n){if(l++,l>=a.length&&l>=c)continue;let t=e._zod.run({value:a[l],issues:[]},i);t instanceof Promise?o.push(t.then(e=>ZI(e,r,l))):ZI(t,r,l)}if(t.rest){let e=a.slice(n.length);for(let n of e){l++;let e=t.rest._zod.run({value:n,issues:[]},i);e instanceof Promise?o.push(e.then(e=>ZI(e,r,l))):ZI(e,r,l)}}return o.length?Promise.all(o).then(()=>r):r}});function ZI(e,t,n){e.issues.length&&t.issues.push(...oI(n,e.issues)),t.value[n]=e.value}const P_e=IF(`$ZodRecord`,(e,t)=>{FI.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!$F(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...oI(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...oI(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&EI.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>cI(e,r,BF())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...oI(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...oI(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),F_e=IF(`$ZodMap`,(e,t)=>{FI.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:`map`,code:`invalid_type`,input:i,inst:e}),n;let a=[];n.value=new Map;for(let[o,s]of i){let c=t.keyType._zod.run({value:o,issues:[]},r),l=t.valueType._zod.run({value:s,issues:[]},r);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([t,a])=>{QI(t,a,n,o,i,e,r)})):QI(c,l,n,o,i,e,r)}return a.length?Promise.all(a).then(()=>n):n}});function QI(e,t,n,r,i,a,o){e.issues.length&&(tI.has(typeof r)?n.issues.push(...oI(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>cI(e,o,BF()))})),t.issues.length&&(tI.has(typeof r)?n.issues.push(...oI(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>cI(e,o,BF()))})),n.value.set(e.value,t.value)}const I_e=IF(`$ZodSet`,(e,t)=>{FI.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:`set`,code:`invalid_type`}),n;let a=[];n.value=new Set;for(let e of i){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?a.push(i.then(e=>$I(e,n))):$I(i,n)}return a.length?Promise.all(a).then(()=>n):n}});function $I(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const L_e=IF(`$ZodEnum`,(e,t)=>{FI.init(e,t);let n=VF(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>tI.has(typeof e)).map(e=>typeof e==`string`?nI(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),R_e=IF(`$ZodLiteral`,(e,t)=>{if(FI.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?nI(e):e?nI(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),z_e=IF(`$ZodFile`,(e,t)=>{FI.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),B_e=IF(`$ZodTransform`,(e,t)=>{FI.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new RF(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new LF;return n.value=i,n}});function eL(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const tL=IF(`$ZodOptional`,(e,t)=>{FI.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,qF(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),qF(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${GF(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>eL(t,e.value)):eL(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),V_e=IF(`$ZodExactOptional`,(e,t)=>{tL.init(e,t),qF(e._zod,`values`,()=>t.innerType._zod.values),qF(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),H_e=IF(`$ZodNullable`,(e,t)=>{FI.init(e,t),qF(e._zod,`optin`,()=>t.innerType._zod.optin),qF(e._zod,`optout`,()=>t.innerType._zod.optout),qF(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${GF(e.source)}|null)$`):void 0}),qF(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),U_e=IF(`$ZodDefault`,(e,t)=>{FI.init(e,t),e._zod.optin=`optional`,qF(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>nL(e,t)):nL(r,t)}});function nL(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const W_e=IF(`$ZodPrefault`,(e,t)=>{FI.init(e,t),e._zod.optin=`optional`,qF(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),G_e=IF(`$ZodNonOptional`,(e,t)=>{FI.init(e,t),qF(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>rL(t,e)):rL(i,e)}});function rL(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const K_e=IF(`$ZodSuccess`,(e,t)=>{FI.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new RF(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),q_e=IF(`$ZodCatch`,(e,t)=>{FI.init(e,t),qF(e._zod,`optin`,()=>t.innerType._zod.optin),qF(e._zod,`optout`,()=>t.innerType._zod.optout),qF(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>cI(e,n,BF()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>cI(e,n,BF()))},input:e.value}),e.issues=[]),e)}}),J_e=IF(`$ZodNaN`,(e,t)=>{FI.init(e,t),e._zod.parse=(t,n)=>((typeof t.value!=`number`||!Number.isNaN(t.value))&&t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),Y_e=IF(`$ZodPipe`,(e,t)=>{FI.init(e,t),qF(e._zod,`values`,()=>t.in._zod.values),qF(e._zod,`optin`,()=>t.in._zod.optin),qF(e._zod,`optout`,()=>t.out._zod.optout),qF(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>iL(e,t.in,n)):iL(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>iL(e,t.out,n)):iL(r,t.out,n)}});function iL(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const X_e=IF(`$ZodCodec`,(e,t)=>{FI.init(e,t),qF(e._zod,`values`,()=>t.in._zod.values),qF(e._zod,`optin`,()=>t.in._zod.optin),qF(e._zod,`optout`,()=>t.out._zod.optout),qF(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>aL(e,t,n)):aL(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>aL(e,t,n)):aL(r,t,n)}}});function aL(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>oL(e,r,t.out,n)):oL(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>oL(e,r,t.in,n)):oL(e,r,t.in,n)}}function oL(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Z_e=IF(`$ZodReadonly`,(e,t)=>{FI.init(e,t),qF(e._zod,`propValues`,()=>t.innerType._zod.propValues),qF(e._zod,`values`,()=>t.innerType._zod.values),qF(e._zod,`optin`,()=>t.innerType?._zod?.optin),qF(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(sL):sL(r)}});function sL(e){return e.value=Object.freeze(e.value),e}const Q_e=IF(`$ZodTemplateLiteral`,(e,t)=>{FI.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=t.startsWith(`^`)?1:0,i=t.endsWith(`$`)?t.length-1:t.length;n.push(t.slice(r,i))}else if(e===null||khe.has(typeof e))n.push(nI(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),$_e=IF(`$ZodFunction`,(e,t)=>(FI.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?gI(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?gI(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await vI(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await vI(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(e._def.output&&e._def.output._zod.def.type===`promise`?t.value=e.implementAsync(t.value):t.value=e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new XI({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),eve=IF(`$ZodPromise`,(e,t)=>{FI.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),tve=IF(`$ZodLazy`,(e,t)=>{FI.init(e,t),qF(e._zod,`innerType`,()=>t.getter()),qF(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),qF(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),qF(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),qF(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),nve=IF(`$ZodCustom`,(e,t)=>{kI.init(e,t),FI.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>cL(t,n,r,e));cL(i,n,r,e)}});function cL(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(dI(e))}}var lL,rve=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ive(){return new rve}(lL=globalThis).__zod_globalRegistry??(lL.__zod_globalRegistry=ive());const uL=globalThis.__zod_globalRegistry;function ave(e,t){return new e({type:`string`,...iI(t)})}function ove(e,t){return new e({type:`string`,coerce:!0,...iI(t)})}function sve(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...iI(t)})}function dL(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...iI(t)})}function cve(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...iI(t)})}function lve(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...iI(t)})}function uve(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...iI(t)})}function dve(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...iI(t)})}function fL(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...iI(t)})}function fve(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...iI(t)})}function pve(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...iI(t)})}function mve(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...iI(t)})}function hve(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...iI(t)})}function gve(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...iI(t)})}function _ve(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...iI(t)})}function vve(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...iI(t)})}function yve(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...iI(t)})}function bve(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...iI(t)})}function xve(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...iI(t)})}function Sve(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...iI(t)})}function Cve(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...iI(t)})}function wve(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...iI(t)})}function Tve(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...iI(t)})}function Eve(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...iI(t)})}function Dve(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...iI(t)})}function Ove(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...iI(t)})}function kve(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...iI(t)})}function Ave(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...iI(t)})}function jve(e,t){return new e({type:`number`,checks:[],...iI(t)})}function Mve(e,t){return new e({type:`number`,coerce:!0,checks:[],...iI(t)})}function Nve(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...iI(t)})}function Pve(e,t){return new e({type:`boolean`,...iI(t)})}function Fve(e,t){return new e({type:`null`,...iI(t)})}function Ive(e){return new e({type:`any`})}function Lve(e){return new e({type:`unknown`})}function Rve(e,t){return new e({type:`never`,...iI(t)})}function pL(e,t){return new jI({check:`less_than`,...iI(t),value:e,inclusive:!1})}function mL(e,t){return new jI({check:`less_than`,...iI(t),value:e,inclusive:!0})}function hL(e,t){return new MI({check:`greater_than`,...iI(t),value:e,inclusive:!1})}function gL(e,t){return new MI({check:`greater_than`,...iI(t),value:e,inclusive:!0})}function _L(e,t){return new Tge({check:`multiple_of`,...iI(t),value:e})}function vL(e,t){return new Oge({check:`max_size`,...iI(t),maximum:e})}function yL(e,t){return new kge({check:`min_size`,...iI(t),minimum:e})}function bL(e,t){return new Age({check:`size_equals`,...iI(t),size:e})}function xL(e,t){return new jge({check:`max_length`,...iI(t),maximum:e})}function SL(e,t){return new Mge({check:`min_length`,...iI(t),minimum:e})}function CL(e,t){return new Nge({check:`length_equals`,...iI(t),length:e})}function zve(e,t){return new Pge({check:`string_format`,format:`regex`,...iI(t),pattern:e})}function Bve(e){return new Fge({check:`string_format`,format:`lowercase`,...iI(e)})}function Vve(e){return new Ige({check:`string_format`,format:`uppercase`,...iI(e)})}function Hve(e,t){return new Lge({check:`string_format`,format:`includes`,...iI(t),includes:e})}function Uve(e,t){return new Rge({check:`string_format`,format:`starts_with`,...iI(t),prefix:e})}function Wve(e,t){return new zge({check:`string_format`,format:`ends_with`,...iI(t),suffix:e})}function Gve(e,t){return new Bge({check:`mime_type`,mime:e,...iI(t)})}function wL(e){return new Vge({check:`overwrite`,tx:e})}function Kve(e){return wL(t=>t.normalize(e))}function qve(){return wL(e=>e.trim())}function Jve(){return wL(e=>e.toLowerCase())}function Yve(){return wL(e=>e.toUpperCase())}function Xve(){return wL(e=>Dhe(e))}function Zve(e,t,n){return new e({type:`array`,element:t,...iI(n)})}function Qve(e,t,n){let r=iI(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function $ve(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...iI(n)})}function eye(e){let t=tye(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(dI(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(dI(r))}},e(n.value,n)));return t}function tye(e,t){let n=new kI({check:`custom`,...iI(t)});return n._zod.check=e,n}function TL(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??uL,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function EL(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,EL(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&kL(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function DL(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
1870
1870
 
1871
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function OL(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:AL(t,`input`,e.processors),output:AL(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function kL(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return kL(r.element,n);if(r.type===`set`)return kL(r.valueType,n);if(r.type===`lazy`)return kL(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return kL(r.innerType,n);if(r.type===`intersection`)return kL(r.left,n)||kL(r.right,n);if(r.type===`record`||r.type===`map`)return kL(r.keyType,n)||kL(r.valueType,n);if(r.type===`pipe`)return kL(r.in,n)||kL(r.out,n);if(r.type===`object`){for(let e in r.shape)if(kL(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(kL(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(kL(e,n))return!0;return!!(r.rest&&kL(r.rest,n))}return!1}const nye=(e,t={})=>n=>{let r=TL({...n,processors:t});return EL(e,r),DL(r,e),OL(r,e)},AL=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=TL({...i??{},target:a,io:t,processors:n});return EL(e,o),DL(o,e),OL(o,e)},rye={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},iye=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=rye[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},aye=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},oye=(e,t,n,r)=>{n.type=`boolean`},sye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},cye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},lye=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},uye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},dye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},fye=(e,t,n,r)=>{n.not={}},pye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},mye=(e,t,n,r)=>{let i=e._zod.def,a=VF(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},hye=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},gye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},_ye=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},vye=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},yye=(e,t,n,r)=>{n.type=`boolean`},bye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},xye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Sye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Cye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},wye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Tye=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=EL(a.element,t,{...r,path:[...r.path,`items`]})},Eye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=EL(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=EL(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},jL=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>EL(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Dye=(e,t,n,r)=>{let i=e._zod.def,a=EL(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=EL(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Oye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>EL(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?EL(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},kye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=EL(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=EL(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=EL(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Aye=(e,t,n,r)=>{let i=e._zod.def,a=EL(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},jye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Nye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Pye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Fye=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;EL(a,t,r);let o=t.seen.get(e);o.ref=a},Iye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Lye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ML=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Rye=(e,t,n,r)=>{let i=e._zod.innerType;EL(i,t,r);let a=t.seen.get(e);a.ref=i},zye=IF(`ZodISODateTime`,(e,t)=>{t_e.init(e,t),zL.init(e,t)});function NL(e){return Dve(zye,e)}const Bye=IF(`ZodISODate`,(e,t)=>{n_e.init(e,t),zL.init(e,t)});function Vye(e){return Ove(Bye,e)}const Hye=IF(`ZodISOTime`,(e,t)=>{r_e.init(e,t),zL.init(e,t)});function Uye(e){return kve(Hye,e)}const Wye=IF(`ZodISODuration`,(e,t)=>{i_e.init(e,t),zL.init(e,t)});function Gye(e){return Ave(Wye,e)}const PL=(e,t)=>{pI.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Vhe(e,t)},flatten:{value:t=>Bhe(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,HF,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,HF,2)}},isEmpty:{get(){return e.issues.length===0}}})};IF(`ZodError`,PL);const FL=IF(`ZodError`,PL,{Parent:Error}),Kye=hI(FL),qye=_I(FL),Jye=yI(FL),Yye=xI(FL),Xye=Uhe(FL),Zye=Whe(FL),Qye=Ghe(FL),$ye=Khe(FL),ebe=qhe(FL),tbe=Jhe(FL),nbe=Yhe(FL),rbe=Xhe(FL),IL=IF(`ZodType`,(e,t)=>(FI.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:AL(e,`input`),output:AL(e,`output`)}}),e.toJSONSchema=nye(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(YF(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>rI(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Kye(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Jye(e,t,n),e.parseAsync=async(t,n)=>qye(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Yye(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xye(e,t,n),e.decode=(t,n)=>Zye(e,t,n),e.encodeAsync=async(t,n)=>Qye(e,t,n),e.decodeAsync=async(t,n)=>$ye(e,t,n),e.safeEncode=(t,n)=>ebe(e,t,n),e.safeDecode=(t,n)=>tbe(e,t,n),e.safeEncodeAsync=async(t,n)=>nbe(e,t,n),e.safeDecodeAsync=async(t,n)=>rbe(e,t,n),e.refine=(t,n)=>e.check(Ybe(t,n)),e.superRefine=t=>e.check(Xbe(t)),e.overwrite=t=>e.check(wL(t)),e.optional=()=>dR(e),e.exactOptional=()=>Lbe(e),e.nullable=()=>fR(e),e.nullish=()=>dR(fR(e)),e.nonoptional=t=>Ube(e,t),e.array=()=>XL(e),e.or=t=>tR([e,t]),e.and=t=>rR(e,t),e.transform=t=>hR(e,lR(t)),e.default=t=>Bbe(e,t),e.prefault=t=>Hbe(e,t),e.catch=t=>Gbe(e,t),e.pipe=t=>hR(e,t),e.readonly=()=>qbe(e),e.describe=t=>{let n=e.clone();return uL.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return uL.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return uL.get(e);let n=e.clone();return uL.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),LL=IF(`_ZodString`,(e,t)=>{II.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iye(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(zve(...t)),e.includes=(...t)=>e.check(Hve(...t)),e.startsWith=(...t)=>e.check(Uve(...t)),e.endsWith=(...t)=>e.check(Wve(...t)),e.min=(...t)=>e.check(SL(...t)),e.max=(...t)=>e.check(xL(...t)),e.length=(...t)=>e.check(CL(...t)),e.nonempty=(...t)=>e.check(SL(1,...t)),e.lowercase=t=>e.check(Bve(t)),e.uppercase=t=>e.check(Vve(t)),e.trim=()=>e.check(qve()),e.normalize=(...t)=>e.check(Kve(...t)),e.toLowerCase=()=>e.check(Jve()),e.toUpperCase=()=>e.check(Yve()),e.slugify=()=>e.check(Xve())}),RL=IF(`ZodString`,(e,t)=>{II.init(e,t),LL.init(e,t),e.email=t=>e.check(sve(ibe,t)),e.url=t=>e.check(fL(HL,t)),e.jwt=t=>e.check(Eve(bbe,t)),e.emoji=t=>e.check(fve(obe,t)),e.guid=t=>e.check(dL(BL,t)),e.uuid=t=>e.check(cve(VL,t)),e.uuidv4=t=>e.check(lve(VL,t)),e.uuidv6=t=>e.check(uve(VL,t)),e.uuidv7=t=>e.check(dve(VL,t)),e.nanoid=t=>e.check(pve(sbe,t)),e.guid=t=>e.check(dL(BL,t)),e.cuid=t=>e.check(mve(cbe,t)),e.cuid2=t=>e.check(hve(lbe,t)),e.ulid=t=>e.check(gve(ube,t)),e.base64=t=>e.check(Cve(_be,t)),e.base64url=t=>e.check(wve(vbe,t)),e.xid=t=>e.check(_ve(dbe,t)),e.ksuid=t=>e.check(vve(fbe,t)),e.ipv4=t=>e.check(yve(pbe,t)),e.ipv6=t=>e.check(bve(mbe,t)),e.cidrv4=t=>e.check(xve(hbe,t)),e.cidrv6=t=>e.check(Sve(gbe,t)),e.e164=t=>e.check(Tve(ybe,t)),e.datetime=t=>e.check(NL(t)),e.date=t=>e.check(Vye(t)),e.time=t=>e.check(Uye(t)),e.duration=t=>e.check(Gye(t))});function Y(e){return ave(RL,e)}const zL=IF(`ZodStringFormat`,(e,t)=>{LI.init(e,t),LL.init(e,t)}),ibe=IF(`ZodEmail`,(e,t)=>{Kge.init(e,t),zL.init(e,t)}),BL=IF(`ZodGUID`,(e,t)=>{Wge.init(e,t),zL.init(e,t)}),VL=IF(`ZodUUID`,(e,t)=>{Gge.init(e,t),zL.init(e,t)}),HL=IF(`ZodURL`,(e,t)=>{qge.init(e,t),zL.init(e,t)});function abe(e){return fL(HL,e)}const obe=IF(`ZodEmoji`,(e,t)=>{Jge.init(e,t),zL.init(e,t)}),sbe=IF(`ZodNanoID`,(e,t)=>{Yge.init(e,t),zL.init(e,t)}),cbe=IF(`ZodCUID`,(e,t)=>{Xge.init(e,t),zL.init(e,t)}),lbe=IF(`ZodCUID2`,(e,t)=>{Zge.init(e,t),zL.init(e,t)}),ube=IF(`ZodULID`,(e,t)=>{Qge.init(e,t),zL.init(e,t)}),dbe=IF(`ZodXID`,(e,t)=>{$ge.init(e,t),zL.init(e,t)}),fbe=IF(`ZodKSUID`,(e,t)=>{e_e.init(e,t),zL.init(e,t)}),pbe=IF(`ZodIPv4`,(e,t)=>{a_e.init(e,t),zL.init(e,t)});IF(`ZodMAC`,(e,t)=>{s_e.init(e,t),zL.init(e,t)});const mbe=IF(`ZodIPv6`,(e,t)=>{o_e.init(e,t),zL.init(e,t)}),hbe=IF(`ZodCIDRv4`,(e,t)=>{c_e.init(e,t),zL.init(e,t)}),gbe=IF(`ZodCIDRv6`,(e,t)=>{l_e.init(e,t),zL.init(e,t)}),_be=IF(`ZodBase64`,(e,t)=>{u_e.init(e,t),zL.init(e,t)}),vbe=IF(`ZodBase64URL`,(e,t)=>{f_e.init(e,t),zL.init(e,t)}),ybe=IF(`ZodE164`,(e,t)=>{p_e.init(e,t),zL.init(e,t)}),bbe=IF(`ZodJWT`,(e,t)=>{h_e.init(e,t),zL.init(e,t)});IF(`ZodCustomStringFormat`,(e,t)=>{g_e.init(e,t),zL.init(e,t)});const UL=IF(`ZodNumber`,(e,t)=>{zI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aye(e,t,n,r),e.gt=(t,n)=>e.check(hL(t,n)),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.lt=(t,n)=>e.check(pL(t,n)),e.lte=(t,n)=>e.check(mL(t,n)),e.max=(t,n)=>e.check(mL(t,n)),e.int=t=>e.check(GL(t)),e.safe=t=>e.check(GL(t)),e.positive=t=>e.check(hL(0,t)),e.nonnegative=t=>e.check(gL(0,t)),e.negative=t=>e.check(pL(0,t)),e.nonpositive=t=>e.check(mL(0,t)),e.multipleOf=(t,n)=>e.check(_L(t,n)),e.step=(t,n)=>e.check(_L(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function WL(e){return jve(UL,e)}const xbe=IF(`ZodNumberFormat`,(e,t)=>{__e.init(e,t),UL.init(e,t)});function GL(e){return Nve(xbe,e)}const Sbe=IF(`ZodBoolean`,(e,t)=>{v_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oye(e,t,n,r)});function KL(e){return Pve(Sbe,e)}const Cbe=IF(`ZodBigInt`,(e,t)=>{BI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sye(e,t,n,r),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.gt=(t,n)=>e.check(hL(t,n)),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.lt=(t,n)=>e.check(pL(t,n)),e.lte=(t,n)=>e.check(mL(t,n)),e.max=(t,n)=>e.check(mL(t,n)),e.positive=t=>e.check(hL(BigInt(0),t)),e.negative=t=>e.check(pL(BigInt(0),t)),e.nonpositive=t=>e.check(mL(BigInt(0),t)),e.nonnegative=t=>e.check(gL(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(_L(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});IF(`ZodBigIntFormat`,(e,t)=>{y_e.init(e,t),Cbe.init(e,t)}),IF(`ZodSymbol`,(e,t)=>{b_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cye(e,t,n,r)}),IF(`ZodUndefined`,(e,t)=>{x_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uye(e,t,n,r)});const wbe=IF(`ZodNull`,(e,t)=>{S_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lye(e,t,n,r)});function qL(e){return Fve(wbe,e)}const Tbe=IF(`ZodAny`,(e,t)=>{C_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function JL(){return Ive(Tbe)}const Ebe=IF(`ZodUnknown`,(e,t)=>{w_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function YL(){return Lve(Ebe)}const Dbe=IF(`ZodNever`,(e,t)=>{T_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fye(e,t,n,r)});function Obe(e){return Rve(Dbe,e)}IF(`ZodVoid`,(e,t)=>{E_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dye(e,t,n,r)}),IF(`ZodDate`,(e,t)=>{D_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pye(e,t,n,r),e.min=(t,n)=>e.check(gL(t,n)),e.max=(t,n)=>e.check(mL(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});const kbe=IF(`ZodArray`,(e,t)=>{O_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tye(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(SL(t,n)),e.nonempty=t=>e.check(SL(1,t)),e.max=(t,n)=>e.check(xL(t,n)),e.length=(t,n)=>e.check(CL(t,n)),e.unwrap=()=>e.element});function XL(e,t){return Zve(kbe,e,t)}const ZL=IF(`ZodObject`,(e,t)=>{A_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eye(e,t,n,r),qF(e,`shape`,()=>t.shape),e.keyof=()=>sR(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:YL()}),e.loose=()=>e.clone({...e._zod.def,catchall:YL()}),e.strict=()=>e.clone({...e._zod.def,catchall:Obe()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fhe(e,t),e.safeExtend=t=>Ihe(e,t),e.merge=t=>Lhe(e,t),e.pick=t=>Nhe(e,t),e.omit=t=>Phe(e,t),e.partial=(...t)=>Rhe(uR,e,t[0]),e.required=(...t)=>zhe(pR,e,t[0])});function QL(e,t){return new ZL({type:`object`,shape:e??{},...iI(t)})}function $L(e,t){return new ZL({type:`object`,shape:e,catchall:YL(),...iI(t)})}const eR=IF(`ZodUnion`,(e,t)=>{KI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jL(e,t,n,r),e.options=t.options});function tR(e,t){return new eR({type:`union`,options:e,...iI(t)})}IF(`ZodXor`,(e,t)=>{eR.init(e,t),j_e.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jL(e,t,n,r),e.options=t.options});const Abe=IF(`ZodDiscriminatedUnion`,(e,t)=>{eR.init(e,t),M_e.init(e,t)});function nR(e,t,n){return new Abe({type:`union`,options:t,discriminator:e,...iI(n)})}const jbe=IF(`ZodIntersection`,(e,t)=>{N_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dye(e,t,n,r)});function rR(e,t){return new jbe({type:`intersection`,left:e,right:t})}const Mbe=IF(`ZodTuple`,(e,t)=>{XI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oye(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function iR(e,t,n){let r=t instanceof FI;return new Mbe({type:`tuple`,items:e,rest:r?t:null,...iI(r?n:t)})}const Nbe=IF(`ZodRecord`,(e,t)=>{P_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kye(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function aR(e,t,n){return new Nbe({type:`record`,keyType:e,valueType:t,...iI(n)})}IF(`ZodMap`,(e,t)=>{F_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cye(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(yL(...t)),e.nonempty=t=>e.check(yL(1,t)),e.max=(...t)=>e.check(vL(...t)),e.size=(...t)=>e.check(bL(...t))}),IF(`ZodSet`,(e,t)=>{I_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wye(e,t,n,r),e.min=(...t)=>e.check(yL(...t)),e.nonempty=t=>e.check(yL(1,t)),e.max=(...t)=>e.check(vL(...t)),e.size=(...t)=>e.check(bL(...t))});const oR=IF(`ZodEnum`,(e,t)=>{L_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mye(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oR({...t,checks:[],...iI(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oR({...t,checks:[],...iI(r),entries:i})}});function sR(e,t){return new oR({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...iI(t)})}const Pbe=IF(`ZodLiteral`,(e,t)=>{R_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hye(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function cR(e,t){return new Pbe({type:`literal`,values:Array.isArray(e)?e:[e],...iI(t)})}IF(`ZodFile`,(e,t)=>{z_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vye(e,t,n,r),e.min=(t,n)=>e.check(yL(t,n)),e.max=(t,n)=>e.check(vL(t,n)),e.mime=(t,n)=>e.check(Gve(Array.isArray(t)?t:[t],n))});const Fbe=IF(`ZodTransform`,(e,t)=>{B_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sye(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new RF(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(dI(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(dI(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function lR(e){return new Fbe({type:`transform`,transform:e})}const uR=IF(`ZodOptional`,(e,t)=>{tL.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ML(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dR(e){return new uR({type:`optional`,innerType:e})}const Ibe=IF(`ZodExactOptional`,(e,t)=>{V_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ML(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lbe(e){return new Ibe({type:`optional`,innerType:e})}const Rbe=IF(`ZodNullable`,(e,t)=>{H_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fR(e){return new Rbe({type:`nullable`,innerType:e})}const zbe=IF(`ZodDefault`,(e,t)=>{U_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Bbe(e,t){return new zbe({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():eI(t)}})}const Vbe=IF(`ZodPrefault`,(e,t)=>{W_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hbe(e,t){return new Vbe({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():eI(t)}})}const pR=IF(`ZodNonOptional`,(e,t)=>{G_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ube(e,t){return new pR({type:`nonoptional`,innerType:e,...iI(t)})}IF(`ZodSuccess`,(e,t)=>{K_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Wbe=IF(`ZodCatch`,(e,t)=>{q_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gbe(e,t){return new Wbe({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}IF(`ZodNaN`,(e,t)=>{J_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gye(e,t,n,r)});const mR=IF(`ZodPipe`,(e,t)=>{Y_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fye(e,t,n,r),e.in=t.in,e.out=t.out});function hR(e,t){return new mR({type:`pipe`,in:e,out:t})}IF(`ZodCodec`,(e,t)=>{mR.init(e,t),X_e.init(e,t)});const Kbe=IF(`ZodReadonly`,(e,t)=>{Z_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Iye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qbe(e){return new Kbe({type:`readonly`,innerType:e})}IF(`ZodTemplateLiteral`,(e,t)=>{Q_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_ye(e,t,n,r)}),IF(`ZodLazy`,(e,t)=>{tve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rye(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),IF(`ZodPromise`,(e,t)=>{eve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),IF(`ZodFunction`,(e,t)=>{$_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xye(e,t,n,r)});const gR=IF(`ZodCustom`,(e,t)=>{nve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bye(e,t,n,r)});function Jbe(e,t){return Qve(gR,e??(()=>!0),t)}function Ybe(e,t={}){return $ve(gR,e,t)}function Xbe(e){return eye(e)}function _R(e,t){return hR(lR(e),t)}const Zbe={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var Qbe;(function(e){})(Qbe||={});function vR(e){return ove(RL,e)}function yR(e){return Mve(UL,e)}const bR={USER_MESSAGE:`user_message`,REJECTED:`rejected`,INTERRUPTED:`interrupted`},$be={REJECTED:`rejected`};function xR(e){if(e===`Tool was rejected by user`)return{rejected:!0};try{let t=JSON.parse(e);if(t.reason===bR.USER_MESSAGE)return{rejected:!0,userNote:t.message};if(t.reason===bR.REJECTED||t.reason===bR.INTERRUPTED)return{rejected:!0};if(t.status===$be.REJECTED)return{rejected:!0,userNote:t.userNote}}catch{}return{rejected:!1}}const SR=`sibling_tool_failed`,CR=JSON.stringify({type:SR,message:`Not executed: a tool call in a preceding parallel batch failed`});function exe(e){try{return JSON.parse(e)?.type===SR}catch{return!1}}var wR=class{concurrency(e,t){return!1}includeInApiDefinitions=!0;isEnabled(e){return!0}async prepare(e,t){return null}needsPermission(e,t,n){return!this.isReadonly}format(e,t){return typeof e==`string`?e:JSON.stringify(e)}formatForLLM(e,t){return this.format(e,t)}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:this.name,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=`success`;return t.status===`error`?n=`error`:t.status===`skipped`&&(n=`skipped`),{phase:n,toolType:t.type??this.name,data:t,summary:t.message??t.summary??`Completed`,...t.errorMessage!==void 0&&{errorMessage:t.errorMessage}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:this.name,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:this.name,data:{},summary:`Completed`}}validateParams(e){return this.parameters.parse(e)}getToolDefinition(){let e=this.getParameterNames();return{name:this.name,description:this.description,arguments:e}}getParameterNames(){return Object.keys(this.parameters.shape)}};const txe=Symbol.for(`server-executed`);var TR=class extends wR{isReadonly=!0;async execute(e,t,n){return txe}format(e,t){return JSON.stringify({type:this.name,status:`server-executed`})}};dt([`codellm`,`agent`,`tools`,`subagent`]);var ER=class e extends TR{name=`subagent`;displayName=`Subagent`;description=`Switch to a different subagent for a task`;static parametersSchema=QL({agent:Y().describe(`The name of the subagent to switch to`),task:Y().describe(`The task description for the subagent`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return JSON.stringify({type:`subagent`,status:`success`,agent:t.agent,task:t.task})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`subagent`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`subagent`,data:t,summary:`Delegated to ${t.agent??`explore`} agent`}}catch{}return{phase:`success`,toolType:`subagent`,data:{},summary:`Delegated`}}};dt([`codellm`,`agent`,`tools`,`todo-write`]);var DR=class e extends TR{name=`todo_write`;displayName=`TodoWrite`;description=`Create and manage a structured task list`;static parametersSchema=QL({todos:_R(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:[]},XL(QL({content:Y().describe(`The task content`),status:sR([`pending`,`in_progress`,`completed`,`cancelled`]).describe(`The status of the task`),id:Y().optional().describe(`Optional task ID`)}))).describe(`Array of todo items`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return`Updated`}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`todo_write`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.todos){let e=t.todos;return{phase:`success`,toolType:`todo_write`,data:t,summary:`${e.filter(e=>e.status===`pending`).length} pending, ${e.filter(e=>e.status===`in_progress`).length} in progress, ${e.filter(e=>e.status===`completed`).length} completed`}}}catch{}return{phase:`success`,toolType:`todo_write`,data:{},summary:`Updated`}}};function OR(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function kR(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 nxe=_R(OR,WL()),AR=_R(OR,WL().optional()),jR=_R(kR,KL()),MR=_R(kR,KL().optional()),rxe=dt([`codellm`,`agent`,`tools`,`ask-user`]);var NR=class e extends wR{isReadonly=!0;name=`ask_user_question`;displayName=`AskUserQuestion`;description=`Ask the user questions during execution to gather preferences, clarify instructions, or get decisions on implementation choices`;static parametersSchema=QL({questions:XL(QL({question:Y().describe(`The question to ask the user`),header:Y().describe(`A header/title for the question`),options:XL(QL({label:Y().describe(`The option label`),description:Y().describe(`A description of the option`)})).describe(`Array of options for the user to select from`),multiSelect:jR.describe(`Whether the user can select multiple options`)})).describe(`Array of questions to ask the user`),answers:aR(Y(),Y()).optional().describe(`User-provided answers to the questions`)});parameters=e.parametersSchema;needsPermission(){return!0}async execute(e){return rxe.debug`Asking user ${e.questions.length} question(s)`,{answers:e.answers||{}}}format(e,t){return JSON.stringify({type:`ask_user_question`,status:`success`,answers:e.answers})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`ask_user_question`,data:{},summary:`Cancelled`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.answers,r=n?Object.keys(n).length:0;return{phase:`success`,toolType:`ask_user_question`,data:t,summary:`Answered ${r} question${r===1?``:`s`}`}}catch{}return{phase:`success`,toolType:`ask_user_question`,data:{},summary:`Answered`}}};const ixe=dt([`codellm`,`agent`,`tools`,`plan-mode`]);var PR=class e extends wR{name=`enter_plan_mode`;displayName=`EnterPlanMode`;description=`Enter plan mode to create a plan before implementing changes`;static parametersSchema=QL({});parameters=e.parametersSchema;isReadonly=!0;needsPermission(e,t,n){return!1}async execute(e,t){return ixe.info`Entering plan mode`,{success:!0}}format(e,t){return`Entered plan mode`}parse(e){let t=xR(e);return t.rejected?{phase:`rejected`,toolType:`enter_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}}:{phase:`success`,toolType:`enter_plan_mode`,data:{},summary:`Entered plan mode`}}};const axe=dt([`codellm`,`agent`,`tools`,`plan-mode`]);var FR=class e extends wR{name=`exit_plan_mode`;displayName=`ExitPlanMode`;description=`Exit plan mode and return to normal agent operation`;static parametersSchema=QL({planFilePath:Y().describe(`Path to the plan file`)});parameters=e.parametersSchema;isReadonly=!0;async prepare(e,t){if(!e.planFilePath)return{error:`Plan not found`,skipPermission:!0};try{let n=await t.workspace.readRawFile(e.planFilePath);return n?{planContent:n}:{error:`Plan not found`,skipPermission:!0}}catch{return{error:`Plan not found`,skipPermission:!0}}}needsPermission(e,t,n){return!n?.skipPermission}async execute(e,t,n){if(n?.error)throw Error(n.error);return axe.info`Exiting plan mode with plan: ${e.planFilePath}`,{planFilePath:e.planFilePath}}format(e,t){return JSON.stringify({type:`exit_plan_mode`,status:`success`,...e.planFilePath&&{planFilePath:e.planFilePath}})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`exit_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{return{phase:`success`,toolType:`exit_plan_mode`,data:JSON.parse(e),summary:`Plan approved`}}catch{}return e.includes(`implement the plan`),{phase:`success`,toolType:`exit_plan_mode`,data:{},summary:`Plan approved`}}},IR;(function(e){e.GeneralPurpose=`GENERAL_PURPOSE`,e.Explore=`EXPLORE`,e.Plan=`PLAN`})(IR||={});const oxe={[IR.GeneralPurpose]:{name:IR.GeneralPurpose,displayName:`Agent`,description:`General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks`,allowedTools:[`*`],defaultModel:`CLAUDE_V4_5_SONNET`},[IR.Explore]:{name:IR.Explore,displayName:`Explore`,description:`Fast agent specialized for exploring codebases. Use for finding files by patterns, searching code for keywords, or answering questions about the codebase.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`},[IR.Plan]:{name:IR.Plan,displayName:`Plan`,description:`Fast agent for creating implementation plans. Explores codebase to understand architecture before planning.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`}},sxe=new Set(Object.values(IR));function cxe(e){return sxe.has(e)}function LR(e){if(cxe(e))return e}function RR(e){return oxe[e]}function zR(){return Object.values(IR)}function BR(e){let t=LR(e);return t?RR(t).displayName:e}function lxe(e,t){let n=LR(e);if(!n)return!1;let r=RR(n);return r.allowedTools.includes(`*`)?!0:r.allowedTools.includes(t)}async function VR(e){return new Promise(t=>setTimeout(t,e))}const HR=dt([`codellm`,`agent`,`loop`]);function UR(e){if(!e)return null;if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e;if(t.text)return t.text;if(t.segment)return UR(t.segment)}return null}function uxe(e){return Math.min((e+1)*2e3,1e4)}function WR(e){return 2**(e+1)*1e3}function*dxe(e,t,n){if(e.error){let t=e.error,r=typeof t==`string`?t:JSON.stringify(t);r.includes(`Credit limit`)||r.includes(`no_usage_points`)||r.includes(`compute_point_budgeting`)||r.includes(`limit_exceeded`)||r.includes(`exhausted`)||r.includes(`purchase more credits`)?yield{__error:new wd({...n.pendingCreditLimitSegment??void 0,message:r})}:Bl(r)?yield{__error:new Ll}:yield{__error:new Cd(r)};return}if(e.type===`no_usage_points`||e.type===`compute_point_budgeting`||e.type===`limit_exceeded`){n.pendingCreditLimitSegment=e;return}if(e.type===`code_llm_credits`){yield{type:`credits`,creditsUsed:e.creditsUsed};return}if(e.type===`collapsible_component`&&e.isThoughts===!0){let t=e.title||`Thinking`,n=UR(e.segment)??``;n&&(yield{type:`thinking_delta`,content:n,title:t}),e.isSpinny===!1&&(yield{type:`thinking_complete`});return}if(e.type===`code_llm_notification`){let t=e.message||UR(e.segment)||`Notification`;yield{...e,type:`notification`,message:t,severity:e.severity??`info`};return}if(e.type===`code_llm_agent_tool_call_start`){yield{type:`tool_call_start`,toolCallId:e.toolCallId,toolName:e.toolName};return}if(e.type===`code_llm_agent_tool_call_delta`){yield{type:`tool_call_delta`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta};return}if(e.type===`code_llm_agent_tool_call_stop`){yield{type:`tool_call_stop`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments};let n=e.toolUseRequest;if(n){let e=n;if(e.name===`edit`){let t=e.input;(`startLineOneIndexed`in t||`endLineOneIndexed`in t)&&(e={...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}})}t.push(e),yield{type:`tool_requested`,tool:e}}return}if(e.toolUseRequest){let n=(Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest]).map(e=>{if(e.name===`edit`){let t=e.input;if(`startLineOneIndexed`in t||`endLineOneIndexed`in t)return{...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}}}return e}),r=new Set(t.map(e=>e.id)),i=n.filter(e=>!r.has(e.id));t.push(...i);for(let e of i)yield{type:`tool_requested`,tool:e};return}if(e.segment){let t=UR(e.segment);t&&(yield{type:`text_delta`,content:t})}}async function*fxe(e,t){let n=t?.generateRequestId?.()??crypto.randomUUID(),r=!1;HR.debug(`Starting agent loop (conversationId={conversationId}, model={model})`,{conversationId:e.conversationId,model:e.model});for(let t=0;t<8;t++){Al(`turn started`,`agent`);let i=n,a=!1;if(t>0){HR.debug(`Retry attempt {attempt}: checking for pending request ID`,{attempt:t});try{let t=await e.apiClient.getPendingRequestIdForConversation(e.conversationId);t?.success&&t.result?.requestId&&(i=t.result.requestId,a=!0)}catch{}}let o=[],s={pendingCreditLimitSegment:null},c=!1;try{let t=e.apiClient.streamAgentMessage({deploymentConversationId:e.conversationId,message:e.message,supportedTools:e.supportedTools,supportedSubAgents:e.supportedSubAgents,mcpTools:e.isPrintMode?[]:e.mcpTools??[],workspacePath:e.workspacePath,...e.swapFolder&&{swapFolder:e.swapFolder},llmName:e.model,requestId:i,docInfos:e.uploadedDocs?Array.from(e.uploadedDocs):[],toolUseResult:e.toolResult,supportsV2:!0,supportsThoughtStreaming:e.supportsThoughtStreaming??!0,supportsParallelToolUse:!0,isPrintMode:e.isPrintMode??!1,...e.subagent&&{subagent:e.subagent},agentMode:e.agentMode,currentFile:e.currentFile,selectionStartLine:e.selectionStartLine,selectionEndLine:e.selectionEndLine,gitBranch:e.gitBranch,gitMain:e.gitMain,gitStatus:e.gitStatus,gitCommits:e.gitCommits,diagnosticIssues:e.diagnosticIssues,availableSkills:e.availableSkills,activeSkills:e.activeSkills,client:e.client,setFolder:e.setFolder,reconnect:a,signal:e.signal});for await(let n of t){if(e.signal?.aborted)break;for(let e of dxe(n,o,s)){if(`__error`in e)throw e.__error;yield e}c=!0}if(e.signal?.aborted){e.apiClient.stopResponseSSE(i).catch(()=>{}),yield{type:`turn_complete_with_tools`,toolCalls:o};return}r&&=(yield{type:`network_status`,online:!0},!1),yield{type:`turn_complete_with_tools`,toolCalls:o},HR.debug(`Agent loop completed with {count} tool calls`,{count:o.length});return}catch(n){let i=n instanceof Error?n:Error(String(n));if(i instanceof Ll){if(c&&t<4&&!e.signal?.aborted){let e=WR(t);HR.warn(`Auth error mid-stream (attempt={attempt}, delay={delayMs}ms) — retrying (server may have re-validated against a stale replica)`,{attempt:t+1,delayMs:e}),Ol(`Mid-stream auth error, retrying`,`warning`,{context:`agent-loop`,attempt:t+1}),yield{type:`retry`,attempt:t+1,maxAttempts:5,delayMs:e,isNetworkError:!1},await VR(e);continue}throw HR.warn(`Auth expired, aborting loop`),i}if(i instanceof wd)throw HR.warn(`Credit limit reached, aborting loop`),Ol(`Credit limit reached`,`warning`,{context:`agent-loop`}),i;let a=Vl(i),o=a?8:5;if(t<o-1&&!e.signal?.aborted){let e=a?uxe(t):WR(t);HR.warn(`Retrying after error (attempt={attempt}, network={isNetErr}, delay={delayMs}ms): {error}`,{attempt:t+1,isNetErr:a,delayMs:e,error:i.message}),a&&!r&&(r=!0,yield{type:`network_status`,online:!1}),yield{type:`retry`,attempt:t+1,maxAttempts:o,delayMs:e,isNetworkError:a},await VR(e);continue}throw HR.error(`All retry attempts exhausted: {error}`,{error:i.message}),Dl(i,{context:`agent-loop-retry-exhausted`}),Vl(i)?i instanceof Rl?i:new Rl(i.message,i):i}}}const GR=dt([`codellm`,`agent`,`runner`]);var pxe=class{queue=[];resolvers=[];closed=!1;push(e){this.closed||(this.resolvers.length>0?this.resolvers.shift()(e):this.queue.push(e))}async next(){return this.queue.length>0?this.queue.shift():this.closed?null:new Promise(e=>{this.resolvers.push(e)})}close(){this.closed=!0;for(let e of this.resolvers)e(null);this.resolvers=[]}drain(){let e=[...this.queue];return this.queue=[],e}};function mxe(e){return e.toUpperCase().includes(`CLAUDE`)}async function*KR(e,t,n){let r=e.maxTurns??2**53-1,i=t,a,o=0,s=0,c=[],l=e.agentMode;GR.info(`Starting agent conversation (model={model}, maxTurns={maxTurns})`,{model:e.model,maxTurns:r});try{for(;o<r;){if(n?.aborted)return GR.info(`Conversation aborted after {numTurns} turns`,{numTurns:o}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:Error(`Execution cancelled`)};o++;let t={...e,swapFolder:a===void 0?e.swapFolder:void 0,setFolder:a===void 0?e.setFolder:void 0,agentMode:l,message:i,...a!==void 0&&{toolResult:a},...n!==void 0&&{signal:n}},r=[],u=new Map,d=new Map,f=new Map,p=[],m=new pxe,h=new AbortController,g=()=>h.abort(`interrupted`);n&&(n.aborted?h.abort(`interrupted`):n.addEventListener(`abort`,g,{once:!0}));let _=async(t,n,r)=>(await e.executeTools([t],n,r))[0],v=e.getConcurrency??(()=>!1),y=e=>{let t=_(e,h.signal,e=>m.push(e)).then(t=>{d.set(e.id,t);for(let[t,n]of f)if(n===e.id){f.delete(t);break}return t}).catch(e=>{throw h.abort(`sibling_tool_failed`),e});u.set(e.id,t)},b=e=>{let t=v(e);typeof t==`string`&&f.has(t)?p.push(e):(typeof t==`string`&&f.set(t,e.id),y(e))},x=!1;for await(let e of fxe(t)){for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(e.type===`turn_complete_with_tools`){r=e.toolCalls,x=!0;continue}if(e.type===`text_delta`&&c.push(e.content),e.type===`tool_requested`){yield e,b(e.tool);continue}yield e}for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(x||GR.warn(`Agent loop exited without turn_complete_with_tools (collected {count} tool calls)`,{count:r.length}),r.length===0){GR.debug(`Turn {numTurns} complete with no tool calls`,{numTurns:o}),n?.removeEventListener(`abort`,g),yield{type:`turn_complete`};break}for(let e of p){let t=v(e);if(typeof t==`string`&&f.has(t)){let e=f.get(t),n=u.get(e);if(n)try{await n}catch{}}h.signal.aborted||b(e)}let S=r.filter(e=>!u.has(e.id));if(S.length>0)if(u.size===0){let t,n=e.executeTools(r,h.signal,e=>m.push(e)).then(e=>{t=e;for(let t=0;t<e.length;t++){let n=r[t];n&&d.set(n.id,e[t])}return m.close(),e}),i=new Set;for(;t===void 0;){let e=await Promise.race([m.next(),n.then(()=>null)]);if(e!==null)e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;else if(t!==void 0)break}t||=await n;for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;for(let e=0;e<t.length;e++){let n=r[e],a=t[e];n&&a&&!i.has(n.id)&&(yield{type:`tool_execution_complete`,tool:n,result:a})}}else for(let e of S)h.signal.aborted||y(e);if(u.size>0){let e=Promise.allSettled(u.values()).then(()=>{m.close()}),t=new Set,n=await m.next();for(;n!==null;)n.type===`mode_changed`&&(l=n.mode),n.type===`tool_execution_complete`&&t.add(n.tool.id),yield n,n=await m.next();await e;for(let e of r){let n=d.get(e.id);n&&!t.has(e.id)&&(yield{type:`tool_execution_complete`,tool:e,result:n})}}s+=r.length;let C=r.map(e=>d.get(e.id)??{id:e.id,content:`Error: tool execution did not complete`});n?.removeEventListener(`abort`,g);for(let t of e.drainEvents?.()??[])t.type===`mode_changed`&&(l=t.mode),yield t;let w=new Set([`task`]),T=(e,t)=>!(!e.rejected||w.has(r[t]?.name??``)),E=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===bR.REJECTED}catch{return!1}}),D=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===bR.INTERRUPTED}catch{return!1}}),O=C.some(e=>{if(!e.rejected)return!1;try{return JSON.parse(e.content).reason===bR.USER_MESSAGE}catch{return!1}});if((E||D)&&!O){yield{type:`turn_complete`};break}let k=C.map(({parsedResult:e,...t})=>t);a=k.length===1?k[0]:k;let A=r.some(e=>e.name===`exit_plan_mode`)&&C.some(e=>{if(e.rejected)return!1;try{return JSON.parse(e.content).type===`exit_plan_mode`}catch{return!1}}),j=`I want you to start implementing the plan now as you have outlined in your plan.`;if(mxe(e.model)){let t=e.dequeueAllQueuedMessage?.({includeHidden:!0});t?(i=A?`${j} ${t.message}`:t.message,t.allHidden||(yield{type:`user_message_dequeued`,content:t.message})):i=A?j:``}else i=A?j:``;yield{type:`turn_complete`}}if(o>=r){GR.warn(`Maximum turns ({maxTurns}) exceeded`,{maxTurns:r});let e=Error(`Maximum turns (${r}) exceeded`);return yield{type:`error`,error:e},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:e}}return GR.info(`Conversation completed (turns={numTurns}, toolCalls={toolCallsExecuted})`,{numTurns:o,toolCallsExecuted:s}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!0}}catch(e){let t=e instanceof Error?e:Error(String(e));return Dl(t,{context:`agent-runner`}),GR.error(`Conversation failed after {numTurns} turns: {error}`,{numTurns:o,toolCallsExecuted:s,error:t}),yield{type:`error`,error:t},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:t}}}const qR=dt([`codellm`,`agent`,`subagent`]);function hxe(e,t){let n=RR(t);return!n||n.allowedTools.includes(`*`)?e:e.filter(e=>lxe(t,e.name))}function gxe(e,t,n,r,i){let a=n.get(e.name)?.displayName??e.name;if(!n.isBuiltinRequest(e))return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)};switch(e.name){case`read`:{let n=t._prepareResult;if(n?.resolvedPath){let t=cF(n.resolvedPath);return{type:`read_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}case`edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.filePath??``);return{type:`edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}return{type:`edit_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,newContent:n?.newContent??``}}case`write`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.filePath??``);return{type:`write_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t),isNewFile:!n?.fileExists}}return{type:`write_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,content:e.input.content??``,isNewFile:!n?.fileExists}}case`bash`:return{type:`run_terminal`,tool:e,displayName:a,command:e.input.command??``,cwd:r,background:!!(e.input.runInBackground??!1),unmatchedPatterns:i?.getUnmatchedBashSegments(e.input.command??``,r)??[]};case`notebook_edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.notebookPath??``);return{type:`notebook_edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}let r=n?.notebook,i=e.input.cellId,o=``;if(i&&r?.cells){let e=r.cells.find(e=>e.id===i||e.metadata?.id===i);e&&(o=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}return{type:`notebook_edit`,tool:e,displayName:a,notebookPath:e.input.notebookPath??``,cellId:i,editMode:e.input.editMode??`replace`,cellType:e.input.cellType,originalContent:o,newContent:e.input.newSource??``}}case`ask_user_question`:return{type:`ask_user_question`,tool:e,displayName:a,questions:Array.isArray(e.input.questions)?e.input.questions:[]};case`exit_plan_mode`:{let n=t._prepareResult;return{type:`exit_plan_mode`,tool:e,displayName:a,planFilePath:e.input.planFilePath??``,planContent:n?.planContent??``}}default:return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}}async function _xe(e){let{prompt:t,subagentType:n,model:r,resume:i,parentContext:a,onProgress:o,signal:s}=e;qR.info(`Starting subagent (type={subagentType}, model={model})`,{subagentType:n,model:r??`default`});let c=RR(n);if(!c)return qR.error(`Unknown subagent type: {subagentType}`,{subagentType:n}),{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Unknown subagent type: ${n}`};let l=NV(),u=hxe(l.getApiToolDefinitions(),n),d=r??c.defaultModel??`CLAUDE_V4_5_SONNET`,f;if(i&&c.supportsResume)f=i;else try{let e=await a.apiClient.createCodellmDeploymentConversation(`CODE_LLM_NON_INTERACTIVE`,a.clientType);if(!e?.result?.deploymentConversationId)return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: no conversation ID returned`};f=e.result.deploymentConversationId}catch(e){return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: ${e instanceof Error?e.message:String(e)}`}}let p=[],m=[],h=[],g=a.permissionProvider&&a.rulesEngine&&a.getAgentMode,_=()=>a.getAgentMode?.()??xd.Yolo,v=c?.name,y={apiClient:a.apiClient,conversationId:f,model:d,workspacePath:a.workspacePath,supportedTools:u,mcpTools:[],uploadedDocs:a.uploadedDocs,isPrintMode:!g,...v&&{subagent:v},supportsThoughtStreaming:!0,agentMode:_(),executeTools:async(e,t,n)=>{let r=[];for(let i of e){if(t?.aborted||s?.aborted)break;m.push(i.name);let e={name:i.name,input:i.input??{}};o?.({type:`tool_requested`,content:`${i.name}`,toolName:i.name,toolInput:e.input,toolId:i.id}),n?.({type:`tool_execution_start`,tool:i});let c=_(),u={...a,toolCallId:i.id,conversationId:f,agentMode:c,status:`executing`};try{let d=l.createToolInstance(i.name,i.input??{},u);await d.prepare();let f=c===xd.Yolo&&i.name!==`ask_user_question`;if(g&&!f&&d.needsPermission()){let c=l.get(i.name)?.displayName??i.name,f=VV(i),p=a.rulesEngine.evaluate(c,f);if(p===`deny`){r.push({id:i.id,content:JSON.stringify({reason:bR.REJECTED}),rejected:!0}),e.result=`denied by rule`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(p!==`allow`){let c=gxe(i,d,l,a.workspacePath,a.rulesEngine);if(a.permissionProvider.needsPermission(c)){n?.({type:`status_changed`,status:Sd.WaitingForToolPermission}),a.emitEvent?.({type:`status_changed`,status:Sd.WaitingForToolPermission});let l;try{let e=a.permissionProvider.requestPermission(c),n=t||s;if(n){let t,r=new Promise((e,r)=>{n.aborted?r(Error(`interrupted`)):(t=()=>r(Error(`interrupted`)),n.addEventListener(`abort`,t,{once:!0}))});try{l=await Promise.race([e,r])}finally{t&&n.removeEventListener(`abort`,t)}}else l=await e}catch{r.push({id:i.id,content:JSON.stringify({reason:bR.INTERRUPTED}),rejected:!0}),e.result=`interrupted`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(n?.({type:`status_changed`,status:Sd.ExecutingTool}),a.emitEvent?.({type:`status_changed`,status:Sd.ExecutingTool}),l===`reject`){r.push({id:i.id,content:JSON.stringify({reason:bR.REJECTED}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`reject_with_message`){r.push({id:i.id,content:JSON.stringify({reason:bR.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(l===`allowAlways`||l===`allowYolo`||l===`accept`){if(l===`allowAlways`&&(c.type===`read_outside_directory`||c.type===`write_outside_directory`||c.type===`edit_outside_directory`||c.type===`notebook_edit_outside_directory`)&&`deducedDirectory`in c){let e=a.allowEditingPaths??[],t=c.deducedDirectory;e.includes(t)||e.push(t)}else if(i.name===`exit_plan_mode`){let e=l===`allowYolo`?xd.Yolo:l===`allowAlways`?xd.AcceptEdits:xd.Normal;a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}else if(l===`allowAlways`){let e=Dd(c.type);a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}}if(typeof l==`object`&&l.type===`accept_with_message`){r.push({id:i.id,content:JSON.stringify({reason:bR.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`accepted with message`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`question_answers`&&d.mergeParams({answers:l.answers}),typeof l==`object`&&l.type===`allow_always_with_rule`&&a.rulesEngine.addAllowRule(l.rule),typeof l==`object`&&l.type===`allow_always_with_rules`)for(let e of l.rules)a.rulesEngine.addAllowRule(e)}}}i.name===`enter_plan_mode`&&(a.setAgentMode?.(xd.PlanMode),u.agentMode=xd.PlanMode,n?.({type:`mode_changed`,mode:xd.PlanMode})),i.name===`exit_plan_mode`&&f&&(a.setAgentMode?.(xd.Normal),u.agentMode=xd.Normal,n?.({type:`mode_changed`,mode:xd.Normal})),await d.execute();let p=d.formatResultForLLM(),m=d.formatResult(),_=typeof p==`string`?p:JSON.stringify(p),v=l.parse(i.name,m);r.push({id:i.id,content:_,parsedResult:v}),e.result=_}catch(t){let n=t instanceof Error?t.message:String(t);r.push({id:i.id,content:`Error: ${n}`}),e.result=`Error: ${n}`}h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id})}for(let t of e)r.some(e=>e.id===t.id)||r.push({id:t.id,content:JSON.stringify({reason:bR.INTERRUPTED}),rejected:!0});return r}};try{o?.({type:`status`,content:`Starting ${n} agent...`});let e=KR(y,t,s),r=await e.next();for(;!r.done;){let t=r.value;switch(t.type){case`text_delta`:p.push(t.content),o?.({type:`text`,content:t.content});break;case`thinking_delta`:o?.({type:`thinking`,content:t.content});break;case`tool_requested`:case`turn_complete`:break;case`tool_execution_complete`:p.length=0;break;case`error`:return{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t.error?.message??`Unknown error`};case`credits`:a.emitEvent?.(t);break;case`mode_changed`:a.emitEvent?.(t);break;case`status_changed`:case`notification`:break}r=await e.next()}let i=r.value;return qR.info(`Subagent completed (type={subagentType}, turns={numTurns}, tools={toolCount})`,{subagentType:n,numTurns:i.numTurns,toolCount:m.length}),{success:i.success,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:i.numTurns,...i.error&&{error:i.error.message}}}catch(e){let t=e instanceof Error?e.message:String(e);return Dl(e instanceof Error?e:Error(t),{context:`subagent-runner`}),qR.error(`Subagent failed (type={subagentType}): {error}`,{subagentType:n,error:t}),{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t}}}const JR=dt([`codellm`,`agent`,`tools`,`task`]);var YR=class e extends wR{name=`task`;displayName=`Task`;description=`Launch a new agent to handle complex, multi-step tasks autonomously.
1871
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function OL(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:AL(t,`input`,e.processors),output:AL(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function kL(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return kL(r.element,n);if(r.type===`set`)return kL(r.valueType,n);if(r.type===`lazy`)return kL(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return kL(r.innerType,n);if(r.type===`intersection`)return kL(r.left,n)||kL(r.right,n);if(r.type===`record`||r.type===`map`)return kL(r.keyType,n)||kL(r.valueType,n);if(r.type===`pipe`)return kL(r.in,n)||kL(r.out,n);if(r.type===`object`){for(let e in r.shape)if(kL(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(kL(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(kL(e,n))return!0;return!!(r.rest&&kL(r.rest,n))}return!1}const nye=(e,t={})=>n=>{let r=TL({...n,processors:t});return EL(e,r),DL(r,e),OL(r,e)},AL=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=TL({...i??{},target:a,io:t,processors:n});return EL(e,o),DL(o,e),OL(o,e)},rye={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},iye=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=rye[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},aye=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},oye=(e,t,n,r)=>{n.type=`boolean`},sye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},cye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},lye=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},uye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},dye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},fye=(e,t,n,r)=>{n.not={}},pye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},mye=(e,t,n,r)=>{let i=e._zod.def,a=VF(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},hye=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},gye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},_ye=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},vye=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},yye=(e,t,n,r)=>{n.type=`boolean`},bye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},xye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Sye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Cye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},wye=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Tye=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=EL(a.element,t,{...r,path:[...r.path,`items`]})},Eye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=EL(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=EL(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},jL=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>EL(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Dye=(e,t,n,r)=>{let i=e._zod.def,a=EL(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=EL(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Oye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>EL(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?EL(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},kye=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=EL(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=EL(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=EL(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Aye=(e,t,n,r)=>{let i=e._zod.def,a=EL(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},jye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Nye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Pye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Fye=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;EL(a,t,r);let o=t.seen.get(e);o.ref=a},Iye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Lye=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ML=(e,t,n,r)=>{let i=e._zod.def;EL(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Rye=(e,t,n,r)=>{let i=e._zod.innerType;EL(i,t,r);let a=t.seen.get(e);a.ref=i},zye=IF(`ZodISODateTime`,(e,t)=>{t_e.init(e,t),zL.init(e,t)});function NL(e){return Dve(zye,e)}const Bye=IF(`ZodISODate`,(e,t)=>{n_e.init(e,t),zL.init(e,t)});function Vye(e){return Ove(Bye,e)}const Hye=IF(`ZodISOTime`,(e,t)=>{r_e.init(e,t),zL.init(e,t)});function Uye(e){return kve(Hye,e)}const Wye=IF(`ZodISODuration`,(e,t)=>{i_e.init(e,t),zL.init(e,t)});function Gye(e){return Ave(Wye,e)}const PL=(e,t)=>{pI.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Vhe(e,t)},flatten:{value:t=>Bhe(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,HF,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,HF,2)}},isEmpty:{get(){return e.issues.length===0}}})};IF(`ZodError`,PL);const FL=IF(`ZodError`,PL,{Parent:Error}),Kye=hI(FL),qye=_I(FL),Jye=yI(FL),Yye=xI(FL),Xye=Uhe(FL),Zye=Whe(FL),Qye=Ghe(FL),$ye=Khe(FL),ebe=qhe(FL),tbe=Jhe(FL),nbe=Yhe(FL),rbe=Xhe(FL),IL=IF(`ZodType`,(e,t)=>(FI.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:AL(e,`input`),output:AL(e,`output`)}}),e.toJSONSchema=nye(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(YF(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>rI(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Kye(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Jye(e,t,n),e.parseAsync=async(t,n)=>qye(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Yye(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xye(e,t,n),e.decode=(t,n)=>Zye(e,t,n),e.encodeAsync=async(t,n)=>Qye(e,t,n),e.decodeAsync=async(t,n)=>$ye(e,t,n),e.safeEncode=(t,n)=>ebe(e,t,n),e.safeDecode=(t,n)=>tbe(e,t,n),e.safeEncodeAsync=async(t,n)=>nbe(e,t,n),e.safeDecodeAsync=async(t,n)=>rbe(e,t,n),e.refine=(t,n)=>e.check(Ybe(t,n)),e.superRefine=t=>e.check(Xbe(t)),e.overwrite=t=>e.check(wL(t)),e.optional=()=>dR(e),e.exactOptional=()=>Lbe(e),e.nullable=()=>fR(e),e.nullish=()=>dR(fR(e)),e.nonoptional=t=>Ube(e,t),e.array=()=>XL(e),e.or=t=>tR([e,t]),e.and=t=>rR(e,t),e.transform=t=>hR(e,lR(t)),e.default=t=>Bbe(e,t),e.prefault=t=>Hbe(e,t),e.catch=t=>Gbe(e,t),e.pipe=t=>hR(e,t),e.readonly=()=>qbe(e),e.describe=t=>{let n=e.clone();return uL.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return uL.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return uL.get(e);let n=e.clone();return uL.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),LL=IF(`_ZodString`,(e,t)=>{II.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iye(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(zve(...t)),e.includes=(...t)=>e.check(Hve(...t)),e.startsWith=(...t)=>e.check(Uve(...t)),e.endsWith=(...t)=>e.check(Wve(...t)),e.min=(...t)=>e.check(SL(...t)),e.max=(...t)=>e.check(xL(...t)),e.length=(...t)=>e.check(CL(...t)),e.nonempty=(...t)=>e.check(SL(1,...t)),e.lowercase=t=>e.check(Bve(t)),e.uppercase=t=>e.check(Vve(t)),e.trim=()=>e.check(qve()),e.normalize=(...t)=>e.check(Kve(...t)),e.toLowerCase=()=>e.check(Jve()),e.toUpperCase=()=>e.check(Yve()),e.slugify=()=>e.check(Xve())}),RL=IF(`ZodString`,(e,t)=>{II.init(e,t),LL.init(e,t),e.email=t=>e.check(sve(ibe,t)),e.url=t=>e.check(fL(HL,t)),e.jwt=t=>e.check(Eve(bbe,t)),e.emoji=t=>e.check(fve(obe,t)),e.guid=t=>e.check(dL(BL,t)),e.uuid=t=>e.check(cve(VL,t)),e.uuidv4=t=>e.check(lve(VL,t)),e.uuidv6=t=>e.check(uve(VL,t)),e.uuidv7=t=>e.check(dve(VL,t)),e.nanoid=t=>e.check(pve(sbe,t)),e.guid=t=>e.check(dL(BL,t)),e.cuid=t=>e.check(mve(cbe,t)),e.cuid2=t=>e.check(hve(lbe,t)),e.ulid=t=>e.check(gve(ube,t)),e.base64=t=>e.check(Cve(_be,t)),e.base64url=t=>e.check(wve(vbe,t)),e.xid=t=>e.check(_ve(dbe,t)),e.ksuid=t=>e.check(vve(fbe,t)),e.ipv4=t=>e.check(yve(pbe,t)),e.ipv6=t=>e.check(bve(mbe,t)),e.cidrv4=t=>e.check(xve(hbe,t)),e.cidrv6=t=>e.check(Sve(gbe,t)),e.e164=t=>e.check(Tve(ybe,t)),e.datetime=t=>e.check(NL(t)),e.date=t=>e.check(Vye(t)),e.time=t=>e.check(Uye(t)),e.duration=t=>e.check(Gye(t))});function Y(e){return ave(RL,e)}const zL=IF(`ZodStringFormat`,(e,t)=>{LI.init(e,t),LL.init(e,t)}),ibe=IF(`ZodEmail`,(e,t)=>{Kge.init(e,t),zL.init(e,t)}),BL=IF(`ZodGUID`,(e,t)=>{Wge.init(e,t),zL.init(e,t)}),VL=IF(`ZodUUID`,(e,t)=>{Gge.init(e,t),zL.init(e,t)}),HL=IF(`ZodURL`,(e,t)=>{qge.init(e,t),zL.init(e,t)});function abe(e){return fL(HL,e)}const obe=IF(`ZodEmoji`,(e,t)=>{Jge.init(e,t),zL.init(e,t)}),sbe=IF(`ZodNanoID`,(e,t)=>{Yge.init(e,t),zL.init(e,t)}),cbe=IF(`ZodCUID`,(e,t)=>{Xge.init(e,t),zL.init(e,t)}),lbe=IF(`ZodCUID2`,(e,t)=>{Zge.init(e,t),zL.init(e,t)}),ube=IF(`ZodULID`,(e,t)=>{Qge.init(e,t),zL.init(e,t)}),dbe=IF(`ZodXID`,(e,t)=>{$ge.init(e,t),zL.init(e,t)}),fbe=IF(`ZodKSUID`,(e,t)=>{e_e.init(e,t),zL.init(e,t)}),pbe=IF(`ZodIPv4`,(e,t)=>{a_e.init(e,t),zL.init(e,t)});IF(`ZodMAC`,(e,t)=>{s_e.init(e,t),zL.init(e,t)});const mbe=IF(`ZodIPv6`,(e,t)=>{o_e.init(e,t),zL.init(e,t)}),hbe=IF(`ZodCIDRv4`,(e,t)=>{c_e.init(e,t),zL.init(e,t)}),gbe=IF(`ZodCIDRv6`,(e,t)=>{l_e.init(e,t),zL.init(e,t)}),_be=IF(`ZodBase64`,(e,t)=>{u_e.init(e,t),zL.init(e,t)}),vbe=IF(`ZodBase64URL`,(e,t)=>{f_e.init(e,t),zL.init(e,t)}),ybe=IF(`ZodE164`,(e,t)=>{p_e.init(e,t),zL.init(e,t)}),bbe=IF(`ZodJWT`,(e,t)=>{h_e.init(e,t),zL.init(e,t)});IF(`ZodCustomStringFormat`,(e,t)=>{g_e.init(e,t),zL.init(e,t)});const UL=IF(`ZodNumber`,(e,t)=>{zI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aye(e,t,n,r),e.gt=(t,n)=>e.check(hL(t,n)),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.lt=(t,n)=>e.check(pL(t,n)),e.lte=(t,n)=>e.check(mL(t,n)),e.max=(t,n)=>e.check(mL(t,n)),e.int=t=>e.check(GL(t)),e.safe=t=>e.check(GL(t)),e.positive=t=>e.check(hL(0,t)),e.nonnegative=t=>e.check(gL(0,t)),e.negative=t=>e.check(pL(0,t)),e.nonpositive=t=>e.check(mL(0,t)),e.multipleOf=(t,n)=>e.check(_L(t,n)),e.step=(t,n)=>e.check(_L(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function WL(e){return jve(UL,e)}const xbe=IF(`ZodNumberFormat`,(e,t)=>{__e.init(e,t),UL.init(e,t)});function GL(e){return Nve(xbe,e)}const Sbe=IF(`ZodBoolean`,(e,t)=>{v_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oye(e,t,n,r)});function KL(e){return Pve(Sbe,e)}const Cbe=IF(`ZodBigInt`,(e,t)=>{BI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sye(e,t,n,r),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.gt=(t,n)=>e.check(hL(t,n)),e.gte=(t,n)=>e.check(gL(t,n)),e.min=(t,n)=>e.check(gL(t,n)),e.lt=(t,n)=>e.check(pL(t,n)),e.lte=(t,n)=>e.check(mL(t,n)),e.max=(t,n)=>e.check(mL(t,n)),e.positive=t=>e.check(hL(BigInt(0),t)),e.negative=t=>e.check(pL(BigInt(0),t)),e.nonpositive=t=>e.check(mL(BigInt(0),t)),e.nonnegative=t=>e.check(gL(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(_L(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});IF(`ZodBigIntFormat`,(e,t)=>{y_e.init(e,t),Cbe.init(e,t)}),IF(`ZodSymbol`,(e,t)=>{b_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cye(e,t,n,r)}),IF(`ZodUndefined`,(e,t)=>{x_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uye(e,t,n,r)});const wbe=IF(`ZodNull`,(e,t)=>{S_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lye(e,t,n,r)});function qL(e){return Fve(wbe,e)}const Tbe=IF(`ZodAny`,(e,t)=>{C_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function JL(){return Ive(Tbe)}const Ebe=IF(`ZodUnknown`,(e,t)=>{w_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function YL(){return Lve(Ebe)}const Dbe=IF(`ZodNever`,(e,t)=>{T_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fye(e,t,n,r)});function Obe(e){return Rve(Dbe,e)}IF(`ZodVoid`,(e,t)=>{E_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dye(e,t,n,r)}),IF(`ZodDate`,(e,t)=>{D_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pye(e,t,n,r),e.min=(t,n)=>e.check(gL(t,n)),e.max=(t,n)=>e.check(mL(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});const kbe=IF(`ZodArray`,(e,t)=>{O_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tye(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(SL(t,n)),e.nonempty=t=>e.check(SL(1,t)),e.max=(t,n)=>e.check(xL(t,n)),e.length=(t,n)=>e.check(CL(t,n)),e.unwrap=()=>e.element});function XL(e,t){return Zve(kbe,e,t)}const ZL=IF(`ZodObject`,(e,t)=>{A_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eye(e,t,n,r),qF(e,`shape`,()=>t.shape),e.keyof=()=>sR(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:YL()}),e.loose=()=>e.clone({...e._zod.def,catchall:YL()}),e.strict=()=>e.clone({...e._zod.def,catchall:Obe()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fhe(e,t),e.safeExtend=t=>Ihe(e,t),e.merge=t=>Lhe(e,t),e.pick=t=>Nhe(e,t),e.omit=t=>Phe(e,t),e.partial=(...t)=>Rhe(uR,e,t[0]),e.required=(...t)=>zhe(pR,e,t[0])});function QL(e,t){return new ZL({type:`object`,shape:e??{},...iI(t)})}function $L(e,t){return new ZL({type:`object`,shape:e,catchall:YL(),...iI(t)})}const eR=IF(`ZodUnion`,(e,t)=>{KI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jL(e,t,n,r),e.options=t.options});function tR(e,t){return new eR({type:`union`,options:e,...iI(t)})}IF(`ZodXor`,(e,t)=>{eR.init(e,t),j_e.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jL(e,t,n,r),e.options=t.options});const Abe=IF(`ZodDiscriminatedUnion`,(e,t)=>{eR.init(e,t),M_e.init(e,t)});function nR(e,t,n){return new Abe({type:`union`,options:t,discriminator:e,...iI(n)})}const jbe=IF(`ZodIntersection`,(e,t)=>{N_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dye(e,t,n,r)});function rR(e,t){return new jbe({type:`intersection`,left:e,right:t})}const Mbe=IF(`ZodTuple`,(e,t)=>{XI.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oye(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function iR(e,t,n){let r=t instanceof FI;return new Mbe({type:`tuple`,items:e,rest:r?t:null,...iI(r?n:t)})}const Nbe=IF(`ZodRecord`,(e,t)=>{P_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kye(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function aR(e,t,n){return new Nbe({type:`record`,keyType:e,valueType:t,...iI(n)})}IF(`ZodMap`,(e,t)=>{F_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cye(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(yL(...t)),e.nonempty=t=>e.check(yL(1,t)),e.max=(...t)=>e.check(vL(...t)),e.size=(...t)=>e.check(bL(...t))}),IF(`ZodSet`,(e,t)=>{I_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wye(e,t,n,r),e.min=(...t)=>e.check(yL(...t)),e.nonempty=t=>e.check(yL(1,t)),e.max=(...t)=>e.check(vL(...t)),e.size=(...t)=>e.check(bL(...t))});const oR=IF(`ZodEnum`,(e,t)=>{L_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mye(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oR({...t,checks:[],...iI(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oR({...t,checks:[],...iI(r),entries:i})}});function sR(e,t){return new oR({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...iI(t)})}const Pbe=IF(`ZodLiteral`,(e,t)=>{R_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hye(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function cR(e,t){return new Pbe({type:`literal`,values:Array.isArray(e)?e:[e],...iI(t)})}IF(`ZodFile`,(e,t)=>{z_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vye(e,t,n,r),e.min=(t,n)=>e.check(yL(t,n)),e.max=(t,n)=>e.check(vL(t,n)),e.mime=(t,n)=>e.check(Gve(Array.isArray(t)?t:[t],n))});const Fbe=IF(`ZodTransform`,(e,t)=>{B_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sye(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new RF(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(dI(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(dI(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function lR(e){return new Fbe({type:`transform`,transform:e})}const uR=IF(`ZodOptional`,(e,t)=>{tL.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ML(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dR(e){return new uR({type:`optional`,innerType:e})}const Ibe=IF(`ZodExactOptional`,(e,t)=>{V_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ML(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lbe(e){return new Ibe({type:`optional`,innerType:e})}const Rbe=IF(`ZodNullable`,(e,t)=>{H_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fR(e){return new Rbe({type:`nullable`,innerType:e})}const zbe=IF(`ZodDefault`,(e,t)=>{U_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Bbe(e,t){return new zbe({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():eI(t)}})}const Vbe=IF(`ZodPrefault`,(e,t)=>{W_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hbe(e,t){return new Vbe({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():eI(t)}})}const pR=IF(`ZodNonOptional`,(e,t)=>{G_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ube(e,t){return new pR({type:`nonoptional`,innerType:e,...iI(t)})}IF(`ZodSuccess`,(e,t)=>{K_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Wbe=IF(`ZodCatch`,(e,t)=>{q_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gbe(e,t){return new Wbe({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}IF(`ZodNaN`,(e,t)=>{J_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gye(e,t,n,r)});const mR=IF(`ZodPipe`,(e,t)=>{Y_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fye(e,t,n,r),e.in=t.in,e.out=t.out});function hR(e,t){return new mR({type:`pipe`,in:e,out:t})}IF(`ZodCodec`,(e,t)=>{mR.init(e,t),X_e.init(e,t)});const Kbe=IF(`ZodReadonly`,(e,t)=>{Z_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Iye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qbe(e){return new Kbe({type:`readonly`,innerType:e})}IF(`ZodTemplateLiteral`,(e,t)=>{Q_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_ye(e,t,n,r)}),IF(`ZodLazy`,(e,t)=>{tve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rye(e,t,n,r),e.unwrap=()=>e._zod.def.getter()}),IF(`ZodPromise`,(e,t)=>{eve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lye(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),IF(`ZodFunction`,(e,t)=>{$_e.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xye(e,t,n,r)});const gR=IF(`ZodCustom`,(e,t)=>{nve.init(e,t),IL.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bye(e,t,n,r)});function Jbe(e,t){return Qve(gR,e??(()=>!0),t)}function Ybe(e,t={}){return $ve(gR,e,t)}function Xbe(e){return eye(e)}function _R(e,t){return hR(lR(e),t)}const Zbe={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var Qbe;(function(e){})(Qbe||={});function vR(e){return ove(RL,e)}function yR(e){return Mve(UL,e)}const bR={USER_MESSAGE:`user_message`,REJECTED:`rejected`,INTERRUPTED:`interrupted`},$be={REJECTED:`rejected`};function xR(e){if(e===`Tool was rejected by user`)return{rejected:!0};try{let t=JSON.parse(e);if(t.reason===bR.USER_MESSAGE)return{rejected:!0,userNote:t.message};if(t.reason===bR.REJECTED||t.reason===bR.INTERRUPTED)return{rejected:!0};if(t.status===$be.REJECTED)return{rejected:!0,userNote:t.userNote}}catch{}return{rejected:!1}}const SR=`sibling_tool_failed`,CR=JSON.stringify({type:SR,message:`Not executed: a tool call in a preceding parallel batch failed`});function exe(e){try{return JSON.parse(e)?.type===SR}catch{return!1}}var wR=class{concurrency(e,t){return!1}includeInApiDefinitions=!0;isEnabled(e){return!0}async prepare(e,t){return null}needsPermission(e,t,n){return!this.isReadonly}timeout(e,t){return 12e4}async onTimeout(e,t,n){throw Error(`${this.displayName} tool timed out after ${n}ms`)}format(e,t){return typeof e==`string`?e:JSON.stringify(e)}formatForLLM(e,t){return this.format(e,t)}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:this.name,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=`success`;return t.status===`error`?n=`error`:t.status===`skipped`&&(n=`skipped`),{phase:n,toolType:t.type??this.name,data:t,summary:t.message??t.summary??`Completed`,...t.errorMessage!==void 0&&{errorMessage:t.errorMessage}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:this.name,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:this.name,data:{},summary:`Completed`}}validateParams(e){return this.parameters.parse(e)}getToolDefinition(){let e=this.getParameterNames();return{name:this.name,description:this.description,arguments:e}}getParameterNames(){return Object.keys(this.parameters.shape)}};const txe=Symbol.for(`server-executed`);var TR=class extends wR{isReadonly=!0;async execute(e,t,n){return txe}format(e,t){return JSON.stringify({type:this.name,status:`server-executed`})}};dt([`codellm`,`agent`,`tools`,`subagent`]);var ER=class e extends TR{name=`subagent`;displayName=`Subagent`;description=`Switch to a different subagent for a task`;static parametersSchema=QL({agent:Y().describe(`The name of the subagent to switch to`),task:Y().describe(`The task description for the subagent`)});parameters=e.parametersSchema;needsPermission(){return!1}timeout(){return 6e5}format(e,t){return JSON.stringify({type:`subagent`,status:`success`,agent:t.agent,task:t.task})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`subagent`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`subagent`,data:t,summary:`Delegated to ${t.agent??`explore`} agent`}}catch{}return{phase:`success`,toolType:`subagent`,data:{},summary:`Delegated`}}};dt([`codellm`,`agent`,`tools`,`todo-write`]);var DR=class e extends TR{name=`todo_write`;displayName=`TodoWrite`;description=`Create and manage a structured task list`;static parametersSchema=QL({todos:_R(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:[]},XL(QL({content:Y().describe(`The task content`),status:sR([`pending`,`in_progress`,`completed`,`cancelled`]).describe(`The status of the task`),id:Y().optional().describe(`Optional task ID`)}))).describe(`Array of todo items`)});parameters=e.parametersSchema;needsPermission(){return!1}format(e,t){return`Updated`}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`todo_write`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.todos){let e=t.todos;return{phase:`success`,toolType:`todo_write`,data:t,summary:`${e.filter(e=>e.status===`pending`).length} pending, ${e.filter(e=>e.status===`in_progress`).length} in progress, ${e.filter(e=>e.status===`completed`).length} completed`}}}catch{}return{phase:`success`,toolType:`todo_write`,data:{},summary:`Updated`}}};function OR(e){if(typeof e!=`string`)return e;let t=e.trim();return t?Number(t):NaN}function kR(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 nxe=_R(OR,WL()),AR=_R(OR,WL().optional()),jR=_R(kR,KL()),MR=_R(kR,KL().optional()),rxe=dt([`codellm`,`agent`,`tools`,`ask-user`]);var NR=class e extends wR{isReadonly=!0;name=`ask_user_question`;displayName=`AskUserQuestion`;description=`Ask the user questions during execution to gather preferences, clarify instructions, or get decisions on implementation choices`;static parametersSchema=QL({questions:XL(QL({question:Y().describe(`The question to ask the user`),header:Y().describe(`A header/title for the question`),options:XL(QL({label:Y().describe(`The option label`),description:Y().describe(`A description of the option`)})).describe(`Array of options for the user to select from`),multiSelect:jR.describe(`Whether the user can select multiple options`)})).describe(`Array of questions to ask the user`),answers:aR(Y(),Y()).optional().describe(`User-provided answers to the questions`)});parameters=e.parametersSchema;needsPermission(){return!0}async execute(e){return rxe.debug`Asking user ${e.questions.length} question(s)`,{answers:e.answers||{}}}format(e,t){return JSON.stringify({type:`ask_user_question`,status:`success`,answers:e.answers})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`ask_user_question`,data:{},summary:`Cancelled`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.answers,r=n?Object.keys(n).length:0;return{phase:`success`,toolType:`ask_user_question`,data:t,summary:`Answered ${r} question${r===1?``:`s`}`}}catch{}return{phase:`success`,toolType:`ask_user_question`,data:{},summary:`Answered`}}};const ixe=dt([`codellm`,`agent`,`tools`,`plan-mode`]);var PR=class e extends wR{name=`enter_plan_mode`;displayName=`EnterPlanMode`;description=`Enter plan mode to create a plan before implementing changes`;static parametersSchema=QL({});parameters=e.parametersSchema;isReadonly=!0;needsPermission(e,t,n){return!1}async execute(e,t){return ixe.info`Entering plan mode`,{success:!0}}format(e,t){return`Entered plan mode`}parse(e){let t=xR(e);return t.rejected?{phase:`rejected`,toolType:`enter_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}}:{phase:`success`,toolType:`enter_plan_mode`,data:{},summary:`Entered plan mode`}}};const axe=dt([`codellm`,`agent`,`tools`,`plan-mode`]);var FR=class e extends wR{name=`exit_plan_mode`;displayName=`ExitPlanMode`;description=`Exit plan mode and return to normal agent operation`;static parametersSchema=QL({planFilePath:Y().describe(`Path to the plan file`)});parameters=e.parametersSchema;isReadonly=!0;async prepare(e,t){if(!e.planFilePath)return{error:`Plan not found`,skipPermission:!0};try{let n=await t.workspace.readRawFile(e.planFilePath);return n?{planContent:n}:{error:`Plan not found`,skipPermission:!0}}catch{return{error:`Plan not found`,skipPermission:!0}}}needsPermission(e,t,n){return!n?.skipPermission}async execute(e,t,n){if(n?.error)throw Error(n.error);return axe.info`Exiting plan mode with plan: ${e.planFilePath}`,{planFilePath:e.planFilePath}}format(e,t){return JSON.stringify({type:`exit_plan_mode`,status:`success`,...e.planFilePath&&{planFilePath:e.planFilePath}})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`exit_plan_mode`,data:{},summary:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{return{phase:`success`,toolType:`exit_plan_mode`,data:JSON.parse(e),summary:`Plan approved`}}catch{}return e.includes(`implement the plan`),{phase:`success`,toolType:`exit_plan_mode`,data:{},summary:`Plan approved`}}},IR;(function(e){e.GeneralPurpose=`GENERAL_PURPOSE`,e.Explore=`EXPLORE`,e.Plan=`PLAN`})(IR||={});const oxe={[IR.GeneralPurpose]:{name:IR.GeneralPurpose,displayName:`Agent`,description:`General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks`,allowedTools:[`*`],defaultModel:`CLAUDE_V4_5_SONNET`},[IR.Explore]:{name:IR.Explore,displayName:`Explore`,description:`Fast agent specialized for exploring codebases. Use for finding files by patterns, searching code for keywords, or answering questions about the codebase.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`},[IR.Plan]:{name:IR.Plan,displayName:`Plan`,description:`Fast agent for creating implementation plans. Explores codebase to understand architecture before planning.`,allowedTools:[`read`,`glob`,`grep`,`bash`,`web_fetch`,`web_search`],defaultModel:`CLAUDE_V4_5_HAIKU`}},sxe=new Set(Object.values(IR));function cxe(e){return sxe.has(e)}function LR(e){if(cxe(e))return e}function RR(e){return oxe[e]}function zR(){return Object.values(IR)}function BR(e){let t=LR(e);return t?RR(t).displayName:e}function lxe(e,t){let n=LR(e);if(!n)return!1;let r=RR(n);return r.allowedTools.includes(`*`)?!0:r.allowedTools.includes(t)}async function VR(e){return new Promise(t=>setTimeout(t,e))}const HR=dt([`codellm`,`agent`,`loop`]);function UR(e){if(!e)return null;if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e;if(t.text)return t.text;if(t.segment)return UR(t.segment)}return null}function uxe(e){return Math.min((e+1)*2e3,1e4)}function WR(e){return 2**(e+1)*1e3}function*dxe(e,t,n){if(e.error){let t=e.error,r=typeof t==`string`?t:JSON.stringify(t);r.includes(`Credit limit`)||r.includes(`no_usage_points`)||r.includes(`compute_point_budgeting`)||r.includes(`limit_exceeded`)||r.includes(`exhausted`)||r.includes(`purchase more credits`)?yield{__error:new wd({...n.pendingCreditLimitSegment??void 0,message:r})}:Bl(r)?yield{__error:new Ll}:yield{__error:new Cd(r)};return}if(e.type===`no_usage_points`||e.type===`compute_point_budgeting`||e.type===`limit_exceeded`){n.pendingCreditLimitSegment=e;return}if(e.type===`code_llm_credits`){yield{type:`credits`,creditsUsed:e.creditsUsed};return}if(e.type===`code_llm_session_info`){yield{type:`session_info`,contextPercent:e.contextPercent??0,contextTokensUsed:e.contextTokensUsed??0,contextWindowMax:e.contextWindowMax??0};return}if(e.type===`collapsible_component`&&e.isThoughts===!0){let t=e.title||`Thinking`,n=UR(e.segment)??``;n&&(yield{type:`thinking_delta`,content:n,title:t}),e.isSpinny===!1&&(yield{type:`thinking_complete`});return}if(e.type===`code_llm_notification`){let t=e.message||UR(e.segment)||`Notification`;yield{...e,type:`notification`,message:t,severity:e.severity??`info`};return}if(e.type===`code_llm_agent_tool_call_start`){yield{type:`tool_call_start`,toolCallId:e.toolCallId,toolName:e.toolName};return}if(e.type===`code_llm_agent_tool_call_delta`){yield{type:`tool_call_delta`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta};return}if(e.type===`code_llm_agent_tool_call_stop`){yield{type:`tool_call_stop`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments};let n=e.toolUseRequest;if(n){let e=n;if(e.name===`edit`){let t=e.input;(`startLineOneIndexed`in t||`endLineOneIndexed`in t)&&(e={...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}})}t.push(e),yield{type:`tool_requested`,tool:e}}return}if(e.toolUseRequest){let n=(Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest]).map(e=>{if(e.name===`edit`){let t=e.input;if(`startLineOneIndexed`in t||`endLineOneIndexed`in t)return{...e,input:{...t,startLine:t.startLineOneIndexed??t.startLine,endLine:t.endLineOneIndexed??t.endLine}}}return e}),r=new Set(t.map(e=>e.id)),i=n.filter(e=>!r.has(e.id));t.push(...i);for(let e of i)yield{type:`tool_requested`,tool:e};return}if(e.segment){let t=UR(e.segment);t&&(yield{type:`text_delta`,content:t})}}async function*fxe(e,t){let n=t?.generateRequestId?.()??crypto.randomUUID(),r=!1;HR.debug(`Starting agent loop (conversationId={conversationId}, model={model})`,{conversationId:e.conversationId,model:e.model});for(let t=0;t<8;t++){Al(`turn started`,`agent`);let i=n,a=!1;if(t>0){HR.debug(`Retry attempt {attempt}: checking for pending request ID`,{attempt:t});try{let t=await e.apiClient.getPendingRequestIdForConversation(e.conversationId);t?.success&&t.result?.requestId&&(i=t.result.requestId,a=!0)}catch{}}let o=[],s={pendingCreditLimitSegment:null},c=!1;try{HR.debug(`Sending SSE request (attempt={attempt}, conversationId={conversationId}, requestId={requestId}, reconnect={reconnect})`,{attempt:t,conversationId:e.conversationId,requestId:i,reconnect:a});let n=e.apiClient.streamAgentMessage({deploymentConversationId:e.conversationId,message:e.message,supportedTools:e.supportedTools,supportedSubAgents:e.supportedSubAgents,mcpTools:e.isPrintMode?[]:e.mcpTools??[],workspacePath:e.workspacePath,...e.swapFolder&&{swapFolder:e.swapFolder},llmName:e.model,requestId:i,docInfos:e.uploadedDocs?Array.from(e.uploadedDocs):[],toolUseResult:e.toolResult,supportsV2:!0,supportsThoughtStreaming:e.supportsThoughtStreaming??!0,supportsParallelToolUse:!0,isPrintMode:e.isPrintMode??!1,...e.subagent&&{subagent:e.subagent},agentMode:e.agentMode,currentFile:e.currentFile,selectionStartLine:e.selectionStartLine,selectionEndLine:e.selectionEndLine,gitBranch:e.gitBranch,gitMain:e.gitMain,gitStatus:e.gitStatus,gitCommits:e.gitCommits,diagnosticIssues:e.diagnosticIssues,availableSkills:e.availableSkills,activeSkills:e.activeSkills,client:e.client,setFolder:e.setFolder,reconnect:a,signal:e.signal});for await(let t of n){if(e.signal?.aborted)break;for(let e of dxe(t,o,s)){if(`__error`in e)throw e.__error;yield e}c=!0}if(e.signal?.aborted){e.apiClient.stopResponseSSE(i).catch(()=>{}),yield{type:`turn_complete_with_tools`,toolCalls:o};return}r&&=(yield{type:`network_status`,online:!0},!1),yield{type:`turn_complete_with_tools`,toolCalls:o},HR.debug(`Agent loop completed with {count} tool calls`,{count:o.length});return}catch(n){let i=n instanceof Error?n:Error(String(n));if(i instanceof Ll){if(c&&t<4&&!e.signal?.aborted){let e=WR(t);HR.warn(`Auth error mid-stream (attempt={attempt}, delay={delayMs}ms) — retrying (server may have re-validated against a stale replica)`,{attempt:t+1,delayMs:e}),Ol(`Mid-stream auth error, retrying`,`warning`,{context:`agent-loop`,attempt:t+1}),yield{type:`retry`,attempt:t+1,maxAttempts:5,delayMs:e,isNetworkError:!1},await VR(e);continue}throw HR.warn(`Auth expired, aborting loop`),i}if(i instanceof wd)throw HR.warn(`Credit limit reached, aborting loop`),Ol(`Credit limit reached`,`warning`,{context:`agent-loop`}),i;let a=Vl(i),o=a?8:5;if(t<o-1&&!e.signal?.aborted){let e=a?uxe(t):WR(t);HR.warn(`Retrying after error (attempt={attempt}, network={isNetErr}, delay={delayMs}ms): {error}`,{attempt:t+1,isNetErr:a,delayMs:e,error:i.message}),a&&!r&&(r=!0,yield{type:`network_status`,online:!1}),yield{type:`retry`,attempt:t+1,maxAttempts:o,delayMs:e,isNetworkError:a},await VR(e);continue}throw HR.error(`All retry attempts exhausted: {error}`,{error:i.message}),Dl(i,{context:`agent-loop-retry-exhausted`}),Vl(i)?i instanceof Rl?i:new Rl(i.message,i):i}}}const GR=dt([`codellm`,`agent`,`runner`]);var pxe=class{queue=[];resolvers=[];closed=!1;push(e){this.closed||(this.resolvers.length>0?this.resolvers.shift()(e):this.queue.push(e))}async next(){return this.queue.length>0?this.queue.shift():this.closed?null:new Promise(e=>{this.resolvers.push(e)})}close(){this.closed=!0;for(let e of this.resolvers)e(null);this.resolvers=[]}drain(){let e=[...this.queue];return this.queue=[],e}};function mxe(e){return e.toUpperCase().includes(`CLAUDE`)}async function*KR(e,t,n){let r=e.maxTurns??2**53-1,i=t,a,o=0,s=0,c=[],l=e.agentMode;GR.info(`Starting agent conversation (model={model}, maxTurns={maxTurns})`,{model:e.model,maxTurns:r});try{for(;o<r;){if(n?.aborted)return GR.info(`Conversation aborted after {numTurns} turns`,{numTurns:o}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:Error(`Execution cancelled`)};o++;let t={...e,swapFolder:a===void 0?e.swapFolder:void 0,setFolder:a===void 0?e.setFolder:void 0,agentMode:l,message:i,...a!==void 0&&{toolResult:a},...n!==void 0&&{signal:n}},r=[],u=new Map,d=new Map,f=new Map,p=[],m=new pxe,h=new AbortController,g=()=>h.abort(`interrupted`);n&&(n.aborted?h.abort(`interrupted`):n.addEventListener(`abort`,g,{once:!0}));let _=async(t,n,r)=>(await e.executeTools([t],n,r))[0],v=e.getConcurrency??(()=>!1),y=e=>{let t=_(e,h.signal,e=>m.push(e)).then(t=>{d.set(e.id,t);for(let[t,n]of f)if(n===e.id){f.delete(t);break}return t}).catch(e=>{throw h.abort(`sibling_tool_failed`),e});u.set(e.id,t)},b=e=>{let t=v(e);typeof t==`string`&&f.has(t)?p.push(e):(typeof t==`string`&&f.set(t,e.id),y(e))},x=!1;for await(let e of fxe(t)){for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(e.type===`turn_complete_with_tools`){r=e.toolCalls,x=!0;continue}if(e.type===`text_delta`&&c.push(e.content),e.type===`tool_requested`){yield e,b(e.tool);continue}yield e}for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),yield e;if(x||GR.warn(`Agent loop exited without turn_complete_with_tools (collected {count} tool calls)`,{count:r.length}),r.length===0){GR.debug(`Turn {numTurns} complete with no tool calls`,{numTurns:o}),n?.removeEventListener(`abort`,g),yield{type:`turn_complete`};break}for(let e of p){let t=v(e);if(typeof t==`string`&&f.has(t)){let e=f.get(t),n=u.get(e);if(n)try{await n}catch{}}h.signal.aborted||b(e)}let S=r.filter(e=>!u.has(e.id));if(S.length>0)if(u.size===0){let t,n=e.executeTools(r,h.signal,e=>m.push(e)).then(e=>{t=e;for(let t=0;t<e.length;t++){let n=r[t];n&&d.set(n.id,e[t])}return m.close(),e}),i=new Set;for(;t===void 0;){let e=await Promise.race([m.next(),n.then(()=>null)]);if(e!==null)e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;else if(t!==void 0)break}t||=await n;for(let e of m.drain())e.type===`mode_changed`&&(l=e.mode),e.type===`tool_execution_complete`&&i.add(e.tool.id),yield e;for(let e=0;e<t.length;e++){let n=r[e],a=t[e];n&&a&&!i.has(n.id)&&(yield{type:`tool_execution_complete`,tool:n,result:a})}}else for(let e of S)h.signal.aborted||y(e);if(u.size>0){let e=Promise.allSettled(u.values()).then(()=>{m.close()}),t=new Set,n=await m.next();for(;n!==null;)n.type===`mode_changed`&&(l=n.mode),n.type===`tool_execution_complete`&&t.add(n.tool.id),yield n,n=await m.next();await e;for(let e of r){let n=d.get(e.id);n&&!t.has(e.id)&&(yield{type:`tool_execution_complete`,tool:e,result:n})}}s+=r.length;let C=r.map(e=>d.get(e.id)??{id:e.id,content:`Error: tool execution did not complete`});n?.removeEventListener(`abort`,g);for(let t of e.drainEvents?.()??[])t.type===`mode_changed`&&(l=t.mode),yield t;let w=new Set([`task`]),T=(e,t)=>!(!e.rejected||w.has(r[t]?.name??``)),E=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===bR.REJECTED}catch{return!1}}),D=C.some((e,t)=>{if(!T(e,t))return!1;try{return JSON.parse(e.content).reason===bR.INTERRUPTED}catch{return!1}}),O=C.some(e=>{if(!e.rejected)return!1;try{return JSON.parse(e.content).reason===bR.USER_MESSAGE}catch{return!1}});if((E||D)&&!O){yield{type:`turn_complete`};break}let k=C.map(({parsedResult:e,...t})=>t);a=k.length===1?k[0]:k;let A=r.some(e=>e.name===`exit_plan_mode`)&&C.some(e=>{if(e.rejected)return!1;try{return JSON.parse(e.content).type===`exit_plan_mode`}catch{return!1}}),j=`I want you to start implementing the plan now as you have outlined in your plan.`;if(mxe(e.model)){let t=e.dequeueAllQueuedMessage?.({includeHidden:!0});t?(i=A?`${j} ${t.message}`:t.message,t.allHidden||(yield{type:`user_message_dequeued`,content:t.message})):i=A?j:``}else i=A?j:``;yield{type:`turn_complete`}}if(o>=r){GR.warn(`Maximum turns ({maxTurns}) exceeded`,{maxTurns:r});let e=Error(`Maximum turns (${r}) exceeded`);return yield{type:`error`,error:e},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:e}}return GR.info(`Conversation completed (turns={numTurns}, toolCalls={toolCallsExecuted})`,{numTurns:o,toolCallsExecuted:s}),{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!0}}catch(e){let t=e instanceof Error?e:Error(String(e));return Dl(t,{context:`agent-runner`}),GR.error(`Conversation failed after {numTurns} turns: {error}`,{numTurns:o,toolCallsExecuted:s,error:t}),yield{type:`error`,error:t},{content:c.join(``),numTurns:o,toolCallsExecuted:s,success:!1,error:t}}}const qR=dt([`codellm`,`agent`,`subagent`]);function hxe(e,t){let n=RR(t);return!n||n.allowedTools.includes(`*`)?e:e.filter(e=>lxe(t,e.name))}function gxe(e,t,n,r,i){let a=n.get(e.name)?.displayName??e.name;if(!n.isBuiltinRequest(e))return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)};switch(e.name){case`read`:{let n=t._prepareResult;if(n?.resolvedPath){let t=cF(n.resolvedPath);return{type:`read_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}case`edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.filePath??``);return{type:`edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}return{type:`edit_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,newContent:n?.newContent??``}}case`write`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.filePath??``);return{type:`write_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t),isNewFile:!n?.fileExists}}return{type:`write_file`,tool:e,displayName:a,filePath:e.input.filePath??``,originalContent:n?.currentContent??``,content:e.input.content??``,isNewFile:!n?.fileExists}}case`bash`:return{type:`run_terminal`,tool:e,displayName:a,command:e.input.command??``,cwd:r,background:!!(e.input.runInBackground??!1),unmatchedPatterns:i?.getUnmatchedBashSegments(e.input.command??``,r)??[]};case`notebook_edit`:{let n=t._prepareResult;if(n?.outsideWorkspace){let t=cF(n.resolvedPath??e.input.notebookPath??``);return{type:`notebook_edit_outside_directory`,tool:e,displayName:a,filePath:t,resolvedPath:t,deducedDirectory:O.dirname(t)}}let r=n?.notebook,i=e.input.cellId,o=``;if(i&&r?.cells){let e=r.cells.find(e=>e.id===i||e.metadata?.id===i);e&&(o=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}return{type:`notebook_edit`,tool:e,displayName:a,notebookPath:e.input.notebookPath??``,cellId:i,editMode:e.input.editMode??`replace`,cellType:e.input.cellType,originalContent:o,newContent:e.input.newSource??``}}case`ask_user_question`:return{type:`ask_user_question`,tool:e,displayName:a,questions:Array.isArray(e.input.questions)?e.input.questions:[]};case`exit_plan_mode`:{let n=t._prepareResult;return{type:`exit_plan_mode`,tool:e,displayName:a,planFilePath:e.input.planFilePath??``,planContent:n?.planContent??``}}default:return{type:`generic`,tool:e,displayName:a,toolName:a,inputSummary:JSON.stringify(e.input??{}).slice(0,200)}}}async function _xe(e){let{prompt:t,subagentType:n,model:r,resume:i,parentContext:a,onProgress:o,signal:s}=e;qR.info(`Starting subagent (type={subagentType}, model={model})`,{subagentType:n,model:r??`default`});let c=RR(n);if(!c)return qR.error(`Unknown subagent type: {subagentType}`,{subagentType:n}),{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Unknown subagent type: ${n}`};let l=NV(),u=hxe(l.getApiToolDefinitions(),n),d=r??c.defaultModel??`CLAUDE_V4_5_SONNET`,f;if(i&&c.supportsResume)f=i;else try{let e=await a.apiClient.createCodellmDeploymentConversation(`CODE_LLM_NON_INTERACTIVE`,a.clientType);if(!e?.result?.deploymentConversationId)return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: no conversation ID returned`};f=e.result.deploymentConversationId}catch(e){return{success:!1,output:``,toolsExecuted:[],toolCalls:[],numTurns:0,error:`Failed to create subagent conversation: ${e instanceof Error?e.message:String(e)}`}}let p=[],m=[],h=[],g=a.permissionProvider&&a.rulesEngine&&a.getAgentMode,_=()=>a.getAgentMode?.()??xd.Yolo,v=c?.name,y={apiClient:a.apiClient,conversationId:f,model:d,workspacePath:a.workspacePath,supportedTools:u,mcpTools:[],uploadedDocs:a.uploadedDocs,isPrintMode:!g,...v&&{subagent:v},supportsThoughtStreaming:!0,agentMode:_(),executeTools:async(e,t,n)=>{let r=[];for(let i of e){if(t?.aborted||s?.aborted)break;m.push(i.name);let e={name:i.name,input:i.input??{}};o?.({type:`tool_requested`,content:`${i.name}`,toolName:i.name,toolInput:e.input,toolId:i.id}),n?.({type:`tool_execution_start`,tool:i});let c=_(),u={...a,toolCallId:i.id,conversationId:f,agentMode:c,status:`executing`};try{let d=l.createToolInstance(i.name,i.input??{},u);await d.prepare();let f=c===xd.Yolo&&i.name!==`ask_user_question`;if(g&&!f&&d.needsPermission()){let c=l.get(i.name)?.displayName??i.name,f=VV(i),p=a.rulesEngine.evaluate(c,f);if(p===`deny`){r.push({id:i.id,content:JSON.stringify({reason:bR.REJECTED}),rejected:!0}),e.result=`denied by rule`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(p!==`allow`){let c=gxe(i,d,l,a.workspacePath,a.rulesEngine);if(a.permissionProvider.needsPermission(c)){n?.({type:`status_changed`,status:Sd.WaitingForToolPermission}),a.emitEvent?.({type:`status_changed`,status:Sd.WaitingForToolPermission});let l;try{let e=a.permissionProvider.requestPermission(c),n=t||s;if(n){let t,r=new Promise((e,r)=>{n.aborted?r(Error(`interrupted`)):(t=()=>r(Error(`interrupted`)),n.addEventListener(`abort`,t,{once:!0}))});try{l=await Promise.race([e,r])}finally{t&&n.removeEventListener(`abort`,t)}}else l=await e}catch{r.push({id:i.id,content:JSON.stringify({reason:bR.INTERRUPTED}),rejected:!0}),e.result=`interrupted`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(n?.({type:`status_changed`,status:Sd.ExecutingTool}),a.emitEvent?.({type:`status_changed`,status:Sd.ExecutingTool}),l===`reject`){r.push({id:i.id,content:JSON.stringify({reason:bR.REJECTED}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`reject_with_message`){r.push({id:i.id,content:JSON.stringify({reason:bR.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`rejected`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(l===`allowAlways`||l===`allowYolo`||l===`accept`){if(l===`allowAlways`&&(c.type===`read_outside_directory`||c.type===`write_outside_directory`||c.type===`edit_outside_directory`||c.type===`notebook_edit_outside_directory`)&&`deducedDirectory`in c){let e=a.allowEditingPaths??[],t=c.deducedDirectory;e.includes(t)||e.push(t)}else if(i.name===`exit_plan_mode`){let e=l===`allowYolo`?xd.Yolo:l===`allowAlways`?xd.AcceptEdits:xd.Normal;a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}else if(l===`allowAlways`){let e=Dd(c.type);a.setAgentMode?.(e),u.agentMode=e,n?.({type:`mode_changed`,mode:e})}}if(typeof l==`object`&&l.type===`accept_with_message`){r.push({id:i.id,content:JSON.stringify({reason:bR.USER_MESSAGE,message:l.message}),rejected:!0}),e.result=`accepted with message`,h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id});continue}if(typeof l==`object`&&l.type===`question_answers`&&d.mergeParams({answers:l.answers}),typeof l==`object`&&l.type===`allow_always_with_rule`&&a.rulesEngine.addAllowRule(l.rule),typeof l==`object`&&l.type===`allow_always_with_rules`)for(let e of l.rules)a.rulesEngine.addAllowRule(e)}}}i.name===`enter_plan_mode`&&(a.setAgentMode?.(xd.PlanMode),u.agentMode=xd.PlanMode,n?.({type:`mode_changed`,mode:xd.PlanMode})),i.name===`exit_plan_mode`&&f&&(a.setAgentMode?.(xd.Normal),u.agentMode=xd.Normal,n?.({type:`mode_changed`,mode:xd.Normal})),await d.execute();let p=d.formatResultForLLM(),m=d.formatResult(),_=typeof p==`string`?p:JSON.stringify(p),v=l.parse(i.name,m);r.push({id:i.id,content:_,parsedResult:v}),e.result=_}catch(t){let n=t instanceof Error?t.message:String(t);r.push({id:i.id,content:`Error: ${n}`}),e.result=`Error: ${n}`}h.push(e),o?.({type:`tool_complete`,content:`${i.name}`,toolName:i.name,toolId:i.id})}for(let t of e)r.some(e=>e.id===t.id)||r.push({id:t.id,content:JSON.stringify({reason:bR.INTERRUPTED}),rejected:!0});return r}};try{o?.({type:`status`,content:`Starting ${n} agent...`});let e=KR(y,t,s),r=await e.next();for(;!r.done;){let t=r.value;switch(t.type){case`text_delta`:p.push(t.content),o?.({type:`text`,content:t.content});break;case`thinking_delta`:o?.({type:`thinking`,content:t.content});break;case`tool_requested`:case`turn_complete`:break;case`tool_execution_complete`:p.length=0;break;case`error`:return{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t.error?.message??`Unknown error`};case`credits`:a.emitEvent?.(t);break;case`mode_changed`:a.emitEvent?.(t);break;case`status_changed`:case`notification`:break}r=await e.next()}let i=r.value;return qR.info(`Subagent completed (type={subagentType}, turns={numTurns}, tools={toolCount})`,{subagentType:n,numTurns:i.numTurns,toolCount:m.length}),{success:i.success,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:i.numTurns,...i.error&&{error:i.error.message}}}catch(e){let t=e instanceof Error?e.message:String(e);return Dl(e instanceof Error?e:Error(t),{context:`subagent-runner`}),qR.error(`Subagent failed (type={subagentType}): {error}`,{subagentType:n,error:t}),{success:!1,output:p.join(``),toolsExecuted:m,toolCalls:h,numTurns:0,error:t}}}const JR=dt([`codellm`,`agent`,`tools`,`task`]);var YR=class e extends wR{name=`task`;displayName=`Task`;description=`Launch a new agent to handle complex, multi-step tasks autonomously.
1872
1872
 
1873
1873
  The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
1874
1874
 
@@ -1880,7 +1880,7 @@ Usage notes:
1880
1880
  - Launch multiple agents concurrently whenever possible, to maximize performance
1881
1881
  - Each agent invocation is stateless - provide a detailed task description
1882
1882
  - The agent's outputs should generally be trusted
1883
- - Clearly tell the agent whether you expect it to write code or just to do research`;isReadonly=!0;concurrency(e){return!0}static parametersSchema=QL({description:Y().describe(`A short (3-5 word) description of the task`),prompt:Y().describe(`The detailed task for the agent to perform autonomously`),subagentType:sR(IR).describe(`The type of specialized agent to use (e.g., 'GENERAL_PURPOSE', 'EXPLORE', 'PLAN')`),model:Y().optional().describe(`Optional model to use for this agent. If not specified, uses the default for the agent type.`),resume:Y().optional().describe(`Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript.`)});parameters=e.parametersSchema;getParameterNames(){return[`description`,`prompt`,`subagentType`,`resume`]}needsPermission(){return!1}async execute(e,t){let{description:n,prompt:r,subagentType:i,model:a,resume:o}=e;JR.info`Launching task: ${n} (type=${i}${o?`, resuming`:``})`;let s=0,c=[],l=()=>{t.emitEvent&&t.emitEvent({type:`tool_display_data`,toolCallId:t.toolCallId,data:{toolCallCount:s,nestedToolCalls:c.slice(-50)}})},u=await _xe({prompt:r,subagentType:i,model:a,resume:o,parentContext:t,onProgress:e=>{if(e.type===`tool_requested`&&e.toolName){s++;let t={};for(let[n,r]of Object.entries(e.toolInput??{})){let e=typeof r==`string`?r:JSON.stringify(r);t[n]=e.length>200?e.slice(0,200)+`...`:e}c.push({id:e.toolId??`tool-${s}`,name:e.toolName,input:t,status:`executing`}),l()}else if(e.type===`tool_complete`&&e.toolId){let t=c.find(t=>t.id===e.toolId);t&&(t.status=`success`),l()}},signal:t.abortController?.signal});return JR.info`Task completed: ${n} (${u.numTurns} turns, ${u.toolsExecuted.length} tools${u.error?`, error: `+u.error:``})`,{type:`task`,status:u.success?`success`:`error`,subagentType:i,description:n,output:u.output,toolsExecuted:u.toolsExecuted,toolCalls:u.toolCalls,numTurns:u.numTurns,...u.error&&{error:u.error}}}format(e){return JSON.stringify(e)}formatForLLM(e){return e.output}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`task`,data:{subagentType:``,description:``,output:``,toolsExecuted:[],toolCalls:[],numTurns:0},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.status===`error`;return{phase:n?`error`:`success`,toolType:`task`,data:{subagentType:t.subagentType??``,description:t.description??``,output:t.output??``,toolsExecuted:t.toolsExecuted??[],toolCalls:t.toolCalls??[],numTurns:t.numTurns??0,...t.error&&{error:t.error}},summary:n?`Task failed: ${t.error??`Unknown error`}`:`${t.subagentType} agent completed (${t.numTurns} turns, ${t.toolsExecuted.length} tools)`,...t.error&&{errorMessage:t.error}}}catch{return{phase:`success`,toolType:`task`,data:{subagentType:``,description:``,output:e,toolsExecuted:[],toolCalls:[],numTurns:0},summary:`Task completed`}}}},XR=class extends wR{isReadonly=!1};const vxe=dt([`codellm`,`agent`,`tools`,`delete`]),ZR=a(oe),yxe=QL({path:Y()});function QR(e){return`'${e.replace(/'/g,`'\\''`)}'`}async function bxe(e){await ZR(`osascript -e ${QR(`tell application "Finder" to delete POSIX file ${JSON.stringify(e)}`)}`)}async function xxe(e,t){let n=e.replace(/'/g,`''`);await ZR(`powershell -NoProfile -Command "${[`Add-Type -AssemblyName Microsoft.VisualBasic`,`[Microsoft.VisualBasic.FileIO.FileSystem]::${t?`DeleteDirectory`:`DeleteFile`}('${n}','OnlyErrorDialogs','SendToRecycleBin')`].join(`; `)}"`)}async function Sxe(e){await ZR(`gio trash ${QR(e)}`)}async function Cxe(e,t){switch(process.platform){case`darwin`:await bxe(e);break;case`win32`:await xxe(e,t);break;default:await Sxe(e);break}}async function wxe(e,t){try{await Be(e,{glob:!1})}catch{await Cxe(e,t)}}var $R=class extends XR{name=`delete`;displayName=`Delete`;description=`Deletes a file or folder by moving it to the system trash (macOS Trash, Windows Recycle Bin, or Linux Trash).`;parameters=yxe;concurrency(e,t){let n=e.path;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{path:n}=e,r=oF(n);if(O.isAbsolute(r)){let i=dF(r,t.workspacePath);if(i.success)n=i.relativePath,e.path=n;else if(t.allowEditingPaths&&t.allowEditingPaths.length>0){if(!t.allowEditingPaths.some(e=>dF(r,e).success))return{skipPermission:!0,error:`Deleting absolute path '${e.path}' is not allowed. The path is outside the workspace directory '${t.workspacePath}'. Use relative paths instead.`}}else return{skipPermission:!0,error:`Deleting absolute path '${e.path}' is not allowed. The path is outside the workspace directory '${t.workspacePath}'. Use relative paths instead.`}}let i=O.isAbsolute(r)?r:O.resolve(t.workspacePath,n);if(![t.workspacePath,...t.allowEditingPaths??[]].some(e=>uF(i,e)))return{skipPermission:!0,error:`Deleting '${e.path}' is not allowed. The resolved path is outside the workspace directory.`};let a=!1,o=!1;try{let e=await Te.stat(i);a=!0,o=e.isDirectory()}catch{a=!1}return a?{resolvedPath:i,isDirectory:o,exists:!0}:{skipPermission:!0,error:`Path '${e.path}' does not exist.`,exists:!1}}needsPermission(e,t,n){return!(n?.skipPermission||t.agentMode===xd.AcceptEdits)}async execute(e,t,n){let r=e.path;if(vxe.debug`Deleting: ${r}${n?.isDirectory?` (directory)`:``}`,n?.error)return{type:`delete`,filePath:r,isDirectory:!1,error:n.error};let i=n?.resolvedPath??``,a=n?.isDirectory??!1;try{await wxe(i,a)}catch(e){return{type:`delete`,filePath:r,isDirectory:a,error:`Failed to move to trash: ${e instanceof Error?e.message:String(e)}`}}return{type:`delete`,filePath:r,isDirectory:a}}format(e){return e.error?JSON.stringify({type:`delete`,status:`error`,error:e.error}):`Deleted successfully`}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`delete`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return t.status===`error`||t.error?{phase:`error`,toolType:`delete`,data:t,summary:t.error??`Error`,errorMessage:t.error}:{phase:`success`,toolType:`delete`,data:t,summary:`Deleted`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`delete`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`delete`,data:{},summary:`Deleted`}}};const ez=dt([`codellm`,`agent`,`tools`,`edit`]);function tz(e){return e.replaceAll(`\r
1883
+ - Clearly tell the agent whether you expect it to write code or just to do research`;isReadonly=!0;concurrency(e){return!0}static parametersSchema=QL({description:Y().describe(`A short (3-5 word) description of the task`),prompt:Y().describe(`The detailed task for the agent to perform autonomously`),subagentType:sR(IR).describe(`The type of specialized agent to use (e.g., 'GENERAL_PURPOSE', 'EXPLORE', 'PLAN')`),model:Y().optional().describe(`Optional model to use for this agent. If not specified, uses the default for the agent type.`),resume:Y().optional().describe(`Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript.`)});parameters=e.parametersSchema;getParameterNames(){return[`description`,`prompt`,`subagentType`,`resume`]}needsPermission(){return!1}timeout(){return 6e5}async execute(e,t){let{description:n,prompt:r,subagentType:i,model:a,resume:o}=e;JR.info`Launching task: ${n} (type=${i}${o?`, resuming`:``})`;let s=0,c=[],l=()=>{t.emitEvent&&t.emitEvent({type:`tool_display_data`,toolCallId:t.toolCallId,data:{toolCallCount:s,nestedToolCalls:c.slice(-50)}})},u=await _xe({prompt:r,subagentType:i,model:a,resume:o,parentContext:t,onProgress:e=>{if(e.type===`tool_requested`&&e.toolName){s++;let t={};for(let[n,r]of Object.entries(e.toolInput??{})){let e=typeof r==`string`?r:JSON.stringify(r);t[n]=e.length>200?e.slice(0,200)+`...`:e}c.push({id:e.toolId??`tool-${s}`,name:e.toolName,input:t,status:`executing`}),l()}else if(e.type===`tool_complete`&&e.toolId){let t=c.find(t=>t.id===e.toolId);t&&(t.status=`success`),l()}},signal:t.abortController?.signal});return JR.info`Task completed: ${n} (${u.numTurns} turns, ${u.toolsExecuted.length} tools${u.error?`, error: `+u.error:``})`,{type:`task`,status:u.success?`success`:`error`,subagentType:i,description:n,output:u.output,toolsExecuted:u.toolsExecuted,toolCalls:u.toolCalls,numTurns:u.numTurns,...u.error&&{error:u.error}}}format(e){return JSON.stringify(e)}formatForLLM(e){return e.output}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`task`,data:{subagentType:``,description:``,output:``,toolsExecuted:[],toolCalls:[],numTurns:0},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.status===`error`;return{phase:n?`error`:`success`,toolType:`task`,data:{subagentType:t.subagentType??``,description:t.description??``,output:t.output??``,toolsExecuted:t.toolsExecuted??[],toolCalls:t.toolCalls??[],numTurns:t.numTurns??0,...t.error&&{error:t.error}},summary:n?`Task failed: ${t.error??`Unknown error`}`:`${t.subagentType} agent completed (${t.numTurns} turns, ${t.toolsExecuted.length} tools)`,...t.error&&{errorMessage:t.error}}}catch{return{phase:`success`,toolType:`task`,data:{subagentType:``,description:``,output:e,toolsExecuted:[],toolCalls:[],numTurns:0},summary:`Task completed`}}}},XR=class extends wR{isReadonly=!1};const vxe=dt([`codellm`,`agent`,`tools`,`delete`]),ZR=a(oe),yxe=QL({path:Y()});function QR(e){return`'${e.replace(/'/g,`'\\''`)}'`}async function bxe(e){await ZR(`osascript -e ${QR(`tell application "Finder" to delete POSIX file ${JSON.stringify(e)}`)}`)}async function xxe(e,t){let n=e.replace(/'/g,`''`);await ZR(`powershell -NoProfile -Command "${[`Add-Type -AssemblyName Microsoft.VisualBasic`,`[Microsoft.VisualBasic.FileIO.FileSystem]::${t?`DeleteDirectory`:`DeleteFile`}('${n}','OnlyErrorDialogs','SendToRecycleBin')`].join(`; `)}"`)}async function Sxe(e){await ZR(`gio trash ${QR(e)}`)}async function Cxe(e,t){switch(process.platform){case`darwin`:await bxe(e);break;case`win32`:await xxe(e,t);break;default:await Sxe(e);break}}async function wxe(e,t){try{await Be(e,{glob:!1})}catch{await Cxe(e,t)}}var $R=class extends XR{name=`delete`;displayName=`Delete`;description=`Deletes a file or folder by moving it to the system trash (macOS Trash, Windows Recycle Bin, or Linux Trash).`;parameters=yxe;concurrency(e,t){let n=e.path;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{path:n}=e,r=oF(n);if(O.isAbsolute(r)){let i=dF(r,t.workspacePath);if(i.success)n=i.relativePath,e.path=n;else if(t.allowEditingPaths&&t.allowEditingPaths.length>0){if(!t.allowEditingPaths.some(e=>dF(r,e).success))return{skipPermission:!0,error:`Deleting absolute path '${e.path}' is not allowed. The path is outside the workspace directory '${t.workspacePath}'. Use relative paths instead.`}}else return{skipPermission:!0,error:`Deleting absolute path '${e.path}' is not allowed. The path is outside the workspace directory '${t.workspacePath}'. Use relative paths instead.`}}let i=O.isAbsolute(r)?r:O.resolve(t.workspacePath,n);if(![t.workspacePath,...t.allowEditingPaths??[]].some(e=>uF(i,e)))return{skipPermission:!0,error:`Deleting '${e.path}' is not allowed. The resolved path is outside the workspace directory.`};let a=!1,o=!1;try{let e=await Te.stat(i);a=!0,o=e.isDirectory()}catch{a=!1}return a?{resolvedPath:i,isDirectory:o,exists:!0}:{skipPermission:!0,error:`Path '${e.path}' does not exist.`,exists:!1}}needsPermission(e,t,n){return!(n?.skipPermission||t.agentMode===xd.AcceptEdits)}async execute(e,t,n){let r=e.path;if(vxe.debug`Deleting: ${r}${n?.isDirectory?` (directory)`:``}`,n?.error)return{type:`delete`,filePath:r,isDirectory:!1,error:n.error};let i=n?.resolvedPath??``,a=n?.isDirectory??!1;try{await wxe(i,a)}catch(e){return{type:`delete`,filePath:r,isDirectory:a,error:`Failed to move to trash: ${e instanceof Error?e.message:String(e)}`}}return{type:`delete`,filePath:r,isDirectory:a}}format(e){return e.error?JSON.stringify({type:`delete`,status:`error`,error:e.error}):`Deleted successfully`}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`delete`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return t.status===`error`||t.error?{phase:`error`,toolType:`delete`,data:t,summary:t.error??`Error`,errorMessage:t.error}:{phase:`success`,toolType:`delete`,data:t,summary:`Deleted`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`delete`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`delete`,data:{},summary:`Deleted`}}};const ez=dt([`codellm`,`agent`,`tools`,`edit`]);function tz(e){return e.replaceAll(`\r
1884
1884
  `,`
1885
1885
  `)}function Txe(e){return e.includes(`\r
1886
1886
  `)?`\r
@@ -1913,7 +1913,7 @@ Usage notes:
1913
1913
  `);t.trim()===n&&(yield t)}},Nxe=function*(e,t){let n=t.split(`
1914
1914
  `);if(n.length<3)return;n[n.length-1]===``&&n.pop();let r=e.split(`
1915
1915
  `),i=n[0].trim(),a=n[n.length-1].trim();for(let e=0;e<r.length;e++)if(r[e].trim()===i){for(let t=e+2;t<r.length;t++)if(r[t].trim()===a){let i=r.slice(e,t+1),a=i.join(`
1916
- `);if(i.length===n.length){let e=0,t=0;for(let r=1;r<i.length-1;r++){let a=i[r].trim(),o=n[r].trim();(a.length>0||o.length>0)&&(t++,a===o&&e++)}if(t===0||e/t>=.5){yield a;break}}break}}},Pxe=function*(e,t){let n=0;for(;;){let r=e.indexOf(t,n);if(r===-1)break;yield t,n=r+t.length}};function Fxe(e,t,n,r=!1){if(t.length===0)throw Error(`old_string cannot be empty`);if(t===n)throw Error(`No changes to apply: oldString and newString are identical.`);let i=!0;for(let a of[Exe,Dxe,Oxe,kxe,Axe,jxe,Mxe,Nxe,Pxe])for(let o of a(e,t)){let t=e.indexOf(o);if(t!==-1){if(i=!1,r)return e.replaceAll(o,n);if(t===e.lastIndexOf(o))return e.substring(0,t)+n+e.substring(t+o.length)}}throw i?Error(`Could not find oldString in the file. It must match exactly, including whitespace, indentation, and line endings.`):Error(`Found multiple matches for oldString. Provide more surrounding context to make the match unique.`)}const Ixe=QL({filePath:Y(),oldString:Y(),newString:Y(),replaceAll:MR});var iz=class extends XR{name=`edit`;displayName=`Edit`;description=`Performs exact string replacements in files. The old_string must be unique in the file unless replace_all is true.`;parameters=Ixe;concurrency(e,t){let n=e.filePath;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{filePath:n}=e,r=!1,i;if(O.isAbsolute(n)){let a=dF(n,t.workspacePath);a.success?(n=a.relativePath,e.filePath=n):t.allowEditingPaths&&t.allowEditingPaths.length>0&&t.allowEditingPaths.some(e=>dF(n,e).success)||(r=!0,i=oF(n))}let a=!1,o=``;if(r){let e=i??n;try{o=await(await import(`node:fs/promises`)).default.readFile(e,`utf-8`),a=!0}catch{a=!1,o=``}if(!a)return{skipPermission:!0,error:`File not found: ${e}`,outsideWorkspace:r,resolvedPath:i}}else try{o=await t.workspace.readRawFile(n),a=!0}catch{a=!1,o=``}if(e.oldString.length===0)return{skipPermission:!0,error:`old_string cannot be empty`,outsideWorkspace:r,resolvedPath:i};if(!a)return{currentContent:o,fileExists:a,newContent:e.newString,outsideWorkspace:r,resolvedPath:i};if(e.oldString===e.newString)return{skipPermission:!0,error:`old_string and new_string must be different`,outsideWorkspace:r,resolvedPath:i};let s=Txe(o),c=nz(tz(e.oldString),s),l=nz(tz(e.newString),s),u;try{u=Fxe(o,c,l,e.replaceAll)}catch(e){return{skipPermission:!0,error:`${e instanceof Error?e.message:String(e)}`,outsideWorkspace:r,resolvedPath:i}}return{currentContent:o,fileExists:a,newContent:u,outsideWorkspace:r,resolvedPath:i}}needsPermission(e,t,n){if(n?.skipPermission)return!1;if(t.agentMode===xd.PlanMode){let n=t.workspacePath,r=O.resolve(n,e.filePath),i=t.plansDir??O.join(te(),hn.configDirName,`plans`);if(uF(r,O.resolve(n,i)))return!1}return n?.outsideWorkspace?!0:t.agentMode!==xd.AcceptEdits}async execute(e,t,n){let{filePath:r}=e;if(ez.debug`Editing file: ${r}${e.replaceAll?` (replace all)`:``}`,n?.error)return ez.warn`Edit failed for ${r}: ${n.error}`,{type:`edit`,targetFile:r,operation:`failed`,error:n.error,lineDiff:0,originalLines:0,newLines:0,unchanged:!0};let i=n?.fileExists??!1,a=n?.currentContent??``,o=n?.newContent??``,s=``,c=``;if(!i)await t.workspace.create(r,e.newString),s=e.newString,c=`created`;else try{await t.workspace.strReplace(r,a,o,1),s=o,c=`modified`}catch(e){return{type:`edit`,targetFile:r,operation:`failed`,error:`Failed to apply replacement: ${e instanceof Error?e.message:String(e)}`,lineDiff:0,originalLines:a.split(`
1916
+ `);if(i.length===n.length){let e=0,t=0;for(let r=1;r<i.length-1;r++){let a=i[r].trim(),o=n[r].trim();(a.length>0||o.length>0)&&(t++,a===o&&e++)}if(t===0||e/t>=.5){yield a;break}}break}}},Pxe=function*(e,t){let n=0;for(;;){let r=e.indexOf(t,n);if(r===-1)break;yield t,n=r+t.length}};function Fxe(e,t,n,r=!1){if(t.length===0)throw Error(`old_string cannot be empty`);if(t===n)throw Error(`No changes to apply: oldString and newString are identical.`);let i=!0;for(let a of[Exe,Dxe,Oxe,kxe,Axe,jxe,Mxe,Nxe,Pxe])for(let o of a(e,t)){let t=e.indexOf(o);if(t!==-1){if(i=!1,r)return e.replaceAll(o,n);if(t===e.lastIndexOf(o))return e.substring(0,t)+n+e.substring(t+o.length)}}throw i?Error(`Could not find oldString in the file. It must match exactly, including whitespace, indentation, and line endings.`):Error(`Found multiple matches for oldString. Provide more surrounding context to make the match unique.`)}const Ixe=QL({filePath:Y(),oldString:Y(),newString:Y(),replaceAll:MR});var iz=class extends XR{name=`edit`;displayName=`Edit`;description=`Performs exact string replacements in files. The old_string must be unique in the file unless replace_all is true.`;parameters=Ixe;timeout(){return 3e5}concurrency(e,t){let n=e.filePath;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{filePath:n}=e,r=!1,i;if(O.isAbsolute(n)){let a=dF(n,t.workspacePath);a.success?(n=a.relativePath,e.filePath=n):t.allowEditingPaths&&t.allowEditingPaths.length>0&&t.allowEditingPaths.some(e=>dF(n,e).success)||(r=!0,i=oF(n))}let a=!1,o=``;if(r){let e=i??n;try{o=await(await import(`node:fs/promises`)).default.readFile(e,`utf-8`),a=!0}catch{a=!1,o=``}if(!a)return{skipPermission:!0,error:`File not found: ${e}`,outsideWorkspace:r,resolvedPath:i}}else try{o=await t.workspace.readRawFile(n),a=!0}catch{a=!1,o=``}if(e.oldString.length===0)return{skipPermission:!0,error:`old_string cannot be empty`,outsideWorkspace:r,resolvedPath:i};if(!a)return{currentContent:o,fileExists:a,newContent:e.newString,outsideWorkspace:r,resolvedPath:i};if(e.oldString===e.newString)return{skipPermission:!0,error:`old_string and new_string must be different`,outsideWorkspace:r,resolvedPath:i};let s=Txe(o),c=nz(tz(e.oldString),s),l=nz(tz(e.newString),s),u;try{u=Fxe(o,c,l,e.replaceAll)}catch(e){return{skipPermission:!0,error:`${e instanceof Error?e.message:String(e)}`,outsideWorkspace:r,resolvedPath:i}}return{currentContent:o,fileExists:a,newContent:u,outsideWorkspace:r,resolvedPath:i}}needsPermission(e,t,n){if(n?.skipPermission)return!1;if(t.agentMode===xd.PlanMode){let n=t.workspacePath,r=O.resolve(n,e.filePath),i=t.plansDir??O.join(te(),hn.configDirName,`plans`);if(uF(r,O.resolve(n,i)))return!1}return n?.outsideWorkspace?!0:t.agentMode!==xd.AcceptEdits}async execute(e,t,n){let{filePath:r}=e;if(ez.debug`Editing file: ${r}${e.replaceAll?` (replace all)`:``}`,n?.error)return ez.warn`Edit failed for ${r}: ${n.error}`,{type:`edit`,targetFile:r,operation:`failed`,error:n.error,lineDiff:0,originalLines:0,newLines:0,unchanged:!0};let i=n?.fileExists??!1,a=n?.currentContent??``,o=n?.newContent??``,s=``,c=``;if(!i)await t.workspace.create(r,e.newString),s=e.newString,c=`created`;else try{await t.workspace.strReplace(r,a,o,1),s=o,c=`modified`}catch(e){return{type:`edit`,targetFile:r,operation:`failed`,error:`Failed to apply replacement: ${e instanceof Error?e.message:String(e)}`,lineDiff:0,originalLines:a.split(`
1917
1917
  `).length,newLines:a.split(`
1918
1918
  `).length,unchanged:!0,originalContent:a,finalContent:a}}let l=a.split(`
1919
1919
  `).length,u=s.split(`
@@ -74897,7 +74897,7 @@ The script returns JSON with error details:
74897
74897
  `).length:0;return{phase:`success`,toolType:`read`,data:{content:n,startLine:r?.startLine,lineCount:i},summary:`Read ${i} lines`}}};function _V(e){let t=e.split(`
74898
74898
  `),n=t[0]??``,r=/^Line\d+: /.test(n),i=/^\s*\d+→/.test(n);if(!r&&!i)return e;let a=r?/^Line\d+: /:/^\s*\d+→/;return t.map(e=>e.replace(a,``)).join(`
74899
74899
  `)}function gCe(e){let t=e.split(`
74900
- `),n=/^Line(\d+): /,r=n.exec(t[0]??``);if(!r)return null;let i=parseInt(r[1],10);for(let e=t.length-1;e>=0;e--){let r=n.exec(t[e]);if(r)return{startLine:i,endLine:parseInt(r[1],10)}}return{startLine:i,endLine:i}}const _Ce=dt([`codellm`,`agent`,`tools`,`write`]),vCe=QL({filePath:Y(),content:Y()});var vV=class extends XR{name=`write`;displayName=`Write`;description=`Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.`;parameters=vCe;concurrency(e,t){let n=e.filePath;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{filePath:n}=e,r=!1,i;if(O.isAbsolute(n)){let a=dF(n,t.workspacePath);a.success?(n=a.relativePath,e.filePath=n):t.allowEditingPaths&&t.allowEditingPaths.length>0&&t.allowEditingPaths.some(e=>dF(n,e).success)||(r=!0,i=oF(n))}let a=!1,o=``;if(r){let e=i??n;try{o=await(await import(`node:fs/promises`)).default.readFile(e,`utf-8`),a=!0}catch{a=!1,o=``}}else try{o=await t.workspace.readRawFile(n),a=!0}catch{a=!1,o=``}return{fileExists:a,currentContent:o,outsideWorkspace:r,resolvedPath:i}}needsPermission(e,t,n){if(n?.skipPermission)return!1;if(t.agentMode===xd.PlanMode){let n=t.workspacePath,r=O.resolve(n,e.filePath),i=t.plansDir??O.join(te(),hn.configDirName,`plans`);if(uF(r,O.resolve(n,i)))return!1}return n?.outsideWorkspace?!0:t.agentMode!==xd.AcceptEdits}async execute(e,t,n){let{filePath:r,content:i}=e;if(_Ce.debug`Writing file: ${r} (${i.split(`
74900
+ `),n=/^Line(\d+): /,r=n.exec(t[0]??``);if(!r)return null;let i=parseInt(r[1],10);for(let e=t.length-1;e>=0;e--){let r=n.exec(t[e]);if(r)return{startLine:i,endLine:parseInt(r[1],10)}}return{startLine:i,endLine:i}}const _Ce=dt([`codellm`,`agent`,`tools`,`write`]),vCe=QL({filePath:Y(),content:Y()});var vV=class extends XR{name=`write`;displayName=`Write`;description=`Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.`;parameters=vCe;timeout(){return 3e5}concurrency(e,t){let n=e.filePath;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let{filePath:n}=e,r=!1,i;if(O.isAbsolute(n)){let a=dF(n,t.workspacePath);a.success?(n=a.relativePath,e.filePath=n):t.allowEditingPaths&&t.allowEditingPaths.length>0&&t.allowEditingPaths.some(e=>dF(n,e).success)||(r=!0,i=oF(n))}let a=!1,o=``;if(r){let e=i??n;try{o=await(await import(`node:fs/promises`)).default.readFile(e,`utf-8`),a=!0}catch{a=!1,o=``}}else try{o=await t.workspace.readRawFile(n),a=!0}catch{a=!1,o=``}return{fileExists:a,currentContent:o,outsideWorkspace:r,resolvedPath:i}}needsPermission(e,t,n){if(n?.skipPermission)return!1;if(t.agentMode===xd.PlanMode){let n=t.workspacePath,r=O.resolve(n,e.filePath),i=t.plansDir??O.join(te(),hn.configDirName,`plans`);if(uF(r,O.resolve(n,i)))return!1}return n?.outsideWorkspace?!0:t.agentMode!==xd.AcceptEdits}async execute(e,t,n){let{filePath:r,content:i}=e;if(_Ce.debug`Writing file: ${r} (${i.split(`
74901
74901
  `).length} lines)`,n?.error)return{type:`write`,filePath:r,lineCount:0,isNewFile:!1,error:n.error};let a=n?.fileExists||!1,o=n?.currentContent||``;a?o?await t.workspace.strReplace(r,o,i,1):(await t.workspace.deleteFile(r),await t.workspace.create(r,i)):await t.workspace.create(r,i);let s=i.split(`
74902
74902
  `).length;return i!==o&&t.onFileModified&&t.onFileModified({original:o,modified:i,filename:r,operation:a?`overwritten`:`created`,isNewFile:!a}),{type:`write`,filePath:r,lineCount:s,isNewFile:!a}}format(e){let t=e;return t.error?JSON.stringify({type:`write`,status:`error`,error:t.error}):t.isNewFile?`Created successfully`:`Updated successfully`}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`write`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return t.status===`error`||t.error?{phase:`error`,toolType:`write`,data:t,summary:t.error??`Error`,errorMessage:t.error}:{phase:`success`,toolType:`write`,data:t,summary:t.isNewFile?`Created`:`Updated`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`write`,data:{},summary:e,errorMessage:e}:e===`Created successfully`?{phase:`success`,toolType:`write`,data:{isNewFile:!0},summary:`Created`}:{phase:`success`,toolType:`write`,data:{},summary:`Updated`}}};const yCe=dt([`codellm`,`agent`,`tools`,`notebook-edit`]),bCe=QL({notebookPath:Y(),cellId:Y().optional(),newSource:Y(),cellType:sR([`code`,`markdown`]).optional(),editMode:sR([`replace`,`insert`,`delete`]).optional()});var yV=class extends XR{name=`notebook_edit`;displayName=`NotebookEdit`;description=`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.`;parameters=bCe;concurrency(e,t){let n=e.notebookPath;if(!n)return!0;let r=oF(n);return`fs:${O.isAbsolute(r)?r:O.resolve(t??``,r)}`}async prepare(e,t){let n=oF(e.notebookPath),r;if(r=O.isAbsolute(n)?n:O.resolve(t.workspacePath,n),O.extname(r).toLowerCase()!==`.ipynb`)return{skipPermission:!0,error:`File '${e.notebookPath}' is not a Jupyter notebook (.ipynb file).`};if((e.editMode??`replace`)===`insert`&&!e.cellType)return{skipPermission:!0,error:`cell_type is required when using edit_mode=insert.`};if(![t.workspacePath,...t.allowEditingPaths??[]].some(e=>uF(r,e))){try{await Te.access(r)}catch{return{skipPermission:!0,error:`File '${e.notebookPath}' does not exist.`}}try{let e=await Te.readFile(r,`utf-8`),t=JSON.parse(e);return Array.isArray(t.cells)?{filePath:r,notebook:t,outsideWorkspace:!0,resolvedPath:r}:{skipPermission:!0,error:`Invalid notebook: missing cells array.`}}catch(e){return{skipPermission:!0,error:`Failed to read notebook: ${e instanceof Error?e.message:`Unknown error`}`}}}try{let e=await Te.readFile(r,`utf-8`),t=JSON.parse(e);return Array.isArray(t.cells)?{filePath:r,notebook:t}:{skipPermission:!0,error:`Invalid notebook: missing cells array.`}}catch(e){return{skipPermission:!0,error:`Failed to read notebook: ${e instanceof Error?e.message:`Unknown error`}`}}}needsPermission(e,t,n){return n?.skipPermission?!1:n?.outsideWorkspace?!0:!(t.agentMode===xd.Yolo||t.agentMode===xd.AcceptEdits)}async execute(e,t,n){if(n?.error)throw Error(n.error);let r=n.filePath,i=n.notebook,a=e.editMode??`replace`,o=e.cellId;if(yCe.debug`Notebook edit: ${a} on ${O.basename(r)}${o?` cell=${o}`:``}`,a===`replace`){if(!o)throw Error(`cell_id is required for replace mode.`);let t=this.findCellIndex(i,o);if(t===-1)throw Error(`Cell with id '${o}' not found in notebook.`);i.cells[t].source=this.splitSource(e.newSource),e.cellType&&(i.cells[t].cell_type=e.cellType)}else if(a===`insert`){let t=this.createCell(e.cellType,e.newSource);if(o){let e=this.findCellIndex(i,o);if(e===-1)throw Error(`Cell with id '${o}' not found in notebook.`);i.cells.splice(e+1,0,t)}else i.cells.unshift(t)}else if(a===`delete`){if(!o)throw Error(`cell_id is required for delete mode.`);let e=this.findCellIndex(i,o);if(e===-1)throw Error(`Cell with id '${o}' not found in notebook.`);i.cells.splice(e,1)}await Te.writeFile(r,JSON.stringify(i,null,1)+`
74903
74903
  `,`utf-8`);let s={replace:`Replaced cell '${o}' in ${O.basename(r)}`,insert:o?`Inserted new cell after '${o}' in ${O.basename(r)}`:`Inserted new cell at the beginning of ${O.basename(r)}`,delete:`Deleted cell '${o}' from ${O.basename(r)}`};return{type:`notebook_edit`,notebookPath:e.notebookPath,message:s[a]??`Notebook edited`,editMode:a,cellId:o}}findCellIndex(e,t){return e.cells.findIndex(e=>e.id===t||e.metadata?.id===t)}splitSource(e){let t=e.split(`
@@ -74912,10 +74912,10 @@ The script returns JSON with error details:
74912
74912
  `).filter(e=>e&&!e.startsWith(`(Results are truncated`)).filter(e=>e.trim()),r=n.length===0?`No files found`:`${n.length} files`;return{phase:`success`,toolType:`glob`,data:{files:n},summary:r}}};dt([`codellm`,`agent`,`tools`,`web-search`]);const CCe=QL({searchTerm:Y().describe(`Search query for web search`),query:Y().optional().describe(`Alternative query parameter`),explanation:Y().optional().describe(`Explanation of why this search is needed`),allowedDomains:XL(Y()).optional().describe(`Only include results from these domains`),blockedDomains:XL(Y()).optional().describe(`Exclude results from these domains`)});var wV=class extends TR{name=`web_search`;displayName=`WebSearch`;description=`Search on the web`;parameters=CCe;isReadonly=!0;concurrency(e){return!0}format(e,t){return JSON.stringify({type:`web_search`,status:`success`})}parse(e){let t=xR(e);return t.rejected?{phase:`rejected`,toolType:`web_search`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}}:{phase:`success`,toolType:`web_search`,data:{},summary:`Found results`}}};dt([`codellm`,`agent`,`tools`,`web-fetch`]);const wCe=QL({url:Y().describe(`The URL to fetch content from`),prompt:Y().describe(`The prompt to run on the fetched content`)});var TV=class extends TR{name=`web_fetch`;displayName=`Fetch`;description=`Fetch content from a URL`;parameters=wCe;isReadonly=!0;concurrency(e){return!0}format(e,t){return JSON.stringify({type:`web_fetch`,status:`success`})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`web_fetch`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return t.status===`error`||t.error?{phase:`error`,toolType:`web_fetch`,data:t,summary:t.error??`Error`,errorMessage:t.error}:{phase:`success`,toolType:`web_fetch`,data:t,summary:`Fetched`}}catch{}let n=(e.length/1024).toFixed(1);return{phase:`success`,toolType:`web_fetch`,data:{content:e},summary:`Fetched ${n} KB`}}};function TCe(e){return e.trim()}const EV=dt([`codellm`,`agent`,`tools`,`bash`]);function DV(e){let t=3e4,n=TCe(e);if(n.length<=t)return n;let r=1;for(let e=0;e<n.length;e++)n[e]===`
74913
74913
  `&&r++;let i=n.substring(0,1e4),a=n.substring(n.length-2e4),o=1;for(let e=0;e<i.length;e++)i[e]===`
74914
74914
  `&&o++;let s=1;for(let e=0;e<a.length;e++)a[e]===`
74915
- `&&s++;return`${i}\n\n... [${r-(o+s)} lines / ${n.length-t} chars truncated] ...\n\n${a}`}var OV=class e extends XR{name=`bash`;displayName=`Bash`;description=`Run a command in a minified terminal. Creates a new terminal by default, unless an id is provided to use an existing terminal.`;static DEFAULT_TIMEOUT_MS=12e4;static MAX_TIMEOUT_MS=6e5;concurrency(e,t){let n=e.command;if(!n)return!1;let r=e.shellId===`new`?void 0:e.shellId;if(e.interactiveMode||r)return!1;try{return PF(n,t).concurrencyKey}catch{return!1}}static getAllowedWritePaths(e){if(e.agentMode===xd.PlanMode)return[e.plansDir??O.join(te(),hn.configDirName,`plans`)]}async prepare(t,n){let{command:r}=t;if(!r)return{analysis:null};try{let t=e.getAllowedWritePaths(n),i=PF(r,n.workspacePath,t?{allowedWritePaths:t}:void 0),a=i.overallMutability===`readonly`,o=i.commands.length>0&&i.commands.every(e=>e.isKnown);return{analysis:i,skipPermission:a&&o&&!i.requiresPermission}}catch{return{analysis:null}}}needsPermission(e,t,n){return n?.analysis?n.analysis.requiresPermission:!0}static Parameters=QL({command:Y().describe(`The command to execute`),explanation:Y().optional().describe(`Explanation of what the command does`),runInBackground:MR.describe(`Whether to run the command in the background`),shellId:vR().optional().describe(`Terminal ID to use (creates new if not provided)`),interactiveMode:MR.describe(`Whether to run in interactive mode`),timeout:yR().optional().describe(`Timeout in milliseconds (default: 120000, max: 600000)`)});parameters=e.Parameters;async execute(t,n,r){let{command:i,runInBackground:a,interactiveMode:o,timeout:s}=t,c=t.shellId===`new`?void 0:t.shellId;EV.debug(`Executing bash command: {cmd}{bg}{interactive}`,{cmd:i.slice(0,200),bg:a?` (background)`:``,interactive:o?` (interactive)`:``});let l=n.terminalService,u=s??e.DEFAULT_TIMEOUT_MS,d=Math.min(u,e.MAX_TIMEOUT_MS),f=n.onOutputUpdate,p=n.abortController?.signal,m=c?parseInt(c):void 0;if(o&&i===`/exit`)return m?(await l.closeTerminal?.(m),{type:`bash`,id:m,command:i,exitCode:0,output:`Terminal closed`,isError:!1,duration:0,runInBackground:!1,interactiveMode:!0,terminated:!0}):{type:`bash`,id:0,command:i,exitCode:1,output:`No terminal ID provided for /exit command`,isError:!0,duration:0,runInBackground:!1,interactiveMode:!0};if(o&&i===`/wait`)if(m){await VR(3e3);let e=l.getOutput(m);return{type:`bash`,id:m,command:i,exitCode:0,output:(e.length>0?e[e.length-1]:null)?.output??`No output available`,isError:!1,duration:3e3,runInBackground:!1,interactiveMode:!0,message:`Terminal state checked - ready for next command`}}else return{type:`bash`,id:0,command:i,exitCode:1,output:`No terminal ID provided for /wait command`,isError:!0,duration:0,runInBackground:!1,interactiveMode:!0};if(o){let e=await l.executeCommand(i,{terminalId:m,alwaysCreateNew:!c,interactiveMode:!0});await VR(3e3);let t=e.result.get(),n=t.output||``;return n=DV(n),{type:`bash`,id:t.id,command:t.command,exitCode:t.exitCode||0,output:n,isError:t.exitCode!==void 0&&t.exitCode!==0,duration:t.duration||0,runInBackground:!1,interactiveMode:!0,message:`Interactive command executed - terminal ready for next command`}}let h=await l.executeCommand(i,{terminalId:m,alwaysCreateNew:!c});if(a){let e=h.result.get();l.markAsBackground?.(e.id);let t=e.output||``;return t=DV(t),{type:`bash`,id:e.id,command:e.command,exitCode:e.exitCode||0,output:t,isError:!1,duration:e.duration||0,runInBackground:!0,message:`Background command started`}}if(h.running){let e=h.result.get().id,t;f&&(t=setInterval(()=>{try{let e=h.result.get();e&&e.output&&f(n.toolCallId,e.output)}catch{}},100));let r=[h.running],i,a=p?new Promise((e,t)=>{p.aborted?t(Error(`interrupted`)):(i=()=>t(Error(`interrupted`)),p.addEventListener(`abort`,i,{once:!0}))}):null;a&&r.push(a);let o=new Promise((e,t)=>{setTimeout(()=>{t(Error(`Terminal command timed out after ${d}ms`))},d)});r.push(o);try{try{await Promise.race(r)}catch(t){if(t instanceof Error&&t.message===`interrupted`){await l.stopCommand(e);let t=h.result.get();return{type:`bash`,id:t.id,command:t.command,exitCode:130,output:(t.output||``)+`
74916
- [Interrupted]`,isError:!0,duration:t.duration||0,runInBackground:!1,terminated:!0}}if(t instanceof Error&&t.message.includes(`timed out`)){let e=h.result.get();return l.markAsBackground?.(e.id),{type:`bash`,id:e.id,command:e.command,exitCode:0,output:`Command running in background with ID: ${e.id}`,isError:!1,duration:e.duration||0,runInBackground:!0,timedOut:!0}}throw t}}finally{t&&clearInterval(t),i&&p&&p.removeEventListener(`abort`,i)}}let g=h.result.get(),_=g.output||``;_=DV(_);let v=g.exitCode||0;return v===0?EV.debug(`Command completed successfully in {duration}ms`,{duration:g.duration||0}):EV.warn(`Command exited with code {exitCode}: {cmd}`,{exitCode:v,cmd:i.slice(0,100)}),{type:`bash`,id:g.id,command:g.command,exitCode:v,output:_,isError:g.exitCode!==void 0&&g.exitCode!==0,duration:g.duration||0,runInBackground:!1}}format(e,t){let n=e;return JSON.stringify({type:`bash`,status:n.isError?`error`:`success`,id:n.id,command:n.command,exitCode:n.exitCode,output:n.output,duration:n.duration,...n.runInBackground&&{runInBackground:!0},...n.terminated&&{terminated:!0},...n.timedOut&&{timedOut:!0},...n.interactiveMode&&{interactiveMode:!0}})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`bash`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.terminated)return{phase:`error`,toolType:`bash`,data:t,summary:`Terminated${t.duration==null?``:` \u00b7 ${(t.duration/1e3).toFixed(1)}s`}`,...t.exitCode!=null&&{exitCode:t.exitCode},...t.duration!=null&&{duration:t.duration}};if(t.timedOut)return{phase:`success`,toolType:`bash`,data:t,summary:`Running in background (id: ${t.id??`?`})`,runInBackground:!0};if(t.runInBackground)return{phase:`success`,toolType:`bash`,data:t,summary:`Started in background (id: ${t.id??`?`})`,runInBackground:!0};let n=t.exitCode??0,r=t.duration==null?``:` \u00b7 ${(t.duration/1e3).toFixed(1)}s`,i=n!==0||t.isError||t.status===`error`;return{phase:i?`error`:`success`,toolType:`bash`,data:t,summary:`exit ${n}${r}`,exitCode:n,...t.duration!=null&&{duration:t.duration},...i&&t.output&&{errorMessage:t.output.slice(-200)}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`bash`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`bash`,data:{},summary:`Completed`}}};const ECe=dt([`codellm`,`agent`,`tools`,`bash-output`]);var kV=class e extends pV{name=`bash_output`;displayName=`BashOutput`;description=`Get the output of a terminal command`;concurrency(e){return!0}static Parameters=QL({shellId:vR().describe(`Terminal ID to get output from`),filter:Y().optional().describe(`Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result.`)});parameters=e.Parameters;needsPermission(){return!1}_applyFilter(e,t){let n=new RegExp(t);return e.map(e=>({...e,output:(e.output??``).split(`
74915
+ `&&s++;return`${i}\n\n... [${r-(o+s)} lines / ${n.length-t} chars truncated] ...\n\n${a}`}var OV=class e extends XR{timeoutSessionByContext=new WeakMap;name=`bash`;displayName=`Bash`;description=`Run a command in a minified terminal. Creates a new terminal by default, unless an id is provided to use an existing terminal.`;static DEFAULT_TIMEOUT_MS=12e4;static MAX_TIMEOUT_MS=6e5;concurrency(e,t){let n=e.command;if(!n)return!1;let r=e.shellId===`new`?void 0:e.shellId;if(e.interactiveMode||r)return!1;try{return PF(n,t).concurrencyKey}catch{return!1}}static getAllowedWritePaths(e){if(e.agentMode===xd.PlanMode)return[e.plansDir??O.join(te(),hn.configDirName,`plans`)]}async prepare(t,n){let{command:r}=t;if(!r)return{analysis:null};try{let t=e.getAllowedWritePaths(n),i=PF(r,n.workspacePath,t?{allowedWritePaths:t}:void 0),a=i.overallMutability===`readonly`,o=i.commands.length>0&&i.commands.every(e=>e.isKnown);return{analysis:i,skipPermission:a&&o&&!i.requiresPermission}}catch{return{analysis:null}}}needsPermission(e,t,n){return n?.analysis?n.analysis.requiresPermission:!0}static Parameters=QL({command:Y().describe(`The command to execute`),explanation:Y().optional().describe(`Explanation of what the command does`),runInBackground:MR.describe(`Whether to run the command in the background`),shellId:vR().optional().describe(`Terminal ID to use (creates new if not provided)`),interactiveMode:MR.describe(`Whether to run in interactive mode`),timeout:yR().optional().describe(`Timeout in milliseconds (default: 120000, max: 600000)`)});parameters=e.Parameters;timeout(t,n){let r=t.timeout,i=typeof r==`number`&&Number.isFinite(r)&&r>0?r:e.DEFAULT_TIMEOUT_MS;return Math.min(i,e.MAX_TIMEOUT_MS)}async onTimeout(e,t,n){if(e.runInBackground)throw Error(`Bash background command timed out unexpectedly`);let r=this.timeoutSessionByContext.get(t);if(!r)throw Error(`Bash command timed out before terminal session was initialized`);this.timeoutSessionByContext.delete(t);let i=t.terminalService.getLiveOutput?.(r)??this.getLatestTerminalOutput(t,r);return t.terminalService.markAsBackground?.(r),i?{type:`bash`,id:i.id,command:i.command,exitCode:0,output:`Command running in background with ID: ${i.id}`,isError:!1,duration:i.duration||0,runInBackground:!0,timedOut:!0}:{type:`bash`,id:r,command:e.command,exitCode:0,output:`Command running in background with ID: ${r}`,isError:!1,duration:0,runInBackground:!0,timedOut:!0}}getLatestTerminalOutput(e,t){let n=e.terminalService.getOutput(t);return n.length>0?n[n.length-1]:null}async execute(e,t,n){let{command:r,runInBackground:i,interactiveMode:a}=e;if(t.abortController?.signal.aborted)throw t.abortController.signal.reason===`tool_timeout`?Error(`tool_timeout`):Error(`interrupted`);this.timeoutSessionByContext.delete(t);let o=e.shellId===`new`?void 0:e.shellId;EV.debug(`Executing bash command: {cmd}{bg}{interactive}`,{cmd:r.slice(0,200),bg:i?` (background)`:``,interactive:a?` (interactive)`:``});let s=t.terminalService,c=t.onOutputUpdate,l=t.abortController?.signal,u=o?parseInt(o):void 0;if(a&&r===`/exit`)return u?(await s.closeTerminal?.(u),{type:`bash`,id:u,command:r,exitCode:0,output:`Terminal closed`,isError:!1,duration:0,runInBackground:!1,interactiveMode:!0,terminated:!0}):{type:`bash`,id:0,command:r,exitCode:1,output:`No terminal ID provided for /exit command`,isError:!0,duration:0,runInBackground:!1,interactiveMode:!0};if(a&&r===`/wait`)if(u){await VR(3e3);let e=s.getOutput(u);return{type:`bash`,id:u,command:r,exitCode:0,output:(e.length>0?e[e.length-1]:null)?.output??`No output available`,isError:!1,duration:3e3,runInBackground:!1,interactiveMode:!0,message:`Terminal state checked - ready for next command`}}else return{type:`bash`,id:0,command:r,exitCode:1,output:`No terminal ID provided for /wait command`,isError:!0,duration:0,runInBackground:!1,interactiveMode:!0};if(a){let e=await s.executeCommand(r,{terminalId:u,alwaysCreateNew:!o,interactiveMode:!0});this.timeoutSessionByContext.set(t,e.result.get().id);try{await VR(3e3);let t=e.result.get(),n=t.output||``;return n=DV(n),{type:`bash`,id:t.id,command:t.command,exitCode:t.exitCode||0,output:n,isError:t.exitCode!==void 0&&t.exitCode!==0,duration:t.duration||0,runInBackground:!1,interactiveMode:!0,message:`Interactive command executed - terminal ready for next command`}}finally{this.timeoutSessionByContext.delete(t)}}let d=await s.executeCommand(r,{terminalId:u,alwaysCreateNew:!o});this.timeoutSessionByContext.set(t,d.result.get().id);try{if(i){let e=d.result.get();s.markAsBackground?.(e.id);let t=e.output||``;return t=DV(t),{type:`bash`,id:e.id,command:e.command,exitCode:e.exitCode||0,output:t,isError:!1,duration:e.duration||0,runInBackground:!0,message:`Background command started`}}if(d.running){let e=d.result.get().id,n;c&&(n=setInterval(()=>{try{let e=d.result.get();e&&e.output&&c(t.toolCallId,e.output)}catch{}},100));let r=[d.running],i,a=l?new Promise((e,t)=>{l.aborted?l.reason===`tool_timeout`?t(Error(`tool_timeout`)):t(Error(`interrupted`)):(i=()=>{if(l.reason===`tool_timeout`){t(Error(`tool_timeout`));return}t(Error(`interrupted`))},l.addEventListener(`abort`,i,{once:!0}))}):null;a&&r.push(a);try{try{await Promise.race(r)}catch(t){if(t instanceof Error&&t.message===`tool_timeout`)throw t;if(t instanceof Error&&t.message===`interrupted`){await s.stopCommand(e);let t=d.result.get();return{type:`bash`,id:t.id,command:t.command,exitCode:130,output:(t.output||``)+`
74916
+ [Interrupted]`,isError:!0,duration:t.duration||0,runInBackground:!1,terminated:!0}}throw t}}finally{n&&clearInterval(n),i&&l&&l.removeEventListener(`abort`,i)}}let e=d.result.get(),n=e.output||``;n=DV(n);let a=e.exitCode||0;return a===0?EV.debug(`Command completed successfully in {duration}ms`,{duration:e.duration||0}):EV.warn(`Command exited with code {exitCode}: {cmd}`,{exitCode:a,cmd:r.slice(0,100)}),{type:`bash`,id:e.id,command:e.command,exitCode:a,output:n,isError:e.exitCode!==void 0&&e.exitCode!==0,duration:e.duration||0,runInBackground:!1}}finally{this.timeoutSessionByContext.delete(t)}}format(e,t){let n=e;return JSON.stringify({type:`bash`,status:n.isError?`error`:`success`,id:n.id,command:n.command,exitCode:n.exitCode,output:n.output,duration:n.duration,...n.runInBackground&&{runInBackground:!0},...n.terminated&&{terminated:!0},...n.timedOut&&{timedOut:!0},...n.interactiveMode&&{interactiveMode:!0}})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`bash`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);if(t.terminated)return{phase:`error`,toolType:`bash`,data:t,summary:`Terminated${t.duration==null?``:` \u00b7 ${(t.duration/1e3).toFixed(1)}s`}`,...t.exitCode!=null&&{exitCode:t.exitCode},...t.duration!=null&&{duration:t.duration}};if(t.timedOut)return{phase:`success`,toolType:`bash`,data:t,summary:`Running in background (id: ${t.id??`?`})`,runInBackground:!0};if(t.runInBackground)return{phase:`success`,toolType:`bash`,data:t,summary:`Started in background (id: ${t.id??`?`})`,runInBackground:!0};let n=t.exitCode??0,r=t.duration==null?``:` \u00b7 ${(t.duration/1e3).toFixed(1)}s`,i=n!==0||t.isError||t.status===`error`;return{phase:i?`error`:`success`,toolType:`bash`,data:t,summary:`exit ${n}${r}`,exitCode:n,...t.duration!=null&&{duration:t.duration},...i&&t.output&&{errorMessage:t.output.slice(-200)}}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`bash`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`bash`,data:{},summary:`Completed`}}};const ECe=dt([`codellm`,`agent`,`tools`,`bash-output`]);var kV=class e extends pV{name=`bash_output`;displayName=`BashOutput`;description=`Get the output of a terminal command`;concurrency(e){return!0}static Parameters=QL({shellId:vR().describe(`Terminal ID to get output from`),filter:Y().optional().describe(`Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result.`)});parameters=e.Parameters;needsPermission(){return!1}_applyFilter(e,t){let n=new RegExp(t);return e.map(e=>({...e,output:(e.output??``).split(`
74917
74917
  `).filter(e=>n.test(e)).join(`
74918
- `)}))}async execute(e,t){let{shellId:n,filter:r}=e;if(ECe.debug`Getting output for shell ${n}${r?` with filter: ${r}`:``}`,!n)throw Error(`shellId parameter is required for bash_output`);let i=t.terminalService,a=parseInt(n),o=i.getLiveOutput?.(a);if(o){let e=[o];return r&&(e=this._applyFilter(e,r)),{type:`bash_output`,terminalId:n,outputs:e,totalOutputs:1}}let s=i.getOutput(a);return r&&(s=this._applyFilter(s,r)),{type:`bash_output`,terminalId:n,outputs:s,totalOutputs:s.length}}format(e,t){return JSON.stringify({...e,status:`success`})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`bash_output`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`bash_output`,data:t,summary:`Retrieved ${t.totalOutputs??t.outputs?.length??0} lines`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`bash_output`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`bash_output`,data:{},summary:`Retrieved`}}};const DCe=dt([`codellm`,`agent`,`tools`,`kill-shell`]);var AV=class e extends XR{name=`kill_shell`;displayName=`KillShell`;description=`Kills a running background bash shell by its ID. Use this tool when you need to terminate a long-running shell. Shell IDs can be found using the /tasks command.`;static Parameters=QL({shellId:vR().describe(`The ID of the background shell to kill`)});parameters=e.Parameters;async execute(e,t){let{shellId:n}=e;if(DCe.debug`Killing shell ${n}`,!n)throw Error(`shellId parameter is required for kill_shell`);let r=t.terminalService,i=parseInt(n),a=await r.stopCommand(i);return r.closeTerminal&&await r.closeTerminal(i),{type:`kill_shell`,shellId:n,success:a}}format(e,t){return JSON.stringify({...e,status:e.success?`success`:`failure`})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`kill_shell`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:t.success?`success`:`error`,toolType:`kill_shell`,data:t,summary:t.success?`Killed shell ${t.shellId}`:`Failed to kill shell ${t.shellId}`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`kill_shell`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`kill_shell`,data:{},summary:`Shell killed`}}},OCe=class{tool;context;params;_prepareResult=null;_executionResult=null;constructor(e,t,n){this.tool=e,this.params=t,this.context=n}getTool(){return this.tool}getParams(){return this.params}mergeParams(e){this.params={...this.params,...e}}getContext(){return this.context}getPrepareResult(){return this._prepareResult}getExecutionResult(){return this._executionResult}async prepare(){return this._prepareResult=await this.tool.prepare(this.params,this.context),this._prepareResult}needsPermission(){return this._prepareResult?.skipPermission?!1:this.tool.needsPermission(this.params,this.context,this._prepareResult)}async execute(){return Al(`tool: ${this.tool.name}`,`tools`),this._executionResult=await this.tool.execute(this.params,this.context,this._prepareResult),this._executionResult}formatResult(){if(this._executionResult===null)throw Error(`Cannot format result before execution completes`);return this.tool.format(this._executionResult,this.params)}formatResultForLLM(){if(this._executionResult===null)throw Error(`Cannot format result before execution completes`);return this.tool.formatForLLM(this._executionResult,this.params)}async executeWithPermission(e){if(await this.prepare(),this.needsPermission()){if(!e)throw Error(`Permission check required but no permission callback provided`);if(!await e())throw Error(`Permission denied`)}return await this.execute(),this.formatResult()}},jV=class{tools;context;_disabledTools;constructor(){this.tools=new Map,this._disabledTools=new Set}setDisabledTools(e){this._disabledTools=new Set(e)}isDisabled(e){return this._disabledTools.has(e)}register(e){if(this.tools.has(e.name))throw Error(`Tool '${e.name}' is already registered`);this.tools.set(e.name,e)}registerAll(e){for(let t of e)this.register(t)}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}getAllTools(){return Array.from(this.tools.values())}setContext(e){this.context=e}getApiToolDefinitions(e){let t=e??this.context;return Array.from(this.tools.values()).filter(e=>e.includeInApiDefinitions).filter(e=>!this._disabledTools.has(e.name)).filter(e=>!t||e.isEnabled(t)).map(e=>e.getToolDefinition())}getMcpToolDefinitions(){return Array.from(this.tools.values()).filter(e=>!e.includeInApiDefinitions).map(e=>e.getToolDefinition())}getReadonlyToolDefinitions(e){return Array.from(this.tools.values()).filter(e=>e.isReadonly&&e.includeInApiDefinitions).filter(e=>!this._disabledTools.has(e.name)).filter(t=>!e||t.isEnabled(e)).map(e=>e.getToolDefinition())}registerMCPTools(e){let t=Array.from(this.tools.entries()).filter(([e,t])=>!t.includeInApiDefinitions).map(([e,t])=>e);for(let e of t)this.tools.delete(e);this.registerAll(e)}createToolInstance(e,t,n){let r=this.get(e);if(!r)throw Error(`Tool '${e}' is not registered`);return new OCe(r,r.validateParams(t),n)}isBuiltinTool(e){let t=this.get(e);return t?t.includeInApiDefinitions:!1}isBuiltinRequest(e){return this.isBuiltinTool(e.name)}unregister(e){return this.tools.delete(e)}parse(e,t){if(exe(t))return{phase:`sibling_failed`,toolType:e,data:{},summary:`Not executed — a sibling tool call in a preceding parallel batch failed`,errorMessage:`Sibling tool call failed`};let n=this.tools.get(e);return n?n.parse(t):this._genericParse(e,t)}_genericParse(e,t){let n=xR(t);if(n.rejected)return{phase:`rejected`,toolType:e,data:{},summary:n.userNote?`Rejected \u00b7 "${n.userNote}"`:`Rejected`,...n.userNote!==void 0&&{userNote:n.userNote}};try{let n=JSON.parse(t),r=`success`;return n.status===`error`?r=`error`:n.status===`skipped`&&(r=`skipped`),{phase:r,toolType:n.type??e,data:n,summary:n.message??n.summary??`Completed`,...n.errorMessage!==void 0&&{errorMessage:n.errorMessage}}}catch{}return t.startsWith(`Error:`)?{phase:`error`,toolType:e,data:{},summary:t,errorMessage:t}:{phase:`success`,toolType:e,data:{},summary:`Completed`}}clear(){this.tools.clear()}};const MV=new jV;MV.register(new $R),MV.register(new iz),MV.register(new gV),MV.register(new vV),MV.register(new yV),MV.register(new xV),MV.register(new CV),MV.register(new wV),MV.register(new TV),MV.register(new OV),MV.register(new kV),MV.register(new AV),MV.register(new ER),MV.register(new DR),MV.register(new NR),MV.register(new PR),MV.register(new FR),MV.register(new YR);function NV(){let e=new jV;return e.register(new $R),e.register(new iz),e.register(new gV),e.register(new vV),e.register(new yV),e.register(new xV),e.register(new CV),e.register(new wV),e.register(new TV),e.register(new OV),e.register(new kV),e.register(new AV),e.register(new ER),e.register(new DR),e.register(new NR),e.register(new PR),e.register(new FR),e.register(new YR),e}function PV(e){let t=e.indexOf(`(`);if(t===-1)return{displayName:e,pattern:null};let n=e.slice(0,t),r=e.lastIndexOf(`)`);if(r===-1||r<=t)return{displayName:e,pattern:``};let i=e.slice(t+1,r).trim();return i===``||i===`*`?{displayName:n,pattern:null}:{displayName:n,pattern:i}}function FV(e,t,n){return e.displayName===t?e.pattern===null?!0:t===`Bash`?ACe(e.pattern,n):e.pattern.startsWith(`domain:`)||e.pattern.startsWith(`//`)||e.pattern.startsWith(`~/`)||kCe(t)?RCe(e.pattern,n):BV(n,e.pattern):!1}function kCe(e){return[`Edit`,`Read`,`Delete`,`LS`,`Upload`].includes(e)}function ACe(e,t){let n=nF(t),r=n[0]?.trim();return r?n.length>1?n.every(t=>IV(e,t)):BV(r,e):!1}function IV(e,t){let n=t.trim();if(!n)return!1;let r=jCe(e,n);return r===null?BV(n,e):r}function jCe(e,t){let n=LV(e),r=LV(t);if(!n||!r)return null;if(n.command!==r.command)return!1;let i=PCe(n.target);if(!i&&FCe(n.target))return null;let a=RV(r.target);if(i){let e=RV(i);return a&&e?LCe(a,e):BV(r.target,n.target)}let o=RV(n.target);return o&&a?zV(o)===zV(a):BV(r.target,n.target)}function LV(e){let t=e.trim().match(/^(?:builtin\s+)?(cd|pushd)\b\s*(.*)$/i);if(!t)return null;let n=t[1].toLowerCase(),r=t[2]?.trim()??``;if(!r)return{command:n,target:`~`};let i=MCe(r);return!i||i===`-`?null:{command:n,target:i}}function MCe(e){let t=!1,n=!1,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];if(r){i+=o,r=!1;continue}if(!t&&o===`\\`){r=!0,i+=o;continue}if(!n&&o===`'`){t=!t,i+=o;continue}if(!t&&o===`"`){n=!n,i+=o;continue}if(!t&&!n&&/\s/.test(o))break;i+=o}return NCe(i.trim())}function NCe(e){return e&&((e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))&&(e=e.slice(1,-1)),e.replace(/\\([\\\s"'])/g,`$1`))}function PCe(e){return e===`*`||e===`**`?`.`:e.endsWith(`/**`)?e.slice(0,-3):e.endsWith(`/*`)?e.slice(0,-2):null}function FCe(e){return/[*?\[]/.test(e)}function RV(e){if(!e)return null;let t=oF(e);if(!O.isAbsolute(t))return null;let n=cF(t);return ICe(O.normalize(n))}function ICe(e){let t=O.normalize(e);return t===O.parse(t).root?t:t.replace(/[\\/]+$/g,``)}function zV(e){return process.platform===`win32`?e.toLowerCase():e}function LCe(e,t){if(zV(e)===zV(t))return!0;let n=O.relative(t,e);return!!n&&!n.startsWith(`..`)&&!O.isAbsolute(n)}function BV(e,t){let n=`^`,r=0;for(;r<t.length;){let e=t[r];e===`*`?t[r+1]===`*`?(n+=`.*`,r+=2):(n+=`.*`,r++):e===`?`?(n+=`.`,r++):(n+=e.replace(/[.+^${}()|\\[\]]/g,`\\$&`),r++)}n+=`$`;try{return new RegExp(n).test(e)}catch{return e===t}}function RCe(e,t){let n=e;n=n.replace(/\\/g,`/`);let r=t.replace(/\\/g,`/`);if(n.startsWith(`//`)){let e=n.slice(2);n=/^[A-Za-z]:/.test(e)?e:`/`+e}if(n.startsWith(`~/`)&&(n=oF(n).replace(/\\/g,`/`)),n.startsWith(`domain:`)){let e=n.slice(7);try{let t=new URL(r);return t.hostname===e||t.hostname.endsWith(`.`+e)}catch{return r.includes(e)}}return zCe(r,n)}function zCe(e,t){let n=`^`,r=0;for(;r<t.length;){let e=t[r];if(e===`*`)t[r+1]===`*`?t[r+2]===`/`?(n+=`(?:.*/)?`,r+=3):(n+=`.*`,r+=2):(n+=`[^/]*`,r++);else if(e===`?`)n+=`[^/]`,r++;else if(e===`[`){let e=t.indexOf(`]`,r);e===-1?(n+=`\\[`,r++):(n+=t.slice(r,e+1),r=e+1)}else n+=e.replace(/[.+^${}()|\\]/g,`\\$&`),r++}n+=`$`;try{return new RegExp(n).test(e)}catch{return e===t}}function VV(e,t){let n=typeof e==`string`?{id:``,type:``,name:e,input:t??{}}:e;if(!MV.isBuiltinRequest(n)){for(let e of Object.values(n.input))if(typeof e==`string`)return e;return``}switch(n.name){case`edit`:return n.input.filePath??``;case`read`:return n.input.filePath??``;case`write`:return n.input.filePath??``;case`bash`:return n.input.command??``;case`navigate_to`:case`new_tab`:case`web_fetch`:return n.input.url??``;case`web_search`:return n.input.searchTerm??``;case`grep`:return n.input.pattern??``;default:return``}}const HV=dt([`codellm`,`agent`,`permissions`]);var BCe=class{denyRules;askRules;allowRules;constructor(e){let{rules:t,cliAllowed:n,cliDenied:r}=e;this.denyRules=[...(t.deny??[]).map(PV),...(r??[]).map(PV)],this.askRules=(t.ask??[]).map(PV),this.allowRules=[...(t.allow??[]).map(PV),...(n??[]).map(PV)]}evaluate(e,t){if(e===`Bash`){let n=nF(t);if(n.length>1){let t=this.evaluateBashCompound(n);return HV.debug`permission: ${e} decision=${t}`,t}}for(let n of this.denyRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=deny`,`deny`;for(let n of this.askRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=ask`,`ask`;for(let n of this.allowRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=allow`,`allow`;return null}evaluateBashCompound(e){let t=`allow`;for(let n of e){let e=n.trim();if(!e)continue;let r=this.evaluateSingleBashSegment(e);if(r===`deny`)return`deny`;r===`ask`&&(t=`ask`),r===null&&t!==`ask`&&(t=null)}return t}evaluateSingleBashSegment(e){for(let t of this.denyRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`deny`;for(let t of this.askRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`ask`;for(let t of this.allowRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`allow`;return null}getUnmatchedBashSegments(e,t){let n=nF(e),r=[];for(let e of n){let n=e.trim();if(!n)continue;let i=this.evaluateSingleBashSegment(n);if(i!==`allow`){if(i===null){let e=EF(OF(n),t);if(e.isKnown&&!e.requiresPermission)continue}r.push(FF(n))}}return[...new Set(r)]}addAllowRule(e){this.allowRules.push(PV(e))}addDenyRule(e){this.denyRules.push(PV(e))}addAskRule(e){this.askRules.push(PV(e))}getAllowRules(){return this.allowRules.map(e=>e.pattern===null?e.displayName:`${e.displayName}(${e.pattern})`)}},UV=G(((e,t)=>{let n=`[^\\\\/]`,r=`[^/]`,i=`(?:\\/|$)`,a=`(?:^|\\/)`,o=`\\.{1,2}${i}`,s={DOT_LITERAL:`\\.`,PLUS_LITERAL:`\\+`,QMARK_LITERAL:`\\?`,SLASH_LITERAL:`\\/`,ONE_CHAR:`(?=.)`,QMARK:r,END_ANCHOR:i,DOTS_SLASH:o,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!${a}${o})`,NO_DOT_SLASH:`(?!\\.{0,1}${i})`,NO_DOTS_SLASH:`(?!${o})`,QMARK_NO_DOT:`[^.\\/]`,STAR:`${r}*?`,START_ANCHOR:a,SEP:`/`},c={...s,SLASH_LITERAL:`[\\\\/]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`\\.{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!\\.{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!\\.{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:`[^.\\\\/]`,START_ANCHOR:`(?:^|[\\\\/])`,END_ANCHOR:`(?:[\\\\/]|$)`,SEP:`\\`};t.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:{alnum:`a-zA-Z0-9`,alpha:`a-zA-Z`,ascii:`\\x00-\\x7F`,blank:` \\t`,cntrl:`\\x00-\\x1F\\x7F`,digit:`0-9`,graph:`\\x21-\\x7E`,lower:`a-z`,print:`\\x20-\\x7E `,punct:`\\-!"#$%&'()\\*+,./:;<=>?@[\\]^_\`{|}~`,space:` \\t\\r\\n\\v\\f`,upper:`A-Z`,word:`A-Za-z0-9_`,xdigit:`A-Fa-f0-9`},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":`*`,"**/**":`**`,"**/**/**":`**`},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:`negate`,open:`(?:(?!(?:`,close:`))${e.STAR})`},"?":{type:`qmark`,open:`(?:`,close:`)?`},"+":{type:`plus`,open:`(?:`,close:`)+`},"*":{type:`star`,open:`(?:`,close:`)*`},"@":{type:`at`,open:`(?:`,close:`)`}}},globChars(e){return e===!0?c:s}}})),WV=G((e=>{let{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:r,REGEX_SPECIAL_CHARS_GLOBAL:i}=UV();e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e),e.hasRegexChars=e=>r.test(e),e.isRegexChar=t=>t.length===1&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(i,`\\$1`),e.toPosixSlashes=e=>e.replace(t,`/`),e.isWindows=()=>{if(typeof navigator<`u`&&navigator.platform){let e=navigator.platform.toLowerCase();return e===`win32`||e===`windows`}return typeof process<`u`&&process.platform?process.platform===`win32`:!1},e.removeBackslashes=e=>e.replace(n,e=>e===`\\`?``:e),e.escapeLast=(t,n,r)=>{let i=t.lastIndexOf(n,r);return i===-1?t:t[i-1]===`\\`?e.escapeLast(t,n,i-1):`${t.slice(0,i)}\\${t.slice(i)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith(`./`)&&(n=n.slice(2),t.prefix=`./`),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?``:`^`}(?:${e})${n.contains?``:`$`}`;return t.negated===!0&&(r=`(?:^(?!${r}).*$)`),r},e.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:`/`),r=n[n.length-1];return r===``?n[n.length-2]:r}})),VCe=G(((e,t)=>{let n=WV(),{CHAR_ASTERISK:r,CHAR_AT:i,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:l,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:d,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:p,CHAR_QUESTION_MARK:m,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:g,CHAR_RIGHT_SQUARE_BRACKET:_}=UV(),v=e=>e===l||e===a,y=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let b=t||{},x=e.length-1,S=b.parts===!0||b.scanToEnd===!0,C=[],w=[],T=[],E=e,D=-1,O=0,k=0,A=!1,j=!1,M=!1,N=!1,P=!1,ee=!1,F=!1,te=!1,I=!1,L=!1,R=0,z,ne,re={value:``,depth:0,isGlob:!1},ie=()=>D>=x,ae=()=>E.charCodeAt(D+1),oe=()=>(z=ne,E.charCodeAt(++D));for(;D<x;){ne=oe();let e;if(ne===a){F=re.backslashes=!0,ne=oe(),ne===u&&(ee=!0);continue}if(ee===!0||ne===u){for(R++;ie()!==!0&&(ne=oe());){if(ne===a){F=re.backslashes=!0,oe();continue}if(ne===u){R++;continue}if(ee!==!0&&ne===s&&(ne=oe())===s){if(A=re.isBrace=!0,M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ee!==!0&&ne===o){if(A=re.isBrace=!0,M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===h&&(R--,R===0)){ee=!1,A=re.isBrace=!0,L=!0;break}}if(S===!0)continue;break}if(ne===l){if(C.push(D),w.push(re),re={value:``,depth:0,isGlob:!1},L===!0)continue;if(z===s&&D===O+1){O+=2;continue}k=D+1;continue}if(b.noext!==!0&&(ne===p||ne===i||ne===r||ne===m||ne===c)&&ae()===d){if(M=re.isGlob=!0,N=re.isExtglob=!0,L=!0,ne===c&&D===O&&(I=!0),S===!0){for(;ie()!==!0&&(ne=oe());){if(ne===a){F=re.backslashes=!0,ne=oe();continue}if(ne===g){M=re.isGlob=!0,L=!0;break}}continue}break}if(ne===r){if(z===r&&(P=re.isGlobstar=!0),M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===m){if(M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===f){for(;ie()!==!0&&(e=oe());){if(e===a){F=re.backslashes=!0,oe();continue}if(e===_){j=re.isBracket=!0,M=re.isGlob=!0,L=!0;break}}if(S===!0)continue;break}if(b.nonegate!==!0&&ne===c&&D===O){te=re.negated=!0,O++;continue}if(b.noparen!==!0&&ne===d){if(M=re.isGlob=!0,S===!0){for(;ie()!==!0&&(ne=oe());){if(ne===d){F=re.backslashes=!0,ne=oe();continue}if(ne===g){L=!0;break}}continue}break}if(M===!0){if(L=!0,S===!0)continue;break}}b.noext===!0&&(N=!1,M=!1);let se=E,ce=``,le=``;O>0&&(ce=E.slice(0,O),E=E.slice(O),k-=O),se&&M===!0&&k>0?(se=E.slice(0,k),le=E.slice(k)):M===!0?(se=``,le=E):se=E,se&&se!==``&&se!==`/`&&se!==E&&v(se.charCodeAt(se.length-1))&&(se=se.slice(0,-1)),b.unescape===!0&&(le&&=n.removeBackslashes(le),se&&F===!0&&(se=n.removeBackslashes(se)));let ue={prefix:ce,input:e,start:O,base:se,glob:le,isBrace:A,isBracket:j,isGlob:M,isExtglob:N,isGlobstar:P,negated:te,negatedExtglob:I};if(b.tokens===!0&&(ue.maxDepth=0,v(ne)||w.push(re),ue.tokens=w),b.parts===!0||b.tokens===!0){let t;for(let n=0;n<C.length;n++){let r=t?t+1:O,i=C[n],a=e.slice(r,i);b.tokens&&(n===0&&O!==0?(w[n].isPrefix=!0,w[n].value=ce):w[n].value=a,y(w[n]),ue.maxDepth+=w[n].depth),(n!==0||a!==``)&&T.push(a),t=i}if(t&&t+1<e.length){let n=e.slice(t+1);T.push(n),b.tokens&&(w[w.length-1].value=n,y(w[w.length-1]),ue.maxDepth+=w[w.length-1].depth)}ue.slashes=C,ue.parts=T}return ue}})),HCe=G(((e,t)=>{let n=UV(),r=WV(),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:c}=n,l=(e,t)=>{if(typeof t.expandRange==`function`)return t.expandRange(...e,t);e.sort();let n=`[${e.join(`-`)}]`;try{new RegExp(n)}catch{return e.map(e=>r.escapeRegex(e)).join(`..`)}return n},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,d=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected a string`);e=c[e]||e;let f={...t},p=typeof f.maxLength==`number`?Math.min(i,f.maxLength):i,m=e.length;if(m>p)throw SyntaxError(`Input length: ${m}, exceeds maximum allowed length: ${p}`);let h={type:`bos`,value:``,output:f.prepend||``},g=[h],_=f.capture?``:`?:`,v=n.globChars(f.windows),y=n.extglobChars(v),{DOT_LITERAL:b,PLUS_LITERAL:x,SLASH_LITERAL:S,ONE_CHAR:C,DOTS_SLASH:w,NO_DOT:T,NO_DOT_SLASH:E,NO_DOTS_SLASH:D,QMARK:O,QMARK_NO_DOT:k,STAR:A,START_ANCHOR:j}=v,M=e=>`(${_}(?:(?!${j}${e.dot?w:b}).)*?)`,N=f.dot?``:T,P=f.dot?O:k,ee=f.bash===!0?M(f):A;f.capture&&(ee=`(${ee})`),typeof f.noext==`boolean`&&(f.noextglob=f.noext);let F={input:e,index:-1,start:0,dot:f.dot===!0,consumed:``,output:``,prefix:``,backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:g};e=r.removePrefix(e,F),m=e.length;let te=[],I=[],L=[],R=h,z,ne=()=>F.index===m-1,re=F.peek=(t=1)=>e[F.index+t],ie=F.advance=()=>e[++F.index]||``,ae=()=>e.slice(F.index+1),oe=(e=``,t=0)=>{F.consumed+=e,F.index+=t},se=e=>{F.output+=e.output==null?e.value:e.output,oe(e.value)},ce=()=>{let e=1;for(;re()===`!`&&(re(2)!==`(`||re(3)===`?`);)ie(),F.start++,e++;return e%2==0?!1:(F.negated=!0,F.start++,!0)},le=e=>{F[e]++,L.push(e)},ue=e=>{F[e]--,L.pop()},de=e=>{if(R.type===`globstar`){let t=F.braces>0&&(e.type===`comma`||e.type===`brace`),n=e.extglob===!0||te.length&&(e.type===`pipe`||e.type===`paren`);e.type!==`slash`&&e.type!==`paren`&&!t&&!n&&(F.output=F.output.slice(0,-R.output.length),R.type=`star`,R.value=`*`,R.output=ee,F.output+=R.output)}if(te.length&&e.type!==`paren`&&(te[te.length-1].inner+=e.value),(e.value||e.output)&&se(e),R&&R.type===`text`&&e.type===`text`){R.output=(R.output||R.value)+e.value,R.value+=e.value;return}e.prev=R,g.push(e),R=e},fe=(e,t)=>{let n={...y[t],conditions:1,inner:``};n.prev=R,n.parens=F.parens,n.output=F.output;let r=(f.capture?`(`:``)+n.open;le(`parens`),de({type:e,value:t,output:F.output?``:C}),de({type:`paren`,extglob:!0,value:ie(),output:r}),te.push(n)},B=e=>{let n=e.close+(f.capture?`)`:``),r;if(e.type===`negate`){let i=ee;e.inner&&e.inner.length>1&&e.inner.includes(`/`)&&(i=M(f)),(i!==ee||ne()||/^\)+$/.test(ae()))&&(n=e.close=`)$))${i}`),e.inner.includes(`*`)&&(r=ae())&&/^\.[^\\/.]+$/.test(r)&&(n=e.close=`)${d(r,{...t,fastpaths:!1}).output})${i})`),e.prev.type===`bos`&&(F.negatedExtglob=!0)}de({type:`paren`,extglob:!0,value:z,output:n}),ue(`parens`)};if(f.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let n=!1,i=e.replace(s,(e,t,r,i,a,o)=>i===`\\`?(n=!0,e):i===`?`?t?t+i+(a?O.repeat(a.length):``):o===0?P+(a?O.repeat(a.length):``):O.repeat(r.length):i===`.`?b.repeat(r.length):i===`*`?t?t+i+(a?ee:``):ee:t?e:`\\${e}`);return n===!0&&(i=f.unescape===!0?i.replace(/\\/g,``):i.replace(/\\+/g,e=>e.length%2==0?`\\\\`:e?`\\`:``)),i===e&&f.contains===!0?(F.output=e,F):(F.output=r.wrapOutput(i,F,t),F)}for(;!ne();){if(z=ie(),z===`\0`)continue;if(z===`\\`){let e=re();if(e===`/`&&f.bash!==!0||e===`.`||e===`;`)continue;if(!e){z+=`\\`,de({type:`text`,value:z});continue}let t=/^\\+/.exec(ae()),n=0;if(t&&t[0].length>2&&(n=t[0].length,F.index+=n,n%2!=0&&(z+=`\\`)),f.unescape===!0?z=ie():z+=ie(),F.brackets===0){de({type:`text`,value:z});continue}}if(F.brackets>0&&(z!==`]`||R.value===`[`||R.value===`[^`)){if(f.posix!==!1&&z===`:`){let e=R.value.slice(1);if(e.includes(`[`)&&(R.posix=!0,e.includes(`:`))){let e=R.value.lastIndexOf(`[`),t=R.value.slice(0,e),n=a[R.value.slice(e+2)];if(n){R.value=t+n,F.backtrack=!0,ie(),!h.output&&g.indexOf(R)===1&&(h.output=C);continue}}}(z===`[`&&re()!==`:`||z===`-`&&re()===`]`)&&(z=`\\${z}`),z===`]`&&(R.value===`[`||R.value===`[^`)&&(z=`\\${z}`),f.posix===!0&&z===`!`&&R.value===`[`&&(z=`^`),R.value+=z,se({value:z});continue}if(F.quotes===1&&z!==`"`){z=r.escapeRegex(z),R.value+=z,se({value:z});continue}if(z===`"`){F.quotes=F.quotes===1?0:1,f.keepQuotes===!0&&de({type:`text`,value:z});continue}if(z===`(`){le(`parens`),de({type:`paren`,value:z});continue}if(z===`)`){if(F.parens===0&&f.strictBrackets===!0)throw SyntaxError(u(`opening`,`(`));let e=te[te.length-1];if(e&&F.parens===e.parens+1){B(te.pop());continue}de({type:`paren`,value:z,output:F.parens?`)`:`\\)`}),ue(`parens`);continue}if(z===`[`){if(f.nobracket===!0||!ae().includes(`]`)){if(f.nobracket!==!0&&f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));z=`\\${z}`}else le(`brackets`);de({type:`bracket`,value:z});continue}if(z===`]`){if(f.nobracket===!0||R&&R.type===`bracket`&&R.value.length===1){de({type:`text`,value:z,output:`\\${z}`});continue}if(F.brackets===0){if(f.strictBrackets===!0)throw SyntaxError(u(`opening`,`[`));de({type:`text`,value:z,output:`\\${z}`});continue}ue(`brackets`);let e=R.value.slice(1);if(R.posix!==!0&&e[0]===`^`&&!e.includes(`/`)&&(z=`/${z}`),R.value+=z,se({value:z}),f.literalBrackets===!1||r.hasRegexChars(e))continue;let t=r.escapeRegex(R.value);if(F.output=F.output.slice(0,-R.value.length),f.literalBrackets===!0){F.output+=t,R.value=t;continue}R.value=`(${_}${t}|${R.value})`,F.output+=R.value;continue}if(z===`{`&&f.nobrace!==!0){le(`braces`);let e={type:`brace`,value:z,output:`(`,outputIndex:F.output.length,tokensIndex:F.tokens.length};I.push(e),de(e);continue}if(z===`}`){let e=I[I.length-1];if(f.nobrace===!0||!e){de({type:`text`,value:z,output:z});continue}let t=`)`;if(e.dots===!0){let e=g.slice(),n=[];for(let t=e.length-1;t>=0&&(g.pop(),e[t].type!==`brace`);t--)e[t].type!==`dots`&&n.unshift(e[t].value);t=l(n,f),F.backtrack=!0}if(e.comma!==!0&&e.dots!==!0){let n=F.output.slice(0,e.outputIndex),r=F.tokens.slice(e.tokensIndex);e.value=e.output=`\\{`,z=t=`\\}`,F.output=n;for(let e of r)F.output+=e.output||e.value}de({type:`brace`,value:z,output:t}),ue(`braces`),I.pop();continue}if(z===`|`){te.length>0&&te[te.length-1].conditions++,de({type:`text`,value:z});continue}if(z===`,`){let e=z,t=I[I.length-1];t&&L[L.length-1]===`braces`&&(t.comma=!0,e=`|`),de({type:`comma`,value:z,output:e});continue}if(z===`/`){if(R.type===`dot`&&F.index===F.start+1){F.start=F.index+1,F.consumed=``,F.output=``,g.pop(),R=h;continue}de({type:`slash`,value:z,output:S});continue}if(z===`.`){if(F.braces>0&&R.type===`dot`){R.value===`.`&&(R.output=b);let e=I[I.length-1];R.type=`dots`,R.output+=z,R.value+=z,e.dots=!0;continue}if(F.braces+F.parens===0&&R.type!==`bos`&&R.type!==`slash`){de({type:`text`,value:z,output:b});continue}de({type:`dot`,value:z,output:b});continue}if(z===`?`){if(!(R&&R.value===`(`)&&f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){fe(`qmark`,z);continue}if(R&&R.type===`paren`){let e=re(),t=z;(R.value===`(`&&!/[!=<:]/.test(e)||e===`<`&&!/<([!=]|\w+>)/.test(ae()))&&(t=`\\${z}`),de({type:`text`,value:z,output:t});continue}if(f.dot!==!0&&(R.type===`slash`||R.type===`bos`)){de({type:`qmark`,value:z,output:k});continue}de({type:`qmark`,value:z,output:O});continue}if(z===`!`){if(f.noextglob!==!0&&re()===`(`&&(re(2)!==`?`||!/[!=<:]/.test(re(3)))){fe(`negate`,z);continue}if(f.nonegate!==!0&&F.index===0){ce();continue}}if(z===`+`){if(f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){fe(`plus`,z);continue}if(R&&R.value===`(`||f.regex===!1){de({type:`plus`,value:z,output:x});continue}if(R&&(R.type===`bracket`||R.type===`paren`||R.type===`brace`)||F.parens>0){de({type:`plus`,value:z});continue}de({type:`plus`,value:x});continue}if(z===`@`){if(f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){de({type:`at`,extglob:!0,value:z,output:``});continue}de({type:`text`,value:z});continue}if(z!==`*`){(z===`$`||z===`^`)&&(z=`\\${z}`);let e=o.exec(ae());e&&(z+=e[0],F.index+=e[0].length),de({type:`text`,value:z});continue}if(R&&(R.type===`globstar`||R.star===!0)){R.type=`star`,R.star=!0,R.value+=z,R.output=ee,F.backtrack=!0,F.globstar=!0,oe(z);continue}let t=ae();if(f.noextglob!==!0&&/^\([^?]/.test(t)){fe(`star`,z);continue}if(R.type===`star`){if(f.noglobstar===!0){oe(z);continue}let n=R.prev,r=n.prev,i=n.type===`slash`||n.type===`bos`,a=r&&(r.type===`star`||r.type===`globstar`);if(f.bash===!0&&(!i||t[0]&&t[0]!==`/`)){de({type:`star`,value:z,output:``});continue}let o=F.braces>0&&(n.type===`comma`||n.type===`brace`),s=te.length&&(n.type===`pipe`||n.type===`paren`);if(!i&&n.type!==`paren`&&!o&&!s){de({type:`star`,value:z,output:``});continue}for(;t.slice(0,3)===`/**`;){let n=e[F.index+4];if(n&&n!==`/`)break;t=t.slice(3),oe(`/**`,3)}if(n.type===`bos`&&ne()){R.type=`globstar`,R.value+=z,R.output=M(f),F.output=R.output,F.globstar=!0,oe(z);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&!a&&ne()){F.output=F.output.slice(0,-(n.output+R.output).length),n.output=`(?:${n.output}`,R.type=`globstar`,R.output=M(f)+(f.strictSlashes?`)`:`|$)`),R.value+=z,F.globstar=!0,F.output+=n.output+R.output,oe(z);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&t[0]===`/`){let e=t[1]===void 0?``:`|$`;F.output=F.output.slice(0,-(n.output+R.output).length),n.output=`(?:${n.output}`,R.type=`globstar`,R.output=`${M(f)}${S}|${S}${e})`,R.value+=z,F.output+=n.output+R.output,F.globstar=!0,oe(z+ie()),de({type:`slash`,value:`/`,output:``});continue}if(n.type===`bos`&&t[0]===`/`){R.type=`globstar`,R.value+=z,R.output=`(?:^|${S}|${M(f)}${S})`,F.output=R.output,F.globstar=!0,oe(z+ie()),de({type:`slash`,value:`/`,output:``});continue}F.output=F.output.slice(0,-R.output.length),R.type=`globstar`,R.output=M(f),R.value+=z,F.output+=R.output,F.globstar=!0,oe(z);continue}let n={type:`star`,value:z,output:ee};if(f.bash===!0){n.output=`.*?`,(R.type===`bos`||R.type===`slash`)&&(n.output=N+n.output),de(n);continue}if(R&&(R.type===`bracket`||R.type===`paren`)&&f.regex===!0){n.output=z,de(n);continue}(F.index===F.start||R.type===`slash`||R.type===`dot`)&&(R.type===`dot`?(F.output+=E,R.output+=E):f.dot===!0?(F.output+=D,R.output+=D):(F.output+=N,R.output+=N),re()!==`*`&&(F.output+=C,R.output+=C)),de(n)}for(;F.brackets>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));F.output=r.escapeLast(F.output,`[`),ue(`brackets`)}for(;F.parens>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`)`));F.output=r.escapeLast(F.output,`(`),ue(`parens`)}for(;F.braces>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`}`));F.output=r.escapeLast(F.output,`{`),ue(`braces`)}if(f.strictSlashes!==!0&&(R.type===`star`||R.type===`bracket`)&&de({type:`maybe_slash`,value:``,output:`${S}?`}),F.backtrack===!0){F.output=``;for(let e of F.tokens)F.output+=e.output==null?e.value:e.output,e.suffix&&(F.output+=e.suffix)}return F};d.fastpaths=(e,t)=>{let a={...t},o=typeof a.maxLength==`number`?Math.min(i,a.maxLength):i,s=e.length;if(s>o)throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);e=c[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:u,ONE_CHAR:d,DOTS_SLASH:f,NO_DOT:p,NO_DOTS:m,NO_DOTS_SLASH:h,STAR:g,START_ANCHOR:_}=n.globChars(a.windows),v=a.dot?m:p,y=a.dot?h:p,b=a.capture?``:`?:`,x={negated:!1,prefix:``},S=a.bash===!0?`.*?`:g;a.capture&&(S=`(${S})`);let C=e=>e.noglobstar===!0?S:`(${b}(?:(?!${_}${e.dot?f:l}).)*?)`,w=e=>{switch(e){case`*`:return`${v}${d}${S}`;case`.*`:return`${l}${d}${S}`;case`*.*`:return`${v}${S}${l}${d}${S}`;case`*/*`:return`${v}${S}${u}${d}${y}${S}`;case`**`:return v+C(a);case`**/*`:return`(?:${v}${C(a)}${u})?${y}${d}${S}`;case`**/*.*`:return`(?:${v}${C(a)}${u})?${y}${S}${l}${d}${S}`;case`**/.*`:return`(?:${v}${C(a)}${u})?${l}${d}${S}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let n=w(t[1]);return n?n+l+t[2]:void 0}}},T=w(r.removePrefix(e,x));return T&&a.strictSlashes!==!0&&(T+=`${u}?`),T},t.exports=d})),UCe=G(((e,t)=>{let n=VCe(),r=HCe(),i=WV(),a=UV(),o=e=>e&&typeof e==`object`&&!Array.isArray(e),s=(e,t,n=!1)=>{if(Array.isArray(e)){let r=e.map(e=>s(e,t,n));return e=>{for(let t of r){let n=t(e);if(n)return n}return!1}}let r=o(e)&&e.tokens&&e.input;if(e===``||typeof e!=`string`&&!r)throw TypeError(`Expected pattern to be a non-empty string`);let i=t||{},a=i.windows,c=r?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=c.state;delete c.state;let u=()=>!1;if(i.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=s(i.ignore,e,n)}let d=(n,r=!1)=>{let{isMatch:o,match:d,output:f}=s.test(n,c,t,{glob:e,posix:a}),p={glob:e,state:l,regex:c,posix:a,input:n,output:f,match:d,isMatch:o};return typeof i.onResult==`function`&&i.onResult(p),o===!1?(p.isMatch=!1,r?p:!1):u(n)?(typeof i.onIgnore==`function`&&i.onIgnore(p),p.isMatch=!1,r?p:!1):(typeof i.onMatch==`function`&&i.onMatch(p),r?p:!0)};return n&&(d.state=l),d};s.test=(e,t,n,{glob:r,posix:a}={})=>{if(typeof e!=`string`)throw TypeError(`Expected input to be a string`);if(e===``)return{isMatch:!1,output:``};let o=n||{},c=o.format||(a?i.toPosixSlashes:null),l=e===r,u=l&&c?c(e):e;return l===!1&&(u=c?c(e):e,l=u===r),(l===!1||o.capture===!0)&&(l=o.matchBase===!0||o.basename===!0?s.matchBase(e,t,n,a):t.exec(u)),{isMatch:!!l,match:l,output:u}},s.matchBase=(e,t,n)=>(t instanceof RegExp?t:s.makeRe(t,n)).test(i.basename(e)),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map(e=>s.parse(e,t)):r(e,{...t,fastpaths:!1}),s.scan=(e,t)=>n(e,t),s.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let i=t||{},a=i.contains?``:`^`,o=i.contains?``:`$`,c=`${a}(?:${e.output})${o}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let l=s.toRegex(c,t);return r===!0&&(l.state=e),l},s.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!=`string`)throw TypeError(`Expected a non-empty string`);let a={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]===`.`||e[0]===`*`)&&(a.output=r.fastpaths(e,t)),a.output||(a=r(e,t)),s.compileRe(a,t,n,i)},s.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?`i`:``))}catch(e){if(t&&t.debug===!0)throw e;return/$^/}},s.constants=a,t.exports=s})),WCe=G(((e,t)=>{let n=UCe(),r=WV();function i(e,t,i=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:r.isWindows()}),n(e,t,i)}Object.assign(i,n),t.exports=i}));const GV=8192;async function KV(e){let t=await m.open(e,`r`);try{let e=Buffer.alloc(GV),{bytesRead:n}=await t.read(e,0,GV,0);for(let t=0;t<n;t++)if(e[t]===0)return!0;return!1}finally{await t.close()}}
74918
+ `)}))}async execute(e,t){let{shellId:n,filter:r}=e;if(ECe.debug`Getting output for shell ${n}${r?` with filter: ${r}`:``}`,!n)throw Error(`shellId parameter is required for bash_output`);let i=t.terminalService,a=parseInt(n),o=i.getLiveOutput?.(a);if(o){let e=[o];return r&&(e=this._applyFilter(e,r)),{type:`bash_output`,terminalId:n,outputs:e,totalOutputs:1}}let s=i.getOutput(a);return r&&(s=this._applyFilter(s,r)),{type:`bash_output`,terminalId:n,outputs:s,totalOutputs:s.length}}format(e,t){return JSON.stringify({...e,status:`success`})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`bash_output`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:`success`,toolType:`bash_output`,data:t,summary:`Retrieved ${t.totalOutputs??t.outputs?.length??0} lines`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`bash_output`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`bash_output`,data:{},summary:`Retrieved`}}};const DCe=dt([`codellm`,`agent`,`tools`,`kill-shell`]);var AV=class e extends XR{name=`kill_shell`;displayName=`KillShell`;description=`Kills a running background bash shell by its ID. Use this tool when you need to terminate a long-running shell. Shell IDs can be found using the /tasks command.`;static Parameters=QL({shellId:vR().describe(`The ID of the background shell to kill`)});parameters=e.Parameters;async execute(e,t){let{shellId:n}=e;if(DCe.debug`Killing shell ${n}`,!n)throw Error(`shellId parameter is required for kill_shell`);let r=t.terminalService,i=parseInt(n),a=await r.stopCommand(i);return r.closeTerminal&&await r.closeTerminal(i),{type:`kill_shell`,shellId:n,success:a}}format(e,t){return JSON.stringify({...e,status:e.success?`success`:`failure`})}parse(e){let t=xR(e);if(t.rejected)return{phase:`rejected`,toolType:`kill_shell`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return{phase:t.success?`success`:`error`,toolType:`kill_shell`,data:t,summary:t.success?`Killed shell ${t.shellId}`:`Failed to kill shell ${t.shellId}`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`kill_shell`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`kill_shell`,data:{},summary:`Shell killed`}}},OCe=class{tool;context;params;timeoutMs=null;remainingTimeoutMs=null;_prepareResult=null;_executionResult=null;constructor(e,t,n){this.tool=e,this.params=t,this.context=n}getTool(){return this.tool}getParams(){return this.params}mergeParams(e){this.params={...this.params,...e}}getContext(){return this.context}getPrepareResult(){return this._prepareResult}getExecutionResult(){return this._executionResult}ensureTimeoutBudget(){if(this.timeoutMs!==null)return;let e=this.tool.timeout(this.params,this.context);if(!Number.isFinite(e)||e<=0)throw Error(`Invalid timeout for tool '${this.tool.name}': ${e}`);this.timeoutMs=e,this.remainingTimeoutMs=e}getRemainingTimeoutMs(){return this.ensureTimeoutBudget(),this.remainingTimeoutMs??0}consumeTimeoutBudget(e){let t=Date.now()-e;this.remainingTimeoutMs=Math.max(0,(this.remainingTimeoutMs??0)-t)}async prepare(){this.ensureTimeoutBudget();let e=this.getRemainingTimeoutMs(),t=Date.now(),n=this.context.abortController,r=new AbortController;this.context.abortController=r;let i;n&&(n.signal.aborted?r.abort(n.signal.reason??`interrupted`):(i=()=>{r.abort(n.signal.reason??`interrupted`)},n.signal.addEventListener(`abort`,i,{once:!0})));try{return this._prepareResult=await this.executeWithTimeout(this.tool.prepare(this.params,this.context),{abortOnTimeout:!0}),this._prepareResult}catch(t){throw t instanceof Error&&t.message===`tool_timeout`?Error(`${this.tool.displayName} tool timed out after ${e}ms`):t}finally{this.consumeTimeoutBudget(t),i&&n&&n.signal.removeEventListener(`abort`,i),this.context.abortController=n}}needsPermission(){return this._prepareResult?.skipPermission?!1:this.tool.needsPermission(this.params,this.context,this._prepareResult)}async executeWithTimeout(e,t){let n=this.getRemainingTimeoutMs();if(n<=0)throw t?.abortOnTimeout&&this.context.abortController?.abort(`tool_timeout`),Error(`tool_timeout`);let r,i=new Promise((e,i)=>{r=setTimeout(()=>{t?.abortOnTimeout&&this.context.abortController?.abort(`tool_timeout`),i(Error(`tool_timeout`))},n)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}}async execute(){Al(`tool: ${this.tool.name}`,`tools`),this.ensureTimeoutBudget();let e=Date.now(),t=this.context.abortController,n=new AbortController;this.context.abortController=n;let r;t&&(t.signal.aborted?n.abort(t.signal.reason??`interrupted`):(r=()=>{n.abort(t.signal.reason??`interrupted`)},t.signal.addEventListener(`abort`,r,{once:!0})));try{return this._executionResult=await this.executeWithTimeout(this.tool.execute(this.params,this.context,this._prepareResult),{abortOnTimeout:!0}),this._executionResult}catch(e){if(e instanceof Error&&e.message===`tool_timeout`){let e=await this.tool.onTimeout(this.params,this.context,this.timeoutMs??12e4);return this._executionResult=e,e}throw e}finally{this.consumeTimeoutBudget(e),r&&t&&t.signal.removeEventListener(`abort`,r),this.context.abortController=t}}formatResult(){if(this._executionResult===null)throw Error(`Cannot format result before execution completes`);return this.tool.format(this._executionResult,this.params)}formatResultForLLM(){if(this._executionResult===null)throw Error(`Cannot format result before execution completes`);return this.tool.formatForLLM(this._executionResult,this.params)}async executeWithPermission(e){if(this.ensureTimeoutBudget(),await this.prepare(),this.needsPermission()){if(!e)throw Error(`Permission check required but no permission callback provided`);if(!await e())throw Error(`Permission denied`)}return await this.execute(),this.formatResult()}},jV=class{tools;context;_disabledTools;constructor(){this.tools=new Map,this._disabledTools=new Set}setDisabledTools(e){this._disabledTools=new Set(e)}isDisabled(e){return this._disabledTools.has(e)}register(e){if(this.tools.has(e.name))throw Error(`Tool '${e.name}' is already registered`);this.tools.set(e.name,e)}registerAll(e){for(let t of e)this.register(t)}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}getAllTools(){return Array.from(this.tools.values())}setContext(e){this.context=e}getApiToolDefinitions(e){let t=e??this.context;return Array.from(this.tools.values()).filter(e=>e.includeInApiDefinitions).filter(e=>!this._disabledTools.has(e.name)).filter(e=>!t||e.isEnabled(t)).map(e=>e.getToolDefinition())}getMcpToolDefinitions(){return Array.from(this.tools.values()).filter(e=>!e.includeInApiDefinitions).map(e=>e.getToolDefinition())}getReadonlyToolDefinitions(e){return Array.from(this.tools.values()).filter(e=>e.isReadonly&&e.includeInApiDefinitions).filter(e=>!this._disabledTools.has(e.name)).filter(t=>!e||t.isEnabled(e)).map(e=>e.getToolDefinition())}registerMCPTools(e){let t=Array.from(this.tools.entries()).filter(([e,t])=>!t.includeInApiDefinitions).map(([e,t])=>e);for(let e of t)this.tools.delete(e);this.registerAll(e)}createToolInstance(e,t,n){let r=this.get(e);if(!r)throw Error(`Tool '${e}' is not registered`);return new OCe(r,r.validateParams(t),n)}isBuiltinTool(e){let t=this.get(e);return t?t.includeInApiDefinitions:!1}isBuiltinRequest(e){return this.isBuiltinTool(e.name)}unregister(e){return this.tools.delete(e)}parse(e,t){if(exe(t))return{phase:`sibling_failed`,toolType:e,data:{},summary:`Not executed — a sibling tool call in a preceding parallel batch failed`,errorMessage:`Sibling tool call failed`};let n=this.tools.get(e);return n?n.parse(t):this._genericParse(e,t)}_genericParse(e,t){let n=xR(t);if(n.rejected)return{phase:`rejected`,toolType:e,data:{},summary:n.userNote?`Rejected \u00b7 "${n.userNote}"`:`Rejected`,...n.userNote!==void 0&&{userNote:n.userNote}};try{let n=JSON.parse(t),r=`success`;return n.status===`error`?r=`error`:n.status===`skipped`&&(r=`skipped`),{phase:r,toolType:n.type??e,data:n,summary:n.message??n.summary??`Completed`,...n.errorMessage!==void 0&&{errorMessage:n.errorMessage}}}catch{}return t.startsWith(`Error:`)?{phase:`error`,toolType:e,data:{},summary:t,errorMessage:t}:{phase:`success`,toolType:e,data:{},summary:`Completed`}}clear(){this.tools.clear()}};const MV=new jV;MV.register(new $R),MV.register(new iz),MV.register(new gV),MV.register(new vV),MV.register(new yV),MV.register(new xV),MV.register(new CV),MV.register(new wV),MV.register(new TV),MV.register(new OV),MV.register(new kV),MV.register(new AV),MV.register(new ER),MV.register(new DR),MV.register(new NR),MV.register(new PR),MV.register(new FR),MV.register(new YR);function NV(){let e=new jV;return e.register(new $R),e.register(new iz),e.register(new gV),e.register(new vV),e.register(new yV),e.register(new xV),e.register(new CV),e.register(new wV),e.register(new TV),e.register(new OV),e.register(new kV),e.register(new AV),e.register(new ER),e.register(new DR),e.register(new NR),e.register(new PR),e.register(new FR),e.register(new YR),e}function PV(e){let t=e.indexOf(`(`);if(t===-1)return{displayName:e,pattern:null};let n=e.slice(0,t),r=e.lastIndexOf(`)`);if(r===-1||r<=t)return{displayName:e,pattern:``};let i=e.slice(t+1,r).trim();return i===``||i===`*`?{displayName:n,pattern:null}:{displayName:n,pattern:i}}function FV(e,t,n){return e.displayName===t?e.pattern===null?!0:t===`Bash`?ACe(e.pattern,n):e.pattern.startsWith(`domain:`)||e.pattern.startsWith(`//`)||e.pattern.startsWith(`~/`)||kCe(t)?RCe(e.pattern,n):BV(n,e.pattern):!1}function kCe(e){return[`Edit`,`Read`,`Delete`,`LS`,`Upload`].includes(e)}function ACe(e,t){let n=nF(t),r=n[0]?.trim();return r?n.length>1?n.every(t=>IV(e,t)):BV(r,e):!1}function IV(e,t){let n=t.trim();if(!n)return!1;let r=jCe(e,n);return r===null?BV(n,e):r}function jCe(e,t){let n=LV(e),r=LV(t);if(!n||!r)return null;if(n.command!==r.command)return!1;let i=PCe(n.target);if(!i&&FCe(n.target))return null;let a=RV(r.target);if(i){let e=RV(i);return a&&e?LCe(a,e):BV(r.target,n.target)}let o=RV(n.target);return o&&a?zV(o)===zV(a):BV(r.target,n.target)}function LV(e){let t=e.trim().match(/^(?:builtin\s+)?(cd|pushd)\b\s*(.*)$/i);if(!t)return null;let n=t[1].toLowerCase(),r=t[2]?.trim()??``;if(!r)return{command:n,target:`~`};let i=MCe(r);return!i||i===`-`?null:{command:n,target:i}}function MCe(e){let t=!1,n=!1,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];if(r){i+=o,r=!1;continue}if(!t&&o===`\\`){r=!0,i+=o;continue}if(!n&&o===`'`){t=!t,i+=o;continue}if(!t&&o===`"`){n=!n,i+=o;continue}if(!t&&!n&&/\s/.test(o))break;i+=o}return NCe(i.trim())}function NCe(e){return e&&((e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))&&(e=e.slice(1,-1)),e.replace(/\\([\\\s"'])/g,`$1`))}function PCe(e){return e===`*`||e===`**`?`.`:e.endsWith(`/**`)?e.slice(0,-3):e.endsWith(`/*`)?e.slice(0,-2):null}function FCe(e){return/[*?\[]/.test(e)}function RV(e){if(!e)return null;let t=oF(e);if(!O.isAbsolute(t))return null;let n=cF(t);return ICe(O.normalize(n))}function ICe(e){let t=O.normalize(e);return t===O.parse(t).root?t:t.replace(/[\\/]+$/g,``)}function zV(e){return process.platform===`win32`?e.toLowerCase():e}function LCe(e,t){if(zV(e)===zV(t))return!0;let n=O.relative(t,e);return!!n&&!n.startsWith(`..`)&&!O.isAbsolute(n)}function BV(e,t){let n=`^`,r=0;for(;r<t.length;){let e=t[r];e===`*`?t[r+1]===`*`?(n+=`.*`,r+=2):(n+=`.*`,r++):e===`?`?(n+=`.`,r++):(n+=e.replace(/[.+^${}()|\\[\]]/g,`\\$&`),r++)}n+=`$`;try{return new RegExp(n).test(e)}catch{return e===t}}function RCe(e,t){let n=e;n=n.replace(/\\/g,`/`);let r=t.replace(/\\/g,`/`);if(n.startsWith(`//`)){let e=n.slice(2);n=/^[A-Za-z]:/.test(e)?e:`/`+e}if(n.startsWith(`~/`)&&(n=oF(n).replace(/\\/g,`/`)),n.startsWith(`domain:`)){let e=n.slice(7);try{let t=new URL(r);return t.hostname===e||t.hostname.endsWith(`.`+e)}catch{return r.includes(e)}}return zCe(r,n)}function zCe(e,t){let n=`^`,r=0;for(;r<t.length;){let e=t[r];if(e===`*`)t[r+1]===`*`?t[r+2]===`/`?(n+=`(?:.*/)?`,r+=3):(n+=`.*`,r+=2):(n+=`[^/]*`,r++);else if(e===`?`)n+=`[^/]`,r++;else if(e===`[`){let e=t.indexOf(`]`,r);e===-1?(n+=`\\[`,r++):(n+=t.slice(r,e+1),r=e+1)}else n+=e.replace(/[.+^${}()|\\]/g,`\\$&`),r++}n+=`$`;try{return new RegExp(n).test(e)}catch{return e===t}}function VV(e,t){let n=typeof e==`string`?{id:``,type:``,name:e,input:t??{}}:e;if(!MV.isBuiltinRequest(n)){for(let e of Object.values(n.input))if(typeof e==`string`)return e;return``}switch(n.name){case`edit`:return n.input.filePath??``;case`read`:return n.input.filePath??``;case`write`:return n.input.filePath??``;case`bash`:return n.input.command??``;case`navigate_to`:case`new_tab`:case`web_fetch`:return n.input.url??``;case`web_search`:return n.input.searchTerm??``;case`grep`:return n.input.pattern??``;default:return``}}const HV=dt([`codellm`,`agent`,`permissions`]);var BCe=class{denyRules;askRules;allowRules;constructor(e){let{rules:t,cliAllowed:n,cliDenied:r}=e;this.denyRules=[...(t.deny??[]).map(PV),...(r??[]).map(PV)],this.askRules=(t.ask??[]).map(PV),this.allowRules=[...(t.allow??[]).map(PV),...(n??[]).map(PV)]}evaluate(e,t){if(e===`Bash`){let n=nF(t);if(n.length>1){let t=this.evaluateBashCompound(n);return HV.debug`permission: ${e} decision=${t}`,t}}for(let n of this.denyRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=deny`,`deny`;for(let n of this.askRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=ask`,`ask`;for(let n of this.allowRules)if(FV(n,e,t))return HV.debug`permission: ${e} decision=allow`,`allow`;return null}evaluateBashCompound(e){let t=`allow`;for(let n of e){let e=n.trim();if(!e)continue;let r=this.evaluateSingleBashSegment(e);if(r===`deny`)return`deny`;r===`ask`&&(t=`ask`),r===null&&t!==`ask`&&(t=null)}return t}evaluateSingleBashSegment(e){for(let t of this.denyRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`deny`;for(let t of this.askRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`ask`;for(let t of this.allowRules)if(t.displayName===`Bash`&&(t.pattern===null||IV(t.pattern,e)))return`allow`;return null}getUnmatchedBashSegments(e,t){let n=nF(e),r=[];for(let e of n){let n=e.trim();if(!n)continue;let i=this.evaluateSingleBashSegment(n);if(i!==`allow`){if(i===null){let e=EF(OF(n),t);if(e.isKnown&&!e.requiresPermission)continue}r.push(FF(n))}}return[...new Set(r)]}addAllowRule(e){this.allowRules.push(PV(e))}addDenyRule(e){this.denyRules.push(PV(e))}addAskRule(e){this.askRules.push(PV(e))}getAllowRules(){return this.allowRules.map(e=>e.pattern===null?e.displayName:`${e.displayName}(${e.pattern})`)}},UV=G(((e,t)=>{let n=`[^\\\\/]`,r=`[^/]`,i=`(?:\\/|$)`,a=`(?:^|\\/)`,o=`\\.{1,2}${i}`,s={DOT_LITERAL:`\\.`,PLUS_LITERAL:`\\+`,QMARK_LITERAL:`\\?`,SLASH_LITERAL:`\\/`,ONE_CHAR:`(?=.)`,QMARK:r,END_ANCHOR:i,DOTS_SLASH:o,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!${a}${o})`,NO_DOT_SLASH:`(?!\\.{0,1}${i})`,NO_DOTS_SLASH:`(?!${o})`,QMARK_NO_DOT:`[^.\\/]`,STAR:`${r}*?`,START_ANCHOR:a,SEP:`/`},c={...s,SLASH_LITERAL:`[\\\\/]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`\\.{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!\\.{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!\\.{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:`[^.\\\\/]`,START_ANCHOR:`(?:^|[\\\\/])`,END_ANCHOR:`(?:[\\\\/]|$)`,SEP:`\\`};t.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:{alnum:`a-zA-Z0-9`,alpha:`a-zA-Z`,ascii:`\\x00-\\x7F`,blank:` \\t`,cntrl:`\\x00-\\x1F\\x7F`,digit:`0-9`,graph:`\\x21-\\x7E`,lower:`a-z`,print:`\\x20-\\x7E `,punct:`\\-!"#$%&'()\\*+,./:;<=>?@[\\]^_\`{|}~`,space:` \\t\\r\\n\\v\\f`,upper:`A-Z`,word:`A-Za-z0-9_`,xdigit:`A-Fa-f0-9`},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":`*`,"**/**":`**`,"**/**/**":`**`},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:`negate`,open:`(?:(?!(?:`,close:`))${e.STAR})`},"?":{type:`qmark`,open:`(?:`,close:`)?`},"+":{type:`plus`,open:`(?:`,close:`)+`},"*":{type:`star`,open:`(?:`,close:`)*`},"@":{type:`at`,open:`(?:`,close:`)`}}},globChars(e){return e===!0?c:s}}})),WV=G((e=>{let{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:r,REGEX_SPECIAL_CHARS_GLOBAL:i}=UV();e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e),e.hasRegexChars=e=>r.test(e),e.isRegexChar=t=>t.length===1&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(i,`\\$1`),e.toPosixSlashes=e=>e.replace(t,`/`),e.isWindows=()=>{if(typeof navigator<`u`&&navigator.platform){let e=navigator.platform.toLowerCase();return e===`win32`||e===`windows`}return typeof process<`u`&&process.platform?process.platform===`win32`:!1},e.removeBackslashes=e=>e.replace(n,e=>e===`\\`?``:e),e.escapeLast=(t,n,r)=>{let i=t.lastIndexOf(n,r);return i===-1?t:t[i-1]===`\\`?e.escapeLast(t,n,i-1):`${t.slice(0,i)}\\${t.slice(i)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith(`./`)&&(n=n.slice(2),t.prefix=`./`),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?``:`^`}(?:${e})${n.contains?``:`$`}`;return t.negated===!0&&(r=`(?:^(?!${r}).*$)`),r},e.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:`/`),r=n[n.length-1];return r===``?n[n.length-2]:r}})),VCe=G(((e,t)=>{let n=WV(),{CHAR_ASTERISK:r,CHAR_AT:i,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:l,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:d,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:p,CHAR_QUESTION_MARK:m,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:g,CHAR_RIGHT_SQUARE_BRACKET:_}=UV(),v=e=>e===l||e===a,y=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let b=t||{},x=e.length-1,S=b.parts===!0||b.scanToEnd===!0,C=[],w=[],T=[],E=e,D=-1,O=0,k=0,A=!1,j=!1,M=!1,N=!1,P=!1,ee=!1,F=!1,te=!1,I=!1,L=!1,R=0,z,ne,re={value:``,depth:0,isGlob:!1},ie=()=>D>=x,ae=()=>E.charCodeAt(D+1),oe=()=>(z=ne,E.charCodeAt(++D));for(;D<x;){ne=oe();let e;if(ne===a){F=re.backslashes=!0,ne=oe(),ne===u&&(ee=!0);continue}if(ee===!0||ne===u){for(R++;ie()!==!0&&(ne=oe());){if(ne===a){F=re.backslashes=!0,oe();continue}if(ne===u){R++;continue}if(ee!==!0&&ne===s&&(ne=oe())===s){if(A=re.isBrace=!0,M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ee!==!0&&ne===o){if(A=re.isBrace=!0,M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===h&&(R--,R===0)){ee=!1,A=re.isBrace=!0,L=!0;break}}if(S===!0)continue;break}if(ne===l){if(C.push(D),w.push(re),re={value:``,depth:0,isGlob:!1},L===!0)continue;if(z===s&&D===O+1){O+=2;continue}k=D+1;continue}if(b.noext!==!0&&(ne===p||ne===i||ne===r||ne===m||ne===c)&&ae()===d){if(M=re.isGlob=!0,N=re.isExtglob=!0,L=!0,ne===c&&D===O&&(I=!0),S===!0){for(;ie()!==!0&&(ne=oe());){if(ne===a){F=re.backslashes=!0,ne=oe();continue}if(ne===g){M=re.isGlob=!0,L=!0;break}}continue}break}if(ne===r){if(z===r&&(P=re.isGlobstar=!0),M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===m){if(M=re.isGlob=!0,L=!0,S===!0)continue;break}if(ne===f){for(;ie()!==!0&&(e=oe());){if(e===a){F=re.backslashes=!0,oe();continue}if(e===_){j=re.isBracket=!0,M=re.isGlob=!0,L=!0;break}}if(S===!0)continue;break}if(b.nonegate!==!0&&ne===c&&D===O){te=re.negated=!0,O++;continue}if(b.noparen!==!0&&ne===d){if(M=re.isGlob=!0,S===!0){for(;ie()!==!0&&(ne=oe());){if(ne===d){F=re.backslashes=!0,ne=oe();continue}if(ne===g){L=!0;break}}continue}break}if(M===!0){if(L=!0,S===!0)continue;break}}b.noext===!0&&(N=!1,M=!1);let se=E,ce=``,le=``;O>0&&(ce=E.slice(0,O),E=E.slice(O),k-=O),se&&M===!0&&k>0?(se=E.slice(0,k),le=E.slice(k)):M===!0?(se=``,le=E):se=E,se&&se!==``&&se!==`/`&&se!==E&&v(se.charCodeAt(se.length-1))&&(se=se.slice(0,-1)),b.unescape===!0&&(le&&=n.removeBackslashes(le),se&&F===!0&&(se=n.removeBackslashes(se)));let ue={prefix:ce,input:e,start:O,base:se,glob:le,isBrace:A,isBracket:j,isGlob:M,isExtglob:N,isGlobstar:P,negated:te,negatedExtglob:I};if(b.tokens===!0&&(ue.maxDepth=0,v(ne)||w.push(re),ue.tokens=w),b.parts===!0||b.tokens===!0){let t;for(let n=0;n<C.length;n++){let r=t?t+1:O,i=C[n],a=e.slice(r,i);b.tokens&&(n===0&&O!==0?(w[n].isPrefix=!0,w[n].value=ce):w[n].value=a,y(w[n]),ue.maxDepth+=w[n].depth),(n!==0||a!==``)&&T.push(a),t=i}if(t&&t+1<e.length){let n=e.slice(t+1);T.push(n),b.tokens&&(w[w.length-1].value=n,y(w[w.length-1]),ue.maxDepth+=w[w.length-1].depth)}ue.slashes=C,ue.parts=T}return ue}})),HCe=G(((e,t)=>{let n=UV(),r=WV(),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:c}=n,l=(e,t)=>{if(typeof t.expandRange==`function`)return t.expandRange(...e,t);e.sort();let n=`[${e.join(`-`)}]`;try{new RegExp(n)}catch{return e.map(e=>r.escapeRegex(e)).join(`..`)}return n},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,d=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected a string`);e=c[e]||e;let f={...t},p=typeof f.maxLength==`number`?Math.min(i,f.maxLength):i,m=e.length;if(m>p)throw SyntaxError(`Input length: ${m}, exceeds maximum allowed length: ${p}`);let h={type:`bos`,value:``,output:f.prepend||``},g=[h],_=f.capture?``:`?:`,v=n.globChars(f.windows),y=n.extglobChars(v),{DOT_LITERAL:b,PLUS_LITERAL:x,SLASH_LITERAL:S,ONE_CHAR:C,DOTS_SLASH:w,NO_DOT:T,NO_DOT_SLASH:E,NO_DOTS_SLASH:D,QMARK:O,QMARK_NO_DOT:k,STAR:A,START_ANCHOR:j}=v,M=e=>`(${_}(?:(?!${j}${e.dot?w:b}).)*?)`,N=f.dot?``:T,P=f.dot?O:k,ee=f.bash===!0?M(f):A;f.capture&&(ee=`(${ee})`),typeof f.noext==`boolean`&&(f.noextglob=f.noext);let F={input:e,index:-1,start:0,dot:f.dot===!0,consumed:``,output:``,prefix:``,backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:g};e=r.removePrefix(e,F),m=e.length;let te=[],I=[],L=[],R=h,z,ne=()=>F.index===m-1,re=F.peek=(t=1)=>e[F.index+t],ie=F.advance=()=>e[++F.index]||``,ae=()=>e.slice(F.index+1),oe=(e=``,t=0)=>{F.consumed+=e,F.index+=t},se=e=>{F.output+=e.output==null?e.value:e.output,oe(e.value)},ce=()=>{let e=1;for(;re()===`!`&&(re(2)!==`(`||re(3)===`?`);)ie(),F.start++,e++;return e%2==0?!1:(F.negated=!0,F.start++,!0)},le=e=>{F[e]++,L.push(e)},ue=e=>{F[e]--,L.pop()},de=e=>{if(R.type===`globstar`){let t=F.braces>0&&(e.type===`comma`||e.type===`brace`),n=e.extglob===!0||te.length&&(e.type===`pipe`||e.type===`paren`);e.type!==`slash`&&e.type!==`paren`&&!t&&!n&&(F.output=F.output.slice(0,-R.output.length),R.type=`star`,R.value=`*`,R.output=ee,F.output+=R.output)}if(te.length&&e.type!==`paren`&&(te[te.length-1].inner+=e.value),(e.value||e.output)&&se(e),R&&R.type===`text`&&e.type===`text`){R.output=(R.output||R.value)+e.value,R.value+=e.value;return}e.prev=R,g.push(e),R=e},fe=(e,t)=>{let n={...y[t],conditions:1,inner:``};n.prev=R,n.parens=F.parens,n.output=F.output;let r=(f.capture?`(`:``)+n.open;le(`parens`),de({type:e,value:t,output:F.output?``:C}),de({type:`paren`,extglob:!0,value:ie(),output:r}),te.push(n)},B=e=>{let n=e.close+(f.capture?`)`:``),r;if(e.type===`negate`){let i=ee;e.inner&&e.inner.length>1&&e.inner.includes(`/`)&&(i=M(f)),(i!==ee||ne()||/^\)+$/.test(ae()))&&(n=e.close=`)$))${i}`),e.inner.includes(`*`)&&(r=ae())&&/^\.[^\\/.]+$/.test(r)&&(n=e.close=`)${d(r,{...t,fastpaths:!1}).output})${i})`),e.prev.type===`bos`&&(F.negatedExtglob=!0)}de({type:`paren`,extglob:!0,value:z,output:n}),ue(`parens`)};if(f.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let n=!1,i=e.replace(s,(e,t,r,i,a,o)=>i===`\\`?(n=!0,e):i===`?`?t?t+i+(a?O.repeat(a.length):``):o===0?P+(a?O.repeat(a.length):``):O.repeat(r.length):i===`.`?b.repeat(r.length):i===`*`?t?t+i+(a?ee:``):ee:t?e:`\\${e}`);return n===!0&&(i=f.unescape===!0?i.replace(/\\/g,``):i.replace(/\\+/g,e=>e.length%2==0?`\\\\`:e?`\\`:``)),i===e&&f.contains===!0?(F.output=e,F):(F.output=r.wrapOutput(i,F,t),F)}for(;!ne();){if(z=ie(),z===`\0`)continue;if(z===`\\`){let e=re();if(e===`/`&&f.bash!==!0||e===`.`||e===`;`)continue;if(!e){z+=`\\`,de({type:`text`,value:z});continue}let t=/^\\+/.exec(ae()),n=0;if(t&&t[0].length>2&&(n=t[0].length,F.index+=n,n%2!=0&&(z+=`\\`)),f.unescape===!0?z=ie():z+=ie(),F.brackets===0){de({type:`text`,value:z});continue}}if(F.brackets>0&&(z!==`]`||R.value===`[`||R.value===`[^`)){if(f.posix!==!1&&z===`:`){let e=R.value.slice(1);if(e.includes(`[`)&&(R.posix=!0,e.includes(`:`))){let e=R.value.lastIndexOf(`[`),t=R.value.slice(0,e),n=a[R.value.slice(e+2)];if(n){R.value=t+n,F.backtrack=!0,ie(),!h.output&&g.indexOf(R)===1&&(h.output=C);continue}}}(z===`[`&&re()!==`:`||z===`-`&&re()===`]`)&&(z=`\\${z}`),z===`]`&&(R.value===`[`||R.value===`[^`)&&(z=`\\${z}`),f.posix===!0&&z===`!`&&R.value===`[`&&(z=`^`),R.value+=z,se({value:z});continue}if(F.quotes===1&&z!==`"`){z=r.escapeRegex(z),R.value+=z,se({value:z});continue}if(z===`"`){F.quotes=F.quotes===1?0:1,f.keepQuotes===!0&&de({type:`text`,value:z});continue}if(z===`(`){le(`parens`),de({type:`paren`,value:z});continue}if(z===`)`){if(F.parens===0&&f.strictBrackets===!0)throw SyntaxError(u(`opening`,`(`));let e=te[te.length-1];if(e&&F.parens===e.parens+1){B(te.pop());continue}de({type:`paren`,value:z,output:F.parens?`)`:`\\)`}),ue(`parens`);continue}if(z===`[`){if(f.nobracket===!0||!ae().includes(`]`)){if(f.nobracket!==!0&&f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));z=`\\${z}`}else le(`brackets`);de({type:`bracket`,value:z});continue}if(z===`]`){if(f.nobracket===!0||R&&R.type===`bracket`&&R.value.length===1){de({type:`text`,value:z,output:`\\${z}`});continue}if(F.brackets===0){if(f.strictBrackets===!0)throw SyntaxError(u(`opening`,`[`));de({type:`text`,value:z,output:`\\${z}`});continue}ue(`brackets`);let e=R.value.slice(1);if(R.posix!==!0&&e[0]===`^`&&!e.includes(`/`)&&(z=`/${z}`),R.value+=z,se({value:z}),f.literalBrackets===!1||r.hasRegexChars(e))continue;let t=r.escapeRegex(R.value);if(F.output=F.output.slice(0,-R.value.length),f.literalBrackets===!0){F.output+=t,R.value=t;continue}R.value=`(${_}${t}|${R.value})`,F.output+=R.value;continue}if(z===`{`&&f.nobrace!==!0){le(`braces`);let e={type:`brace`,value:z,output:`(`,outputIndex:F.output.length,tokensIndex:F.tokens.length};I.push(e),de(e);continue}if(z===`}`){let e=I[I.length-1];if(f.nobrace===!0||!e){de({type:`text`,value:z,output:z});continue}let t=`)`;if(e.dots===!0){let e=g.slice(),n=[];for(let t=e.length-1;t>=0&&(g.pop(),e[t].type!==`brace`);t--)e[t].type!==`dots`&&n.unshift(e[t].value);t=l(n,f),F.backtrack=!0}if(e.comma!==!0&&e.dots!==!0){let n=F.output.slice(0,e.outputIndex),r=F.tokens.slice(e.tokensIndex);e.value=e.output=`\\{`,z=t=`\\}`,F.output=n;for(let e of r)F.output+=e.output||e.value}de({type:`brace`,value:z,output:t}),ue(`braces`),I.pop();continue}if(z===`|`){te.length>0&&te[te.length-1].conditions++,de({type:`text`,value:z});continue}if(z===`,`){let e=z,t=I[I.length-1];t&&L[L.length-1]===`braces`&&(t.comma=!0,e=`|`),de({type:`comma`,value:z,output:e});continue}if(z===`/`){if(R.type===`dot`&&F.index===F.start+1){F.start=F.index+1,F.consumed=``,F.output=``,g.pop(),R=h;continue}de({type:`slash`,value:z,output:S});continue}if(z===`.`){if(F.braces>0&&R.type===`dot`){R.value===`.`&&(R.output=b);let e=I[I.length-1];R.type=`dots`,R.output+=z,R.value+=z,e.dots=!0;continue}if(F.braces+F.parens===0&&R.type!==`bos`&&R.type!==`slash`){de({type:`text`,value:z,output:b});continue}de({type:`dot`,value:z,output:b});continue}if(z===`?`){if(!(R&&R.value===`(`)&&f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){fe(`qmark`,z);continue}if(R&&R.type===`paren`){let e=re(),t=z;(R.value===`(`&&!/[!=<:]/.test(e)||e===`<`&&!/<([!=]|\w+>)/.test(ae()))&&(t=`\\${z}`),de({type:`text`,value:z,output:t});continue}if(f.dot!==!0&&(R.type===`slash`||R.type===`bos`)){de({type:`qmark`,value:z,output:k});continue}de({type:`qmark`,value:z,output:O});continue}if(z===`!`){if(f.noextglob!==!0&&re()===`(`&&(re(2)!==`?`||!/[!=<:]/.test(re(3)))){fe(`negate`,z);continue}if(f.nonegate!==!0&&F.index===0){ce();continue}}if(z===`+`){if(f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){fe(`plus`,z);continue}if(R&&R.value===`(`||f.regex===!1){de({type:`plus`,value:z,output:x});continue}if(R&&(R.type===`bracket`||R.type===`paren`||R.type===`brace`)||F.parens>0){de({type:`plus`,value:z});continue}de({type:`plus`,value:x});continue}if(z===`@`){if(f.noextglob!==!0&&re()===`(`&&re(2)!==`?`){de({type:`at`,extglob:!0,value:z,output:``});continue}de({type:`text`,value:z});continue}if(z!==`*`){(z===`$`||z===`^`)&&(z=`\\${z}`);let e=o.exec(ae());e&&(z+=e[0],F.index+=e[0].length),de({type:`text`,value:z});continue}if(R&&(R.type===`globstar`||R.star===!0)){R.type=`star`,R.star=!0,R.value+=z,R.output=ee,F.backtrack=!0,F.globstar=!0,oe(z);continue}let t=ae();if(f.noextglob!==!0&&/^\([^?]/.test(t)){fe(`star`,z);continue}if(R.type===`star`){if(f.noglobstar===!0){oe(z);continue}let n=R.prev,r=n.prev,i=n.type===`slash`||n.type===`bos`,a=r&&(r.type===`star`||r.type===`globstar`);if(f.bash===!0&&(!i||t[0]&&t[0]!==`/`)){de({type:`star`,value:z,output:``});continue}let o=F.braces>0&&(n.type===`comma`||n.type===`brace`),s=te.length&&(n.type===`pipe`||n.type===`paren`);if(!i&&n.type!==`paren`&&!o&&!s){de({type:`star`,value:z,output:``});continue}for(;t.slice(0,3)===`/**`;){let n=e[F.index+4];if(n&&n!==`/`)break;t=t.slice(3),oe(`/**`,3)}if(n.type===`bos`&&ne()){R.type=`globstar`,R.value+=z,R.output=M(f),F.output=R.output,F.globstar=!0,oe(z);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&!a&&ne()){F.output=F.output.slice(0,-(n.output+R.output).length),n.output=`(?:${n.output}`,R.type=`globstar`,R.output=M(f)+(f.strictSlashes?`)`:`|$)`),R.value+=z,F.globstar=!0,F.output+=n.output+R.output,oe(z);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&t[0]===`/`){let e=t[1]===void 0?``:`|$`;F.output=F.output.slice(0,-(n.output+R.output).length),n.output=`(?:${n.output}`,R.type=`globstar`,R.output=`${M(f)}${S}|${S}${e})`,R.value+=z,F.output+=n.output+R.output,F.globstar=!0,oe(z+ie()),de({type:`slash`,value:`/`,output:``});continue}if(n.type===`bos`&&t[0]===`/`){R.type=`globstar`,R.value+=z,R.output=`(?:^|${S}|${M(f)}${S})`,F.output=R.output,F.globstar=!0,oe(z+ie()),de({type:`slash`,value:`/`,output:``});continue}F.output=F.output.slice(0,-R.output.length),R.type=`globstar`,R.output=M(f),R.value+=z,F.output+=R.output,F.globstar=!0,oe(z);continue}let n={type:`star`,value:z,output:ee};if(f.bash===!0){n.output=`.*?`,(R.type===`bos`||R.type===`slash`)&&(n.output=N+n.output),de(n);continue}if(R&&(R.type===`bracket`||R.type===`paren`)&&f.regex===!0){n.output=z,de(n);continue}(F.index===F.start||R.type===`slash`||R.type===`dot`)&&(R.type===`dot`?(F.output+=E,R.output+=E):f.dot===!0?(F.output+=D,R.output+=D):(F.output+=N,R.output+=N),re()!==`*`&&(F.output+=C,R.output+=C)),de(n)}for(;F.brackets>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));F.output=r.escapeLast(F.output,`[`),ue(`brackets`)}for(;F.parens>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`)`));F.output=r.escapeLast(F.output,`(`),ue(`parens`)}for(;F.braces>0;){if(f.strictBrackets===!0)throw SyntaxError(u(`closing`,`}`));F.output=r.escapeLast(F.output,`{`),ue(`braces`)}if(f.strictSlashes!==!0&&(R.type===`star`||R.type===`bracket`)&&de({type:`maybe_slash`,value:``,output:`${S}?`}),F.backtrack===!0){F.output=``;for(let e of F.tokens)F.output+=e.output==null?e.value:e.output,e.suffix&&(F.output+=e.suffix)}return F};d.fastpaths=(e,t)=>{let a={...t},o=typeof a.maxLength==`number`?Math.min(i,a.maxLength):i,s=e.length;if(s>o)throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);e=c[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:u,ONE_CHAR:d,DOTS_SLASH:f,NO_DOT:p,NO_DOTS:m,NO_DOTS_SLASH:h,STAR:g,START_ANCHOR:_}=n.globChars(a.windows),v=a.dot?m:p,y=a.dot?h:p,b=a.capture?``:`?:`,x={negated:!1,prefix:``},S=a.bash===!0?`.*?`:g;a.capture&&(S=`(${S})`);let C=e=>e.noglobstar===!0?S:`(${b}(?:(?!${_}${e.dot?f:l}).)*?)`,w=e=>{switch(e){case`*`:return`${v}${d}${S}`;case`.*`:return`${l}${d}${S}`;case`*.*`:return`${v}${S}${l}${d}${S}`;case`*/*`:return`${v}${S}${u}${d}${y}${S}`;case`**`:return v+C(a);case`**/*`:return`(?:${v}${C(a)}${u})?${y}${d}${S}`;case`**/*.*`:return`(?:${v}${C(a)}${u})?${y}${S}${l}${d}${S}`;case`**/.*`:return`(?:${v}${C(a)}${u})?${l}${d}${S}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let n=w(t[1]);return n?n+l+t[2]:void 0}}},T=w(r.removePrefix(e,x));return T&&a.strictSlashes!==!0&&(T+=`${u}?`),T},t.exports=d})),UCe=G(((e,t)=>{let n=VCe(),r=HCe(),i=WV(),a=UV(),o=e=>e&&typeof e==`object`&&!Array.isArray(e),s=(e,t,n=!1)=>{if(Array.isArray(e)){let r=e.map(e=>s(e,t,n));return e=>{for(let t of r){let n=t(e);if(n)return n}return!1}}let r=o(e)&&e.tokens&&e.input;if(e===``||typeof e!=`string`&&!r)throw TypeError(`Expected pattern to be a non-empty string`);let i=t||{},a=i.windows,c=r?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=c.state;delete c.state;let u=()=>!1;if(i.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=s(i.ignore,e,n)}let d=(n,r=!1)=>{let{isMatch:o,match:d,output:f}=s.test(n,c,t,{glob:e,posix:a}),p={glob:e,state:l,regex:c,posix:a,input:n,output:f,match:d,isMatch:o};return typeof i.onResult==`function`&&i.onResult(p),o===!1?(p.isMatch=!1,r?p:!1):u(n)?(typeof i.onIgnore==`function`&&i.onIgnore(p),p.isMatch=!1,r?p:!1):(typeof i.onMatch==`function`&&i.onMatch(p),r?p:!0)};return n&&(d.state=l),d};s.test=(e,t,n,{glob:r,posix:a}={})=>{if(typeof e!=`string`)throw TypeError(`Expected input to be a string`);if(e===``)return{isMatch:!1,output:``};let o=n||{},c=o.format||(a?i.toPosixSlashes:null),l=e===r,u=l&&c?c(e):e;return l===!1&&(u=c?c(e):e,l=u===r),(l===!1||o.capture===!0)&&(l=o.matchBase===!0||o.basename===!0?s.matchBase(e,t,n,a):t.exec(u)),{isMatch:!!l,match:l,output:u}},s.matchBase=(e,t,n)=>(t instanceof RegExp?t:s.makeRe(t,n)).test(i.basename(e)),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map(e=>s.parse(e,t)):r(e,{...t,fastpaths:!1}),s.scan=(e,t)=>n(e,t),s.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let i=t||{},a=i.contains?``:`^`,o=i.contains?``:`$`,c=`${a}(?:${e.output})${o}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let l=s.toRegex(c,t);return r===!0&&(l.state=e),l},s.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!=`string`)throw TypeError(`Expected a non-empty string`);let a={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]===`.`||e[0]===`*`)&&(a.output=r.fastpaths(e,t)),a.output||(a=r(e,t)),s.compileRe(a,t,n,i)},s.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?`i`:``))}catch(e){if(t&&t.debug===!0)throw e;return/$^/}},s.constants=a,t.exports=s})),WCe=G(((e,t)=>{let n=UCe(),r=WV();function i(e,t,i=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:r.isWindows()}),n(e,t,i)}Object.assign(i,n),t.exports=i}));const GV=8192;async function KV(e){let t=await m.open(e,`r`);try{let e=Buffer.alloc(GV),{bytesRead:n}=await t.read(e,0,GV,0);for(let t=0;t<n;t++)if(e[t]===0)return!0;return!1}finally{await t.close()}}
74919
74919
  /** @license
74920
74920
  * fzf v0.5.2
74921
74921
  * Copyright (c) 2021 Ajit
@@ -75084,7 +75084,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
75084
75084
  `)};this.entries.push(n),this.entries.length>this.maxEntries?(this.entries=this.entries.slice(-this.maxEntries),this.enqueueWrite(()=>this.rewriteFile())):this.enqueueWrite(()=>this.appendLine(n))}isNavigating(){return this.navIndex!==-1}navigateUp(){if(this.entries.length===0)return null;if(this.navIndex===-1)this.navIndex=this.entries.length-1;else if(this.navIndex>0)this.navIndex--;else return null;return this.entries[this.navIndex]??null}navigateDown(){return this.navIndex===-1?null:(this.navIndex++,this.navIndex>=this.entries.length?(this.navIndex=-1,null):this.entries[this.navIndex]??null)}resetNavigation(){this.navIndex=-1}getEntries(){return this.entries}enqueueWrite(e){this.writeQueue=this.writeQueue.then(e).catch(()=>{})}async appendLine(e){try{await Ee(k(this.filePath),{recursive:!0});let t=await De(this.filePath,`a`);try{await t.write(JSON.stringify(e)+`
75085
75085
  `)}finally{await t.close()}}catch{}}async rewriteFile(){try{await Ee(k(this.filePath),{recursive:!0});let e=this.entries.map(e=>JSON.stringify(e)).join(`
75086
75086
  `)+`
75087
- `;await ke(this.filePath,e,`utf-8`)}catch{}}};const bq=e=>{let t=typeof e;return e!==null&&(t===`object`||t===`function`)},xq=new Set([`__proto__`,`prototype`,`constructor`]),Sq=1e6,WOe=e=>e>=`0`&&e<=`9`;function Cq(e){if(e===`0`)return!0;if(/^[1-9]\d*$/.test(e)){let t=Number.parseInt(e,10);return t<=2**53-1&&t<=Sq}return!1}function wq(e,t){return xq.has(e)?!1:(e&&Cq(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function GOe(e){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);let t=[],n=``,r=`start`,i=!1,a=0;for(let o of e){if(a++,i){n+=o,i=!1;continue}if(o===`\\`){if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);i=!0,r=r===`start`?`property`:r;continue}switch(o){case`.`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`property`;break}if(!wq(n,t))return[];n=``,r=`property`;break;case`[`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`index`;break}if(r===`property`||r===`start`){if((n||r===`property`)&&!wq(n,t))return[];n=``}r=`index`;break;case`]`:if(r===`index`){if(n===``)n=(t.pop()||``)+`[]`,r=`property`;else{let e=Number.parseInt(n,10);!Number.isNaN(e)&&Number.isFinite(e)&&e>=0&&e<=2**53-1&&e<=Sq&&n===String(e)?t.push(e):t.push(n),n=``,r=`indexEnd`}break}if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);n+=o;break;default:if(r===`index`&&!WOe(o))throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);r===`start`&&(r=`property`),n+=o}}switch(i&&(n+=`\\`),r){case`property`:if(!wq(n,t))return[];break;case`index`:throw Error(`Index was not closed`);case`start`:t.push(``);break}return t}function Tq(e){if(typeof e==`string`)return GOe(e);if(Array.isArray(e)){let t=[];for(let[n,r]of e.entries()){if(typeof r!=`string`&&typeof r!=`number`)throw TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof r}`);if(typeof r==`number`&&!Number.isFinite(r))throw TypeError(`Path segment at index ${n} must be a finite number, got ${r}`);if(xq.has(r))return[];typeof r==`string`&&Cq(r)?t.push(Number.parseInt(r,10)):t.push(r)}return t}return[]}function Eq(e,t,n){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return n===void 0?e:n;let r=Tq(t);if(r.length===0)return n;for(let t=0;t<r.length;t++){let i=r[t];if(e=e[i],e==null){if(t!==r.length-1)return n;break}}return e===void 0?n:e}function Dq(e,t,n){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return e;let r=e,i=Tq(t);if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];if(t===i.length-1)e[r]=n;else if(!bq(e[r])){let n=typeof i[t+1]==`number`;e[r]=n?[]:{}}e=e[r]}return r}function KOe(e,t){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=Tq(t);if(n.length===0)return!1;for(let t=0;t<n.length;t++){let r=n[t];if(t===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;if(e=e[r],!bq(e))return!1}}function Oq(e,t){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=Tq(t);if(n.length===0)return!1;for(let t of n){if(!bq(e)||!(t in e))return!1;e=e[t]}return!0}const kq=ee.homedir(),Aq=ee.tmpdir(),{env:jq}=H,qOe=e=>{let t=O.join(kq,`Library`);return{data:O.join(t,`Application Support`,e),config:O.join(t,`Preferences`,e),cache:O.join(t,`Caches`,e),log:O.join(t,`Logs`,e),temp:O.join(Aq,e)}},JOe=e=>{let t=jq.APPDATA||O.join(kq,`AppData`,`Roaming`),n=jq.LOCALAPPDATA||O.join(kq,`AppData`,`Local`);return{data:O.join(n,e,`Data`),config:O.join(t,e,`Config`),cache:O.join(n,e,`Cache`),log:O.join(n,e,`Log`),temp:O.join(Aq,e)}},YOe=e=>{let t=O.basename(kq);return{data:O.join(jq.XDG_DATA_HOME||O.join(kq,`.local`,`share`),e),config:O.join(jq.XDG_CONFIG_HOME||O.join(kq,`.config`),e),cache:O.join(jq.XDG_CACHE_HOME||O.join(kq,`.cache`),e),log:O.join(jq.XDG_STATE_HOME||O.join(kq,`.local`,`state`),e),temp:O.join(Aq,t,e)}};function XOe(e,{suffix:t=`nodejs`}={}){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);return t&&(e+=`-${t}`),H.platform===`darwin`?qOe(e):H.platform===`win32`?JOe(e):YOe(e)}const Mq=(e,t)=>{let{onError:n}=t;return function(...t){return e.apply(void 0,t).catch(n)}},Nq=(e,t)=>{let{onError:n}=t;return function(...t){try{return e.apply(void 0,t)}catch(e){return n(e)}}},Pq=(e,t)=>{let{isRetriable:n}=t;return function(t){let{timeout:r}=t,i=t.interval??250,a=Date.now()+r;return function t(...r){return e.apply(void 0,r).catch(e=>{if(!n(e)||Date.now()>=a)throw e;let o=Math.round(i*Math.random());return o>0?new Promise(e=>setTimeout(e,o)).then(()=>t.apply(void 0,r)):t.apply(void 0,r)})}}},Fq=(e,t)=>{let{isRetriable:n}=t;return function(t){let{timeout:r}=t,i=Date.now()+r;return function(...t){for(;;)try{return e.apply(void 0,t)}catch(e){if(!n(e)||Date.now()>=i)throw e;continue}}}},Iq={isChangeErrorOk:e=>{if(!Iq.isNodeError(e))return!1;let{code:t}=e;return t===`ENOSYS`||!ZOe&&(t===`EINVAL`||t===`EPERM`)},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!Iq.isNodeError(e))return!1;let{code:t}=e;return t===`EMFILE`||t===`ENFILE`||t===`EAGAIN`||t===`EBUSY`||t===`EACCESS`||t===`EACCES`||t===`EACCS`||t===`EPERM`},onChangeError:e=>{if(!Iq.isNodeError(e)||!Iq.isChangeErrorOk(e))throw e}},Lq={onError:Iq.onChangeError},Rq={onError:()=>void 0},ZOe=H.getuid?!H.getuid():!1,zq={isRetriable:Iq.isRetriableError},Bq={attempt:{chmod:Mq(a(c.chmod),Lq),chown:Mq(a(c.chown),Lq),close:Mq(a(c.close),Rq),fsync:Mq(a(c.fsync),Rq),mkdir:Mq(a(c.mkdir),Rq),realpath:Mq(a(c.realpath),Rq),stat:Mq(a(c.stat),Rq),unlink:Mq(a(c.unlink),Rq),chmodSync:Nq(c.chmodSync,Lq),chownSync:Nq(c.chownSync,Lq),closeSync:Nq(c.closeSync,Rq),existsSync:Nq(c.existsSync,Rq),fsyncSync:Nq(c.fsync,Rq),mkdirSync:Nq(c.mkdirSync,Rq),realpathSync:Nq(c.realpathSync,Rq),statSync:Nq(c.statSync,Rq),unlinkSync:Nq(c.unlinkSync,Rq)},retry:{close:Pq(a(c.close),zq),fsync:Pq(a(c.fsync),zq),open:Pq(a(c.open),zq),readFile:Pq(a(c.readFile),zq),rename:Pq(a(c.rename),zq),stat:Pq(a(c.stat),zq),write:Pq(a(c.write),zq),writeFile:Pq(a(c.writeFile),zq),closeSync:Fq(c.closeSync,zq),fsyncSync:Fq(c.fsyncSync,zq),openSync:Fq(c.openSync,zq),readFileSync:Fq(c.readFileSync,zq),renameSync:Fq(c.renameSync,zq),statSync:Fq(c.statSync,zq),writeSync:Fq(c.writeSync,zq),writeFileSync:Fq(c.writeFileSync,zq)}},QOe={},$Oe=H.geteuid?H.geteuid():-1,eke=H.getegid?H.getegid():-1,tke=!!H.getuid;H.getuid&&H.getuid();const nke=e=>e instanceof Error&&`code`in e,Vq=e=>typeof e==`string`,Hq=e=>e===void 0,rke=H.platform===`linux`,Uq=H.platform===`win32`,Wq=[`SIGHUP`,`SIGINT`,`SIGTERM`];Uq||Wq.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),rke&&Wq.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const ike=new class{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=e=>{if(!this.exited){this.exited=!0;for(let e of this.callbacks)e();e&&(Uq&&e!==`SIGINT`&&e!==`SIGTERM`&&e!==`SIGKILL`?H.kill(H.pid,`SIGTERM`):H.kill(H.pid,e))}},this.hook=()=>{H.once(`exit`,()=>this.exit());for(let e of Wq)try{H.once(e,()=>this.exit(e))}catch{}},this.register=e=>(this.callbacks.add(e),()=>{this.callbacks.delete(e)}),this.hook()}}().register,Gq={store:{},create:e=>{let t=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6);return`${e}${`.tmp-${Date.now().toString().slice(-10)}${t}`}`},get:(e,t,n=!0)=>{let r=Gq.truncate(t(e));return r in Gq.store?Gq.get(e,t,n):(Gq.store[r]=n,[r,()=>delete Gq.store[r]])},purge:e=>{Gq.store[e]&&(delete Gq.store[e],Bq.attempt.unlink(e))},purgeSync:e=>{Gq.store[e]&&(delete Gq.store[e],Bq.attempt.unlinkSync(e))},purgeSyncAll:()=>{for(let e in Gq.store)Gq.purgeSync(e)},truncate:e=>{let t=O.basename(e);if(t.length<=128)return e;let n=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(t);if(!n)return e;let r=t.length-128;return`${e.slice(0,-t.length)}${n[1]}${n[2].slice(0,-r)}${n[3]}`}};ike(Gq.purgeSyncAll);function Kq(e,t,n=QOe){if(Vq(n))return Kq(e,t,{encoding:n});let r={timeout:n.timeout??1e3},i=null,a=null,o=null;try{let s=Bq.attempt.realpathSync(e),c=!!s;e=s||e,[a,i]=Gq.get(e,n.tmpCreate||Gq.create,n.tmpPurge!==!1);let l=tke&&Hq(n.chown),u=Hq(n.mode);if(c&&(l||u)){let t=Bq.attempt.statSync(e);t&&(n={...n},l&&(n.chown={uid:t.uid,gid:t.gid}),u&&(n.mode=t.mode))}if(!c){let t=O.dirname(e);Bq.attempt.mkdirSync(t,{mode:511,recursive:!0})}o=Bq.retry.openSync(r)(a,`w`,n.mode||438),n.tmpCreated&&n.tmpCreated(a),Vq(t)?Bq.retry.writeSync(r)(o,t,0,n.encoding||`utf8`):Hq(t)||Bq.retry.writeSync(r)(o,t,0,t.length,0),n.fsync!==!1&&(n.fsyncWait===!1?Bq.attempt.fsync(o):Bq.retry.fsyncSync(r)(o)),Bq.retry.closeSync(r)(o),o=null,n.chown&&(n.chown.uid!==$Oe||n.chown.gid!==eke)&&Bq.attempt.chownSync(a,n.chown.uid,n.chown.gid),n.mode&&n.mode!==438&&Bq.attempt.chmodSync(a,n.mode);try{Bq.retry.renameSync(r)(a,e)}catch(t){if(!nke(t)||t.code!==`ENAMETOOLONG`)throw t;Bq.retry.renameSync(r)(a,Gq.truncate(e))}i(),a=null}finally{o&&Bq.attempt.closeSync(o),a&&Gq.purge(a)}}var qq=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dynamicAnchor=void 0;let t=BW(),n=HW(),r=$W(),i=nG(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}e.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}e.default=a})),Jq=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dynamicRef=void 0;let t=BW(),n=HW(),r=nG(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}e.dynamicRef=a,e.default=i})),ake=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qq(),n=VW();e.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),oke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Jq();e.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),ske=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qq(),n=Jq(),r=ake(),i=oke();e.default=[t.default,n.default,r.default,i.default]})),cke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cG();e.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),lke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cG();e.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),uke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=VW();e.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),dke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cke(),n=lke(),r=uke();e.default=[t.default,n.default,r.default]})),fke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=BW(),n=VW(),r=HW();e.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),pke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=BW(),n=VW();e.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),mke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fke(),n=pke();e.default=[t.default,n.default]})),hke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rG(),n=aG(),r=uG(),i=ske(),a=dke(),o=mke(),s=dG(),c=fG();e.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),gke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/schema`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],type:[`object`,`boolean`],$comment:`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,properties:{definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}}}})),_ke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:`meta`,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}}}})),vke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/unevaluated`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:`meta`,title:`Unevaluated applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}}}})),yke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/content`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}}}})),bke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/core`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:`meta`,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},$defs:{anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}}}})),xke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/format-annotation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:`meta`,title:`Format vocabulary meta-schema for annotation results`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),Ske=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:`meta`,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),Cke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:`meta`,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),wke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=gke(),n=_ke(),r=vke(),i=yke(),a=bke(),o=xke(),s=Ske(),c=Cke(),l=[`/properties`];function u(e){return[t,n,r,i,a,u(this,o),s,u(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function u(t,n){return e?t.$dataMetaSchema(n,l):n}}e.default=u})),Tke=G(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;let n=tG(),r=hke(),i=pG(),a=wke(),o=`https://json-schema.org/draft/2020-12/schema`;var s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};e.Ajv2020=s,t.exports=e=s,t.exports.Ajv2020=s,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=s;var c=XW();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return c.KeywordCxt}});var l=BW();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return l.CodeGen}});var u=ZW();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return u.default}});var d=QW();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return d.default}})}));const Eke=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!Dke(i,a)&&r||Object.defineProperty(e,n,a)},Dke=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Oke=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},kke=(e,t)=>`/* Wrapped ${e}*/\n${t}`,Ake=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),jke=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),Mke=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=kke.bind(null,r,t.toString());Object.defineProperty(i,`name`,jke);let{writable:a,enumerable:o,configurable:s}=Ake;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function Nke(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))Eke(e,t,r,n);return Oke(e,t),Mke(e,t,r),e}const Yq=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);let{wait:n=0,maxWait:r=1/0,before:i=!1,after:a=!0}=t;if(n<0||r<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!a)throw Error("Both `before` and `after` are false, function wouldn't be called.");let o,s,c,l=function(...t){let l=this,u=()=>{o=void 0,s&&=(clearTimeout(s),void 0),a&&(c=e.apply(l,t))},d=()=>{s=void 0,o&&=(clearTimeout(o),void 0),a&&(c=e.apply(l,t))},f=i&&!o;return clearTimeout(o),o=setTimeout(u,n),r>0&&r!==1/0&&!s&&(s=setTimeout(d,r)),f&&(c=e.apply(l,t)),c};return Nke(l,e),l.cancel=()=>{o&&=(clearTimeout(o),void 0),s&&=(clearTimeout(s),void 0)},l};var Xq=G(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),Zq=G(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),Qq=G(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Xq(),a=Zq();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),$q=G(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),eJ=G(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),tJ=G(((e,t)=>{let n=Zq(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Xq(),{safeRe:a,t:o}=Qq(),s=$q(),{compareIdentifiers:c}=eJ();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),nJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),Pke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Fke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Ike=G(((e,t)=>{let n=tJ();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Lke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Rke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).major})),zke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).minor})),Bke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).patch})),Vke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),rJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Hke=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(t,e,r)})),Uke=G(((e,t)=>{let n=rJ();t.exports=(e,t)=>n(e,t,!0)})),iJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Wke=G(((e,t)=>{let n=iJ();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Gke=G(((e,t)=>{let n=iJ();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),aJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)>0})),oJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)<0})),Kke=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)===0})),sJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)!==0})),cJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)>=0})),lJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)<=0})),uJ=G(((e,t)=>{let n=Kke(),r=sJ(),i=aJ(),a=cJ(),o=oJ(),s=lJ();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),qke=G(((e,t)=>{let n=tJ(),r=nJ(),{safeRe:i,t:a}=Qq();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Jke=G(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),dJ=G(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(k(this.set[t],e,this.options))return!0;return!1}};let r=new(Jke()),i=$q(),a=fJ(),o=Zq(),s=tJ(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Qq(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Xq(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),fJ=G(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=$q(),{safeRe:i,t:a}=Qq(),o=uJ(),s=Zq(),c=tJ(),l=dJ()})),pJ=G(((e,t)=>{let n=dJ();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Yke=G(((e,t)=>{let n=dJ();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Xke=G(((e,t)=>{let n=tJ(),r=dJ();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Zke=G(((e,t)=>{let n=tJ(),r=dJ();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Qke=G(((e,t)=>{let n=tJ(),r=dJ(),i=aJ();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),$ke=G(((e,t)=>{let n=dJ();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),mJ=G(((e,t)=>{let n=tJ(),r=fJ(),{ANY:i}=r,a=dJ(),o=pJ(),s=aJ(),c=oJ(),l=lJ(),u=cJ();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),eAe=G(((e,t)=>{let n=mJ();t.exports=(e,t,r)=>n(e,t,`>`,r)})),tAe=G(((e,t)=>{let n=mJ();t.exports=(e,t,r)=>n(e,t,`<`,r)})),nAe=G(((e,t)=>{let n=dJ();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),rAe=G(((e,t)=>{let n=pJ(),r=rJ();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),iAe=G(((e,t)=>{let n=dJ(),r=fJ(),{ANY:i}=r,a=pJ(),o=rJ(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),aAe=G(((e,t)=>{let n=Qq(),r=Xq(),i=tJ(),a=eJ();t.exports={parse:nJ(),valid:Pke(),clean:Fke(),inc:Ike(),diff:Lke(),major:Rke(),minor:zke(),patch:Bke(),prerelease:Vke(),compare:rJ(),rcompare:Hke(),compareLoose:Uke(),compareBuild:iJ(),sort:Wke(),rsort:Gke(),gt:aJ(),lt:oJ(),eq:Kke(),neq:sJ(),gte:cJ(),lte:lJ(),cmp:uJ(),coerce:qke(),Comparator:fJ(),Range:dJ(),satisfies:pJ(),toComparators:Yke(),maxSatisfying:Xke(),minSatisfying:Zke(),minVersion:Qke(),validRange:$ke(),outside:mJ(),gtr:eAe(),ltr:tAe(),intersects:nAe(),simplifyRange:rAe(),subset:iAe(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));const oAe=Object.prototype.toString;function hJ(e,t,n){return e?e.constructor===t?!0:oAe.call(e)===n:!1}function gJ(e){return hJ(e,Uint8Array,`[object Uint8Array]`)}function sAe(e){return hJ(e,ArrayBuffer,`[object ArrayBuffer]`)}function cAe(e){return gJ(e)||sAe(e)}function lAe(e){if(!gJ(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function uAe(e){if(!cAe(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function _J(e,t){if(e.length===0)return new Uint8Array;t??=e.reduce((e,t)=>e+t.length,0);let n=new Uint8Array(t),r=0;for(let t of e)lAe(t),n.set(t,r),r+=t.length;return n}const vJ={utf8:new globalThis.TextDecoder(`utf8`)};function yJ(e,t=`utf8`){return uAe(e),vJ[t]??=new globalThis.TextDecoder(t),vJ[t].decode(e)}function dAe(e){if(typeof e!=`string`)throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}const fAe=new globalThis.TextEncoder;function bJ(e){return dAe(e),fAe.encode(e)}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));var pAe=Tke(),xJ=Qe(aAe(),1);const SJ=`aes-256-cbc`,CJ=new Set([`aes-256-cbc`,`aes-256-gcm`,`aes-256-ctr`]),mAe=e=>typeof e==`string`&&CJ.has(e),wJ=()=>Object.create(null),TJ=e=>e!==void 0,EJ=(e,t)=>{let n=new Set([`undefined`,`symbol`,`function`]),r=typeof t;if(n.has(r))throw TypeError(`Setting a value of type \`${r}\` for key \`${e}\` is not allowed as it's not supported by JSON`)},DJ=`__internal__`,OJ=`${DJ}.migrations.version`;var hAe=class{path;events;#e;#t;#n;#r;#i={};#a=!1;#o;#s;#c;constructor(e={}){let t=this.#l(e);this.#r=t,this.#u(t),this.#f(t),this.#p(t),this.events=new EventTarget,this.#t=t.encryptionKey,this.#n=t.encryptionAlgorithm??SJ,this.path=this.#m(t),this.#h(t),t.watch&&this._watch()}get(e,t){if(this.#r.accessPropertiesByDotNotation)return this._get(e,t);let{store:n}=this;return e in n?n[e]:t}set(e,t){if(typeof e!=`string`&&typeof e!=`object`)throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof e}`);if(typeof e!=`object`&&t===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(e))throw TypeError(`Please don't use the ${DJ} key, as it's used to manage this module internal operations.`);let{store:n}=this,r=(e,t)=>{if(EJ(e,t),this.#r.accessPropertiesByDotNotation)Dq(n,e,t);else{if(e===`__proto__`||e===`constructor`||e===`prototype`)return;n[e]=t}};if(typeof e==`object`){let t=e;for(let[e,n]of Object.entries(t))r(e,n)}else r(e,t);this.store=n}has(e){return this.#r.accessPropertiesByDotNotation?Oq(this.store,e):e in this.store}appendToArray(e,t){EJ(e,t);let n=this.#r.accessPropertiesByDotNotation?this._get(e,[]):e in this.store?this.store[e]:[];if(!Array.isArray(n))throw TypeError(`The key \`${e}\` is already set to a non-array value`);this.set(e,[...n,t])}reset(...e){for(let t of e)TJ(this.#i[t])&&this.set(t,this.#i[t])}delete(e){let{store:t}=this;this.#r.accessPropertiesByDotNotation?KOe(t,e):delete t[e],this.store=t}clear(){let e=wJ();for(let t of Object.keys(this.#i))TJ(this.#i[t])&&(EJ(t,this.#i[t]),this.#r.accessPropertiesByDotNotation?Dq(e,t,this.#i[t]):e[t]=this.#i[t]);this.store=e}onDidChange(e,t){if(typeof e!=`string`)throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof e}`);if(typeof t!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`);return this._handleValueChange(()=>this.get(e),t)}onDidAnyChange(e){if(typeof e!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof e}`);return this._handleStoreChange(e)}get size(){return Object.keys(this.store).filter(e=>!this._isReservedKeyPath(e)).length}get store(){try{let e=c.readFileSync(this.path,this.#t?null:`utf8`);return(e=>{let t=this._deserialize(e);return this.#a||this._validate(t),Object.assign(wJ(),t)})(this._decryptData(e))}catch(e){if(e?.code===`ENOENT`)return this._ensureDirectory(),wJ();if(this.#r.clearInvalidConfig){let t=e;if(t.name===`SyntaxError`||t.message?.startsWith(`Config schema violation:`)||t.message===`Failed to decrypt config data.`)return wJ()}throw e}}set store(e){if(this._ensureDirectory(),!Oq(e,DJ))try{let t=c.readFileSync(this.path,this.#t?null:`utf8`),n=this._decryptData(t),r=this._deserialize(n);Oq(r,DJ)&&Dq(e,DJ,Eq(r,DJ))}catch{}this.#a||this._validate(e),this._write(e),this.events.dispatchEvent(new Event(`change`))}*[Symbol.iterator](){for(let[e,t]of Object.entries(this.store))this._isReservedKeyPath(e)||(yield[e,t])}_closeWatcher(){this.#o&&=(this.#o.close(),void 0),this.#s&&=(c.unwatchFile(this.path),!1),this.#c=void 0}_decryptData(e){let t=this.#t;if(!t)return typeof e==`string`?e:yJ(e);let n=this.#n,r=n===`aes-256-gcm`?16:0,i=`:`.codePointAt(0),a=typeof e==`string`?e.codePointAt(16):e[16];if(!(i!==void 0&&a===i)){if(n===`aes-256-cbc`)return typeof e==`string`?e:yJ(e);throw Error(`Failed to decrypt config data.`)}let o=e=>{if(r===0)return{ciphertext:e};let t=e.length-r;if(t<0)throw Error(`Invalid authentication tag length.`);return{ciphertext:e.slice(0,t),authenticationTag:e.slice(t)}},s=e.slice(0,16),c=e.slice(17),l=typeof c==`string`?bJ(c):c,u=e=>{let{ciphertext:r,authenticationTag:i}=o(l),a=Pe.pbkdf2Sync(t,e,1e4,32,`sha512`),c=Pe.createDecipheriv(n,a,s);return i&&c.setAuthTag(i),yJ(_J([c.update(r),c.final()]))};try{return u(s)}catch{try{return u(s.toString())}catch{}}if(n===`aes-256-cbc`)return typeof e==`string`?e:yJ(e);throw Error(`Failed to decrypt config data.`)}_handleStoreChange(e){let t=this.store,n=()=>{let n=t,i=this.store;r(i,n)||(t=i,e.call(this,i,n))};return this.events.addEventListener(`change`,n),()=>{this.events.removeEventListener(`change`,n)}}_handleValueChange(e,t){let n=e(),i=()=>{let i=n,a=e();r(a,i)||(n=a,t.call(this,a,i))};return this.events.addEventListener(`change`,i),()=>{this.events.removeEventListener(`change`,i)}}_deserialize=e=>JSON.parse(e);_serialize=e=>JSON.stringify(e,void 0,` `);_validate(e){if(!this.#e||this.#e(e)||!this.#e.errors)return;let t=this.#e.errors.map(({instancePath:e,message:t=``})=>`\`${e.slice(1)}\` ${t}`);throw Error(`Config schema violation: `+t.join(`; `))}_ensureDirectory(){c.mkdirSync(O.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e),n=this.#t;if(n){let e=Pe.randomBytes(16),r=Pe.pbkdf2Sync(n,e,1e4,32,`sha512`),i=Pe.createCipheriv(this.#n,r,e),a=_J([i.update(bJ(t)),i.final()]),o=[e,bJ(`:`),a];this.#n===`aes-256-gcm`&&o.push(i.getAuthTag()),t=_J(o)}if(H.env.SNAP)c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});else try{Kq(this.path,t,{mode:this.#r.configFileMode})}catch(e){if(e?.code===`EXDEV`){c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});return}throw e}}_watch(){if(this._ensureDirectory(),c.existsSync(this.path)||this._write(wJ()),H.platform===`win32`||H.platform===`darwin`){this.#c??=Yq(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:100});let e=O.dirname(this.path),t=O.basename(this.path);this.#o=c.watch(e,{persistent:!1,encoding:`utf8`},(e,n)=>{n&&n!==t||typeof this.#c==`function`&&this.#c()})}else this.#c??=Yq(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:1e3}),c.watchFile(this.path,{persistent:!1},(e,t)=>{typeof this.#c==`function`&&this.#c()}),this.#s=!0}_migrate(e,t,n){let r=this._get(OJ,`0.0.0`),i=Object.keys(e).filter(e=>this._shouldPerformMigration(e,r,t)),a=structuredClone(this.store);for(let o of i)try{n&&n(this,{fromVersion:r,toVersion:o,finalVersion:t,versions:i});let s=e[o];s?.(this),this._set(OJ,o),r=o,a=structuredClone(this.store)}catch(e){this.store=a;let t=e instanceof Error?e.message:String(e);throw Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${t}`)}(this._isVersionInRangeFormat(r)||!xJ.default.eq(r,t))&&this._set(OJ,t)}_containsReservedKey(e){return typeof e==`string`?this._isReservedKeyPath(e):!e||typeof e!=`object`?!1:this._objectContainsReservedKey(e)}_objectContainsReservedKey(e){if(!e||typeof e!=`object`)return!1;for(let[t,n]of Object.entries(e))if(this._isReservedKeyPath(t)||this._objectContainsReservedKey(n))return!0;return!1}_isReservedKeyPath(e){return e===DJ||e.startsWith(`${DJ}.`)}_isVersionInRangeFormat(e){return xJ.default.clean(e)===null}_shouldPerformMigration(e,t,n){return this._isVersionInRangeFormat(e)?t!==`0.0.0`&&xJ.default.satisfies(t,e)?!1:xJ.default.satisfies(n,e):!(xJ.default.lte(e,t)||xJ.default.gt(e,n))}_get(e,t){return Eq(this.store,e,t)}_set(e,t){let{store:n}=this;Dq(n,e,t),this.store=n}#l(e){let t={configName:`config`,fileExtension:`json`,projectSuffix:`nodejs`,clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...e};if(t.encryptionAlgorithm??=SJ,!mAe(t.encryptionAlgorithm))throw TypeError(`The \`encryptionAlgorithm\` option must be one of: ${[...CJ].join(`, `)}`);if(!t.cwd){if(!t.projectName)throw Error("Please specify the `projectName` option.");t.cwd=XOe(t.projectName,{suffix:t.projectSuffix}).config}return typeof t.fileExtension==`string`&&(t.fileExtension=t.fileExtension.replace(/^\.+/,``)),t}#u(e){if(!(e.schema??e.ajvOptions??e.rootSchema))return;if(e.schema&&typeof e.schema!=`object`)throw TypeError("The `schema` option must be an object.");let t=hG.default.default,n=new pAe.Ajv2020({allErrors:!0,useDefaults:!0,...e.ajvOptions});t(n);let r={...e.rootSchema,type:`object`,properties:e.schema};this.#e=n.compile(r),this.#d(e.schema)}#d(e){let t=Object.entries(e??{});for(let[e,n]of t){if(!n||typeof n!=`object`||!Object.hasOwn(n,`default`))continue;let{default:t}=n;t!==void 0&&(this.#i[e]=t)}}#f(e){e.defaults&&Object.assign(this.#i,e.defaults)}#p(e){e.serialize&&(this._serialize=e.serialize),e.deserialize&&(this._deserialize=e.deserialize)}#m(e){let t=typeof e.fileExtension==`string`?e.fileExtension:void 0,n=t?`.${t}`:``;return O.resolve(e.cwd,`${e.configName??`config`}${n}`)}#h(e){if(e.migrations){this.#g(e),this._validate(this.store);return}let t=this.store,n=Object.assign(wJ(),e.defaults??{},t);this._validate(n);try{je.deepEqual(t,n)}catch{this.store=n}}#g(e){let{migrations:t,projectVersion:n}=e;if(t){if(!n)throw Error("Please specify the `projectVersion` option.");this.#a=!0;try{let r=this.store,i=Object.assign(wJ(),e.defaults??{},r);try{je.deepEqual(r,i)}catch{this._write(i)}this._migrate(t,n,e.beforeEachMigration)}finally{this.#a=!1}}}};const kJ=`api_key`;async function gAe(e){if(await e.getSecret(kJ))return;let t;try{t=new hAe({projectName:`abacusai-cli`,configName:`storage`})}catch{return}let n=t.get(`codellm.apikey`),r=t.get(`codellm.devicecode`);typeof n==`string`&&n&&await e.setSecret(kJ,n),typeof r==`string`&&r&&await e.setSecret(`device_code`,r),(n||r)&&t.clear()}const AJ=`aes-256-gcm`;var _Ae=class{storePath;data=null;constructor(){this.storePath=O.join(te(),hn.configDirName,`keystore.enc`)}getMachineKey(){let e=`${I()}:${process.env.USER??process.env.USERNAME??`user`}`;return Re(e,Buffer.from(e.padEnd(16,`0`).slice(0,16)),1e5,32,`sha256`)}encrypt(e){let t=this.getMachineKey(),n=ze(12),r=Fe(AJ,t,n),i=Buffer.concat([r.update(e,`utf-8`),r.final()]),a=r.getAuthTag();return Buffer.concat([n,a,i])}decrypt(e){let t=this.getMachineKey(),n=e.subarray(0,12),r=e.subarray(12,28),i=e.subarray(28),a=Ie(AJ,t,n);return a.setAuthTag(r),a.update(i).toString(`utf-8`)+a.final(`utf-8`)}async load(){if(this.data!==null)return this.data;try{let e=await m.readFile(this.storePath),t=this.decrypt(e);this.data=JSON.parse(t)}catch{this.data={}}return this.data}async save(){let e=O.dirname(this.storePath);await m.mkdir(e,{recursive:!0});let t=this.encrypt(JSON.stringify(this.data??{}));await m.writeFile(this.storePath,t)}async getSecret(e){return(await this.load())[e]??null}async setSecret(e,t){let n=await this.load();n[e]=t,await this.save()}async deleteSecret(e){let t=await this.load();delete t[e],await this.save()}};async function vAe(){try{let e=await import(`keytar`),t=e.default??e,n=hn.keychainService;return{async getSecret(e){return t.getPassword(n,e)},async setSecret(e,r){await t.setPassword(n,e,r)},async deleteSecret(e){await t.deletePassword(n,e)}}}catch{return new _Ae}}const jJ=`api_key`,MJ=`device_code`,NJ=`auth_token`;var PJ=class e{storage;envApiKey;envDeviceCode;storedApiKey=null;storedDeviceCode=null;storedToken=null;constructor(e,t={}){this.storage=e,this.envApiKey=t.apiKey??null,this.envDeviceCode=t.deviceCode??null}static async create(){let t=await vAe();await gAe(t);let n=new e(t,{apiKey:process.env[`${hn.envPrefix}API_KEY`]??null,deviceCode:process.env[`${hn.internalEnvPrefix}DEVICE_CODE`]??null});return await n.loadFromStorage(),n}static async createWithStorage(t,n){let r=new e(t,{apiKey:n?.apiKey??process.env[`${hn.envPrefix}API_KEY`]??null,deviceCode:n?.deviceCode??process.env[`${hn.internalEnvPrefix}DEVICE_CODE`]??null});return await r.loadFromStorage(),r}async loadFromStorage(){let[e,t,n]=await Promise.all([this.storage.getSecret(jJ),this.storage.getSecret(MJ),this.storage.getSecret(NJ)]);if(this.storedApiKey=e,this.storedDeviceCode=t,n)try{this.storedToken=JSON.parse(n)}catch{this.storedToken=null}}async loginWithApiKey(e){this.storedApiKey=e,await this.storage.setSecret(jJ,e),Al(`login`,`auth`)}async loginWithDeviceCode(e){this.storedDeviceCode=e,await this.storage.setSecret(MJ,e),Al(`login`,`auth`)}async loginWithToken(e){this.storedToken=e,await this.storage.setSecret(NJ,JSON.stringify(e)),Al(`login`,`auth`)}async logout(){return this.isEnvAuth()?!1:(this.storedApiKey=null,this.storedDeviceCode=null,this.storedToken=null,await Promise.all([this.storage.deleteSecret(jJ),this.storage.deleteSecret(MJ),this.storage.deleteSecret(NJ)]),Al(`logout`,`auth`),!0)}getAuthKind(){return this.envApiKey?{type:`env_api_key`}:this.envDeviceCode?{type:`env_device_code`}:this.storedApiKey?{type:`api_key`}:this.storedDeviceCode?{type:`device_code`}:this.storedToken?{type:`oauth_token`}:{type:`logged_out`}}isAuthenticated(){return this.getAuthKind().type!==`logged_out`}isEnvAuth(){let e=this.getAuthKind();return e.type===`env_api_key`||e.type===`env_device_code`}async getHeaders(){return this.envApiKey?{APIKEY:this.envApiKey}:this.envDeviceCode?{DEVICECODE:this.envDeviceCode}:this.storedApiKey?{APIKEY:this.storedApiKey}:this.storedDeviceCode?{DEVICECODE:this.storedDeviceCode}:this.storedToken?{APIKEY:this.storedToken.accessToken}:{}}};async function FJ(){try{return(await import(`node-machine-id`)).machineIdSync({original:!1})}catch{let e=`${I()}:${process.platform}`;return Le(`sha256`).update(e).digest(`hex`)}}
75087
+ `;await ke(this.filePath,e,`utf-8`)}catch{}}};const bq=e=>{let t=typeof e;return e!==null&&(t===`object`||t===`function`)},xq=new Set([`__proto__`,`prototype`,`constructor`]),Sq=1e6,WOe=e=>e>=`0`&&e<=`9`;function Cq(e){if(e===`0`)return!0;if(/^[1-9]\d*$/.test(e)){let t=Number.parseInt(e,10);return t<=2**53-1&&t<=Sq}return!1}function wq(e,t){return xq.has(e)?!1:(e&&Cq(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function GOe(e){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);let t=[],n=``,r=`start`,i=!1,a=0;for(let o of e){if(a++,i){n+=o,i=!1;continue}if(o===`\\`){if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);i=!0,r=r===`start`?`property`:r;continue}switch(o){case`.`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`property`;break}if(!wq(n,t))return[];n=``,r=`property`;break;case`[`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`index`;break}if(r===`property`||r===`start`){if((n||r===`property`)&&!wq(n,t))return[];n=``}r=`index`;break;case`]`:if(r===`index`){if(n===``)n=(t.pop()||``)+`[]`,r=`property`;else{let e=Number.parseInt(n,10);!Number.isNaN(e)&&Number.isFinite(e)&&e>=0&&e<=2**53-1&&e<=Sq&&n===String(e)?t.push(e):t.push(n),n=``,r=`indexEnd`}break}if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);n+=o;break;default:if(r===`index`&&!WOe(o))throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);r===`start`&&(r=`property`),n+=o}}switch(i&&(n+=`\\`),r){case`property`:if(!wq(n,t))return[];break;case`index`:throw Error(`Index was not closed`);case`start`:t.push(``);break}return t}function Tq(e){if(typeof e==`string`)return GOe(e);if(Array.isArray(e)){let t=[];for(let[n,r]of e.entries()){if(typeof r!=`string`&&typeof r!=`number`)throw TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof r}`);if(typeof r==`number`&&!Number.isFinite(r))throw TypeError(`Path segment at index ${n} must be a finite number, got ${r}`);if(xq.has(r))return[];typeof r==`string`&&Cq(r)?t.push(Number.parseInt(r,10)):t.push(r)}return t}return[]}function Eq(e,t,n){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return n===void 0?e:n;let r=Tq(t);if(r.length===0)return n;for(let t=0;t<r.length;t++){let i=r[t];if(e=e[i],e==null){if(t!==r.length-1)return n;break}}return e===void 0?n:e}function Dq(e,t,n){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return e;let r=e,i=Tq(t);if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];if(t===i.length-1)e[r]=n;else if(!bq(e[r])){let n=typeof i[t+1]==`number`;e[r]=n?[]:{}}e=e[r]}return r}function KOe(e,t){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=Tq(t);if(n.length===0)return!1;for(let t=0;t<n.length;t++){let r=n[t];if(t===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;if(e=e[r],!bq(e))return!1}}function Oq(e,t){if(!bq(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=Tq(t);if(n.length===0)return!1;for(let t of n){if(!bq(e)||!(t in e))return!1;e=e[t]}return!0}const kq=ee.homedir(),Aq=ee.tmpdir(),{env:jq}=H,qOe=e=>{let t=O.join(kq,`Library`);return{data:O.join(t,`Application Support`,e),config:O.join(t,`Preferences`,e),cache:O.join(t,`Caches`,e),log:O.join(t,`Logs`,e),temp:O.join(Aq,e)}},JOe=e=>{let t=jq.APPDATA||O.join(kq,`AppData`,`Roaming`),n=jq.LOCALAPPDATA||O.join(kq,`AppData`,`Local`);return{data:O.join(n,e,`Data`),config:O.join(t,e,`Config`),cache:O.join(n,e,`Cache`),log:O.join(n,e,`Log`),temp:O.join(Aq,e)}},YOe=e=>{let t=O.basename(kq);return{data:O.join(jq.XDG_DATA_HOME||O.join(kq,`.local`,`share`),e),config:O.join(jq.XDG_CONFIG_HOME||O.join(kq,`.config`),e),cache:O.join(jq.XDG_CACHE_HOME||O.join(kq,`.cache`),e),log:O.join(jq.XDG_STATE_HOME||O.join(kq,`.local`,`state`),e),temp:O.join(Aq,t,e)}};function XOe(e,{suffix:t=`nodejs`}={}){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);return t&&(e+=`-${t}`),H.platform===`darwin`?qOe(e):H.platform===`win32`?JOe(e):YOe(e)}const Mq=(e,t)=>{let{onError:n}=t;return function(...t){return e.apply(void 0,t).catch(n)}},Nq=(e,t)=>{let{onError:n}=t;return function(...t){try{return e.apply(void 0,t)}catch(e){return n(e)}}},Pq=(e,t)=>{let{isRetriable:n}=t;return function(t){let{timeout:r}=t,i=t.interval??250,a=Date.now()+r;return function t(...r){return e.apply(void 0,r).catch(e=>{if(!n(e)||Date.now()>=a)throw e;let o=Math.round(i*Math.random());return o>0?new Promise(e=>setTimeout(e,o)).then(()=>t.apply(void 0,r)):t.apply(void 0,r)})}}},Fq=(e,t)=>{let{isRetriable:n}=t;return function(t){let{timeout:r}=t,i=Date.now()+r;return function(...t){for(;;)try{return e.apply(void 0,t)}catch(e){if(!n(e)||Date.now()>=i)throw e;continue}}}},Iq={isChangeErrorOk:e=>{if(!Iq.isNodeError(e))return!1;let{code:t}=e;return t===`ENOSYS`||!ZOe&&(t===`EINVAL`||t===`EPERM`)},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!Iq.isNodeError(e))return!1;let{code:t}=e;return t===`EMFILE`||t===`ENFILE`||t===`EAGAIN`||t===`EBUSY`||t===`EACCESS`||t===`EACCES`||t===`EACCS`||t===`EPERM`},onChangeError:e=>{if(!Iq.isNodeError(e)||!Iq.isChangeErrorOk(e))throw e}},Lq={onError:Iq.onChangeError},Rq={onError:()=>void 0},ZOe=H.getuid?!H.getuid():!1,zq={isRetriable:Iq.isRetriableError},Bq={attempt:{chmod:Mq(a(c.chmod),Lq),chown:Mq(a(c.chown),Lq),close:Mq(a(c.close),Rq),fsync:Mq(a(c.fsync),Rq),mkdir:Mq(a(c.mkdir),Rq),realpath:Mq(a(c.realpath),Rq),stat:Mq(a(c.stat),Rq),unlink:Mq(a(c.unlink),Rq),chmodSync:Nq(c.chmodSync,Lq),chownSync:Nq(c.chownSync,Lq),closeSync:Nq(c.closeSync,Rq),existsSync:Nq(c.existsSync,Rq),fsyncSync:Nq(c.fsync,Rq),mkdirSync:Nq(c.mkdirSync,Rq),realpathSync:Nq(c.realpathSync,Rq),statSync:Nq(c.statSync,Rq),unlinkSync:Nq(c.unlinkSync,Rq)},retry:{close:Pq(a(c.close),zq),fsync:Pq(a(c.fsync),zq),open:Pq(a(c.open),zq),readFile:Pq(a(c.readFile),zq),rename:Pq(a(c.rename),zq),stat:Pq(a(c.stat),zq),write:Pq(a(c.write),zq),writeFile:Pq(a(c.writeFile),zq),closeSync:Fq(c.closeSync,zq),fsyncSync:Fq(c.fsyncSync,zq),openSync:Fq(c.openSync,zq),readFileSync:Fq(c.readFileSync,zq),renameSync:Fq(c.renameSync,zq),statSync:Fq(c.statSync,zq),writeSync:Fq(c.writeSync,zq),writeFileSync:Fq(c.writeFileSync,zq)}},QOe={},$Oe=H.geteuid?H.geteuid():-1,eke=H.getegid?H.getegid():-1,tke=!!H.getuid;H.getuid&&H.getuid();const nke=e=>e instanceof Error&&`code`in e,Vq=e=>typeof e==`string`,Hq=e=>e===void 0,rke=H.platform===`linux`,Uq=H.platform===`win32`,Wq=[`SIGHUP`,`SIGINT`,`SIGTERM`];Uq||Wq.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),rke&&Wq.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const ike=new class{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=e=>{if(!this.exited){this.exited=!0;for(let e of this.callbacks)e();e&&(Uq&&e!==`SIGINT`&&e!==`SIGTERM`&&e!==`SIGKILL`?H.kill(H.pid,`SIGTERM`):H.kill(H.pid,e))}},this.hook=()=>{H.once(`exit`,()=>this.exit());for(let e of Wq)try{H.once(e,()=>this.exit(e))}catch{}},this.register=e=>(this.callbacks.add(e),()=>{this.callbacks.delete(e)}),this.hook()}}().register,Gq={store:{},create:e=>{let t=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6);return`${e}${`.tmp-${Date.now().toString().slice(-10)}${t}`}`},get:(e,t,n=!0)=>{let r=Gq.truncate(t(e));return r in Gq.store?Gq.get(e,t,n):(Gq.store[r]=n,[r,()=>delete Gq.store[r]])},purge:e=>{Gq.store[e]&&(delete Gq.store[e],Bq.attempt.unlink(e))},purgeSync:e=>{Gq.store[e]&&(delete Gq.store[e],Bq.attempt.unlinkSync(e))},purgeSyncAll:()=>{for(let e in Gq.store)Gq.purgeSync(e)},truncate:e=>{let t=O.basename(e);if(t.length<=128)return e;let n=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(t);if(!n)return e;let r=t.length-128;return`${e.slice(0,-t.length)}${n[1]}${n[2].slice(0,-r)}${n[3]}`}};ike(Gq.purgeSyncAll);function Kq(e,t,n=QOe){if(Vq(n))return Kq(e,t,{encoding:n});let r={timeout:n.timeout??1e3},i=null,a=null,o=null;try{let s=Bq.attempt.realpathSync(e),c=!!s;e=s||e,[a,i]=Gq.get(e,n.tmpCreate||Gq.create,n.tmpPurge!==!1);let l=tke&&Hq(n.chown),u=Hq(n.mode);if(c&&(l||u)){let t=Bq.attempt.statSync(e);t&&(n={...n},l&&(n.chown={uid:t.uid,gid:t.gid}),u&&(n.mode=t.mode))}if(!c){let t=O.dirname(e);Bq.attempt.mkdirSync(t,{mode:511,recursive:!0})}o=Bq.retry.openSync(r)(a,`w`,n.mode||438),n.tmpCreated&&n.tmpCreated(a),Vq(t)?Bq.retry.writeSync(r)(o,t,0,n.encoding||`utf8`):Hq(t)||Bq.retry.writeSync(r)(o,t,0,t.length,0),n.fsync!==!1&&(n.fsyncWait===!1?Bq.attempt.fsync(o):Bq.retry.fsyncSync(r)(o)),Bq.retry.closeSync(r)(o),o=null,n.chown&&(n.chown.uid!==$Oe||n.chown.gid!==eke)&&Bq.attempt.chownSync(a,n.chown.uid,n.chown.gid),n.mode&&n.mode!==438&&Bq.attempt.chmodSync(a,n.mode);try{Bq.retry.renameSync(r)(a,e)}catch(t){if(!nke(t)||t.code!==`ENAMETOOLONG`)throw t;Bq.retry.renameSync(r)(a,Gq.truncate(e))}i(),a=null}finally{o&&Bq.attempt.closeSync(o),a&&Gq.purge(a)}}var qq=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dynamicAnchor=void 0;let t=BW(),n=HW(),r=$W(),i=nG(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}e.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}e.default=a})),Jq=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dynamicRef=void 0;let t=BW(),n=HW(),r=nG(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}e.dynamicRef=a,e.default=i})),ake=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qq(),n=VW();e.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),oke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Jq();e.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),ske=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qq(),n=Jq(),r=ake(),i=oke();e.default=[t.default,n.default,r.default,i.default]})),cke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cG();e.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),lke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cG();e.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),uke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=VW();e.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),dke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cke(),n=lke(),r=uke();e.default=[t.default,n.default,r.default]})),fke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=BW(),n=VW(),r=HW();e.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),pke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=BW(),n=VW();e.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),mke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fke(),n=pke();e.default=[t.default,n.default]})),hke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rG(),n=aG(),r=uG(),i=ske(),a=dke(),o=mke(),s=dG(),c=fG();e.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),gke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/schema`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],type:[`object`,`boolean`],$comment:`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,properties:{definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}}}})),_ke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:`meta`,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}}}})),vke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/unevaluated`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:`meta`,title:`Unevaluated applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}}}})),yke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/content`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}}}})),bke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/core`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:`meta`,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},$defs:{anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}}}})),xke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/format-annotation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:`meta`,title:`Format vocabulary meta-schema for annotation results`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),Ske=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:`meta`,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),Cke=G(((e,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:`meta`,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),wke=G((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=gke(),n=_ke(),r=vke(),i=yke(),a=bke(),o=xke(),s=Ske(),c=Cke(),l=[`/properties`];function u(e){return[t,n,r,i,a,u(this,o),s,u(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function u(t,n){return e?t.$dataMetaSchema(n,l):n}}e.default=u})),Tke=G(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;let n=tG(),r=hke(),i=pG(),a=wke(),o=`https://json-schema.org/draft/2020-12/schema`;var s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};e.Ajv2020=s,t.exports=e=s,t.exports.Ajv2020=s,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=s;var c=XW();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return c.KeywordCxt}});var l=BW();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return l.CodeGen}});var u=ZW();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return u.default}});var d=QW();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return d.default}})}));const Eke=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!Dke(i,a)&&r||Object.defineProperty(e,n,a)},Dke=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Oke=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},kke=(e,t)=>`/* Wrapped ${e}*/\n${t}`,Ake=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),jke=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),Mke=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=kke.bind(null,r,t.toString());Object.defineProperty(i,`name`,jke);let{writable:a,enumerable:o,configurable:s}=Ake;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function Nke(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))Eke(e,t,r,n);return Oke(e,t),Mke(e,t,r),e}const Yq=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);let{wait:n=0,maxWait:r=1/0,before:i=!1,after:a=!0}=t;if(n<0||r<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!a)throw Error("Both `before` and `after` are false, function wouldn't be called.");let o,s,c,l=function(...t){let l=this,u=()=>{o=void 0,s&&=(clearTimeout(s),void 0),a&&(c=e.apply(l,t))},d=()=>{s=void 0,o&&=(clearTimeout(o),void 0),a&&(c=e.apply(l,t))},f=i&&!o;return clearTimeout(o),o=setTimeout(u,n),r>0&&r!==1/0&&!s&&(s=setTimeout(d,r)),f&&(c=e.apply(l,t)),c};return Nke(l,e),l.cancel=()=>{o&&=(clearTimeout(o),void 0),s&&=(clearTimeout(s),void 0)},l};var Xq=G(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),Zq=G(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),Qq=G(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=Xq(),a=Zq();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),$q=G(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),eJ=G(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),tJ=G(((e,t)=>{let n=Zq(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=Xq(),{safeRe:a,t:o}=Qq(),s=$q(),{compareIdentifiers:c}=eJ();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),nJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),Pke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Fke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Ike=G(((e,t)=>{let n=tJ();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Lke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Rke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).major})),zke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).minor})),Bke=G(((e,t)=>{let n=tJ();t.exports=(e,t)=>new n(e,t).patch})),Vke=G(((e,t)=>{let n=nJ();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),rJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Hke=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(t,e,r)})),Uke=G(((e,t)=>{let n=rJ();t.exports=(e,t)=>n(e,t,!0)})),iJ=G(((e,t)=>{let n=tJ();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Wke=G(((e,t)=>{let n=iJ();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Gke=G(((e,t)=>{let n=iJ();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),aJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)>0})),oJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)<0})),Kke=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)===0})),sJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)!==0})),cJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)>=0})),lJ=G(((e,t)=>{let n=rJ();t.exports=(e,t,r)=>n(e,t,r)<=0})),uJ=G(((e,t)=>{let n=Kke(),r=sJ(),i=aJ(),a=cJ(),o=oJ(),s=lJ();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),qke=G(((e,t)=>{let n=tJ(),r=nJ(),{safeRe:i,t:a}=Qq();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Jke=G(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),dJ=G(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(k(this.set[t],e,this.options))return!0;return!1}};let r=new(Jke()),i=$q(),a=fJ(),o=Zq(),s=tJ(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Qq(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=Xq(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),fJ=G(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=$q(),{safeRe:i,t:a}=Qq(),o=uJ(),s=Zq(),c=tJ(),l=dJ()})),pJ=G(((e,t)=>{let n=dJ();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Yke=G(((e,t)=>{let n=dJ();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Xke=G(((e,t)=>{let n=tJ(),r=dJ();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Zke=G(((e,t)=>{let n=tJ(),r=dJ();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Qke=G(((e,t)=>{let n=tJ(),r=dJ(),i=aJ();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),$ke=G(((e,t)=>{let n=dJ();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),mJ=G(((e,t)=>{let n=tJ(),r=fJ(),{ANY:i}=r,a=dJ(),o=pJ(),s=aJ(),c=oJ(),l=lJ(),u=cJ();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),eAe=G(((e,t)=>{let n=mJ();t.exports=(e,t,r)=>n(e,t,`>`,r)})),tAe=G(((e,t)=>{let n=mJ();t.exports=(e,t,r)=>n(e,t,`<`,r)})),nAe=G(((e,t)=>{let n=dJ();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),rAe=G(((e,t)=>{let n=pJ(),r=rJ();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),iAe=G(((e,t)=>{let n=dJ(),r=fJ(),{ANY:i}=r,a=pJ(),o=rJ(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),aAe=G(((e,t)=>{let n=Qq(),r=Xq(),i=tJ(),a=eJ();t.exports={parse:nJ(),valid:Pke(),clean:Fke(),inc:Ike(),diff:Lke(),major:Rke(),minor:zke(),patch:Bke(),prerelease:Vke(),compare:rJ(),rcompare:Hke(),compareLoose:Uke(),compareBuild:iJ(),sort:Wke(),rsort:Gke(),gt:aJ(),lt:oJ(),eq:Kke(),neq:sJ(),gte:cJ(),lte:lJ(),cmp:uJ(),coerce:qke(),Comparator:fJ(),Range:dJ(),satisfies:pJ(),toComparators:Yke(),maxSatisfying:Xke(),minSatisfying:Zke(),minVersion:Qke(),validRange:$ke(),outside:mJ(),gtr:eAe(),ltr:tAe(),intersects:nAe(),simplifyRange:rAe(),subset:iAe(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));const oAe=Object.prototype.toString;function hJ(e,t,n){return e?e.constructor===t?!0:oAe.call(e)===n:!1}function gJ(e){return hJ(e,Uint8Array,`[object Uint8Array]`)}function sAe(e){return hJ(e,ArrayBuffer,`[object ArrayBuffer]`)}function cAe(e){return gJ(e)||sAe(e)}function lAe(e){if(!gJ(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function uAe(e){if(!cAe(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function _J(e,t){if(e.length===0)return new Uint8Array;t??=e.reduce((e,t)=>e+t.length,0);let n=new Uint8Array(t),r=0;for(let t of e)lAe(t),n.set(t,r),r+=t.length;return n}const vJ={utf8:new globalThis.TextDecoder(`utf8`)};function yJ(e,t=`utf8`){return uAe(e),vJ[t]??=new globalThis.TextDecoder(t),vJ[t].decode(e)}function dAe(e){if(typeof e!=`string`)throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}const fAe=new globalThis.TextEncoder;function bJ(e){return dAe(e),fAe.encode(e)}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));var pAe=Tke(),xJ=Qe(aAe(),1);const SJ=`aes-256-cbc`,CJ=new Set([`aes-256-cbc`,`aes-256-gcm`,`aes-256-ctr`]),mAe=e=>typeof e==`string`&&CJ.has(e),wJ=()=>Object.create(null),TJ=e=>e!==void 0,EJ=(e,t)=>{let n=new Set([`undefined`,`symbol`,`function`]),r=typeof t;if(n.has(r))throw TypeError(`Setting a value of type \`${r}\` for key \`${e}\` is not allowed as it's not supported by JSON`)},DJ=`__internal__`,OJ=`${DJ}.migrations.version`;var hAe=class{path;events;#e;#t;#n;#r;#i={};#a=!1;#o;#s;#c;constructor(e={}){let t=this.#l(e);this.#r=t,this.#u(t),this.#f(t),this.#p(t),this.events=new EventTarget,this.#t=t.encryptionKey,this.#n=t.encryptionAlgorithm??SJ,this.path=this.#m(t),this.#h(t),t.watch&&this._watch()}get(e,t){if(this.#r.accessPropertiesByDotNotation)return this._get(e,t);let{store:n}=this;return e in n?n[e]:t}set(e,t){if(typeof e!=`string`&&typeof e!=`object`)throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof e}`);if(typeof e!=`object`&&t===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(e))throw TypeError(`Please don't use the ${DJ} key, as it's used to manage this module internal operations.`);let{store:n}=this,r=(e,t)=>{if(EJ(e,t),this.#r.accessPropertiesByDotNotation)Dq(n,e,t);else{if(e===`__proto__`||e===`constructor`||e===`prototype`)return;n[e]=t}};if(typeof e==`object`){let t=e;for(let[e,n]of Object.entries(t))r(e,n)}else r(e,t);this.store=n}has(e){return this.#r.accessPropertiesByDotNotation?Oq(this.store,e):e in this.store}appendToArray(e,t){EJ(e,t);let n=this.#r.accessPropertiesByDotNotation?this._get(e,[]):e in this.store?this.store[e]:[];if(!Array.isArray(n))throw TypeError(`The key \`${e}\` is already set to a non-array value`);this.set(e,[...n,t])}reset(...e){for(let t of e)TJ(this.#i[t])&&this.set(t,this.#i[t])}delete(e){let{store:t}=this;this.#r.accessPropertiesByDotNotation?KOe(t,e):delete t[e],this.store=t}clear(){let e=wJ();for(let t of Object.keys(this.#i))TJ(this.#i[t])&&(EJ(t,this.#i[t]),this.#r.accessPropertiesByDotNotation?Dq(e,t,this.#i[t]):e[t]=this.#i[t]);this.store=e}onDidChange(e,t){if(typeof e!=`string`)throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof e}`);if(typeof t!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`);return this._handleValueChange(()=>this.get(e),t)}onDidAnyChange(e){if(typeof e!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof e}`);return this._handleStoreChange(e)}get size(){return Object.keys(this.store).filter(e=>!this._isReservedKeyPath(e)).length}get store(){try{let e=c.readFileSync(this.path,this.#t?null:`utf8`);return(e=>{let t=this._deserialize(e);return this.#a||this._validate(t),Object.assign(wJ(),t)})(this._decryptData(e))}catch(e){if(e?.code===`ENOENT`)return this._ensureDirectory(),wJ();if(this.#r.clearInvalidConfig){let t=e;if(t.name===`SyntaxError`||t.message?.startsWith(`Config schema violation:`)||t.message===`Failed to decrypt config data.`)return wJ()}throw e}}set store(e){if(this._ensureDirectory(),!Oq(e,DJ))try{let t=c.readFileSync(this.path,this.#t?null:`utf8`),n=this._decryptData(t),r=this._deserialize(n);Oq(r,DJ)&&Dq(e,DJ,Eq(r,DJ))}catch{}this.#a||this._validate(e),this._write(e),this.events.dispatchEvent(new Event(`change`))}*[Symbol.iterator](){for(let[e,t]of Object.entries(this.store))this._isReservedKeyPath(e)||(yield[e,t])}_closeWatcher(){this.#o&&=(this.#o.close(),void 0),this.#s&&=(c.unwatchFile(this.path),!1),this.#c=void 0}_decryptData(e){let t=this.#t;if(!t)return typeof e==`string`?e:yJ(e);let n=this.#n,r=n===`aes-256-gcm`?16:0,i=`:`.codePointAt(0),a=typeof e==`string`?e.codePointAt(16):e[16];if(!(i!==void 0&&a===i)){if(n===`aes-256-cbc`)return typeof e==`string`?e:yJ(e);throw Error(`Failed to decrypt config data.`)}let o=e=>{if(r===0)return{ciphertext:e};let t=e.length-r;if(t<0)throw Error(`Invalid authentication tag length.`);return{ciphertext:e.slice(0,t),authenticationTag:e.slice(t)}},s=e.slice(0,16),c=e.slice(17),l=typeof c==`string`?bJ(c):c,u=e=>{let{ciphertext:r,authenticationTag:i}=o(l),a=Pe.pbkdf2Sync(t,e,1e4,32,`sha512`),c=Pe.createDecipheriv(n,a,s);return i&&c.setAuthTag(i),yJ(_J([c.update(r),c.final()]))};try{return u(s)}catch{try{return u(s.toString())}catch{}}if(n===`aes-256-cbc`)return typeof e==`string`?e:yJ(e);throw Error(`Failed to decrypt config data.`)}_handleStoreChange(e){let t=this.store,n=()=>{let n=t,i=this.store;r(i,n)||(t=i,e.call(this,i,n))};return this.events.addEventListener(`change`,n),()=>{this.events.removeEventListener(`change`,n)}}_handleValueChange(e,t){let n=e(),i=()=>{let i=n,a=e();r(a,i)||(n=a,t.call(this,a,i))};return this.events.addEventListener(`change`,i),()=>{this.events.removeEventListener(`change`,i)}}_deserialize=e=>JSON.parse(e);_serialize=e=>JSON.stringify(e,void 0,` `);_validate(e){if(!this.#e||this.#e(e)||!this.#e.errors)return;let t=this.#e.errors.map(({instancePath:e,message:t=``})=>`\`${e.slice(1)}\` ${t}`);throw Error(`Config schema violation: `+t.join(`; `))}_ensureDirectory(){c.mkdirSync(O.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e),n=this.#t;if(n){let e=Pe.randomBytes(16),r=Pe.pbkdf2Sync(n,e,1e4,32,`sha512`),i=Pe.createCipheriv(this.#n,r,e),a=_J([i.update(bJ(t)),i.final()]),o=[e,bJ(`:`),a];this.#n===`aes-256-gcm`&&o.push(i.getAuthTag()),t=_J(o)}if(H.env.SNAP)c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});else try{Kq(this.path,t,{mode:this.#r.configFileMode})}catch(e){if(e?.code===`EXDEV`){c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});return}throw e}}_watch(){if(this._ensureDirectory(),c.existsSync(this.path)||this._write(wJ()),H.platform===`win32`||H.platform===`darwin`){this.#c??=Yq(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:100});let e=O.dirname(this.path),t=O.basename(this.path);this.#o=c.watch(e,{persistent:!1,encoding:`utf8`},(e,n)=>{n&&n!==t||typeof this.#c==`function`&&this.#c()})}else this.#c??=Yq(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:1e3}),c.watchFile(this.path,{persistent:!1},(e,t)=>{typeof this.#c==`function`&&this.#c()}),this.#s=!0}_migrate(e,t,n){let r=this._get(OJ,`0.0.0`),i=Object.keys(e).filter(e=>this._shouldPerformMigration(e,r,t)),a=structuredClone(this.store);for(let o of i)try{n&&n(this,{fromVersion:r,toVersion:o,finalVersion:t,versions:i});let s=e[o];s?.(this),this._set(OJ,o),r=o,a=structuredClone(this.store)}catch(e){this.store=a;let t=e instanceof Error?e.message:String(e);throw Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${t}`)}(this._isVersionInRangeFormat(r)||!xJ.default.eq(r,t))&&this._set(OJ,t)}_containsReservedKey(e){return typeof e==`string`?this._isReservedKeyPath(e):!e||typeof e!=`object`?!1:this._objectContainsReservedKey(e)}_objectContainsReservedKey(e){if(!e||typeof e!=`object`)return!1;for(let[t,n]of Object.entries(e))if(this._isReservedKeyPath(t)||this._objectContainsReservedKey(n))return!0;return!1}_isReservedKeyPath(e){return e===DJ||e.startsWith(`${DJ}.`)}_isVersionInRangeFormat(e){return xJ.default.clean(e)===null}_shouldPerformMigration(e,t,n){return this._isVersionInRangeFormat(e)?t!==`0.0.0`&&xJ.default.satisfies(t,e)?!1:xJ.default.satisfies(n,e):!(xJ.default.lte(e,t)||xJ.default.gt(e,n))}_get(e,t){return Eq(this.store,e,t)}_set(e,t){let{store:n}=this;Dq(n,e,t),this.store=n}#l(e){let t={configName:`config`,fileExtension:`json`,projectSuffix:`nodejs`,clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...e};if(t.encryptionAlgorithm??=SJ,!mAe(t.encryptionAlgorithm))throw TypeError(`The \`encryptionAlgorithm\` option must be one of: ${[...CJ].join(`, `)}`);if(!t.cwd){if(!t.projectName)throw Error("Please specify the `projectName` option.");t.cwd=XOe(t.projectName,{suffix:t.projectSuffix}).config}return typeof t.fileExtension==`string`&&(t.fileExtension=t.fileExtension.replace(/^\.+/,``)),t}#u(e){if(!(e.schema??e.ajvOptions??e.rootSchema))return;if(e.schema&&typeof e.schema!=`object`)throw TypeError("The `schema` option must be an object.");let t=hG.default.default,n=new pAe.Ajv2020({allErrors:!0,useDefaults:!0,...e.ajvOptions});t(n);let r={...e.rootSchema,type:`object`,properties:e.schema};this.#e=n.compile(r),this.#d(e.schema)}#d(e){let t=Object.entries(e??{});for(let[e,n]of t){if(!n||typeof n!=`object`||!Object.hasOwn(n,`default`))continue;let{default:t}=n;t!==void 0&&(this.#i[e]=t)}}#f(e){e.defaults&&Object.assign(this.#i,e.defaults)}#p(e){e.serialize&&(this._serialize=e.serialize),e.deserialize&&(this._deserialize=e.deserialize)}#m(e){let t=typeof e.fileExtension==`string`?e.fileExtension:void 0,n=t?`.${t}`:``;return O.resolve(e.cwd,`${e.configName??`config`}${n}`)}#h(e){if(e.migrations){this.#g(e),this._validate(this.store);return}let t=this.store,n=Object.assign(wJ(),e.defaults??{},t);this._validate(n);try{je.deepEqual(t,n)}catch{this.store=n}}#g(e){let{migrations:t,projectVersion:n}=e;if(t){if(!n)throw Error("Please specify the `projectVersion` option.");this.#a=!0;try{let r=this.store,i=Object.assign(wJ(),e.defaults??{},r);try{je.deepEqual(r,i)}catch{this._write(i)}this._migrate(t,n,e.beforeEachMigration)}finally{this.#a=!1}}}};const kJ=`api_key`;async function gAe(e){if(await e.getSecret(kJ))return;let t;try{t=new hAe({projectName:`abacusai-cli`,configName:`storage`})}catch{return}let n=t.get(`codellm.apikey`),r=t.get(`codellm.devicecode`);typeof n==`string`&&n&&await e.setSecret(kJ,n),typeof r==`string`&&r&&await e.setSecret(`device_code`,r),(n||r)&&t.clear()}const AJ=`aes-256-gcm`;var _Ae=class{storePath;data=null;constructor(){this.storePath=O.join(te(),hn.configDirName,`keystore.enc`)}getMachineKey(){let e=`${I()}:${process.env.USER??process.env.USERNAME??`user`}`;return Re(e,Buffer.from(e.padEnd(16,`0`).slice(0,16)),1e5,32,`sha256`)}encrypt(e){let t=this.getMachineKey(),n=ze(12),r=Fe(AJ,t,n),i=Buffer.concat([r.update(e,`utf-8`),r.final()]),a=r.getAuthTag();return Buffer.concat([n,a,i])}decrypt(e){let t=this.getMachineKey(),n=e.subarray(0,12),r=e.subarray(12,28),i=e.subarray(28),a=Ie(AJ,t,n);return a.setAuthTag(r),a.update(i).toString(`utf-8`)+a.final(`utf-8`)}async load(){if(this.data!==null)return this.data;try{let e=await m.readFile(this.storePath),t=this.decrypt(e);this.data=JSON.parse(t)}catch{this.data={}}return this.data}async save(){let e=O.dirname(this.storePath);await m.mkdir(e,{recursive:!0});let t=this.encrypt(JSON.stringify(this.data??{}));await m.writeFile(this.storePath,t)}async getSecret(e){return(await this.load())[e]??null}async setSecret(e,t){let n=await this.load();n[e]=t,await this.save()}async deleteSecret(e){let t=await this.load();delete t[e],await this.save()}};async function vAe(){try{let e=await import(`keytar`),t=e.default??e,n=hn.keychainService;return{async getSecret(e){return t.getPassword(n,e)},async setSecret(e,r){await t.setPassword(n,e,r)},async deleteSecret(e){await t.deletePassword(n,e)}}}catch{return new _Ae}}const jJ=`api_key`,MJ=`device_code`,NJ=`auth_token`;var PJ=class e{storage;envApiKey;envDeviceCode;storedApiKey=null;storedDeviceCode=null;storedToken=null;constructor(e,t={}){this.storage=e,this.envApiKey=t.apiKey??null,this.envDeviceCode=t.deviceCode??null}static async create(){let t=await vAe();await gAe(t);let n=new e(t,{apiKey:process.env[`${hn.envPrefix}API_KEY`]??null,deviceCode:process.env[`${hn.internalEnvPrefix}DEVICE_CODE`]??null});return await n.loadFromStorage(),n}static async createWithStorage(t,n){let r=new e(t,{apiKey:n?.apiKey??process.env[`${hn.envPrefix}API_KEY`]??null,deviceCode:n?.deviceCode??process.env[`${hn.internalEnvPrefix}DEVICE_CODE`]??null});return await r.loadFromStorage(),r}async loadFromStorage(){let[e,t,n]=await Promise.all([this.storage.getSecret(jJ),this.storage.getSecret(MJ),this.storage.getSecret(NJ)]);if(this.storedApiKey=e,this.storedDeviceCode=t,n)try{this.storedToken=JSON.parse(n)}catch{this.storedToken=null}}async loginWithApiKey(e){this.storedApiKey=e,await this.storage.setSecret(jJ,e),Al(`login`,`auth`)}async loginWithDeviceCode(e){this.storedDeviceCode=e,await this.storage.setSecret(MJ,e),Al(`login`,`auth`)}async loginWithToken(e){this.storedToken=e,await this.storage.setSecret(NJ,JSON.stringify(e)),Al(`login`,`auth`)}async logout(){return this.isEnvAuth()?!1:(this.storedApiKey=null,this.storedDeviceCode=null,this.storedToken=null,await Promise.all([this.storage.deleteSecret(jJ),this.storage.deleteSecret(MJ),this.storage.deleteSecret(NJ)]),Al(`logout`,`auth`),!0)}getAuthKind(){return this.envDeviceCode?{type:`env_device_code`}:this.envApiKey?{type:`env_api_key`}:this.storedDeviceCode?{type:`device_code`}:this.storedApiKey?{type:`api_key`}:this.storedToken?{type:`oauth_token`}:{type:`logged_out`}}isAuthenticated(){return this.getAuthKind().type!==`logged_out`}isEnvAuth(){let e=this.getAuthKind();return e.type===`env_api_key`||e.type===`env_device_code`}async getHeaders(){return this.envDeviceCode?{DEVICECODE:this.envDeviceCode}:this.envApiKey?{APIKEY:this.envApiKey}:this.storedDeviceCode?{DEVICECODE:this.storedDeviceCode}:this.storedApiKey?{APIKEY:this.storedApiKey}:this.storedToken?{APIKEY:this.storedToken.accessToken}:{}}};async function FJ(){try{return(await import(`node-machine-id`)).machineIdSync({original:!1})}catch{let e=`${I()}:${process.platform}`;return Le(`sha256`).update(e).digest(`hex`)}}
75088
75088
  /**
75089
75089
  * @license React
75090
75090
  * react.production.js
@@ -75140,7 +75140,7 @@ No matching component was found for:
75140
75140
  `).map(e=>Zje(e,i)).join(`
75141
75141
  `):t===`truncate-start`&&(r=r.split(`
75142
75142
  `).map(e=>Xje(e,i)).join(`
75143
- `))}}r=xMe(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&SMe(l,u,e,t),e.style.borderStyle&&_Me(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+sZ(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-sZ(e.style,`Right`):void 0,o=r?u+sZ(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-sZ(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+sZ(e.style,`Top`):o,r=f?u+c.getComputedHeight()-sZ(e.style,`Bottom`):s;for(let i of e.childNodes)cZ(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var CMe=class{rootNode;lastWidth=0;cachedLines=null;output=new Qje(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),cZ(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(JJ(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>JJ(t)>e?$J(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},wMe;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(wMe||={});const lZ=`\x1B[?25h`,uZ=`\x1B[?25l`;function TMe(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function EMe(e){return TMe(99,e)}function dZ(e){let t=e??ZX(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function DMe(e){return(e??ZX()).isTTY}function fZ(e){let t=dZ(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function pZ(e){let t=dZ(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function OMe(e){let t=dZ(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function mZ(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function hZ(...e){return mZ(``,...e)}function gZ(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function kMe(e){return`\x1B]9;`+gZ(e)+`\x07`}function _Z(e,...t){return`\x1B]99;`+t.map(gZ).join(`:`)+`;`+gZ(e)+`\x07`}function AMe(e){return`\x1B]777;notify;;`+gZ(e)+`\x07`}const vZ=`\x1B]9;4;0\x07`;function jMe(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function MMe(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function NMe(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var PMe=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??ZX(),this.profile=$X(this.env),pMe(this.profile),this.terminalType=dZ(this.env),this._isDark=e?.isDark??BX(),this._writer=e?.writer??null,e?.isDark!==void 0&&VX(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,VX(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return XX.parse(e);let t=this._isDark?e.dark:e.light;return XX.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=nZ(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return iZ(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!DMe(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(_Z(r,`d=0:p=title`,n)):this.write(_Z(r))),this.write(AMe(i)),this.write(kMe(i))}showProgress(e){if(!fZ(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(MMe(n));break;case`warning`:this.write(NMe(n));break;default:this.write(jMe(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),fZ(this.env)&&this.write(vZ)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){pZ(this.env)&&this.write(EMe(e))}clearClipboard(){pZ(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return OMe(this.env)?mZ(e)+t+hZ():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(vZ),this._progressHideTimer=null},500)}},FMe=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;requestFullRedrawOnNextCommit=!1;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new wY(this.terminal),this.ownsTui=!0):(this.terminal=new sje,this.tui=new wY(this.terminal),this.ownsTui=!0),this.terminalOutput=new PMe({writer:e=>this.terminal.write(e)}),this.rootNode=hX(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.requestFullRedrawOnNextCommit?(this.requestFullRedrawOnNextCommit=!1,this.tui.requestRender(!0)):this.tui.requestRender(),performance.clearMeasures()},this.bridge=new CMe(this.rootNode),this.tui.addChild(this.bridge),this.container=OX.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!pY(e)&&vY(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){OX.updateContainerSync(e,this.container,null),OX.flushSyncWork()}requestFullRedraw(){this.requestFullRedrawOnNextCommit=!0,this.bridge.invalidate(),this.tui.requestRender(!0)}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(H.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=H.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||H.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),OX.updateContainerSync(null,this.container,null),OX.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),H.stdout.write(lZ))}disableInputProtocols(){this.terminal.write(OY),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=H.rawListeners(`warning`),H.removeAllListeners(`warning`),this.warningInterceptor=()=>{},H.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(H.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,H.stdout.isTTY&&(this.disableInputProtocols(),H.stdout.write(lZ)),H.stdin.isTTY&&H.stdin.isRaw&&H.stdin.setRawMode(!1),this.onSuspended?.(),H.removeListener(`SIGTSTP`,t),H.kill(H.pid,`SIGTSTP`)},n=()=>{H.stdin.isTTY&&H.stdin.setRawMode(!0),H.stdout.isTTY&&(H.stdout.write(uZ),this.terminal.write(`\x1B[?2004h`),this.terminal.write(DY),e&&this.terminal.write(`\x1B[>7u`)),H.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return H.on(`SIGTSTP`,t),H.on(`SIGCONT`,n),()=>{H.removeListener(`SIGTSTP`,t),H.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function IMe(e,t){let n=new FMe(t),r=Z.createElement(PX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});return n.render(r),n.start(),{rerender(e){let t=Z.createElement(PX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},requestFullRedraw(){n.requestFullRedraw()},cleanupTerminal(){n.cleanupTerminal()}}}function Q({children:e,...t}){return(0,X.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function $({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Z.useCallback)(c=>(n&&(c=iZ().dim().render(c)),e&&(c=rZ(c,e,`foreground`)),t&&(c=rZ(c,t,`background`)),r&&(c=iZ().bold().render(c)),i&&(c=iZ().italic().render(c)),a&&(c=iZ().underline().render(c)),o&&(c=iZ().strikethrough().render(c)),s&&(c=iZ().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,X.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const LMe=/\x1b\[[\d:]*;(\d+)/;function RMe(e){let t=LMe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const yZ={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},bZ=(e,t={})=>{let{addInputListener:n}=(0,Z.use)(jX),r=(0,Z.useRef)(e);r.current=e,(0,Z.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(pY(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);yZ.upArrow=!1,yZ.downArrow=!1,yZ.leftArrow=!1,yZ.rightArrow=!1,yZ.pageDown=!1,yZ.pageUp=!1,yZ.home=!1,yZ.end=!1,yZ.return=!1,yZ.escape=!1,yZ.ctrl=!1,yZ.shift=!1,yZ.tab=!1,yZ.backspace=!1,yZ.delete=!1,yZ.meta=!1,yZ.super=!1,yZ.paste=!0,yZ.raw=e,r.current(n,{...yZ});return}let t=qAe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);yZ.upArrow=i===`up`,yZ.downArrow=i===`down`,yZ.leftArrow=i===`left`,yZ.rightArrow=i===`right`,yZ.pageDown=i===`pagedown`,yZ.pageUp=i===`pageup`,yZ.home=i===`home`,yZ.end=i===`end`,yZ.return=i===`return`||i===`enter`,yZ.escape=i===`escape`,yZ.ctrl=a,yZ.shift=o,yZ.tab=i===`tab`,yZ.backspace=i===`backspace`,yZ.delete=i===`delete`,yZ.meta=s,yZ.super=RMe(e),yZ.paste=!1,yZ.raw=e;let c=yZ,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=XAe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},zMe=()=>{let e=(0,Z.use)(MX);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},xZ=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Z.use)(kX),l=(0,Z.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Z.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Z.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function SZ(){return(0,Z.use)(AX)}const CZ=()=>{let e=(0,Z.use)(NX);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},wZ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function BMe(){return new RegExp(wZ.source,`g`)}function VMe(e){return e.replace(wZ,``)}function HMe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function TZ(e){return`\x1B]2;`+HMe(e)+`\x07`}var EZ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.9-canary.0`,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/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.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`,"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`,trash:`^9.0.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`}}})),DZ=Qe(EZ(),1);let OZ=null;function kZ(e){let t=(0,xJ.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function AZ(e){if(!e)return``;try{return y(e)}catch{return e}}function jZ(){return{invokedPath:AZ(process.argv[1]??``),execPath:AZ(process.execPath??process.argv[0]??``)}}function MZ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function NZ(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function PZ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=jZ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function FZ(){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{invokedPath:t,execPath:n}=jZ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!MZ(n)?`bun`:`npm`}function UMe(){let{execPath:e,invokedPath:t}=jZ();return NZ(t)||NZ(e)?!1:MZ(e)||MZ(t)}function IZ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=jZ();return!(MZ(r)||MZ(n)||NZ(n)||NZ(r)||process.env.npm_config_user_agent)}function WMe(){let{execPath:e}=jZ(),t=FZ(),n=PZ();return IZ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:UMe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function GMe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function KMe(e){let t=Date.now();if(OZ&&t-OZ.timestamp<6e4)return OZ.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 OZ={tags:r,timestamp:t},r}async function qMe(e,t,n,r){let i=t??kZ(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:FZ(),isEphemeral:PZ(),installationType:`native`,downloadUrl:l.url}}async function JMe(e,t){let n=t??kZ(e),r=FZ(),i=PZ(),a=(await KMe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function LZ(e,t,n,r){let i=WMe();if(i.installationType===`native`)try{return await qMe(e,t,GMe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await JMe(e,t)}function RZ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.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 zZ(e){try{return{ok:!0,output:le(RZ(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}async function BZ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=D.join(P.tmpdir(),`abacusai-update-${Date.now()}`),n=D.join(P.homedir(),hn.configDirName,`bin`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName;try{await we.mkdir(t,{recursive:!0}),await we.mkdir(n,{recursive:!0});let a=D.join(t,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await we.writeFile(a,s),le(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=D.join(t,i),l=D.join(n,i);return await we.copyFile(c,l),r||await we.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await we.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function YMe(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 VZ(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
75143
+ `))}}r=xMe(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&SMe(l,u,e,t),e.style.borderStyle&&_Me(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+sZ(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-sZ(e.style,`Right`):void 0,o=r?u+sZ(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-sZ(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+sZ(e.style,`Top`):o,r=f?u+c.getComputedHeight()-sZ(e.style,`Bottom`):s;for(let i of e.childNodes)cZ(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var CMe=class{rootNode;lastWidth=0;cachedLines=null;output=new Qje(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),cZ(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(JJ(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>JJ(t)>e?$J(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},wMe;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(wMe||={});const lZ=`\x1B[?25h`,uZ=`\x1B[?25l`;function TMe(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function EMe(e){return TMe(99,e)}function dZ(e){let t=e??ZX(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function DMe(e){return(e??ZX()).isTTY}function fZ(e){let t=dZ(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function pZ(e){let t=dZ(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function OMe(e){let t=dZ(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function mZ(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function hZ(...e){return mZ(``,...e)}function gZ(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function kMe(e){return`\x1B]9;`+gZ(e)+`\x07`}function _Z(e,...t){return`\x1B]99;`+t.map(gZ).join(`:`)+`;`+gZ(e)+`\x07`}function AMe(e){return`\x1B]777;notify;;`+gZ(e)+`\x07`}const vZ=`\x1B]9;4;0\x07`;function jMe(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function MMe(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function NMe(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var PMe=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??ZX(),this.profile=$X(this.env),pMe(this.profile),this.terminalType=dZ(this.env),this._isDark=e?.isDark??BX(),this._writer=e?.writer??null,e?.isDark!==void 0&&VX(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,VX(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return XX.parse(e);let t=this._isDark?e.dark:e.light;return XX.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=nZ(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return iZ(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!DMe(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(_Z(r,`d=0:p=title`,n)):this.write(_Z(r))),this.write(AMe(i)),this.write(kMe(i))}showProgress(e){if(!fZ(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(MMe(n));break;case`warning`:this.write(NMe(n));break;default:this.write(jMe(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),fZ(this.env)&&this.write(vZ)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){pZ(this.env)&&this.write(EMe(e))}clearClipboard(){pZ(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return OMe(this.env)?mZ(e)+t+hZ():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(vZ),this._progressHideTimer=null},500)}},FMe=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;requestFullRedrawOnNextCommit=!1;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new wY(this.terminal),this.ownsTui=!0):(this.terminal=new sje,this.tui=new wY(this.terminal),this.ownsTui=!0),this.terminalOutput=new PMe({writer:e=>this.terminal.write(e)}),this.rootNode=hX(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.requestFullRedrawOnNextCommit?(this.requestFullRedrawOnNextCommit=!1,this.tui.requestRender(!0)):this.tui.requestRender(),performance.clearMeasures()},this.bridge=new CMe(this.rootNode),this.tui.addChild(this.bridge),this.container=OX.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!pY(e)&&vY(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){OX.updateContainerSync(e,this.container,null),OX.flushSyncWork()}requestFullRedraw(){this.requestFullRedrawOnNextCommit=!0,this.bridge.invalidate(),this.tui.requestRender(!0)}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(H.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=H.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||H.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),OX.updateContainerSync(null,this.container,null),OX.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),H.stdout.write(lZ))}disableInputProtocols(){this.terminal.write(OY),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=H.rawListeners(`warning`),H.removeAllListeners(`warning`),this.warningInterceptor=()=>{},H.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(H.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,H.stdout.isTTY&&(this.disableInputProtocols(),H.stdout.write(lZ)),H.stdin.isTTY&&H.stdin.isRaw&&H.stdin.setRawMode(!1),this.onSuspended?.(),H.removeListener(`SIGTSTP`,t),H.kill(H.pid,`SIGTSTP`)},n=()=>{H.stdin.isTTY&&H.stdin.setRawMode(!0),H.stdout.isTTY&&(H.stdout.write(uZ),this.terminal.write(`\x1B[?2004h`),this.terminal.write(DY),e&&this.terminal.write(`\x1B[>7u`)),H.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return H.on(`SIGTSTP`,t),H.on(`SIGCONT`,n),()=>{H.removeListener(`SIGTSTP`,t),H.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function IMe(e,t){let n=new FMe(t),r=Z.createElement(PX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});return n.render(r),n.start(),{rerender(e){let t=Z.createElement(PX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},requestFullRedraw(){n.requestFullRedraw()},cleanupTerminal(){n.cleanupTerminal()}}}function Q({children:e,...t}){return(0,X.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function $({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Z.useCallback)(c=>(n&&(c=iZ().dim().render(c)),e&&(c=rZ(c,e,`foreground`)),t&&(c=rZ(c,t,`background`)),r&&(c=iZ().bold().render(c)),i&&(c=iZ().italic().render(c)),a&&(c=iZ().underline().render(c)),o&&(c=iZ().strikethrough().render(c)),s&&(c=iZ().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,X.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const LMe=/\x1b\[[\d:]*;(\d+)/;function RMe(e){let t=LMe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const yZ={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},bZ=(e,t={})=>{let{addInputListener:n}=(0,Z.use)(jX),r=(0,Z.useRef)(e);r.current=e,(0,Z.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(pY(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);yZ.upArrow=!1,yZ.downArrow=!1,yZ.leftArrow=!1,yZ.rightArrow=!1,yZ.pageDown=!1,yZ.pageUp=!1,yZ.home=!1,yZ.end=!1,yZ.return=!1,yZ.escape=!1,yZ.ctrl=!1,yZ.shift=!1,yZ.tab=!1,yZ.backspace=!1,yZ.delete=!1,yZ.meta=!1,yZ.super=!1,yZ.paste=!0,yZ.raw=e,r.current(n,{...yZ});return}let t=qAe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);yZ.upArrow=i===`up`,yZ.downArrow=i===`down`,yZ.leftArrow=i===`left`,yZ.rightArrow=i===`right`,yZ.pageDown=i===`pagedown`,yZ.pageUp=i===`pageup`,yZ.home=i===`home`,yZ.end=i===`end`,yZ.return=i===`return`||i===`enter`,yZ.escape=i===`escape`,yZ.ctrl=a,yZ.shift=o,yZ.tab=i===`tab`,yZ.backspace=i===`backspace`,yZ.delete=i===`delete`,yZ.meta=s,yZ.super=RMe(e),yZ.paste=!1,yZ.raw=e;let c=yZ,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=XAe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},zMe=()=>{let e=(0,Z.use)(MX);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},xZ=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Z.use)(kX),l=(0,Z.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Z.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Z.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function SZ(){return(0,Z.use)(AX)}const CZ=()=>{let e=(0,Z.use)(NX);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},wZ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function BMe(){return new RegExp(wZ.source,`g`)}function VMe(e){return e.replace(wZ,``)}function HMe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function TZ(e){return`\x1B]2;`+HMe(e)+`\x07`}var EZ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.9-canary.1`,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/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.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`,"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`,trash:`^9.0.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`}}})),DZ=Qe(EZ(),1);let OZ=null;function kZ(e){let t=(0,xJ.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function AZ(e){if(!e)return``;try{return y(e)}catch{return e}}function jZ(){return{invokedPath:AZ(process.argv[1]??``),execPath:AZ(process.execPath??process.argv[0]??``)}}function MZ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function NZ(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function PZ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=jZ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function FZ(){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{invokedPath:t,execPath:n}=jZ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!MZ(n)?`bun`:`npm`}function UMe(){let{execPath:e,invokedPath:t}=jZ();return NZ(t)||NZ(e)?!1:MZ(e)||MZ(t)}function IZ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=jZ();return!(MZ(r)||MZ(n)||NZ(n)||NZ(r)||process.env.npm_config_user_agent)}function WMe(){let{execPath:e}=jZ(),t=FZ(),n=PZ();return IZ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:UMe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function GMe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function KMe(e){let t=Date.now();if(OZ&&t-OZ.timestamp<6e4)return OZ.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 OZ={tags:r,timestamp:t},r}async function qMe(e,t,n,r){let i=t??kZ(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:FZ(),isEphemeral:PZ(),installationType:`native`,downloadUrl:l.url}}async function JMe(e,t){let n=t??kZ(e),r=FZ(),i=PZ(),a=(await KMe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function LZ(e,t,n,r){let i=WMe();if(i.installationType===`native`)try{return await qMe(e,t,GMe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await JMe(e,t)}function RZ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.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 zZ(e){try{return{ok:!0,output:le(RZ(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}async function BZ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=D.join(P.tmpdir(),`abacusai-update-${Date.now()}`),n=D.join(P.homedir(),hn.configDirName,`bin`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName;try{await we.mkdir(t,{recursive:!0}),await we.mkdir(n,{recursive:!0});let a=D.join(t,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await we.writeFile(a,s),le(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=D.join(t,i),l=D.join(n,i);return await we.copyFile(c,l),r||await we.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await we.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function YMe(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 VZ(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
75144
75144
  `),process.exit(1)),t?YMe(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const HZ=dt([`codellm`,`cli`,`exit`]),UZ=new Set,WZ=new Set,GZ=new Set;let KZ=!1,qZ=!1,JZ=null,YZ;async function XMe(e){let t=e.map(e=>new Promise(t=>{let n=`writableLength`in e?e.writableLength:0;if((`bufferSize`in e?e.bufferSize:n)===0){t();return}let r=e.write.bind(e),i=!1,a=()=>{let n=`writableLength`in e?e.writableLength:0;(`bufferSize`in e?e.bufferSize:n)===0&&!i&&(i=!0,e.write=r,t())};e.once(`drain`,a),e.write(``,`utf-8`,()=>{a()}),e.write=function(){return!1}}));await Promise.all(t)}async function XZ(e,t,n,r){if(KZ)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:UZ.size,syncCallbacks:WZ.size}),KZ=!0,UZ.size>0&&t&&HZ.error`SYNCHRONOUS TERMINATION NOTICE: When explicitly exiting the process via process.exit or via a parent process, asynchronous tasks in your exitHooks will not run. Either remove these tasks, use gracefulExit() instead of process.exit(), or ensure your parent process sends a SIGINT to the process running this code.`;let i=0;n>0?i=128+n:YZ===void 0?(typeof H.exitCode==`number`||typeof H.exitCode==`string`)&&(i=Number(H.exitCode)):i=YZ;let a=(t=!1)=>{(t||e)&&(JZ?JZ.call(H,i):H.exit(i))};for(let e of WZ)try{e(i)}catch(e){HZ.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of UZ)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{HZ.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(GZ);c.length>0&&o.push(XMe(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),HZ.error`Error during exit cleanup: ${e}`,a(!0)}}function ZMe(){qZ||(qZ=!0,H.once(`beforeExit`,()=>{XZ(!0,!1,-128)}),H.once(`SIGINT`,()=>{XZ(!0,!1,2)}),H.once(`SIGTERM`,()=>{XZ(!0,!1,15)}),H.once(`exit`,()=>{XZ(!1,!0,0)}),H.on(`message`,e=>{e===`shutdown`&&XZ(!0,!0,-128)}),JZ||(JZ=H.exit.bind(H),H.exit=function(e){if(YZ===void 0&&(YZ=e??0),UZ.size===0&&GZ.size===0){if(JZ){JZ(e??0);return}H.exit(e??0)}XZ(!0,!1,-128).catch(e=>{HZ.error`Error during exit: ${e}`,JZ?JZ(1):H.exit(1)})}))}function ZZ(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(KZ)throw Error(`Cannot install exit hook while exit handlers are running`);t?.logger?.debug?.(`Registering exit hook`,{wait:t?.wait,hasStreams:t?.streams!==void 0}),ZMe();let n=t?.wait??0,r=t?.streams??[H.stdout,H.stderr];if(n>0){let t=[e,n];UZ.add(t);for(let e of r)GZ.add(e);return()=>{UZ.delete(t);for(let e of r)GZ.delete(e)}}return WZ.add(e),()=>{WZ.delete(e)}}function QZ(e){e!==void 0&&(H.exitCode=e),XZ(!0,!1,-128)}const $Z=`${hn.internalEnvPrefix}CLIENT_KIND`;function QMe(){let e=process.env[$Z]?.trim();if(!e)return tt.CLI;try{return nt(e)}catch{throw Error(`Invalid ${$Z} value: ${e}. Expected one of ${Object.values(tt).join(`, `)}.`)}}function eQ(e){process.stdout.write(JSON.stringify(e)+`
75145
75145
  `)}function $Me(e){try{return JSON.parse(e)}catch{return null}}async function eNe({agentArgs:e}){Al(`ndjson IPC host started`,`cli`);let t=QMe(),n=await PJ.create(),r=new Ul(n,Sn(),gn.userAgentNames.desktop,DZ.default.version);if(!n.isAuthenticated())try{(await r.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
75146
75146
  `),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
@@ -75171,7 +75171,7 @@ A few things to keep in mind (Add Relevant ONES BELOW AS TODOS):
75171
75171
  - Create a validation table:
75172
75172
  | Requirement | Expected | Actual | Pass/Fail |
75173
75173
  - If ANY constraint fails: web_search for correct examples before proceeding AND FIX IT. Do not declare success.
75174
- Follow TASK instructions EXACTLY. Do NOT take shortcuts that bypass task requirements. Add "Re-read ALL requirements from task description and CONFIRM they are met" 2 times to the list of todos.\nThis is the task description: <task_description>${f}</task_description>`);let p=d?`conversation: ${d}`:`conversation: new`;process.stderr.write(`model: ${s} | cwd: ${r} | ${p}\n`);let m=new yq(`cli-print`);await m.load(),m.append(f);let h=``,g=``,_=0;for await(let e of u.send(f))switch(e.type){case`text_delta`:h+=e.content;break;case`thinking_delta`:g+=e.content;break;case`tool_requested`:{let t=e.tool.name,n=e.tool.id;if(o===`stream-json`)nQ({type:`tool_call`,name:t,id:n,input:e.tool.input});else{let n=Object.entries(e.tool.input??{}).slice(0,2).map(([e,t])=>`${e}=${JSON.stringify(t).slice(0,60)}`).join(`, `);process.stderr.write(` ${t}(${n})\n`)}break}case`tool_execution_complete`:if(o===`stream-json`){let t=typeof e.result?.content==`string`?e.result.content.slice(0,200):``;nQ({type:`tool_result`,id:e.tool.id,result:t})}break;case`notification`:o===`stream-json`?nQ({type:`notification`,severity:e.severity,message:e.message,...e.actions?{actions:e.actions}:{}}):(e.severity===`error`||e.severity===`warning`)&&process.stderr.write(`[${e.severity}] ${e.message}\n`);break;case`error`:o===`stream-json`?nQ({type:`error`,message:e.error.message}):process.stderr.write(`Error: ${e.error.message}\n`);break;case`credits`:_+=e.creditsUsed;break;default:break}o===`stream-json`?(g&&nQ({type:`thinking`,content:g}),h&&nQ({type:`text`,content:h}),_>0&&nQ({type:`credits`,creditsUsed:_}),nQ({type:`result`,success:!0}),await new Promise(e=>{process.stdout.write(``,`utf8`,()=>e())})):(h&&(process.stdout.write(h),process.stdout.write(`
75174
+ Follow TASK instructions EXACTLY. Do NOT take shortcuts that bypass task requirements. Add "Re-read ALL requirements from task description and CONFIRM they are met" 2 times to the list of todos.\nThis is the task description: <task_description>${f}</task_description>`);let p=d?`conversation: ${d}`:`conversation: new`;process.stderr.write(`model: ${s} | cwd: ${r} | ${p}\n`);let m=new yq(`cli-print`);await m.load(),m.append(f);let h=``,g=``,_=0;for await(let e of u.send(f))switch(e.type){case`text_delta`:h+=e.content;break;case`thinking_delta`:g+=e.content;break;case`tool_requested`:{let t=e.tool.name,n=e.tool.id;if(o===`stream-json`)nQ({type:`tool_call`,name:t,id:n,input:e.tool.input});else{let n=Object.entries(e.tool.input??{}).slice(0,2).map(([e,t])=>`${e}=${JSON.stringify(t).slice(0,60)}`).join(`, `);process.stderr.write(` ${t}(${n})\n`)}break}case`tool_execution_complete`:if(o===`stream-json`){let t=typeof e.result?.content==`string`?e.result.content.slice(0,200):``;nQ({type:`tool_result`,id:e.tool.id,result:t})}break;case`notification`:o===`stream-json`?nQ({type:`notification`,severity:e.severity,message:e.message,...e.actions?{actions:e.actions}:{}}):(e.severity===`error`||e.severity===`warning`)&&process.stderr.write(`[${e.severity}] ${e.message}\n`);break;case`error`:o===`stream-json`?nQ({type:`error`,message:e.error.message}):process.stderr.write(`Error: ${e.error.message}\n`);break;case`credits`:_+=e.creditsUsed;break;case`session_info`:o===`stream-json`&&nQ({type:`session_info`,contextPercent:e.contextPercent,contextTokensUsed:e.contextTokensUsed,contextWindowMax:e.contextWindowMax});break;default:break}o===`stream-json`?(g&&nQ({type:`thinking`,content:g}),h&&nQ({type:`text`,content:h}),_>0&&nQ({type:`credits`,creditsUsed:_}),nQ({type:`result`,success:!0}),await new Promise(e=>{process.stdout.write(``,`utf8`,()=>e())})):(h&&(process.stdout.write(h),process.stdout.write(`
75175
75175
  `)),_>0&&process.stderr.write(`Credits used: ${_.toFixed(2)}\n`)),process.exit(0)}var rQ=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},oNe={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},iQ=new class{#e=oNe;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function sNe(e){setTimeout(e,0)}var aQ=typeof window>`u`||`Deno`in globalThis;function oQ(){}function cNe(e,t){return typeof e==`function`?e(t):e}function sQ(e){return typeof e==`number`&&e>=0&&e!==1/0}function cQ(e,t){return Math.max(e+(t||0)-Date.now(),0)}function lQ(e,t){return typeof e==`function`?e(t):e}function uQ(e,t){return typeof e==`function`?e(t):e}function dQ(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==pQ(o,t.options))return!1}else if(!hQ(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function fQ(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(mQ(t.options.mutationKey)!==mQ(a))return!1}else if(!hQ(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function pQ(e,t){return(t?.queryKeyHashFn||mQ)(e)}function mQ(e){return JSON.stringify(e,(e,t)=>yQ(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function hQ(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>hQ(e[n],t[n])):!1}var lNe=Object.prototype.hasOwnProperty;function gQ(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=vQ(e)&&vQ(t);if(!r&&!(yQ(e)&&yQ(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:lNe.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=gQ(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function _Q(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function vQ(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function yQ(e){if(!bQ(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!bQ(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function bQ(e){return Object.prototype.toString.call(e)===`[object Object]`}function uNe(e){return new Promise(t=>{iQ.setTimeout(t,e)})}function xQ(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:gQ(e,t)}function dNe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function fNe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var SQ=Symbol();function CQ(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===SQ?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function wQ(e,t){return typeof e==`function`?e(...t):!!e}function pNe(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var TQ=new class extends rQ{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!aQ&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function EQ(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var mNe=sNe;function hNe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=mNe,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var DQ=hNe(),OQ=new class extends rQ{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!aQ&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function gNe(e){return Math.min(1e3*2**e,3e4)}function kQ(e){return(e??`online`)===`online`?OQ.isOnline():!0}var AQ=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function jQ(e){let t=!1,n=0,r,i=EQ(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new AQ(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>TQ.isFocused()&&(e.networkMode===`always`||OQ.isOnline())&&e.canRun(),u=()=>kQ(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(aQ?0:3),o=e.retryDelay??gNe,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),uNe(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var MQ=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sQ(this.gcTime)&&(this.#e=iQ.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(aQ?1/0:300*1e3))}clearGcTimeout(){this.#e&&=(iQ.clearTimeout(this.#e),void 0)}},_Ne=class extends MQ{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=FQ(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=FQ(this.options);e.data!==void 0&&(this.setState(PQ(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=xQ(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(oQ).catch(oQ):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>uQ(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===SQ||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>lQ(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!cQ(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=CQ(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=jQ({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof AQ&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof AQ){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...NQ(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...PQ(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),DQ.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function NQ(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:kQ(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function PQ(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function FQ(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vNe=class extends rQ{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=EQ(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),IQ(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return LQ(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return LQ(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof uQ(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!_Q(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&RQ(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||uQ(this.options.enabled,this.#t)!==uQ(t.enabled,this.#t)||lQ(this.options.staleTime,this.#t)!==lQ(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||uQ(this.options.enabled,this.#t)!==uQ(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return bNe(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(oQ)),t}#g(){this.#b();let e=lQ(this.options.staleTime,this.#t);if(aQ||this.#r.isStale||!sQ(e))return;let t=cQ(this.#r.dataUpdatedAt,e)+1;this.#d=iQ.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(aQ||uQ(this.options.enabled,this.#t)===!1||!sQ(this.#p)||this.#p===0)&&(this.#f=iQ.setInterval(()=>{(this.options.refetchIntervalInBackground||TQ.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(iQ.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(iQ.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&IQ(e,t),o=i&&RQ(e,n,t,r);(a||o)&&(l={...l,...NQ(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=xQ(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=xQ(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:zQ(e,t),refetch:this.refetch,promise:this.#o,isEnabled:uQ(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=EQ())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!_Q(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){DQ.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function yNe(e,t){return uQ(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function IQ(e,t){return yNe(e,t)||e.state.data!==void 0&&LQ(e,t,t.refetchOnMount)}function LQ(e,t,n){if(uQ(t.enabled,e)!==!1&&lQ(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&zQ(e,t)}return!1}function RQ(e,t,n,r){return(e!==t||uQ(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&zQ(e,n)}function zQ(e,t){return uQ(t.enabled,e)!==!1&&e.isStaleByTime(lQ(t.staleTime,e))}function bNe(e,t){return!_Q(e.getCurrentResult(),t)}function BQ(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{pNe(e,()=>t.signal,()=>n=!0)},u=CQ(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?fNe:dNe;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?xNe:VQ,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:VQ(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function VQ(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function xNe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var SNe=class extends MQ{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||CNe(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=jQ({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),DQ.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function CNe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var wNe=class extends rQ{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new SNe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=HQ(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=HQ(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=HQ(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=HQ(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){DQ.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>fQ(t,e))}findAll(e={}){return this.getAll().filter(t=>fQ(e,t))}notify(e){DQ.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return DQ.batch(()=>Promise.all(e.map(e=>e.continue().catch(oQ))))}};function HQ(e){return e.options.scope?.id}var TNe=class extends rQ{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??pQ(r,t),a=this.get(i);return a||(a=new _Ne({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){DQ.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>dQ(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>dQ(e,t)):t}notify(e){DQ.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){DQ.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){DQ.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ENe=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new TNe,this.#t=e.mutationCache||new wNe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=TQ.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=OQ.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(lQ(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=cNe(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return DQ.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;DQ.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return DQ.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=DQ.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(oQ).catch(oQ)}invalidateQueries(e,t={}){return DQ.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=DQ.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(oQ)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(oQ)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(lQ(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(oQ).catch(oQ)}fetchInfiniteQuery(e){return e.behavior=BQ(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(oQ).catch(oQ)}ensureInfiniteQueryData(e){return e.behavior=BQ(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return OQ.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(mQ(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{hQ(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(mQ(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{hQ(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=pQ(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===SQ&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},UQ=Z.createContext(void 0),WQ=e=>{let t=Z.useContext(UQ);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},DNe=({client:e,children:t})=>(Z.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,X.jsx)(UQ.Provider,{value:e,children:t})),GQ=Z.createContext(!1),ONe=()=>Z.useContext(GQ);GQ.Provider;function kNe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ANe=Z.createContext(kNe()),jNe=()=>Z.useContext(ANe),MNe=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?wQ(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},NNe=e=>{Z.useEffect(()=>{e.clearReset()},[e])},PNe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||wQ(n,[e.error,r])),FNe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},INe=(e,t)=>e.isLoading&&e.isFetching&&!t,LNe=(e,t)=>e?.suspense&&t.isPending,KQ=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function RNe(e,t,n){let r=ONe(),i=jNe(),a=WQ(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,FNe(o),MNe(o,i,s),NNe(i);let c=!a.getQueryCache().get(o.queryHash),[l]=Z.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=d?l.subscribe(DQ.batchCalls(e)):oQ;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Z.useEffect(()=>{l.setOptions(o)},[o,l]),LNe(o,u))throw KQ(o,l,i);if(PNe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!aQ&&INe(u,r)&&(c?KQ(o,l,i):s?.promise)?.catch(oQ).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function qQ(e,t){return RNe(e,vNe,t)}function JQ(e){return typeof e==`string`?e:BX()?e.dark:e.light}const YQ=(e,t)=>({light:e,dark:t}),XQ=YQ(`#7c7f93`,`#585b70`),ZQ=YQ(`#9ca0b0`,`#45475a`),QQ=YQ(`#1e66f5`,`#89b4fa`),$Q=YQ(`#8839ef`,`#cba6f7`),e$=YQ(`#179299`,`#94e2d5`),t$=YQ(`#40a02b`,`#a6e3a1`),zNe=YQ(`#d20f39`,`#f38ba8`),n$=YQ(`#df8e1d`,`#f9e2af`),r$=YQ(`#9ca0b0`,`#45475a`),BNe=YQ(`#d5edd4`,`#394545`),i$=YQ(`#40a02b`,`#a6e3a1`),VNe=YQ(`#b5dbb3`,`#4a5f4f`),HNe=YQ(`#f0d0d5`,`#493446`),a$=YQ(`#d20f39`,`#f38ba8`),UNe=YQ(`#e5aeb5`,`#5e3d51`),WNe=YQ(`#1e66f5`,`#89b4fa`),GNe=YQ(`#1e66f5`,`#89b4fa`),KNe=YQ(`#8839ef`,`#cba6f7`),qNe=YQ(`#dd7878`,`#f2cdcd`),o$=YQ(`#8839ef`,`#cba6f7`),s$=YQ(`#40a02b`,`#a6e3a1`),JNe=YQ(`#fe640b`,`#fab387`),c$=YQ(`#9ca0b0`,`#45475a`),l$=YQ(`#1e66f5`,`#89b4fa`),u$=YQ(`#d20f39`,`#f38ba8`),d$=YQ(`#df8e1d`,`#f9e2af`),YNe=YQ(`#4c4f69`,`#cdd6f4`);function f$(e){return(e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e).replace(/<br\s*\/?>/gi,`
75176
75176
  `).replace(/\\n/g,`
75177
75177
  `).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,``).replace(/\*\*(.+?)\*\*/g,`<b>$1</b>`).replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,`<i>$1</i>`).replace(/~~(.+?)~~/g,`<s>$1</s>`)}function XNe(e){let t=e.split(`
@@ -75202,7 +75202,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
75202
75202
  `)+n,i=r+1,r=e.indexOf(`
75203
75203
  `,i)}while(r!==-1);return a+=e.substr(i),a}}})),oBe=G(((e,t)=>{let n=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,r=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,i=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,a=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,o=new Map([[`n`,`
75204
75204
  `],[`r`,`\r`],[`t`,` `],[`b`,`\b`],[`f`,`\f`],[`v`,`\v`],[`0`,`\0`],[`\\`,`\\`],[`e`,`\x1B`],[`a`,`\x07`]]);function s(e){let t=e[0]===`u`,n=e[1]===`{`;return t&&!n&&e.length===5||e[0]===`x`&&e.length===3?String.fromCharCode(parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(parseInt(e.slice(2,-1),16)):o.get(e)||e}function c(e,t){let n=[],r=t.trim().split(/\s*,\s*/g),o;for(let t of r){let r=Number(t);if(!Number.isNaN(r))n.push(r);else if(o=t.match(i))n.push(o[2].replace(a,(e,t,n)=>t?s(t):n));else throw Error(`Invalid Chalk template style argument: ${t} (in style '${e}')`)}return n}function l(e){r.lastIndex=0;let t=[],n;for(;(n=r.exec(e))!==null;){let e=n[1];if(n[2]){let r=c(e,n[2]);t.push([e].concat(r))}else t.push([e])}return t}function u(e,t){let n={};for(let e of t)for(let t of e.styles)n[t[0]]=e.inverse?null:t.slice(1);let r=e;for(let[e,t]of Object.entries(n))if(Array.isArray(t)){if(!(e in r))throw Error(`Unknown Chalk style: ${e}`);r=t.length>0?r[e](...t):r[e]}return r}t.exports=(e,t)=>{let r=[],i=[],a=[];if(t.replace(n,(t,n,o,c,d,f)=>{if(n)a.push(s(n));else if(c){let t=a.join(``);a=[],i.push(r.length===0?t:u(e,r)(t)),r.push({inverse:o,styles:l(c)})}else if(d){if(r.length===0)throw Error(`Found extraneous } in Chalk template literal`);i.push(u(e,r)(a.join(``))),a=[],r.pop()}else a.push(f)}),i.push(a.join(``)),r.length>0){let e=`Chalk template literal is missing ${r.length} closing bracket${r.length===1?``:`s`} (\`}\`)`;throw Error(e)}return i.join(``)}})),sBe=G(((e,t)=>{let n=iBe(),{stdout:r,stderr:i}=FY(),{stringReplaceAll:a,stringEncaseCRLFWithFirstIndex:o}=aBe(),{isArray:s}=Array,c=[`ansi`,`ansi`,`ansi256`,`ansi16m`],l=Object.create(null),u=(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=r?r.level:0;e.level=t.level===void 0?n:t.level};var d=class{constructor(e){return f(e)}};let f=e=>{let t={};return u(t,e),t.template=(...e)=>b(t.template,...e),Object.setPrototypeOf(t,p.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=d,t.template};function p(e){return f(e)}for(let[e,t]of Object.entries(n))l[e]={get(){let n=_(this,g(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:n}),n}};l.visible={get(){let e=_(this,this._styler,!0);return Object.defineProperty(this,`visible`,{value:e}),e}};let m=[`rgb`,`hex`,`keyword`,`hsl`,`hsv`,`hwb`,`ansi`,`ansi256`];for(let e of m)l[e]={get(){let{level:t}=this;return function(...r){let i=g(n.color[c[t]][e](...r),n.color.close,this._styler);return _(this,i,this._isEmpty)}}};for(let e of m){let t=`bg`+e[0].toUpperCase()+e.slice(1);l[t]={get(){let{level:t}=this;return function(...r){let i=g(n.bgColor[c[t]][e](...r),n.bgColor.close,this._styler);return _(this,i,this._isEmpty)}}}}let h=Object.defineProperties(()=>{},{...l,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),g=(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}},_=(e,t,n)=>{let r=(...e)=>s(e[0])&&s(e[0].raw)?v(r,b(r,...e)):v(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,h),r._generator=e,r._styler=t,r._isEmpty=n,r},v=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?``:t;let n=e._styler;if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.indexOf(`\x1B`)!==-1)for(;n!==void 0;)t=a(t,n.close,n.open),n=n.parent;let s=t.indexOf(`
75205
- `);return s!==-1&&(t=o(t,i,r,s)),r+t+i},y,b=(e,...t)=>{let[n]=t;if(!s(n)||!s(n.raw))return t.join(` `);let r=t.slice(1),i=[n.raw[0]];for(let e=1;e<n.length;e++)i.push(String(r[e-1]).replace(/[{}\\]/g,`\\$&`),String(n.raw[e]));return y===void 0&&(y=oBe()),y(e,i.join(``))};Object.defineProperties(p.prototype,l);let x=p();x.supportsColor=r,x.stderr=p({level:i?i.level:0}),x.stderr.supportsColor=i,t.exports=x})),y0=G((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.parse=e.stringify=e.toJson=e.fromJson=e.DEFAULT_THEME=e.plain=void 0;var n=t(sBe());e.plain=function(e){return e},e.DEFAULT_THEME={keyword:n.default.blue,built_in:n.default.cyan,type:n.default.cyan.dim,literal:n.default.blue,number:n.default.green,regexp:n.default.red,string:n.default.red,subst:e.plain,symbol:e.plain,class:n.default.blue,function:n.default.yellow,title:e.plain,params:e.plain,comment:n.default.green,doctag:n.default.green,meta:n.default.grey,"meta-keyword":e.plain,"meta-string":e.plain,section:e.plain,tag:n.default.grey,name:n.default.blue,"builtin-name":e.plain,attr:n.default.cyan,attribute:e.plain,variable:e.plain,bullet:e.plain,code:e.plain,emphasis:n.default.italic,strong:n.default.bold,formula:e.plain,link:n.default.underline,quote:e.plain,"selector-tag":e.plain,"selector-id":e.plain,"selector-class":e.plain,"selector-attr":e.plain,"selector-pseudo":e.plain,"template-tag":e.plain,"template-variable":e.plain,addition:n.default.green,deletion:n.default.red,default:e.plain};function r(t){for(var r={},i=0,a=Object.keys(t);i<a.length;i++){var o=a[i],s=t[o];Array.isArray(s)?r[o]=s.reduce(function(t,n){return n===`plain`?e.plain:t[n]},n.default):r[o]=n.default[s]}return r}e.fromJson=r;function i(e){for(var t={},n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];t[i]=t[i]._styles}return t}e.toJson=i;function a(e){return JSON.stringify(i(e))}e.stringify=a;function o(e){return r(JSON.parse(e))}e.parse=o})),b0=G((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.supportsLanguage=e.listLanguages=e.highlight=void 0;var o=r(zze()),s=r(Qze()),c=a(eBe()),l=y0();function u(e,t,n){switch(t===void 0&&(t={}),e.type){case`text`:var r=e.data;return n===void 0?(t.default||l.DEFAULT_THEME.default||l.plain)(r):r;case`tag`:var i=/hljs-(\w+)/.exec(e.attribs.class);if(i){var a=i[1],o=e.childNodes.map(function(e){return u(e,t,a)}).join(``);return(t[a]||l.DEFAULT_THEME[a]||l.plain)(o)}return e.childNodes.map(function(e){return u(e,t)}).join(``)}throw Error(`Invalid node type `+e.type)}function d(e,t){return t===void 0&&(t={}),s.parseFragment(e,{treeAdapter:c.default}).childNodes.map(function(e){return u(e,t)}).join(``)}function f(e,t){return t===void 0&&(t={}),d(t.language?o.highlight(e,{language:t.language,ignoreIllegals:t.ignoreIllegals}).value:o.highlightAuto(e,t.languageSubset).value,t.theme)}e.highlight=f;function p(){return o.listLanguages()}e.listLanguages=p;function m(e){return!!o.getLanguage(e)}e.supportsLanguage=m,e.default=f,i(y0(),e)}))();function x0(e){return aZ(JQ(e))}function S0(){let e=iZ();return{keyword:x0(o$),built_in:x0(l$),type:x0(d$),literal:x0(o$),number:x0(JNe),regexp:x0(s$),string:x0(s$),subst:x0(u$),symbol:x0(YNe),class:x0(d$),function:x0(l$),title:x0(l$),params:x0(u$),comment:x0(c$),doctag:x0(c$),meta:x0(XQ),"meta-keyword":x0(o$),"meta-string":x0(s$),section:b0.plain,tag:x0(o$),name:x0(l$),"builtin-name":x0(l$),attr:x0(u$),attribute:x0(u$),variable:x0(u$),bullet:b0.plain,code:b0.plain,emphasis:t=>e.italic().render(t),strong:t=>e.bold().render(t),formula:b0.plain,link:t=>e.underline().render(t),quote:x0(c$),"selector-tag":x0(o$),"selector-id":x0(l$),"selector-class":x0(d$),"selector-attr":x0(u$),"selector-pseudo":x0(o$),"template-tag":x0(o$),"template-variable":x0(u$),addition:x0(t$),deletion:x0(n$),default:b0.plain}}const C0=(0,Z.createContext)(null);function cBe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lBe(e){switch(e){case`success`:return`green`;case`error`:return`red`;case`rejected`:case`interrupted`:return`yellow`;default:return`white`}}function w0(){let[e,t]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>{t(e=>!e)},500);return()=>clearInterval(e)},[]),(0,X.jsx)($,{color:`brightblack`,dimColor:!e,children:`●`})}function T0({name:e,params:t,status:n=`pending`,showSpinner:r,isAwaitingPermission:i,toolCallId:a,paramsLanguage:o}){let s=lBe(n),c=(0,Z.useMemo)(()=>S0(),[]),l=(0,Z.use)(C0),u=i??(l!=null&&(a!=null&&a===l||a==null&&r)),d;d=u?(0,X.jsx)($,{color:`yellow`,children:`◌`}):r?(0,X.jsx)(w0,{}):(0,X.jsx)($,{color:s,children:`⏺`});let f=null;if(t){let e=t;if(o&&(0,b0.supportsLanguage)(o))try{e=(0,b0.highlight)(t,{language:o,theme:c})}catch{}f=o?(0,X.jsxs)($,{children:[`(`,e,`)`]}):(0,X.jsxs)($,{dimColor:!0,children:[`(`,t,`)`]})}return(0,X.jsxs)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:[d,(0,X.jsx)($,{color:`cyan`,children:e}),f]})}function E0({children:e,color:t=`brightblack`,indent:n=2}){return(0,X.jsxs)(Q,{marginLeft:n,flexDirection:`row`,alignItems:`flex-start`,gap:1,children:[(0,X.jsx)($,{color:t,dimColor:!0,children:`⎿`}),(0,X.jsx)($,{color:t,dimColor:!0,children:e})]})}function D0({children:e,indent:t=4}){return(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:t,children:e})}function O0(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,py:`python`,rb:`ruby`,rs:`rust`,go:`go`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`,php:`php`,swift:`swift`,kt:`kotlin`,scala:`scala`,sh:`bash`,bash:`bash`,zsh:`bash`,json:`json`,yaml:`yaml`,yml:`yaml`,xml:`xml`,html:`html`,css:`css`,scss:`scss`,less:`less`,sql:`sql`,md:`markdown`,markdown:`markdown`,txt:`plaintext`,mmd:`mermaid`,mermaid:`mermaid`}[O.extname(e).toLowerCase().slice(1)]}function uBe(e){try{return a0(e)}catch{return null}}function k0({content:e,filePath:t,startLine:n=1,maxLines:r=4,dimmed:i=!1}){let a=(0,Z.useMemo)(()=>S0(),[]),{displayContent:o,totalLines:s,hasMore:c,displayLineCount:l}=(0,Z.useMemo)(()=>{let t=e.split(`
75205
+ `);return s!==-1&&(t=o(t,i,r,s)),r+t+i},y,b=(e,...t)=>{let[n]=t;if(!s(n)||!s(n.raw))return t.join(` `);let r=t.slice(1),i=[n.raw[0]];for(let e=1;e<n.length;e++)i.push(String(r[e-1]).replace(/[{}\\]/g,`\\$&`),String(n.raw[e]));return y===void 0&&(y=oBe()),y(e,i.join(``))};Object.defineProperties(p.prototype,l);let x=p();x.supportsColor=r,x.stderr=p({level:i?i.level:0}),x.stderr.supportsColor=i,t.exports=x})),y0=G((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.parse=e.stringify=e.toJson=e.fromJson=e.DEFAULT_THEME=e.plain=void 0;var n=t(sBe());e.plain=function(e){return e},e.DEFAULT_THEME={keyword:n.default.blue,built_in:n.default.cyan,type:n.default.cyan.dim,literal:n.default.blue,number:n.default.green,regexp:n.default.red,string:n.default.red,subst:e.plain,symbol:e.plain,class:n.default.blue,function:n.default.yellow,title:e.plain,params:e.plain,comment:n.default.green,doctag:n.default.green,meta:n.default.grey,"meta-keyword":e.plain,"meta-string":e.plain,section:e.plain,tag:n.default.grey,name:n.default.blue,"builtin-name":e.plain,attr:n.default.cyan,attribute:e.plain,variable:e.plain,bullet:e.plain,code:e.plain,emphasis:n.default.italic,strong:n.default.bold,formula:e.plain,link:n.default.underline,quote:e.plain,"selector-tag":e.plain,"selector-id":e.plain,"selector-class":e.plain,"selector-attr":e.plain,"selector-pseudo":e.plain,"template-tag":e.plain,"template-variable":e.plain,addition:n.default.green,deletion:n.default.red,default:e.plain};function r(t){for(var r={},i=0,a=Object.keys(t);i<a.length;i++){var o=a[i],s=t[o];Array.isArray(s)?r[o]=s.reduce(function(t,n){return n===`plain`?e.plain:t[n]},n.default):r[o]=n.default[s]}return r}e.fromJson=r;function i(e){for(var t={},n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];t[i]=t[i]._styles}return t}e.toJson=i;function a(e){return JSON.stringify(i(e))}e.stringify=a;function o(e){return r(JSON.parse(e))}e.parse=o})),b0=G((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.supportsLanguage=e.listLanguages=e.highlight=void 0;var o=r(zze()),s=r(Qze()),c=a(eBe()),l=y0();function u(e,t,n){switch(t===void 0&&(t={}),e.type){case`text`:var r=e.data;return n===void 0?(t.default||l.DEFAULT_THEME.default||l.plain)(r):r;case`tag`:var i=/hljs-(\w+)/.exec(e.attribs.class);if(i){var a=i[1],o=e.childNodes.map(function(e){return u(e,t,a)}).join(``);return(t[a]||l.DEFAULT_THEME[a]||l.plain)(o)}return e.childNodes.map(function(e){return u(e,t)}).join(``)}throw Error(`Invalid node type `+e.type)}function d(e,t){return t===void 0&&(t={}),s.parseFragment(e,{treeAdapter:c.default}).childNodes.map(function(e){return u(e,t)}).join(``)}function f(e,t){return t===void 0&&(t={}),d(t.language?o.highlight(e,{language:t.language,ignoreIllegals:t.ignoreIllegals}).value:o.highlightAuto(e,t.languageSubset).value,t.theme)}e.highlight=f;function p(){return o.listLanguages()}e.listLanguages=p;function m(e){return!!o.getLanguage(e)}e.supportsLanguage=m,e.default=f,i(y0(),e)}))();function x0(e){return aZ(JQ(e))}function S0(){let e=iZ();return{keyword:x0(o$),built_in:x0(l$),type:x0(d$),literal:x0(o$),number:x0(JNe),regexp:x0(s$),string:x0(s$),subst:x0(u$),symbol:x0(YNe),class:x0(d$),function:x0(l$),title:x0(l$),params:x0(u$),comment:x0(c$),doctag:x0(c$),meta:x0(XQ),"meta-keyword":x0(o$),"meta-string":x0(s$),section:b0.plain,tag:x0(o$),name:x0(l$),"builtin-name":x0(l$),attr:x0(u$),attribute:x0(u$),variable:x0(u$),bullet:b0.plain,code:b0.plain,emphasis:t=>e.italic().render(t),strong:t=>e.bold().render(t),formula:b0.plain,link:t=>e.underline().render(t),quote:x0(c$),"selector-tag":x0(o$),"selector-id":x0(l$),"selector-class":x0(d$),"selector-attr":x0(u$),"selector-pseudo":x0(o$),"template-tag":x0(o$),"template-variable":x0(u$),addition:x0(t$),deletion:x0(n$),default:b0.plain}}const C0=(0,Z.createContext)(null);function cBe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lBe(e){switch(e){case`success`:return`green`;case`error`:return`red`;case`rejected`:case`interrupted`:return`yellow`;default:return`white`}}function w0(){let[e,t]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>{t(e=>!e)},500);return()=>clearInterval(e)},[]),(0,X.jsx)($,{color:`brightblack`,dimColor:!e,children:`●`})}function T0({name:e,params:t,status:n=`pending`,showSpinner:r,isAwaitingPermission:i,toolCallId:a,paramsLanguage:o}){let s=lBe(n),c=(0,Z.useMemo)(()=>S0(),[]),l=(0,Z.use)(C0),u=i??(l!=null&&(a!=null&&a===l||a==null&&r)),d;d=u?(0,X.jsx)($,{color:`yellow`,children:`◌`}):r?(0,X.jsx)(w0,{}):(0,X.jsx)($,{color:s,children:`●`});let f=null;if(t){let e=t;if(o&&(0,b0.supportsLanguage)(o))try{e=(0,b0.highlight)(t,{language:o,theme:c})}catch{}f=o?(0,X.jsxs)($,{children:[`(`,e,`)`]}):(0,X.jsxs)($,{dimColor:!0,children:[`(`,t,`)`]})}return(0,X.jsxs)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:[d,(0,X.jsx)($,{color:`cyan`,children:e}),f]})}function E0({children:e,color:t=`brightblack`,indent:n=2}){return(0,X.jsxs)(Q,{marginLeft:n,flexDirection:`row`,alignItems:`flex-start`,gap:1,children:[(0,X.jsx)($,{color:t,dimColor:!0,children:`⎿`}),(0,X.jsx)($,{color:t,dimColor:!0,children:e})]})}function D0({children:e,indent:t=4}){return(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:t,children:e})}function O0(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,py:`python`,rb:`ruby`,rs:`rust`,go:`go`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`,php:`php`,swift:`swift`,kt:`kotlin`,scala:`scala`,sh:`bash`,bash:`bash`,zsh:`bash`,json:`json`,yaml:`yaml`,yml:`yaml`,xml:`xml`,html:`html`,css:`css`,scss:`scss`,less:`less`,sql:`sql`,md:`markdown`,markdown:`markdown`,txt:`plaintext`,mmd:`mermaid`,mermaid:`mermaid`}[O.extname(e).toLowerCase().slice(1)]}function uBe(e){try{return a0(e)}catch{return null}}function k0({content:e,filePath:t,startLine:n=1,maxLines:r=4,dimmed:i=!1}){let a=(0,Z.useMemo)(()=>S0(),[]),{displayContent:o,totalLines:s,hasMore:c,displayLineCount:l}=(0,Z.useMemo)(()=>{let t=e.split(`
75206
75206
  `),n=t.length,i=t.slice(0,r);return{displayContent:i.join(`
75207
75207
  `),displayLineCount:i.length,totalLines:n,hasMore:n>r}},[e,r]),u=(0,Z.useMemo)(()=>{if(!o)return o;let n=t?O0(t):void 0;if(n===`mermaid`){let t=uBe(e);if(t!==null)return t}if(n&&(0,b0.supportsLanguage)(n))try{return(0,b0.highlight)(o,{language:n,theme:a})}catch{}return o},[o,t,e,a]);if(!o)return null;let d=(n+s-1).toString().length;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[u.split(`
75208
75208
  `).map((e,t)=>{let r=n+t;return(0,X.jsxs)($,{dimColor:i,children:[(0,X.jsxs)($,{dimColor:!0,children:[String(r).padStart(d,` `),` │ `]}),e]},t)}),c&&(0,X.jsxs)($,{dimColor:!0,children:[` ... `,s-l,` more lines`]})]})}function A0(e,t,n){let r=O0(t);if(r&&r!==`mermaid`&&(0,b0.supportsLanguage)(r))try{return(0,b0.highlight)(e,{language:r,...n?{theme:n}:{}}).split(`
@@ -75217,7 +75217,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
75217
75217
  `).length:0,r=e.newContent?e.newContent.split(`
75218
75218
  `).length:0;return Math.max(n,r)>=500*2}const l2=(0,Z.memo)(({files:e,dimmed:t=!1,showSummary:n=!0})=>{let r=(0,Z.useMemo)(()=>{let t=[],n=[],r=0;for(let i=0;i<e.length;i++)a2(e[i].filePath)?n[i]=-1:(t.push(e[i]),n[i]=r++);let i=XBe(t);return e.map((e,t)=>{let r=n[t];return r===-1?{additions:0,deletions:0}:i[r]??{additions:0,deletions:0}})},[e]),i=r.reduce((e,t)=>e+t.additions,0),a=r.reduce((e,t)=>e+t.deletions,0);return e.length===0?(0,X.jsx)($,{dimColor:!0,children:`No changes`}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[n&&(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,X.jsxs)($,{dimColor:!0,children:[e.length,` file`,e.length===1?``:`s`,` changed`]}),i>0&&(0,X.jsxs)($,{color:i$,children:[`+`,i]}),a>0&&(0,X.jsxs)($,{color:a$,children:[`-`,a]})]}),e.map((e,n)=>{let i=r[n]??{additions:0,deletions:0};if(a2(e.filePath))return(0,X.jsx)(c2,{filePath:e.filePath,originalContent:e.originalContent,newContent:e.newContent,dimmed:t},e.filePath);let a=QBe(e,i);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(J0,{filePath:e.filePath,stats:i,isNewFile:e.isNewFile,isDeletedFile:e.isDeletedFile,dimmed:t}),a?(0,X.jsxs)($,{dimColor:!0,children:[` `,`Diff not shown — too large (`,i.additions+i.deletions,` changes)`]}):(0,X.jsx)(Q0,{filePath:e.filePath,originalContent:e.originalContent,newContent:e.newContent,dimmed:t,paddingLeft:1})]},e.filePath)})]})});l2.displayName=`MultiFileDiff`;const u2=(0,Z.memo)(({content:e,maxLinesPerCell:t=10,dimmed:n=!1})=>{let r=(0,Z.useMemo)(()=>$0(e),[e]),i=(0,Z.useMemo)(()=>S0(),[]);if(!r)return(0,X.jsx)($,{dimColor:!0,children:`Invalid notebook JSON`});let a=n2(r);return r.cells.length===0?(0,X.jsx)($,{dimColor:!0,children:`Empty notebook`}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)($,{dimColor:!0,children:[r.cells.length,` cell`,r.cells.length===1?``:`s`]}),r.cells.map((e,r)=>{let o=e2(e),s=t2(e),c=i2(r2(e.cell_type,a)),l=o.split(`
75219
75219
  `),u=l.length>t,d=u?l.slice(0,t):l,f=A0(d.join(`
75220
- `),c,i);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{dimColor:n,children:` ┈ `}),(0,X.jsxs)($,{bold:!0,dimColor:n,children:[`Cell `,r+1]}),(0,X.jsxs)($,{dimColor:!0,children:[` [`,e.cell_type,`]`]}),s&&(0,X.jsxs)($,{dimColor:!0,children:[` `,s]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`(`,l.length,` line`,l.length===1?``:`s`,`)`]})]}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:2,children:[d.map((e,t)=>(0,X.jsxs)($,{dimColor:n,children:[(0,X.jsxs)($,{dimColor:!0,children:[String(t+1).padStart(Math.max(1,l.length.toString().length),` `),` │ `]}),f[t]??e]},t)),u&&(0,X.jsxs)($,{dimColor:!0,children:[` ... `,l.length-t,` more lines`]})]})]},`cell-${r}`)})]})});u2.displayName=`NotebookPreview`;const $Be=QL({filePath:Y(),oldString:Y(),newString:Y(),replaceAll:z0});function eVe({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=(0,Z.useContext)(G0),[a,o]=(0,Z.useState)(!1),s=a||i,c=n!=null&&(t===`success`||n.phase===`skipped`),{isFocused:l}=xZ({id:`edit-tool-${e?.filePath||e?.file_path||`unknown`}`,isActive:!i&&c});bZ((e,t)=>{l&&t.ctrl&&e===`o`&&o(e=>!e)},{isActive:l&&!i&&c});let u=$Be.safeParse(P0(e));if(!u.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let d=u.data,f=n?.data.targetFile??d.filePath,p=!n&&(t===`executing`||t===`pending`),m=N0(f),h=r?.isPlanFile??!1,g=n?.data.isNewFile??r?.isNewFile??!1,_=g?`Create`:`Update`;if(h&&t===`success`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`success`}),(0,X.jsx)(E0,{children:`Updated plan`})]});if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`});return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`rejected`}),!h&&e&&t&&(0,X.jsx)(D0,{children:(0,X.jsx)(Q0,{filePath:f,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(p)return(0,X.jsx)(T0,{name:_,params:m,status:`pending`,showSpinner:!0});if(!n)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:_,params:m,status:`pending`})});if(n.phase===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error executing tool`})]});let v=n.phase===`skipped`,y=n.summary??`Updated`,b=r?.originalContent,x=r?.finalContent??r?.newContent;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:v?`rejected`:`success`}),(0,X.jsx)(E0,{color:v?`yellow`:void 0,children:y}),!v&&b!==void 0&&x!==void 0&&(0,X.jsx)(D0,{children:g?(0,X.jsx)(k0,{filePath:f,content:x,maxLines:s?100:15}):(0,X.jsx)(Q0,{filePath:f,originalContent:b,newContent:x})})]})}const tVe={displayName:`Edit`,getHeaderParams(e){try{return N0(e?.filePath||e?.file_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,X.jsx)(eVe,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},nVe=QL({notebookPath:Y(),cellId:Y().optional(),newSource:Y(),cellType:sR([`code`,`markdown`]).optional(),editMode:sR([`replace`,`insert`,`delete`]).optional()});function rVe(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 iVe({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=nVe.safeParse(P0(e));if(!i.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let a=i.data,o=N0(a.notebookPath),s=a.editMode??`replace`,c=rVe(s,a.cellId,a.cellType);if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`});return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`rejected`}),(0,X.jsxs)($,{dimColor:!0,children:[` `,c]}),s!==`delete`&&e&&t&&(0,X.jsx)(D0,{children:(0,X.jsx)(s2,{cellIndex:0,cellType:a.cellType??`code`,cellId:a.cellId,language:a.cellType===`markdown`?`markdown`:`python`,originalSource:e,newSource:t,status:`modified`,dimmed:!0})}),i]})}if(t===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error editing notebook`})]});if(!n&&(t===`executing`||t===`pending`))return(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`pending`,showSpinner:!0});if(!n)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`pending`})});if(n.phase===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:n.errorMessage??`Error editing notebook`})]});let l=n.summary??`Notebook edited`,u=r?.originalContent,d=r?.newContent;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`success`}),(0,X.jsxs)($,{dimColor:!0,children:[` `,c]}),(0,X.jsx)(E0,{children:l}),s!==`delete`&&u!==void 0&&d!==void 0&&(0,X.jsx)(D0,{children:s===`insert`||!u?(0,X.jsx)(Q0,{filePath:i2(a.cellType===`markdown`?`markdown`:`python`),originalContent:``,newContent:d,showHeader:!1,paddingLeft:1}):(0,X.jsx)(s2,{cellIndex:0,cellType:a.cellType??`code`,cellId:a.cellId,language:a.cellType===`markdown`?`markdown`:`python`,originalSource:u,newSource:d,status:`modified`})})]})}const aVe={displayName:`Edit notebook`,getHeaderParams(e){try{return N0(e?.notebookPath||e?.notebook_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,X.jsx)(iVe,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},oVe=/\/var\/folders\/.*\/T\/TemporaryItems\/.*screencaptureui.*\//i,d2=O.join(te(),hn.configDirName,`screenshots`);function f2(e){return oVe.test(e)}function sVe(e){try{let t=p2(e.replace(/\\ /g,` `));if(!f(t))return null;f(d2)||p(d2,{recursive:!0});let n=O.basename(t),r=O.join(d2,n);return l(t,r),r}catch{return null}}function p2(e){if(e.startsWith(`file://`))try{return decodeURIComponent(e.slice(7))}catch{return e.slice(7)}return e}let m2;function h2(){if(m2!==void 0)return m2;try{return ce(`which`,[`wl-paste`],{stdio:`ignore`}),m2=`wl-paste`,`wl-paste`}catch{}try{return ce(`which`,[`xclip`],{stdio:`ignore`}),m2=`xclip`,`xclip`}catch{}return m2=null,null}async function g2(){try{if(process.platform===`darwin`){let e=ce(`osascript`,[`-e`,`clipboard info`],{encoding:`utf8`,timeout:2e3});return/PNGf|JPEG|TIFF|GIF/i.test(e)}if(process.platform===`win32`)return ce(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()`],{encoding:`utf8`,timeout:2e3}).trim().toLowerCase()===`true`;let e=h2();if(e===`wl-paste`)return ce(`wl-paste`,[`--list-types`],{encoding:`utf8`,timeout:2e3}).includes(`image/`);if(e===`xclip`)return ce(`xclip`,[`-selection`,`clipboard`,`-t`,`TARGETS`,`-o`],{encoding:`utf8`,timeout:2e3}).includes(`image/`)}catch{}return!1}async function _2(){try{f(d2)||p(d2,{recursive:!0});let e=Date.now(),t=O.join(d2,`clipboard-${e}.png`);if(process.platform===`darwin`)ce(`osascript`,[`-e`,`
75220
+ `),c,i);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{dimColor:n,children:` ┈ `}),(0,X.jsxs)($,{bold:!0,dimColor:n,children:[`Cell `,r+1]}),(0,X.jsxs)($,{dimColor:!0,children:[` [`,e.cell_type,`]`]}),s&&(0,X.jsxs)($,{dimColor:!0,children:[` `,s]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`(`,l.length,` line`,l.length===1?``:`s`,`)`]})]}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:2,children:[d.map((e,t)=>(0,X.jsxs)($,{dimColor:n,children:[(0,X.jsxs)($,{dimColor:!0,children:[String(t+1).padStart(Math.max(1,l.length.toString().length),` `),` │ `]}),f[t]??e]},t)),u&&(0,X.jsxs)($,{dimColor:!0,children:[` ... `,l.length-t,` more lines`]})]})]},`cell-${r}`)})]})});u2.displayName=`NotebookPreview`;const $Be=QL({filePath:Y(),oldString:Y(),newString:Y(),replaceAll:z0});function eVe({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=(0,Z.useContext)(G0),[a,o]=(0,Z.useState)(!1),s=a||i,c=n!=null&&(t===`success`||n.phase===`skipped`),{isFocused:l}=xZ({id:`edit-tool-${e?.filePath||e?.file_path||`unknown`}`,isActive:!i&&c});bZ((e,t)=>{l&&t.ctrl&&e===`o`&&o(e=>!e)},{isActive:l&&!i&&c});let u=$Be.safeParse(P0(e));if(!u.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let d=u.data,f=n?.data.targetFile??d.filePath,p=!n&&(t===`executing`||t===`pending`),m=N0(f),h=r?.isPlanFile??!1,g=n?.data.isNewFile??r?.isNewFile??!1,_=g?`Create`:`Update`;if(h&&t===`success`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`success`}),(0,X.jsx)(E0,{children:`Updated plan`})]});if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`});return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`rejected`}),!h&&e&&t&&(0,X.jsx)(D0,{children:(0,X.jsx)(Q0,{filePath:f,originalContent:e,newContent:t,dimmed:!0})}),i]})}if(p)return(0,X.jsx)(T0,{name:_,params:m,status:`pending`,showSpinner:!0});if(!n)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:_,params:m,status:`pending`})});if(n.phase===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error executing tool`})]});let v=n.phase===`skipped`,y=n.summary??`Updated`,b=r?.originalContent,x=r?.finalContent??r?.newContent;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:_,params:m,status:v?`rejected`:`success`}),(0,X.jsx)(E0,{color:v?`yellow`:void 0,children:y}),!v&&b!==void 0&&x!==void 0&&(0,X.jsx)(D0,{children:g?(0,X.jsx)(k0,{filePath:f,content:x,maxLines:s?100:15}):(0,X.jsx)(Q0,{filePath:f,originalContent:b,newContent:x})})]})}const tVe={displayName:`Edit`,getHeaderParams(e){try{return N0(e?.filePath||e?.file_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,X.jsx)(eVe,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},nVe=QL({notebookPath:Y(),cellId:Y().optional(),newSource:Y(),cellType:sR([`code`,`markdown`]).optional(),editMode:sR([`replace`,`insert`,`delete`]).optional()});function rVe(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 iVe({rawInput:e,status:t,parsedResult:n,toolDisplayData:r}){let i=nVe.safeParse(P0(e));if(!i.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let a=i.data,o=N0(a.notebookPath),s=a.editMode??`replace`,c=rVe(s,a.cellId,a.cellType);if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`){let e=r?.originalContent??``,t=r?.newContent??``,i=n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`});return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`rejected`}),(0,X.jsxs)($,{dimColor:!0,children:[` `,c]}),s!==`delete`&&e&&t&&(0,X.jsx)(D0,{children:(0,X.jsx)(s2,{cellIndex:0,cellType:a.cellType??`code`,cellId:a.cellId,language:a.cellType===`markdown`?`markdown`:`python`,originalSource:e,newSource:t,status:`modified`,dimmed:!0})}),i]})}if(t===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error editing notebook`})]});if(!n&&(t===`executing`||t===`pending`))return(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`pending`,showSpinner:!0});if(!n)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`pending`})});if(n.phase===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:n.errorMessage??`Error editing notebook`})]});let l=n.summary??`Notebook edited`,u=r?.originalContent,d=r?.newContent;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Edit notebook`,params:o,status:`success`}),(0,X.jsxs)($,{dimColor:!0,children:[` `,c]}),(0,X.jsx)(E0,{children:l}),s!==`delete`&&u!==void 0&&d!==void 0&&(0,X.jsx)(D0,{children:s===`insert`||!u?(0,X.jsx)(Q0,{filePath:i2(a.cellType===`markdown`?`markdown`:`python`),originalContent:``,newContent:d,showHeader:!1,paddingLeft:1}):(0,X.jsx)(s2,{cellIndex:0,cellType:a.cellType??`code`,cellId:a.cellId,language:a.cellType===`markdown`?`markdown`:`python`,originalSource:u,newSource:d,status:`modified`})})]})}const aVe={displayName:`Edit notebook`,getHeaderParams(e){try{return N0(e?.notebookPath||e?.notebook_path||`[unknown]`)}catch{return`[unknown]`}},renderUI(e,t,n,r){return(0,X.jsx)(iVe,{rawInput:e,status:t,parsedResult:n,toolDisplayData:r})}},oVe=/^\/var\/folders\/.*\/T\/TemporaryItems\/.*screencaptureui.*\/.*$/i,d2=O.join(te(),hn.configDirName,`screenshots`);function f2(e){return oVe.test(e)}function sVe(e){try{let t=p2(e.replace(/\\ /g,` `));if(!f(t))return null;f(d2)||p(d2,{recursive:!0});let n=O.basename(t),r=O.join(d2,n);return l(t,r),r}catch{return null}}function p2(e){if(e.startsWith(`file://`))try{return decodeURIComponent(e.slice(7))}catch{return e.slice(7)}return e}let m2;function h2(){if(m2!==void 0)return m2;try{return ce(`which`,[`wl-paste`],{stdio:`ignore`}),m2=`wl-paste`,`wl-paste`}catch{}try{return ce(`which`,[`xclip`],{stdio:`ignore`}),m2=`xclip`,`xclip`}catch{}return m2=null,null}async function g2(){try{if(process.platform===`darwin`){let e=ce(`osascript`,[`-e`,`clipboard info`],{encoding:`utf8`,timeout:2e3});return/PNGf|JPEG|TIFF|GIF/i.test(e)}if(process.platform===`win32`)return ce(`powershell`,[`-NoProfile`,`-Command`,`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()`],{encoding:`utf8`,timeout:2e3}).trim().toLowerCase()===`true`;let e=h2();if(e===`wl-paste`)return ce(`wl-paste`,[`--list-types`],{encoding:`utf8`,timeout:2e3}).includes(`image/`);if(e===`xclip`)return ce(`xclip`,[`-selection`,`clipboard`,`-t`,`TARGETS`,`-o`],{encoding:`utf8`,timeout:2e3}).includes(`image/`)}catch{}return!1}async function _2(){try{f(d2)||p(d2,{recursive:!0});let e=Date.now(),t=O.join(d2,`clipboard-${e}.png`);if(process.platform===`darwin`)ce(`osascript`,[`-e`,`
75221
75221
  set destFile to "${t}"
75222
75222
  try
75223
75223
  set imgData to (clipboard info for «class PNGf»)
@@ -75243,10 +75243,10 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
75243
75243
  `,`utf8`)}function N4(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 hHe(e,t){let n=rHe(t,{});try{s.existsSync(e)&&s.unlinkSync(e)}catch{}let r=V.createServer(e=>{let t=new pHe(t=>{!e.destroyed&&e.writable&&e.write(M4(t))}),r=Buffer.alloc(0);e.on(`data`,async e=>{r=Buffer.concat([r,e]);let[i,a]=N4(r);r=a;for(let e of i)try{await t.message(e,n)}catch(e){Dl(e,{context:`rpc-deserialization`})}}),e.on(`close`,()=>{t.close()}),e.on(`error`,n=>{Dl(n,{context:`socket-server`}),e.destroy(),t.close()})});return new Promise((t,n)=>{r.on(`error`,e=>{Dl(e,{context:`socket-server`}),n(e)}),r.listen(e,()=>{r.removeListener(`error`,n),r.on(`error`,e=>{Dl(e,{context:`socket-server`})});try{s.chmodSync(e,438)}catch{}t({getSocketPath:()=>e,dispose:()=>{r.close();try{s.existsSync(e)&&s.unlinkSync(e)}catch{}}})})})}var gHe=class{peer;constructor(e){this.peer=e}async call(e){let t=await this.peer.request(e);return{...t,body:()=>Promise.resolve(t.body)}}},_He=class extends ZVe{constructor(e){super(new gHe(e),{url:`orpc:/`})}};function vHe(e,t){let n=t?.timeoutMs??2e3;return new Promise((t,r)=>{let i=V.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 dHe(e=>{!i.destroyed&&i.writable&&i.write(M4(e))}),n=Buffer.alloc(0);i.on(`data`,async t=>{n=Buffer.concat([n,t]);let[r,i]=N4(n);n=i;for(let t of r)try{await e.message(t)}catch(e){Dl(e,{context:`rpc-deserialization`})}}),i.on(`close`,()=>e.close()),i.on(`error`,t=>{Dl(t,{context:`socket-client`}),i.destroy(),e.close()}),t({link:new _He(e),dispose:()=>{e.close(),i.destroy()}})}),i.on(`error`,e=>{clearTimeout(a),Dl(e,{context:`socket-connect`}),r(e)})})}const P4=Symbol(`ORPC_LAZY_SYMBOL`);function F4(e,t={}){return{[P4]:{loader:e,meta:t}}}function I4(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&P4 in e}function L4(e){return e[P4].meta}function R4(e){return I4(e)?e[P4].loader():Promise.resolve({default:e})}function yHe(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 bHe(e,t,n){return n.dedupeLeading&&yHe(t,e)?t:[...e,...t]}function z4(e,t){return[...e,t]}var B4=class{"~orpc";constructor(e){this[`~orpc`]=e}};function V4(e){return e instanceof B4?!0:d4(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function xHe(e,t){return{...e,...t}}function SHe(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=C2(t),i=e[n];return new q2(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function CHe(e){return{output:e,context:{}}}function H4(e,...t){let n=C2(t);return async(...[t,r])=>{let i=w2(n.path),{default:a}=await R4(e),o=r?.context??{},s=await V2(n.context??{},o),c=SHe(a[`~orpc`].errorMap),l=async e=>e instanceof q2?await WVe(a[`~orpc`].errorMap,e):e;try{let e=await A2({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),I2(w2(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>EHe(e.procedure,e))));return N2(e)?e instanceof r4?e:PVe(e,o4(F2({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 wHe(e,t){let n=e[`~orpc`].inputSchema;return n?A2({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new q2(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new c4({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function THe(e,t){let n=e[`~orpc`].outputSchema;return n?A2({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new q2(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new c4({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function EHe(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 wHe(e,l));let u=n[o],d=u?await A2({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,xHe(s,t),l),context:t}}},l,CHe)).output)):await A2({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await THe(e,d):d};return a(0,t.context,t.input)}const U4=Symbol(`ORPC_HIDDEN_ROUTER_CONTRACT`);function W4(e,t){return new Proxy(e,{get(e,n){return n===U4?t:Reflect.get(e,n)}})}function DHe(e){return e[U4]}function G4(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||V4(n))return;if(!I4(n)){n=n[r];continue}let i=n,a=t.slice(e);return F4(async()=>R4(G4((await R4(i)).default,a)),L4(i))}return n}function K4(e){return new Proxy(e,{get(t,n){return typeof n==`string`?K4(G4(e,[n])):Reflect.get(t,n)}})}function q4(e,t){if(I4(e)){let n=L4(e),r=n?.prefix?v4(t.prefix,n?.prefix):t.prefix;return K4(F4(async()=>{let{default:n}=await R4(e);return R4(q4(n,t))},{...n,prefix:r}))}if(V4(e)){let n=bHe(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new B4({...e[`~orpc`],route:b4(e[`~orpc`].route,t),errorMap:l4(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]=q4(e[r],t);return n}function J4(e,t,n=[]){let r=e.router,i=DHe(e.router);if(i!==void 0&&(r=i),I4(r))n.push({router:r,path:e.path});else if(d4(r))t({contract:r,path:e.path});else for(let i in r)J4({router:r[i],path:[...e.path,i]},t,n);return n}function OHe(e,t){return new B4({...e[`~orpc`],errorMap:t[`~orpc`].errorMap,route:t[`~orpc`].route,meta:t[`~orpc`].meta})}const kHe={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function Y4(e,t){return t===void 0?kHe[e]:t}function X4(e){let t=((...t)=>e(...t));return t.mapInput=t=>X4((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?X4(t).mapInput(n):t;return X4((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 AHe(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&&R2(e.options)||R2(e)&&e.isNotFound===!0)throw e;return[J2(e).toJSON(),void 0]}}}var jHe=class e extends B4{errors(t){return new e({...this[`~orpc`],errorMap:l4(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:g4(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:_4(this[`~orpc`].route,t)})}use(t,n){let r=n?X4(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:z4(this[`~orpc`].middlewares,r)})}callable(...e){let t=H4(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=AHe(H4(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)})}},Z4=class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-Y4(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-Y4(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:Y4(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:Y4(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:Y4(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:Y4(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:Y4(`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 X4(e)}errors(t){return new e({...this[`~orpc`],errorMap:l4(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?X4(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:z4(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:g4(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:_4(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:Y4(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:Y4(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new jHe({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:v4(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:y4(this[`~orpc`].tags,t)})}router(e){return q4(e,this[`~orpc`])}lazy(e){return q4(F4(e),this[`~orpc`])}};new Z4({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:Y4(`initialInputValidationIndex`),outputValidationIndex:Y4(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function Q4(e,t,n){return d4(e)?new Z4({...e[`~orpc`],config:t,middlewares:n,inputValidationIndex:Y4(`initialInputValidationIndex`,t?.initialInputValidationIndex)+n.length,outputValidationIndex:Y4(`initialOutputValidationIndex`,t?.initialOutputValidationIndex)+n.length,dedupeLeadingMiddlewares:Y4(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}):new Proxy(e,{get:(r,i)=>{if(typeof i!=`string`)return Reflect.get(r,i);let a;i===`middleware`?a=e=>X4(e):i===`use`?a=r=>Q4(e,t,z4(n,r)):i===`router`?a=r=>W4(q4(r,{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:Y4(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e):i===`lazy`&&(a=r=>W4(q4(F4(r),{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:Y4(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e));let o=eHe(r,[i]);if(!o)return a??o;let s=Q4(o,t,n);return a?new Proxy(a,{get(e,t){return Reflect.get(s,t)}}):s}})}function $4(e,t={}){let n=Q4(e,t,[]),r=new Proxy(n,{get:(t,n)=>{let i;n===`$context`?i=()=>r:n===`$config`&&(i=t=>$4(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 MHe=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)}},NHe=class{constructor(e,t,n,r){this.matcher=t,this.codec=n,new MHe(r.plugins).init(r,e),this.interceptors=w2(r.interceptors),this.clientInterceptors=w2(r.clientInterceptors),this.rootInterceptors=w2(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}:I2(this.rootInterceptors,{...t,request:e,prefix:n},async t=>A2({name:`${e.method} ${e.url.pathname}`},async e=>{let n;try{return await I2(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 A2({name:`find_procedure`},()=>this.matcher.match(a,`/${s.replace(/^\/|\/$/g,``)}`));if(!c)return{matched:!1,response:void 0};e?.updateName(`${T2}.${c.path.join(`/`)}`),e?.setAttribute(`rpc.system`,T2),e?.setAttribute(`rpc.method`,c.path.join(`.`)),n=`decode_input`;let l=await A2({name:`decode_input`},()=>this.codec.decode(t,c.params,c.procedure));n=void 0,N2(l)&&(l=F2({name:`consume_event_iterator_input`,signal:t.signal},l));let u=H4(c.procedure,{context:r,path:c.path,interceptors:this.clientInterceptors});n=`call_procedure`;let d=await u(l,{signal:t.signal,lastEventId:i4(t.headers[`last-event-id`])});return n=void 0,{matched:!0,response:this.codec.encode(d,c.procedure)}})}catch(t){n!==`call_procedure`&&k2(e,t);let r=n===`decode_input`&&!(t instanceof q2)?new q2(`BAD_REQUEST`,{message:`Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,cause:t}):J2(t);return{matched:!0,response:this.codec.encodeError(r)}}}))}},PHe=class{constructor(e){this.serializer=e}async decode(e,t,n){let r=e.method===`GET`?kVe(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())}}},FHe=class{filter;tree=new jVe;pendingRouters=[];constructor(e={}){this.filter=e.filter??!0}init(e,t=[]){let n=J4({router:e,path:t},t=>{if(!V2(this.filter,t))return;let{path:n,contract:r}=t,i=m4(n);V4(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:m4(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 R4(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 R4(G4(n.router,n.path));if(!V4(e))throw Error(`
75244
75244
  [Contract-First] Missing or invalid implementation for procedure at path: ${m4(n.path)}.
75245
75245
  Ensure that the procedure is correctly defined and matches the expected contract.
75246
- `);n.procedure=OHe(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},IHe=class extends NHe{constructor(e,t={}){let n=new h4(new p4(t)),r=new FHe(t),i=new PHe(n);super(e,r,i,t)}},LHe=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=D.join(P.homedir(),hn.configDirName,`cli`);this.socketPath=D.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=D.dirname(this.socketPath);s.existsSync(e)||s.mkdirSync(e,{recursive:!0});let t=$4(tHe),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 hHe(this.socketPath,new IHe(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},RHe=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[hn.socketEnvVar];if(e&&c.existsSync(e))return e;try{let e=O.join(ee.homedir(),hn.configDirName,hn.ideDirName),t=c.readdirSync(e).filter(e=>e.endsWith(`.sock`));if(t.length===0)return null;let n=null;for(let r of t){let t=O.join(e,r);try{let e=c.statSync(t);(!n||e.mtimeMs>n.mtime)&&(n={path:t,mtime:e.mtimeMs})}catch{}}if(n&&c.existsSync(n.path))return n.path}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await vHe(e,{timeoutMs:2e3});this.client=s4(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 e3=(0,Z.createContext)(null);function t3(){let e=(0,Z.use)(e3);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function zHe({children:e,initialFile:t}){let[n,r]=(0,Z.useState)(t),[i,a]=(0,Z.useState)(void 0),[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let e=!1;return(async()=>{let t=new LHe;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 RHe(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,X.jsx)(e3.Provider,{value:{currentFile:n,selectionStartLine:i,selectionEndLine:o,connection:c,pushServer:u},children:e})}const n3=(0,Z.createContext)(null);function BHe({children:e}){let[t,n]=(0,Z.useState)(`idle`),r=(0,Z.useCallback)(()=>n(`upload`),[]),i=(0,Z.useCallback)(()=>n(`download`),[]),a=(0,Z.useCallback)(()=>n(`idle`),[]),o=(0,Z.useMemo)(()=>({activity:t,setActivity:n,startUpload:r,startDownload:i,stopActivity:a}),[t,r,i,a]);return(0,X.jsx)(n3.Provider,{value:o,children:e})}function r3(){let e=(0,Z.use)(n3);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}const i3=(0,Z.createContext)(null),VHe=()=>{let e=(0,Z.use)(i3);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e},HHe=({children:e})=>{let{isFocused:t}=SZ(),n=CZ(),r=(0,Z.useRef)(t);r.current=t;let i=(0,Z.useCallback)((e,t)=>{r.current||n.notify({body:e,title:t})},[n]),a=(0,Z.useCallback)(e=>{r.current||n.notify({body:e,title:`Action Required`})},[n]),o=(0,Z.useCallback)(e=>{r.current||n.notify({body:e,title:`Task Complete`})},[n]),s=(0,Z.useMemo)(()=>({notifyIfUnfocused:i,notifyActionRequired:a,notifyTaskComplete:o}),[i,a,o]);return(0,X.jsx)(i3.Provider,{value:s,children:e})},a3=(0,Z.createContext)(null),o3=()=>{let e=(0,Z.use)(a3);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},s3=(0,Z.memo)(({children:e,client:t,authManager:n,onAuthExpired:r})=>{let[i,a]=(0,Z.useState)(!1),o=(0,Z.useCallback)(()=>a(!1),[]),s=(0,Z.useMemo)(()=>({apiClient:t,authManager:n,authExpired:i,setAuthExpired:a,clearAuthExpired:o,onAuthExpired:r}),[i,t,n,o,r]);return(0,X.jsx)(a3.Provider,{value:s,children:e})});s3.displayName=`ApiClientProvider`;const c3=(0,Z.createContext)(null);function l3(e,t){let n=t?new Set(t):null;return e.map(e=>{if(e.type!==`code_llm_tool_call`||e.status!==`transient`||e.toolUseResult||n&&!n.has(e.id))return e;let t=Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.name??``:e.toolUseRequest?.name??``,r=Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.id??e.id:e.toolUseRequest?.id??e.id;return{...e,status:`completed`,toolUseResult:{id:r,content:`Error: tool execution orphaned`},parsedResult:{phase:`error`,toolType:t,data:{},summary:``}}})}function UHe(e,t){switch(t.type){case`INIT_SEND`:return[...l3(e.filter(e=>e.temp!==!0)),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=l3(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`TURN_COMPLETE`:{let n=l3(e,t.toolCallIds);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n}case`FINALIZE`:{let n=l3(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[...l3(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;case`ADD_CREDITS`:return[...e,t.seg];case`TOOL_CALL_START`:{let{toolCallId:n,toolName:r,textSegId:i}=t,a;return a=i?e.filter(e=>!e.isSpinny).map(e=>e.id===i?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...a,{id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:r,input:{}},isStreamingArgs:!0,streamingArguments:``}]}case`TOOL_CALL_DELTA`:{let{toolCallId:n,argumentsDelta:r}=t;return e.map(e=>e.id===n?{...e,streamingArguments:(e.streamingArguments??``)+r}:e)}case`TOOL_CALL_STOP`:{let{toolCallId:n,toolName:r,arguments:i}=t,a={};try{a=JSON.parse(i)}catch{}return e.map(e=>e.id===n?{...e,isStreamingArgs:!1,streamingArguments:i,toolUseRequest:{id:n,name:r,input:a}}:e)}default:return e}}function WHe(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 u3=(0,Z.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=H0(),o=(0,Z.useRef)(i),s=(0,Z.useRef)(i),c=(0,Z.useRef)(null),{notifyActionRequired:l,notifyTaskComplete:u}=VHe(),{startUpload:d,startDownload:f,stopActivity:p}=r3(),{authManager:m,setAuthExpired:h,onAuthExpired:g}=o3(),_=CZ(),{connection:v,pushServer:y}=t3(),b=(0,Z.useRef)(v),x=(0,Z.useRef)(y);(0,Z.useEffect)(()=>{b.current=v},[v]),(0,Z.useEffect)(()=>{x.current=y},[y]);let[S,C]=(0,Z.useState)(Sd.Idle),[w,T]=(0,Z.useReducer)(UHe,[]),E=(0,Z.useRef)(new Map),[D,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)([]),[P,ee]=(0,Z.useState)([]),[F,te]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!0),[ne,re]=(0,Z.useState)(!0),[ie,ae]=(0,Z.useState)(0),oe=(0,Z.useRef)(0),se=(0,Z.useRef)(!0),ce=(0,Z.useRef)(null),le=(0,Z.useRef)(Sd.Idle),ue=(0,Z.useCallback)(e=>{le.current=e,C(e)},[]);(0,Z.useEffect)(()=>()=>{ce.current&&clearTimeout(ce.current),c.current&&clearTimeout(c.current)},[]);let[de,fe]=(0,Z.useState)(null),B=cF(process.cwd()),pe=(0,Z.useCallback)(e=>{M.current=e,j(e)},[]),me=(0,Z.useCallback)(()=>{let e=N.current.shift();if(!e){pe(null);return}e.request=ge.current?.refreshPermissionRequest(e.request)??e.request;let t=!1;(e.editorDiffFilePath||e.editorToolViewShown)&&x.current&&x.current.waitForDecision(e.request.tool.id).then(n=>{t||(t=!0,ue(n===`accept`||n===`allowAlways`||n===`allowYolo`?Sd.ExecutingTool:Sd.Submitted),e.resolve(n),me())}).catch(()=>{}),pe({request:e.request,resolve:n=>{t||(t=!0,ue(n===`accept`||n===`allowAlways`||n===`allowYolo`||typeof n==`object`&&n.type===`accept_with_message`||typeof n==`object`&&n.type===`question_answers`?Sd.ExecutingTool:Sd.Submitted),setTimeout(()=>{e.resolve(n),me()},0).unref())}}),ue(Sd.WaitingForToolPermission),l(`Abacus.AI is waiting for your input`)},[l,ue,pe]),he=(0,Z.useMemo)(()=>new hq(async e=>{let t=b.current,n=e,r=null;if(t&&x.current&&e.type===`edit_file`){let i=e.tool.id,a=E.current.get(i),o=(e.tool.input??{}).filePath??e.filePath??``,s=a?.originalContent??e.originalContent??``,c=a?.newContent??e.newContent??``;o&&(s||c)&&await t.showDiff({filePath:o,originalContent:s,modifiedContent:c,toolId:i})&&(n={...e,diffShownInEditor:!0},r=o)}if(t&&x.current&&e.type===`write_file`&&!e.isNewFile){let i=e.tool.id,a=e.filePath??``,o=e.originalContent??``,s=e.content??``;a&&(o||s)&&await t.showDiff({filePath:a,originalContent:o,modifiedContent:s,toolId:i})&&(n={...e,diffShownInEditor:!0},r=a)}let i=!1;t&&e.type===`exit_plan_mode`&&e.planFilePath&&(x.current&&await t.showToolView({filePath:e.planFilePath,toolKey:e.tool.id}).catch(()=>!1)&&(i=!0),i||await t.openPlanFile(e.planFilePath).catch(()=>{}));let a=await new Promise(e=>{let t={request:n,editorDiffFilePath:r,editorToolViewShown:i,resolve:e},a=N.current.length===0&&!M.current;N.current.push(t),a&&me()});if(r&&t){let e=a===`reject`||typeof a==`object`&&a.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return a}),[me]),ge=(0,Z.useRef)(null);function _e(){return new mq({allowedDirectories:[B,...r?.[`add-dir`]?.map(e=>{let t=oF(e);return cF(O.isAbsolute(t)?t:O.resolve(B,t))})??[]],primaryWorkspace:B,apiClient:t,mode:s.current,permissionProvider:he,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=b.current;return t?t.getDiagnostics(e):[]}},onMcpAuthRequired:void 0,cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`],clientType:tt.CLI})}ge.current||=(s.current=o.current,_e());let ve=ge.current,ye=(0,Z.useCallback)(()=>{ee(ve.getQueueEntries().map(e=>({...e})))},[ve]),be=(0,Z.useCallback)(e=>{s.current=e,ve.setMode(e),N.current=N.current.filter(t=>Ed(t.request.type,e)?(t.resolve(`accept`),!1):!0);let t=M.current;t&&Ed(t.request.type,e)&&t.resolve(`accept`)},[ve]);(0,Z.useEffect)(()=>(o.current=i,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{be(i),c.current=null},500),c.current.unref(),()=>{c.current&&=(clearTimeout(c.current),null)}),[i,be]),(0,Z.useEffect)(()=>{(async()=>{let e=!0;if(r?.conversationId)try{await Ee(r.conversationId)}catch{e=!1}e&&r?.prompt&&await Oe({message:r.prompt})})()},[]),(0,Z.useEffect)(()=>{let e=!1,t=0,n=1e3,r=()=>{if(e)return;t+=n;let i=ve.mcp.listServers(),a=i.filter(e=>e.status===`auth-required`);if(a.length>0){let e=a.map(e=>e.config.name??e.config.id).join(`, `);V(`${a.length} MCP server(s) require auth (${e}). Use /mcp auth <name> to authenticate.`,`warning`,!0);return}t<1e4&&i.some(e=>e.status!==`connected`&&e.status!==`error`)&&setTimeout(r,n)},i=setTimeout(r,n);return()=>{e=!0,clearTimeout(i)}},[]),(0,Z.useEffect)(()=>{switch(S){case Sd.Submitted:case Sd.Streaming:_.showProgress({state:`indeterminate`});break;case Sd.ExecutingTool:_.showProgress({state:`indeterminate`});break;case Sd.WaitingForToolPermission:_.hideProgress();break;case Sd.Idle:_.hideProgress();break}},[S,_]);let V=(0,Z.useCallback)((e,t=`info`,n=!1)=>{T({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),xe=(0,Z.useCallback)(()=>{T({type:`CLEAR`}),k(null),ue(Sd.Idle),fe(null),E.current.clear(),c.current&&=(clearTimeout(c.current),null),s.current=o.current,ge.current=_e()},[t,B,he]),Se=(0,Z.useCallback)(()=>{T({type:`CLEAR`})},[]),Ce=(0,Z.useCallback)(()=>{T({type:`REMOVE_TEMP`})},[]),we=(0,Z.useCallback)(()=>{let e=ve.dq();ye(),e.length>0&&te(e.map(e=>e.message).join(`
75247
- `)),ve.stop();let t=M.current;t&&t.resolve(`reject`);for(let e of N.current)e.resolve(`reject`);N.current.length=0,pe(null),ue(Sd.Idle)},[ve,ye,ue,pe]),Te=(0,Z.useCallback)(()=>{A&&A.resolve(`reject`)},[A]),Ee=(0,Z.useCallback)(async e=>{ue(Sd.LoadingConversation),T({type:`CLEAR`}),k(null),fe(e);try{let t=await ve.loadConversation(e);t.title&&k(t.title),t.segments.length>0&&T({type:`LOAD`,segments:t.segments.map(e=>WHe(e))})}catch{V(`Failed to load conversation`,`error`)}finally{ue(Sd.Idle)}},[ve,V,ue]),De=(0,Z.useCallback)(async(e,t)=>{await ve.mcp.refresh(),t&&V(`MCP tools refreshed`,`info`,!0)},[ve,V]),Oe=(0,Z.useCallback)(async({message:e,selectedModel:t,fileAttachments:n,activeSkills:r})=>{if(!e||S===Sd.LoadingConversation)return;t&&ve.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();T({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}}),ue(Sd.Submitted),d();let s=null,c=null,l=[],_=new Set,v,y=b.current,x=y?.getCurrentFile(),C=y?.getSelectionRange();if(y&&x)try{let e=(await y.getDiagnostics([x])).filter(e=>e.severity===`error`||e.severity===`warning`);e.length>0&&(v=e.map(e=>`${e.file}:${e.line}:${e.column} [${e.severity}] ${e.message}`).join(`
75248
- `))}catch{}try{for await(let e of ve.send(i,{diagnosticIssues:v,currentFile:x??void 0,selectionStartLine:C?.startLine,selectionEndLine:C?.endLine,activeSkills:r})){let t=()=>{c&&=(T({type:`THINKING_COMPLETE`,segId:c,endTime:Date.now()}),null)};switch(e.type){case`text_delta`:{ue(Sd.Streaming),p(),f(),t();let n=e.content;s||=crypto.randomUUID(),T({type:`TEXT_DELTA`,segId:s,content:n});break}case`thinking_delta`:{let t=e.content;c||=crypto.randomUUID(),T({type:`THINKING_DELTA`,segId:c,content:t,startTime:Date.now()});break}case`thinking_complete`:t();break;case`tool_display_data`:{let{toolCallId:t,data:n}=e,r=E.current.get(t)??{};E.current.set(t,{...r,...n}),T({type:`TOOL_DISPLAY_DATA`,toolCallId:t,data:n});break}case`tool_call_start`:t(),_.add(e.toolCallId),T({type:`TOOL_CALL_START`,toolCallId:e.toolCallId,toolName:e.toolName,textSegId:s}),s=null;break;case`tool_call_delta`:T({type:`TOOL_CALL_DELTA`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta});break;case`tool_call_stop`:T({type:`TOOL_CALL_STOP`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments});break;case`tool_requested`:{le.current!==Sd.WaitingForToolPermission&&ue(Sd.ExecutingTool),p(),d(),t();let n=e.tool.id;if(l.push(n),_.has(n)){T({type:`TOOL_CALL_STOP`,toolCallId:n,toolName:e.tool.name,arguments:JSON.stringify(e.tool.input??{})}),s=null;break}let r={id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:e.tool.name,input:e.tool.input},toolDisplayData:E.current.get(n)};T({type:`TOOL_REQUESTED`,toolCallId:n,textSegId:s,toolSeg:r}),s=null;break}case`tool_execution_complete`:{p(),f();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};T({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n},spinnySeg:i}),s=null;break}case`notification`:T({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`:T({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`:T({type:`TOOL_USER_MESSAGE`,seg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.message}});break;case`retry`:L({attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,isNetworkError:e.isNetworkError});break;case`network_status`:e.online?(ce.current&&=(clearTimeout(ce.current),null),se.current=!0,z(!0),re(!0),L(null),setTimeout(()=>{if(le.current===Sd.Idle&&ve.getQueueEntries().length>0){let e=ve.dq();if(e.length>0){ye();let t=e.map(e=>e.message).join(`
75249
- `),n=cq.matchSkill(t.trim());Oe(n?{message:t,activeSkills:[n.skill.id]}:{message:t})}}},0).unref?.()):(se.current=!1,z(!1),ce.current||=setTimeout(()=>{ce.current=null,se.current||re(!1)},3e4));break;case`user_message_dequeued`:T({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}}),ye(),s=null,c=null,l.length=0;break;case`credits`:oe.current+=e.creditsUsed,ae(t=>t+e.creditsUsed);break;case`turn_complete`:T({type:`TURN_COMPLETE`,textSegId:s,toolCallIds:[...l]}),s=null,l.length=0,ye();break}}}catch(e){if(e instanceof Ll)m.isEnvAuth()||(h(!0),g?.()),T({type:`REMOVE_USER_SEG`,userSegId:o}),V(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Vl(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;T({type:`REMOVE_USER_SEG`,userSegId:o}),V(t,`error`,!0)}te(i),ve.dq(),ye()}finally{p(),L(null);let e=ve.getConversationId();e&&fe(e),T({type:`FINALIZE`,textSegId:s}),oe.current>0&&(T({type:`ADD_CREDITS`,seg:{id:`credits-${Date.now()}`,status:`completed`,source:`bot`,type:`code_llm_credits`,creditsUsed:oe.current}}),oe.current=0),ue(Sd.Idle),u(`Abacus.AI completed the task`)}},[ve,S,V,u,d,f,p,a,m,h]);(0,Z.useEffect)(()=>(ve.onAutoRestart=e=>{le.current===Sd.Idle&&Oe({message:e})},()=>{ve.onAutoRestart=null}),[ve,Oe]);let ke=(0,Z.useCallback)((e,t)=>{let n=ve.nq(e,t);return ye(),n},[ve,ye]),Ae=(0,Z.useCallback)(e=>{let t=ve.dq(e);return ye(),t},[ve,ye]),je=(0,Z.useCallback)((e,t)=>{ve.remove(e,t),ye()},[ve,ye]),Me=(0,Z.useCallback)((e,t)=>{let n=ve.setContent(e,t);return ye(),n},[ve,ye]),Ne=(0,Z.useCallback)(e=>{ve.clearQueue(e),ye()},[ve,ye]),Pe=(0,Z.useCallback)(()=>{te(null)},[]),Fe=(0,Z.useCallback)(e=>ve.isDirectoryAllowed(e),[ve]),Ie=(0,Z.useCallback)((e,t)=>ve.addAllowedDirectory(e,t),[ve]),Le=(0,Z.useCallback)(()=>ve.listTerminalSessions(),[ve]),Re=(0,Z.useCallback)(e=>ve.getTerminalSessionOutput(e),[ve]),ze=(0,Z.useCallback)(e=>ve.stopTerminalSession(e),[ve]),Be=(0,Z.useMemo)(()=>({conversationId:de,conversationTitle:D,segments:w,segmentsLength:w.length,sendMessage:Oe,stop:we,rejectPendingPermission:Te,agentStatus:S,clearSegments:xe,clearSegmentsOnly:Se,clearTempSegments:Ce,loadConversation:Ee,addNotification:V,mcp:ve.mcp,isDirectoryAllowed:Fe,addAllowedDirectory:Ie,pendingToolPermission:A,refreshMcpTools:De,queuedMessages:P,nq:ke,dq:Ae,removeFromQueue:je,setQueuedMessageContent:Me,clearQueue:Ne,dequeuedOnStop:F,clearDequeuedOnStop:Pe,retryState:I,networkOnline:R,debouncedNetworkOnline:ne,listTerminalSessions:Le,getTerminalSessionOutput:Re,stopTerminalSession:ze,totalCredits:ie}),[de,D,w,Oe,we,Te,S,xe,Se,Ce,Ee,V,ve,Fe,Ie,A,De,P,ke,Ae,je,Me,Ne,F,Pe,I,R,ne,Le,Re,ze,ie]);return(0,X.jsx)(c3.Provider,{value:Be,children:e})});u3.displayName=`AgentProvider`;function d3(){let e=(0,Z.use)(c3);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${u3.name}>?`);return e}function f3(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function GHe({toolName:e,status:t,parsedResult:n}){let{agentStatus:r}=d3(),i=f3(e);if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return n?.userNote?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`rejected`}),(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`rejected`}),(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]});if(t===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:n?.errorMessage??n?.summary??`MCP tool execution failed`})]});let a=r===Sd.WaitingForToolPermission&&!n,o=!n&&(r===Sd.Streaming||r===Sd.ExecutingTool),s=n?.phase===`error`;return a?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`yellow`,children:`●`}),(0,X.jsx)($,{color:`cyan`,children:i})]}):o?(0,X.jsx)(T0,{name:i,status:`pending`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:s?`error`:`success`}),(0,X.jsx)(E0,{color:s?`red`:`brightblack`,children:s?`Error: ${n.errorMessage??n.summary??`Tool execution failed`}`:n.summary??`Executed successfully`})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:i,status:`pending`})})}function KHe(e){return{displayName:f3(e),getHeaderParams(e){return``},renderUI(t,n,r){return(0,X.jsx)(GHe,{toolName:e,rawInput:t,status:n,parsedResult:r})}}}function p3(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 qHe={displayName:`Search`,getHeaderParams(e){try{return p3(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=p3(e);return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:r,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error matching files`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,X.jsx)(JHe,{searchParams:r,parsedResult:n}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Search`,params:r,status:`pending`})})}};function JHe({searchParams:e,parsedResult:t}){let n=(0,Z.useContext)(G0),r=t.data.files??[],i=n?30:10,a=r.slice(0,i),o=r.length-a.length;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:e,status:`success`}),(0,X.jsx)(E0,{children:t.summary}),r.length>0&&(0,X.jsxs)(D0,{children:[a.map((e,t)=>(0,X.jsx)($,{dimColor:!0,children:e},t)),o>0&&(0,X.jsxs)($,{dimColor:!0,children:[`… +`,o,` more file`,o===1?``:`s`]})]})]})}function m3(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 YHe={displayName:`Search`,getHeaderParams(e){try{return m3(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=m3(e);return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:r,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error searching content`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,X.jsx)(XHe,{searchParams:r,parsedResult:n}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Search`,params:r,status:`pending`})})}};function XHe({searchParams:e,parsedResult:t}){let n=(0,Z.useContext)(G0),r=t.data.matches??[],i=n?30:10,a=r.slice(0,i),o=r.length-a.length;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:e,status:`success`}),(0,X.jsx)(E0,{children:t.summary}),r.length>0&&(0,X.jsxs)(D0,{children:[a.map((e,t)=>(0,X.jsx)($,{dimColor:!0,children:e},t)),o>0&&(0,X.jsxs)($,{dimColor:!0,children:[`… +`,o,` more match`,o===1?``:`es`]})]})]})}const ZHe=QL({url:Y()}),QHe={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=ZHe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`success`}),(0,X.jsx)(E0,{children:n.summary??`Fetched content`})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`pending`})})}},$He=QL({searchTerm:Y(),query:Y().optional(),explanation:Y().optional(),allowedDomains:XL(Y()).optional(),blockedDomains:XL(Y()).optional()}),eUe={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=$He.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:``,status:`error`}),(0,X.jsx)(E0,{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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`success`}),(0,X.jsx)(E0,{children:`Found results`})]})}},tUe=QL({shellId:Y(),filter:Y().optional()}),nUe={displayName:`BashOutput`,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=tUe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`rejected`}),n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`success`}),(0,X.jsx)(E0,{children:n.summary})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`pending`})})}};var rUe=class{startTime;constructor(){this.startTime=performance.now()}getElapsedSeconds(){return(performance.now()-this.startTime)/1e3}getElapsedMs(){return performance.now()-this.startTime}getFormattedDuration(){return h3(this.getElapsedMs())}reset(){this.startTime=performance.now()}};function h3(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(` `)}function iUe(e,t,n){let r=n?50:t,i=e.split(`
75246
+ `);n.procedure=OHe(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},IHe=class extends NHe{constructor(e,t={}){let n=new h4(new p4(t)),r=new FHe(t),i=new PHe(n);super(e,r,i,t)}},LHe=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=D.join(P.homedir(),hn.configDirName,`cli`);this.socketPath=D.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=D.dirname(this.socketPath);s.existsSync(e)||s.mkdirSync(e,{recursive:!0});let t=$4(tHe),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 hHe(this.socketPath,new IHe(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},RHe=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[hn.socketEnvVar];if(e&&c.existsSync(e))return e;try{let e=O.join(ee.homedir(),hn.configDirName,hn.ideDirName),t=c.readdirSync(e).filter(e=>e.endsWith(`.sock`));if(t.length===0)return null;let n=null;for(let r of t){let t=O.join(e,r);try{let e=c.statSync(t);(!n||e.mtimeMs>n.mtime)&&(n={path:t,mtime:e.mtimeMs})}catch{}}if(n&&c.existsSync(n.path))return n.path}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await vHe(e,{timeoutMs:2e3});this.client=s4(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 e3=(0,Z.createContext)(null);function t3(){let e=(0,Z.use)(e3);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function zHe({children:e,initialFile:t}){let[n,r]=(0,Z.useState)(t),[i,a]=(0,Z.useState)(void 0),[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let e=!1;return(async()=>{let t=new LHe;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 RHe(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,X.jsx)(e3.Provider,{value:{currentFile:n,selectionStartLine:i,selectionEndLine:o,connection:c,pushServer:u},children:e})}const n3=(0,Z.createContext)(null);function BHe({children:e}){let[t,n]=(0,Z.useState)(`idle`),r=(0,Z.useCallback)(()=>n(`upload`),[]),i=(0,Z.useCallback)(()=>n(`download`),[]),a=(0,Z.useCallback)(()=>n(`idle`),[]),o=(0,Z.useMemo)(()=>({activity:t,setActivity:n,startUpload:r,startDownload:i,stopActivity:a}),[t,r,i,a]);return(0,X.jsx)(n3.Provider,{value:o,children:e})}function r3(){let e=(0,Z.use)(n3);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}const i3=(0,Z.createContext)(null),VHe=()=>{let e=(0,Z.use)(i3);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e},HHe=({children:e})=>{let{isFocused:t}=SZ(),n=CZ(),r=(0,Z.useRef)(t);r.current=t;let i=(0,Z.useCallback)((e,t)=>{r.current||n.notify({body:e,title:t})},[n]),a=(0,Z.useCallback)(e=>{r.current||n.notify({body:e,title:`Action Required`})},[n]),o=(0,Z.useCallback)(e=>{r.current||n.notify({body:e,title:`Task Complete`})},[n]),s=(0,Z.useMemo)(()=>({notifyIfUnfocused:i,notifyActionRequired:a,notifyTaskComplete:o}),[i,a,o]);return(0,X.jsx)(i3.Provider,{value:s,children:e})},a3=(0,Z.createContext)(null),o3=()=>{let e=(0,Z.use)(a3);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},s3=(0,Z.memo)(({children:e,client:t,authManager:n,onAuthExpired:r})=>{let[i,a]=(0,Z.useState)(!1),o=(0,Z.useCallback)(()=>a(!1),[]),s=(0,Z.useMemo)(()=>({apiClient:t,authManager:n,authExpired:i,setAuthExpired:a,clearAuthExpired:o,onAuthExpired:r}),[i,t,n,o,r]);return(0,X.jsx)(a3.Provider,{value:s,children:e})});s3.displayName=`ApiClientProvider`;const c3=(0,Z.createContext)(null);function l3(e,t){let n=t?new Set(t):null;return e.map(e=>{if(e.type!==`code_llm_tool_call`||e.status!==`transient`||e.toolUseResult||n&&!n.has(e.id))return e;let t=Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.id??e.id:e.toolUseRequest?.id??e.id;return{...e,status:`completed`,isStreamingArgs:!1,toolUseResult:{id:t,content:JSON.stringify({reason:bR.INTERRUPTED}),rejected:!0}}})}function UHe(e,t){switch(t.type){case`INIT_SEND`:return[...l3(e.filter(e=>e.temp!==!0)),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=l3(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`TURN_COMPLETE`:{let n=l3(e,t.toolCallIds);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n}case`FINALIZE`:{let n=l3(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[...l3(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;case`ADD_CREDITS`:return[...e,t.seg];case`TOOL_CALL_START`:{let{toolCallId:n,toolName:r,textSegId:i}=t,a;return a=i?e.filter(e=>!e.isSpinny).map(e=>e.id===i?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...a,{id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:r,input:{}},isStreamingArgs:!0,streamingArguments:``}]}case`TOOL_CALL_DELTA`:{let{toolCallId:n,argumentsDelta:r}=t;return e.map(e=>e.id===n?{...e,streamingArguments:(e.streamingArguments??``)+r}:e)}case`TOOL_CALL_STOP`:{let{toolCallId:n,toolName:r,arguments:i}=t,a={};try{a=JSON.parse(i)}catch{}return e.map(e=>e.id===n?{...e,isStreamingArgs:!1,streamingArguments:i,toolUseRequest:{id:n,name:r,input:a}}:e)}default:return e}}function WHe(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 u3=(0,Z.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=H0(),o=(0,Z.useRef)(i),s=(0,Z.useRef)(i),c=(0,Z.useRef)(null),{notifyActionRequired:l,notifyTaskComplete:u}=VHe(),{startUpload:d,startDownload:f,stopActivity:p}=r3(),{authManager:m,setAuthExpired:h,onAuthExpired:g}=o3(),_=CZ(),{connection:v,pushServer:y}=t3(),b=(0,Z.useRef)(v),x=(0,Z.useRef)(y);(0,Z.useEffect)(()=>{b.current=v},[v]),(0,Z.useEffect)(()=>{x.current=y},[y]);let[S,C]=(0,Z.useState)(Sd.Idle),[w,T]=(0,Z.useReducer)(UHe,[]),E=(0,Z.useRef)(new Map),[D,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)([]),[P,ee]=(0,Z.useState)([]),[F,te]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!0),[ne,re]=(0,Z.useState)(!0),[ie,ae]=(0,Z.useState)(0),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(null),fe=(0,Z.useRef)(0),B=(0,Z.useRef)(!0),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(Sd.Idle),he=(0,Z.useCallback)(e=>{me.current=e,C(e)},[]);(0,Z.useEffect)(()=>()=>{pe.current&&clearTimeout(pe.current),c.current&&clearTimeout(c.current)},[]);let[ge,_e]=(0,Z.useState)(null),ve=cF(process.cwd()),ye=(0,Z.useCallback)(e=>{M.current=e,j(e)},[]),be=(0,Z.useCallback)(()=>{let e=N.current.shift();if(!e){ye(null);return}e.request=xe.current?.refreshPermissionRequest(e.request)??e.request;let t=!1;(e.editorDiffFilePath||e.editorToolViewShown)&&x.current&&x.current.waitForDecision(e.request.tool.id).then(n=>{t||(t=!0,he(n===`accept`||n===`allowAlways`||n===`allowYolo`?Sd.ExecutingTool:Sd.Submitted),e.resolve(n),be())}).catch(()=>{}),ye({request:e.request,resolve:n=>{t||(t=!0,he(n===`accept`||n===`allowAlways`||n===`allowYolo`||typeof n==`object`&&n.type===`accept_with_message`||typeof n==`object`&&n.type===`question_answers`?Sd.ExecutingTool:Sd.Submitted),setTimeout(()=>{e.resolve(n),be()},0).unref())}}),he(Sd.WaitingForToolPermission),l(`Abacus.AI is waiting for your input`)},[l,he,ye]),V=(0,Z.useMemo)(()=>new hq(async e=>{let t=b.current,n=e,r=null;if(t&&x.current&&e.type===`edit_file`){let i=e.tool.id,a=E.current.get(i),o=(e.tool.input??{}).filePath??e.filePath??``,s=a?.originalContent??e.originalContent??``,c=a?.newContent??e.newContent??``;o&&(s||c)&&await t.showDiff({filePath:o,originalContent:s,modifiedContent:c,toolId:i})&&(n={...e,diffShownInEditor:!0},r=o)}if(t&&x.current&&e.type===`write_file`&&!e.isNewFile){let i=e.tool.id,a=e.filePath??``,o=e.originalContent??``,s=e.content??``;a&&(o||s)&&await t.showDiff({filePath:a,originalContent:o,modifiedContent:s,toolId:i})&&(n={...e,diffShownInEditor:!0},r=a)}let i=!1;t&&e.type===`exit_plan_mode`&&e.planFilePath&&(x.current&&await t.showToolView({filePath:e.planFilePath,toolKey:e.tool.id}).catch(()=>!1)&&(i=!0),i||await t.openPlanFile(e.planFilePath).catch(()=>{}));let a=await new Promise(e=>{let t={request:n,editorDiffFilePath:r,editorToolViewShown:i,resolve:e},a=N.current.length===0&&!M.current;N.current.push(t),a&&be()});if(r&&t){let e=a===`reject`||typeof a==`object`&&a.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return a}),[be]),xe=(0,Z.useRef)(null);function Se(){return new mq({allowedDirectories:[ve,...r?.[`add-dir`]?.map(e=>{let t=oF(e);return cF(O.isAbsolute(t)?t:O.resolve(ve,t))})??[]],primaryWorkspace:ve,apiClient:t,mode:s.current,permissionProvider:V,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=b.current;return t?t.getDiagnostics(e):[]}},onMcpAuthRequired:void 0,cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`],clientType:tt.CLI})}xe.current||=(s.current=o.current,Se());let Ce=xe.current,we=(0,Z.useCallback)(()=>{ee(Ce.getQueueEntries().map(e=>({...e})))},[Ce]),Te=(0,Z.useCallback)(e=>{s.current=e,Ce.setMode(e),N.current=N.current.filter(t=>Ed(t.request.type,e)?(t.resolve(`accept`),!1):!0);let t=M.current;t&&Ed(t.request.type,e)&&t.resolve(`accept`)},[Ce]);(0,Z.useEffect)(()=>(o.current=i,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{Te(i),c.current=null},500),c.current.unref(),()=>{c.current&&=(clearTimeout(c.current),null)}),[i,Te]),(0,Z.useEffect)(()=>{(async()=>{let e=!0;if(r?.conversationId)try{await Me(r.conversationId)}catch{e=!1}e&&r?.prompt&&await Pe({message:r.prompt})})()},[]),(0,Z.useEffect)(()=>{let e=!1,t=0,n=1e3,r=()=>{if(e)return;t+=n;let i=Ce.mcp.listServers(),a=i.filter(e=>e.status===`auth-required`);if(a.length>0){let e=a.map(e=>e.config.name??e.config.id).join(`, `);Ee(`${a.length} MCP server(s) require auth (${e}). Use /mcp auth <name> to authenticate.`,`warning`,!0);return}t<1e4&&i.some(e=>e.status!==`connected`&&e.status!==`error`)&&setTimeout(r,n)},i=setTimeout(r,n);return()=>{e=!0,clearTimeout(i)}},[]),(0,Z.useEffect)(()=>{switch(S){case Sd.Submitted:case Sd.Streaming:_.showProgress({state:`indeterminate`});break;case Sd.ExecutingTool:_.showProgress({state:`indeterminate`});break;case Sd.WaitingForToolPermission:_.hideProgress();break;case Sd.Idle:_.hideProgress();break}},[S,_]);let Ee=(0,Z.useCallback)((e,t=`info`,n=!1)=>{T({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),De=(0,Z.useCallback)(()=>{T({type:`CLEAR`}),k(null),he(Sd.Idle),_e(null),E.current.clear(),c.current&&=(clearTimeout(c.current),null),s.current=o.current,xe.current=Se()},[t,ve,V]),Oe=(0,Z.useCallback)(()=>{T({type:`CLEAR`})},[]),ke=(0,Z.useCallback)(()=>{T({type:`REMOVE_TEMP`})},[]),Ae=(0,Z.useCallback)(()=>{let e=Ce.dq();we(),e.length>0&&te(e.map(e=>e.message).join(`
75247
+ `)),Ce.stop();let t=M.current;t&&t.resolve(`reject`);for(let e of N.current)e.resolve(`reject`);N.current.length=0,ye(null),he(Sd.Idle)},[Ce,we,he,ye]),je=(0,Z.useCallback)(()=>{A&&A.resolve(`reject`)},[A]),Me=(0,Z.useCallback)(async e=>{he(Sd.LoadingConversation),T({type:`CLEAR`}),k(null),_e(e);try{let t=await Ce.loadConversation(e);t.title&&k(t.title),t.segments.length>0&&T({type:`LOAD`,segments:t.segments.map(e=>WHe(e))})}catch{Ee(`Failed to load conversation`,`error`)}finally{he(Sd.Idle)}},[Ce,Ee,he]),Ne=(0,Z.useCallback)(async(e,t)=>{await Ce.mcp.refresh(),t&&Ee(`MCP tools refreshed`,`info`,!0)},[Ce,Ee]),Pe=(0,Z.useCallback)(async({message:e,selectedModel:t,fileAttachments:n,activeSkills:r})=>{if(!e||S===Sd.LoadingConversation)return;t&&Ce.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();T({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}}),he(Sd.Submitted),d();let s=null,c=null,l=[],_=new Set,v,y=b.current,x=y?.getCurrentFile(),C=y?.getSelectionRange();if(y&&x)try{let e=(await y.getDiagnostics([x])).filter(e=>e.severity===`error`||e.severity===`warning`);e.length>0&&(v=e.map(e=>`${e.file}:${e.line}:${e.column} [${e.severity}] ${e.message}`).join(`
75248
+ `))}catch{}try{for await(let e of Ce.send(i,{diagnosticIssues:v,currentFile:x??void 0,selectionStartLine:C?.startLine,selectionEndLine:C?.endLine,activeSkills:r})){let t=()=>{c&&=(T({type:`THINKING_COMPLETE`,segId:c,endTime:Date.now()}),null)};switch(e.type){case`text_delta`:{he(Sd.Streaming),p(),f(),t();let n=e.content;s||=crypto.randomUUID(),T({type:`TEXT_DELTA`,segId:s,content:n});break}case`thinking_delta`:{let t=e.content;c||=crypto.randomUUID(),T({type:`THINKING_DELTA`,segId:c,content:t,startTime:Date.now()});break}case`thinking_complete`:t();break;case`tool_display_data`:{let{toolCallId:t,data:n}=e,r=E.current.get(t)??{};E.current.set(t,{...r,...n}),T({type:`TOOL_DISPLAY_DATA`,toolCallId:t,data:n});break}case`tool_call_start`:t(),_.add(e.toolCallId),T({type:`TOOL_CALL_START`,toolCallId:e.toolCallId,toolName:e.toolName,textSegId:s}),s=null;break;case`tool_call_delta`:T({type:`TOOL_CALL_DELTA`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta});break;case`tool_call_stop`:T({type:`TOOL_CALL_STOP`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments});break;case`tool_requested`:{me.current!==Sd.WaitingForToolPermission&&he(Sd.ExecutingTool),p(),d(),t();let n=e.tool.id;if(l.push(n),_.has(n)){T({type:`TOOL_CALL_STOP`,toolCallId:n,toolName:e.tool.name,arguments:JSON.stringify(e.tool.input??{})}),s=null;break}let r={id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:e.tool.name,input:e.tool.input},toolDisplayData:E.current.get(n)};T({type:`TOOL_REQUESTED`,toolCallId:n,textSegId:s,toolSeg:r}),s=null;break}case`tool_execution_complete`:{p(),f();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};T({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n},spinnySeg:i}),s=null;break}case`notification`:T({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`:T({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`:T({type:`TOOL_USER_MESSAGE`,seg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.message}});break;case`retry`:L({attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,isNetworkError:e.isNetworkError});break;case`network_status`:e.online?(pe.current&&=(clearTimeout(pe.current),null),B.current=!0,z(!0),re(!0),L(null),setTimeout(()=>{if(me.current===Sd.Idle&&Ce.getQueueEntries().length>0){let e=Ce.dq();if(e.length>0){we();let t=e.map(e=>e.message).join(`
75249
+ `),n=cq.matchSkill(t.trim());Pe(n?{message:t,activeSkills:[n.skill.id]}:{message:t})}}},0).unref?.()):(B.current=!1,z(!1),pe.current||=setTimeout(()=>{pe.current=null,B.current||re(!1)},3e4));break;case`user_message_dequeued`:T({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}}),we(),s=null,c=null,l.length=0;break;case`credits`:fe.current+=e.creditsUsed,ae(t=>t+e.creditsUsed);break;case`session_info`:se(e.contextPercent),le(e.contextTokensUsed),de(e.contextWindowMax);break;case`turn_complete`:T({type:`TURN_COMPLETE`,textSegId:s,toolCallIds:[...l]}),s=null,l.length=0,we();break}}}catch(e){if(e instanceof Ll)m.isEnvAuth()||(h(!0),g?.()),T({type:`REMOVE_USER_SEG`,userSegId:o}),Ee(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Vl(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;T({type:`REMOVE_USER_SEG`,userSegId:o}),Ee(t,`error`,!0)}te(i),Ce.dq(),we()}finally{p(),L(null);let e=Ce.getConversationId();e&&_e(e),T({type:`FINALIZE`,textSegId:s}),fe.current>0&&(T({type:`ADD_CREDITS`,seg:{id:`credits-${Date.now()}`,status:`completed`,source:`bot`,type:`code_llm_credits`,creditsUsed:fe.current}}),fe.current=0),he(Sd.Idle),u(`Abacus.AI completed the task`)}},[Ce,S,Ee,u,d,f,p,a,m,h]);(0,Z.useEffect)(()=>(Ce.onAutoRestart=e=>{me.current===Sd.Idle&&Pe({message:e})},()=>{Ce.onAutoRestart=null}),[Ce,Pe]);let Fe=(0,Z.useCallback)((e,t)=>{let n=Ce.nq(e,t);return we(),n},[Ce,we]),Ie=(0,Z.useCallback)(e=>{let t=Ce.dq(e);return we(),t},[Ce,we]),Le=(0,Z.useCallback)((e,t)=>{Ce.remove(e,t),we()},[Ce,we]),Re=(0,Z.useCallback)((e,t)=>{let n=Ce.setContent(e,t);return we(),n},[Ce,we]),ze=(0,Z.useCallback)(e=>{Ce.clearQueue(e),we()},[Ce,we]),Be=(0,Z.useCallback)(()=>{te(null)},[]),Ve=(0,Z.useCallback)(e=>Ce.isDirectoryAllowed(e),[Ce]),H=(0,Z.useCallback)((e,t)=>Ce.addAllowedDirectory(e,t),[Ce]),He=(0,Z.useCallback)(()=>Ce.listTerminalSessions(),[Ce]),Ue=(0,Z.useCallback)(e=>Ce.getTerminalSessionOutput(e),[Ce]),U=(0,Z.useCallback)(e=>Ce.stopTerminalSession(e),[Ce]),We=(0,Z.useMemo)(()=>({conversationId:ge,conversationTitle:D,segments:w,segmentsLength:w.length,sendMessage:Pe,stop:Ae,rejectPendingPermission:je,agentStatus:S,clearSegments:De,clearSegmentsOnly:Oe,clearTempSegments:ke,loadConversation:Me,addNotification:Ee,mcp:Ce.mcp,isDirectoryAllowed:Ve,addAllowedDirectory:H,pendingToolPermission:A,refreshMcpTools:Ne,queuedMessages:P,nq:Fe,dq:Ie,removeFromQueue:Le,setQueuedMessageContent:Re,clearQueue:ze,dequeuedOnStop:F,clearDequeuedOnStop:Be,retryState:I,networkOnline:R,debouncedNetworkOnline:ne,listTerminalSessions:He,getTerminalSessionOutput:Ue,stopTerminalSession:U,totalCredits:ie,contextPercent:oe,contextTokensUsed:ce,contextWindowMax:ue}),[ge,D,w,Pe,Ae,je,S,De,Oe,ke,Me,Ee,Ce,Ve,H,A,Ne,P,Fe,Ie,Le,Re,ze,F,Be,I,R,ne,He,Ue,U,ie,oe,ce,ue]);return(0,X.jsx)(c3.Provider,{value:We,children:e})});u3.displayName=`AgentProvider`;function d3(){let e=(0,Z.use)(c3);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${u3.name}>?`);return e}function f3(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function GHe({toolName:e,status:t,parsedResult:n}){let{agentStatus:r}=d3(),i=f3(e);if(t===`interrupted`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return n?.userNote?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`rejected`}),(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`rejected`}),(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]});if(t===`error`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:n?.errorMessage??n?.summary??`MCP tool execution failed`})]});let a=r===Sd.WaitingForToolPermission&&!n,o=!n&&(r===Sd.Streaming||r===Sd.ExecutingTool),s=n?.phase===`error`;return a?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`yellow`,children:`●`}),(0,X.jsx)($,{color:`cyan`,children:i})]}):o?(0,X.jsx)(T0,{name:i,status:`pending`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:i,status:s?`error`:`success`}),(0,X.jsx)(E0,{color:s?`red`:`brightblack`,children:s?`Error: ${n.errorMessage??n.summary??`Tool execution failed`}`:n.summary??`Executed successfully`})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:i,status:`pending`})})}function KHe(e){return{displayName:f3(e),getHeaderParams(e){return``},renderUI(t,n,r){return(0,X.jsx)(GHe,{toolName:e,rawInput:t,status:n,parsedResult:r})}}}function p3(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 qHe={displayName:`Search`,getHeaderParams(e){try{return p3(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=p3(e);return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:r,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error matching files`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,X.jsx)(JHe,{searchParams:r,parsedResult:n}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Search`,params:r,status:`pending`})})}};function JHe({searchParams:e,parsedResult:t}){let n=(0,Z.useContext)(G0),r=t.data.files??[],i=n?30:10,a=r.slice(0,i),o=r.length-a.length;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:e,status:`success`}),(0,X.jsx)(E0,{children:t.summary}),r.length>0&&(0,X.jsxs)(D0,{children:[a.map((e,t)=>(0,X.jsx)($,{dimColor:!0,children:e},t)),o>0&&(0,X.jsxs)($,{dimColor:!0,children:[`… +`,o,` more file`,o===1?``:`s`]})]})]})}function m3(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 YHe={displayName:`Search`,getHeaderParams(e){try{return m3(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=m3(e);return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:r,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error searching content`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,X.jsx)(XHe,{searchParams:r,parsedResult:n}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Search`,params:r,status:`pending`})})}};function XHe({searchParams:e,parsedResult:t}){let n=(0,Z.useContext)(G0),r=t.data.matches??[],i=n?30:10,a=r.slice(0,i),o=r.length-a.length;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Search`,params:e,status:`success`}),(0,X.jsx)(E0,{children:t.summary}),r.length>0&&(0,X.jsxs)(D0,{children:[a.map((e,t)=>(0,X.jsx)($,{dimColor:!0,children:e},t)),o>0&&(0,X.jsxs)($,{dimColor:!0,children:[`… +`,o,` more match`,o===1?``:`es`]})]})]})}const ZHe=QL({url:Y()}),QHe={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=ZHe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`success`}),(0,X.jsx)(E0,{children:n.summary??`Fetched content`})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Fetch`,params:a,status:`pending`})})}},$He=QL({searchTerm:Y(),query:Y().optional(),explanation:Y().optional(),allowedDomains:XL(Y()).optional(),blockedDomains:XL(Y()).optional()}),eUe={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=$He.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:``,status:`error`}),(0,X.jsx)(E0,{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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`WebSearch`,params:o,status:`success`}),(0,X.jsx)(E0,{children:`Found results`})]})}},tUe=QL({shellId:Y(),filter:Y().optional()}),nUe={displayName:`BashOutput`,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=tUe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`rejected`}),n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`success`}),(0,X.jsx)(E0,{children:n.summary})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`BashOutput`,params:i,status:`pending`})})}};var rUe=class{startTime;constructor(){this.startTime=performance.now()}getElapsedSeconds(){return(performance.now()-this.startTime)/1e3}getElapsedMs(){return performance.now()-this.startTime}getFormattedDuration(){return h3(this.getElapsedMs())}reset(){this.startTime=performance.now()}};function h3(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(` `)}function iUe(e,t,n){let r=n?50:t,i=e.split(`
75250
75250
  `).filter(Boolean);return i.length<=r?{lines:i,isTruncated:!1,hiddenCount:0}:{lines:i.slice(0,r),isTruncated:!0,hiddenCount:i.length-r}}function aUe(e){let[t]=(0,Z.useState)(Date.now()),[n,r]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{if(!e)return;let n=setInterval(()=>{r(Date.now()-t)},1e3);return()=>clearInterval(n)},[e,t]),n}function oUe({command:e,toolCallId:t,executionResult:n}){let{agentStatus:r}=d3(),i=(0,Z.useContext)(G0),[a,o]=(0,Z.useState)(!1),s=a||i,c=!n&&(r===Sd.Streaming||r===Sd.ExecutingTool),l=aUe(c),u=l>=5e3,d=(0,Z.useDeferredValue)(n?.output||``),{lines:f,isTruncated:p,hiddenCount:m}=(0,Z.useMemo)(()=>iUe(d,7,s),[d,s]),h=!i&&!c&&n!==void 0&&(p||a),{isFocused:g}=xZ({id:`bash-tool-${t}`,isActive:h});bZ((e,t)=>{g&&t.ctrl&&e===`o`&&o(e=>!e)},{isActive:g&&h});let _=e.length>500?e.slice(0,500)+`…`:e,v=n?.exitCode??0,y=n?.status===`error`||v!==0,b=c?`pending`:y?`error`:`success`;if(c){let e=u?h3(l):null;return(0,X.jsxs)(Q,{flexDirection:`column`,gap:0,children:[(0,X.jsx)(T0,{name:`Bash`,params:_,paramsLanguage:`bash`,status:b,showSpinner:!0}),(0,X.jsxs)(E0,{color:`brightblack`,children:[`Running…`,e?` ${e}`:null]})]})}if(n){let e=f.length>0,t=`exit ${v} (${cBe(n.duration??0)})`;return(0,X.jsxs)(Q,{flexDirection:`column`,gap:0,children:[(0,X.jsx)(T0,{name:`Bash`,params:_,paramsLanguage:`bash`,status:b}),(0,X.jsx)(D0,{children:e?(0,X.jsxs)(X.Fragment,{children:[y&&(0,X.jsx)($,{color:`red`,dimColor:!0,children:`Error:`}),f.map((e,t)=>(0,X.jsx)($,{color:y?`red`:void 0,dimColor:!0,children:e},t)),p&&(0,X.jsxs)($,{dimColor:!0,children:[`… +`,m,` `,s?`more `:``,`line`,m===1?``:`s`,s?``:` (ctrl+o to expand)`]})]}):(0,X.jsx)($,{dimColor:!0,children:`(no content)`})}),(0,X.jsx)(E0,{color:y?`red`:`brightblack`,children:t})]})}return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`Bash`,params:_,paramsLanguage:`bash`,status:`pending`})})}const sUe=QL({command:Y(),explanation:Y().optional(),runInBackground:z0,shellId:Y().optional(),interactiveMode:z0,timeout:yR().optional()});function cUe({rawInput:e,status:t,parsedResult:n}){let r=sUe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:``,paramsLanguage:`bash`,status:`error`}),(0,X.jsx)(E0,{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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]});if(t===`rejected`)return n?.userNote?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:o,paramsLanguage:`bash`,status:`rejected`}),(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]});if(n?.data?.timedOut)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,X.jsx)(E0,{children:`Running in the background`})]});if(n?.runInBackground)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`Bash`,params:`${o}${s}`,paramsLanguage:`bash`,status:`success`}),(0,X.jsx)(E0,{children:n.summary})]});let c=e?.id||`unknown`,l=n?.data;return(0,X.jsx)(oUe,{command:`${o}${s}`,toolCallId:c,executionResult:l})}const lUe={displayName:`Bash`,getHeaderParams(e){try{return e?.command||`[no command]`}catch{return`[unknown]`}},renderUI(e,t,n){return(0,X.jsx)(cUe,{rawInput:e,status:t,parsedResult:n})}},uUe=QL({shellId:Y()}),g3={read:gVe,delete:qBe,write:bVe,edit:tVe,notebook_edit:aVe,grep:YHe,glob:qHe,web_search:eUe,web_fetch:QHe,bash:lUe,bash_output:nUe,kill_shell:{displayName:`KillShell`,getHeaderParams(e){try{return`id: ${e.shellId||``}`}catch{return`[unknown]`}},renderUI(e,t,n){let r=uUe.safeParse(P0(e));if(!r.success)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`KillShell`,params:``,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`KillShell`,params:i,status:`interrupted`}),(0,X.jsx)(E0,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`KillShell`,params:i,status:`rejected`}),n?.userNote?(0,X.jsxs)(E0,{color:`yellow`,children:[`Rejected · `,(0,X.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,X.jsx)(E0,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,X.jsx)(T0,{name:`KillShell`,params:i,status:`pending`,showSpinner:!0}):n?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:`KillShell`,params:i,status:`success`}),(0,X.jsx)(E0,{children:n.summary})]}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(T0,{name:`KillShell`,params:i,status:`pending`})})}},navigate_to:zBe,new_tab:VBe,close_tab:jBe,switch_active_tab:KBe,refresh_tab:WBe,get_tab_content:LBe,computer:NBe,get_interactive_elements:FBe,perform_interactive_element_action:UBe,ask_user_question:_Be,enter_plan_mode:vBe,exit_plan_mode:SBe,subagent:wBe,task:EBe,todo_write:kBe,get_diagnostics:SVe};function dUe(e,t){g3[e]=t??KHe(e)}function fUe(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 pUe(e,t=4){let n=[];for(let r of e){if(n.length>=t)break;for(let e of fUe(r)){if(n.length>=t)break;let r=g3[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 _3=(0,Z.memo)(({counts:e,segments:t})=>{let n=(0,Z.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]),r=(0,Z.useMemo)(()=>pUe(t),[t]);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:XQ,children:`⟐`}),(0,X.jsx)($,{color:XQ,dimColor:!0,children:n}),(0,X.jsx)($,{color:XQ,dimColor:!0,children:`(ctrl+o to expand)`})]}),r.map((e,t)=>(0,X.jsx)(Q,{flexDirection:`row`,paddingLeft:2,children:(0,X.jsxs)($,{color:XQ,dimColor:!0,children:[`⎿ `,e.label,` `,e.detail]})},t))]})});_3.displayName=`CompactedPlaceholder`;const v3=(0,Z.createContext)(null);function mUe(){let e=(0,Z.use)(v3);if(!e)throw Error(`useUpdate must be used within UpdateProvider`);return e}function hUe({children:e,configService:t}){let[n,r]=(0,Z.useState)(null),{autoUpdate:i,updateChannel:a,baseUrl:o}=(0,Z.useMemo)(()=>({autoUpdate:t.get(`autoUpdate`)!==!1,updateChannel:t.get(`updateChannel`),baseUrl:t.get(`baseUrl`)}),[t]);(0,Z.useEffect)(()=>{if(IZ())return;let e=!0,t=()=>{LZ(DZ.default.version,a,o).then(t=>{e&&r(e=>e?.latestVersion===t?.latestVersion?e:t)}).catch(()=>{})};t();let n=setInterval(t,6e4);return()=>{e=!1,clearInterval(n)}},[a,o]);let s=(0,Z.useMemo)(()=>({updateInfo:n,autoUpdate:i}),[n,i]);return(0,X.jsx)(v3.Provider,{value:s,children:e})}const y3=(0,Z.createContext)(null),b3=()=>{let e=(0,Z.use)(y3);if(!e)throw Error(`${b3.name} must be used within a ${x3.name}`);return e};function x3({children:e}){let[t,n]=(0,Z.useState)({columns:process.stdout.columns-8,rows:process.stdout.rows}),r=(0,Z.useCallback)(()=>{n({columns:process.stdout.columns-8,rows:process.stdout.rows})},[]);(0,Z.useLayoutEffect)(()=>(process.stdout.on(`resize`,r),()=>{process.stdout.off(`resize`,r)}),[r]);let i=(0,Z.useMemo)(()=>({width:t.columns,height:t.rows}),[t.columns,t.rows]);return(0,X.jsx)(y3.Provider,{value:i,children:e})}function gUe(){let{height:e}=b3();return Math.max(0,e-3)}let S3=function(e){return e.Models=`models`,e.UserInfo=`userInfo`,e.CreateConversation=`create-conversation`,e.GetConversation=`get-conversation`,e.Grep=`grep`,e.ReadFile=`read-file`,e.EditFile=`edit-file`,e.Bash=`bash`,e.BashOutput=`bash-output`,e.MCPTool=`mcp-tool`,e.PrInfo=`pr-info`,e}({});function _Ue(e){return qQ({queryKey:[S3.Models],queryFn:async()=>{try{return(await e.listLLMModels())?.result??[]}catch{return[]}},initialData:[],staleTime:300*1e3,retry:1,refetchOnMount:`always`,refetchOnWindowFocus:!1})}function C3(e){return typeof e==`string`?e:typeof e==`object`&&e&&`segment`in e?e.segment:null}function vUe(){return process.platform===`win32`}async function yUe(e){return new Promise(t=>setTimeout(t,e))}function bUe({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 xUe=bUe();function w3(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(`›`)?e:e.replace(xUe,``)}const SUe=new Intl.Segmenter,CUe=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$`,`v`),wUe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+`,`v`),TUe=RegExp(`^\\p{RGI_Emoji}$`,`v`),EUe=/^[\d#*]\u20E3$/,DUe=/\p{Extended_Pictographic}/gu;function OUe(e){if(e.length>50)return!1;if(EUe.test(e))return!0;if(e.includes(`‍`)){let t=e.match(DUe);return t!==null&&t.length>=2}return!1}function kUe(e){return e.replace(wUe,``)}function AUe(e){return CUe.test(e)}function jUe(e,t){let n=0;if(e.length>1)for(let r of e.slice(1))r>=`＀`&&r<=`￯`&&(n+=WJ(r.codePointAt(0),t));return n}function MUe(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=w3(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 SUe.segment(i)){if(AUe(e))continue;if(TUe.test(e)||OUe(e)){a+=2;continue}let t=kUe(e).codePointAt(0);a+=WJ(t,o),a+=jUe(e,o)}return a}const NUe=[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 PUe(e){let t=e;for(let e of NUe)t=t.replace(e,``);return t}const T3=new Map,E3=1e3;function D3(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<=E3){let t=T3.get(e);if(t)return t}let n=Array.from(e);return e.length<=E3&&T3.set(e,n),n}function O3(e){return D3(e).length}function k3(e,t,n){return D3(e).slice(t,n).join(``)}function A3(e){return D3(o(VMe(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 j3=new Map,M3=e=>{if(/^[\u0020-\u007E]*$/.test(e))return e.length;if(j3.has(e))return j3.get(e);let t=MUe(e);return j3.set(e,t),t};BMe();function FUe(e,t){if(!I3(e[t]))return!1;let n=t+1;for(;n<e.length&&R3(e[n]);)n++;return n>=e.length||!I3(e[n])}function IUe(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=G3(n,o,s,!0);if(e)o=e.row,s=e.col;else{let e=n[o]||``,t=W3(e,s);s=t===null?O3(e):t+1;break}}return o!==r||s!==i?Y3(e6(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=K3(n,o,s);if(e)o=e.row,s=e.col;else break}return o!==r||s!==i?Y3(e6(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=G3(n,o,s,!1);if(t){if(c=t.row,l=t.col+1,e<a-1){let e=G3(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=O3(n[c]||``);l=Math.min(l,e)}return c!==r||l!==i?Y3(e6(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{...e6(e),lines:[``],cursorRow:0,cursorCol:0,preferredCol:null};let s=e6(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=e6(e),{startOffset:s,endOffset:c}=J3(r,a,o.lines),{startRow:l,startCol:u,endRow:d,endCol:f}=q3(s,c,o.lines);return Y3(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<O3(t)?Y3(e6(e),r,i,r,O3(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 Y3(e6(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 Y3(e6(e),0,0,0,O3(t),``)}else{let n=e6(e),{startOffset:i,endOffset:a}=J3(r,t,n.lines),{startRow:o,startCol:s,endRow:c,endCol:l}=q3(i,a,n.lines);return Y3(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 Y3(e6(e),0,0,0,O3(t),``)}else{let t=Math.max(0,r-o+1),n=r-t+1,i=e6(e),{startOffset:a,endOffset:s}=J3(t,n,i.lines),{startRow:c,startCol:l,endRow:u,endCol:d}=q3(a,s,i.lines);return{...Y3(i,c,l,u,d,``),cursorRow:t,cursorCol:0}}return e;case`l`:return Y3(e6(e),r,i,r,Math.min(O3(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=O3(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=O3(e);if(t===0)o<a.length-1&&(o++,s=0);else if(s<t-1){s++;let n=D3(e);for(;s<n.length&&R3(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=O3(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=O3(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=G3(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=K3(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=D3(n[o]||``);if(s<e.length&&I3(e[s])&&(s+1>=e.length||!z3(e[s+1])||I3(e[s])&&FUe(e,s))){let e=G3(n,o,s+1,!1);if(e){o=e.row,s=e.col;continue}}}let t=G3(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=O3(a[r]||``);if(i<o){let t=Math.min(n,o-i);return Y3(e6(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<O3(r[t]||``)?n+1:n;return{...e,cursorCol:i,preferredCol:null}}case`vim_open_line_below`:{let{cursorRow:t,lines:n}=e,r=e6(e),i=O3(n[t]||``);return Y3(r,t,i,t,i,`
75251
75251
  `)}case`vim_open_line_above`:{let{cursorRow:t}=e;return{...Y3(e6(e),t,0,t,0,`
75252
75252
  `),cursorRow:t,cursorCol:0}}case`vim_append_at_line_end`:{let{cursorRow:t,lines:n}=e,r=O3(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=D3(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=O3(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=D3(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}}const N3=dt([`codellm`,`cli`,`text-buffer`]);let P3=0;const LUe=/\[Pasted text (#\d+) \+\d+ lines\]/g;function RUe(e){return e.length>500?!0:e.split(/\r\n|\r|\n/).length>5}function zUe(e){P3++;let t=`#${P3}`;return{placeholder:`[Pasted text ${t} +${e.split(/\r\n|\r|\n/).length} lines]`,id:t}}function F3(e){return e===void 0?!1:!/[\s,.;!?]/.test(e)}const I3=e=>/[\w\p{L}\p{N}]/u.test(e),L3=e=>/\s/.test(e),R3=e=>/\p{M}/u.test(e),z3=e=>I3(e)||R3(e),B3=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`,V3=(e,t)=>!I3(e)||!I3(t)?!1:B3(e)!==B3(t),H3=(e,t)=>{let n=D3(e),r=t;if(r>=n.length)return null;let i=n[r];if(I3(i))for(;r<n.length&&z3(n[r]);){if(r+1<n.length&&I3(n[r+1])&&V3(n[r],n[r+1])){r++;break}r++}else if(!L3(i))for(;r<n.length&&!I3(n[r])&&!L3(n[r]);)r++;for(;r<n.length&&L3(n[r]);)r++;return r<n.length?r:null},U3=(e,t)=>{let n=D3(e),r=t;if(r<=0)return null;for(r--;r>=0&&L3(n[r]);)r--;if(r<0)return null;if(I3(n[r])){for(;r>=0&&I3(n[r]);){if(r-1>=0&&I3(n[r-1])&&V3(n[r],n[r-1]))return r;r--}return r+1}else{for(;r>=0&&!I3(n[r])&&!L3(n[r]);)r--;return r+1}},W3=(e,t)=>{let n=D3(e),r=t,i=r<n.length&&z3(n[r])&&(r+1>=n.length||!z3(n[r+1])||I3(n[r])&&r+1<n.length&&I3(n[r+1])&&V3(n[r],n[r+1])),a=r<n.length&&!z3(n[r])&&!L3(n[r])&&(r+1>=n.length||L3(n[r+1])||z3(n[r+1]));if(i||a)for(r++;r<n.length&&L3(n[r]);)r++;if(r<n.length&&!z3(n[r]))for(;r<n.length&&L3(n[r]);)r++;let o=!1,s=-1;if(r<n.length&&z3(n[r]))for(;r<n.length&&z3(n[r]);){if(o=!0,I3(n[r])&&(s=r),r+1<n.length&&I3(n[r+1])&&V3(n[r],n[r+1])){r++,I3(n[r-1])&&(s=r-1);break}r++}else if(r<n.length&&!L3(n[r]))for(;r<n.length&&!I3(n[r])&&!L3(n[r]);)o=!0,s=r,r++;return o&&s>=t?s:null},G3=(e,t,n,r)=>{let i=e[t]||``,a=r?H3(i,n):W3(i,n);if(a!==null)return{row:t,col:a};for(let n=t+1;n<e.length;n++){let t=e[n]||``,i=D3(t);if(i.length===0){let t=!1;for(let r=n+1;r<e.length;r++){let n=D3(e[r]||``),i=0;for(;i<n.length&&L3(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&&L3(i[a]);)a++;if(a<i.length){if(r)return{row:n,col:a};{let e=W3(t,a);if(e!==null)return{row:n,col:e}}}}return null},K3=(e,t,n)=>{let r=U3(e[t]||``,n);if(r!==null)return{row:t,col:r};for(let n=t-1;n>=0;n--){let t=e[n]||``,r=D3(t);if(r.length===0)continue;let i=r.length;for(;i>0&&L3(r[i-1]);)i--;if(i>0){let e=U3(t,i);if(e!==null)return{row:n,col:e}}}return null},q3=(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}},J3=(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}},Y3=(e,t,n,r,i,a)=>{let o=t=>e.lines[t]||``,s=e=>O3(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=k3(o(t),0,u),p=k3(o(r),d),m=a.replace(/\r\n/g,`
@@ -75321,37 +75321,38 @@ key_bindings:
75321
75321
  `))}`}const h6=(0,Z.memo)(({version:e,cwd:t,onDismiss:n})=>{let[r,i]=(0,Z.useState)({type:`input`}),a=(0,Z.useRef)(null),o=(0,Z.useRef)(n);o.current=n;let s=(0,Z.useCallback)(n=>{let r=n.trim();if(!r)return;let a=uWe(t);i({type:`confirm`,info:{description:r,platform:`${L()}`,arch:F(),shell:cWe(),terminal:lWe(),version:`v${e}`,gitBranch:a.branch,gitCommit:a.commit,gitRemote:a.remote,hasLocalChanges:a.hasLocalChanges,includeGitInfo:!1}})},[t,e]),c=(0,Z.useCallback)(()=>{r.type===`confirm`&&i({type:`submitted`,feedbackId:dWe()})},[r]),l=(0,Z.useCallback)(()=>{r.type===`confirm`&&i({type:`confirm`,info:{...r.info,includeGitInfo:!r.info.includeGitInfo}})},[r]),u=(0,Z.useCallback)(()=>{if(r.type!==`submitted`)return;let e=r,t=d.current;t?.type===`confirm`&&p6(fWe(t.info,e.feedbackId)),o.current()},[r]),d=(0,Z.useRef)(null);if(bZ((0,Z.useCallback)((e,t)=>{if(t.escape){o.current();return}if(r.type===`confirm`){if(t.return){c();return}if(e===`g`){l();return}}if(r.type===`submitted`){t.return?u():o.current();return}},[r,c,u,l]),{isActive:r.type!==`input`}),r.type===`confirm`&&(d.current=r),r.type===`input`)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(Q,{borderStyle:l6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{}),(0,X.jsx)($,{dimColor:!0,children:` Describe the issue below:`}),(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(t6,{ref:a,placeholder:`Describe your feedback or bug...`,onSubmit:s,onKeyDown:e=>{e.key.escape&&(e.preventDefault(),o.current())}})]}),(0,X.jsx)($,{}),(0,X.jsx)($,{dimColor:!0,children:` Enter to continue · Esc to cancel`})]});if(r.type===`confirm`){let{info:e}=r;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(Q,{borderStyle:l6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{}),(0,X.jsx)($,{dimColor:!0,children:` This report will include:`}),(0,X.jsxs)($,{children:[` - Your feedback / bug description: `,(0,X.jsx)($,{color:`yellow`,children:e.description})]}),(0,X.jsxs)($,{children:[` - Environment info: `,(0,X.jsxs)($,{color:`yellow`,children:[e.platform,` (`,e.arch,`), `,e.shell,`, `,e.terminal,`, `,e.version]})]}),(0,X.jsxs)($,{children:[` - Git repo metadata: `,e.includeGitInfo?(0,X.jsxs)($,{color:`yellow`,children:[e.gitBranch,`, `,e.gitCommit,` @ `,e.gitRemote,e.hasLocalChanges?`, has local changes`:``]}):(0,X.jsx)($,{dimColor:!0,children:`not included (press g to include)`})]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`We will use your feedback to debug related issues or to improve the CLI's functionality.`]}),(0,X.jsx)($,{}),(0,X.jsx)($,{dimColor:!0,children:` Enter to submit · g to toggle git info · Esc to cancel`})]})}return r.type===`submitted`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(Q,{borderStyle:l6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{bold:!0,children:` Submit Feedback / Bug Report`}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)($,{}),(0,X.jsx)($,{color:`green`,children:` Thank you for your report!`}),(0,X.jsxs)($,{children:[` Feedback ID: `,(0,X.jsx)($,{color:`cyan`,children:r.feedbackId})]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Press Enter to open your browser and draft a GitHub issue, or any other key to close.`]})]}):null});h6.displayName=`FeedbackOverlay`;const g6=.25,_6=(0,Z.memo)(({text:e,color:t=QQ})=>{let n=tZ(),[r,i]=(0,Z.useState)(0),a=e.length;(0,Z.useEffect)(()=>{if(n<=QX.Ascii)return;let e=setInterval(()=>{(0,Z.startTransition)(()=>{i(e=>e+1)})},100);return()=>clearInterval(e)},[n]);let o=(0,Z.useMemo)(()=>pWe(JQ(t)),[t]);return(0,X.jsx)($,{children:(0,Z.useMemo)(()=>{if(n<=QX.Ascii)return e;if(n===QX.ANSI){let t=r%a,n=Math.max(a*.6,3),i=``,s=XX.fromRgb(o.r,o.g,o.b);for(let r=0;r<a;r++){let o=Math.abs(r-t),c=a-o,l=Math.min(o,c);Math.max(0,1-l/n)>.5?i+=iZ().foreground(s).bold().render(e[r]):i+=iZ().foreground(s).dim().render(e[r])}return i}let t=r%a,i=Math.max(a*.6,3),s=``;for(let n=0;n<a;n++){let r=Math.abs(n-t),c=a-r,l=Math.min(r,c),u=mWe(o,Math.max(0,1-l/i)),d=XX.fromRgb(u.r,u.g,u.b);s+=iZ().foreground(d).render(e[n])}return s},[r,a,o,e,n])})});_6.displayName=`Shimmer`;function pWe(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 mWe(e,t){let n=Math.floor(e.r*g6),r=Math.floor(e.g*g6),i=Math.floor(e.b*g6);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 v6=(0,Z.memo)(({initialEmail:e,auth:t,onDismiss:n})=>{let[r,i]=(0,Z.useState)(()=>e?{type:`connecting`,email:e}:{type:`input`,mode:`email`}),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(n);d.current=n;let f=(0,Z.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,Z.useEffect)(()=>{e&&f(e)},[]),(0,Z.useEffect)(()=>{r.type===`polling`&&(o(!1),c(!1),p6(r.verificationUri).then(e=>{u.current||o(e)}))},[r.type===`polling`?r.verificationUri:null]),(0,Z.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,Z.useEffect)(()=>{if(r.type===`success`){let e=setTimeout(()=>d.current(),1500);return()=>clearTimeout(e)}},[r.type]);let p=(0,Z.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,Z.useCallback)(()=>{u.current=!0,d.current()},[]),h=(0,Z.useCallback)(()=>{r.type===`polling`&&m6(r.verificationUri).then(e=>{e&&c(!0)})},[r]);if(bZ((0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{dimColor:!0,children:e?` Email:`:` API Key:`}),(0,X.jsx)(t6,{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,X.jsxs)($,{dimColor:!0,children:[` `,`Enter to submit · Esc to cancel · Ctrl+A to switch to`,` `,e?`API key`:`email`]})]})}return r.type===`connecting`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Logging in as ${r.email}...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`polling`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{children:[` `,a?(0,X.jsx)($,{color:`yellow`,children:`Opening browser to sign in...`}):(0,X.jsx)(_6,{text:`Opening browser to sign in...`})]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Browser didn't open? Use the URL below to sign in`,` `,(0,X.jsxs)($,{dimColor:!1,color:s?`green`:`brightblack`,children:[`(`,s?`copied!`:`c to copy`,`)`]})]}),(0,X.jsxs)($,{color:`cyan`,children:[` `,r.verificationUri]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{children:[` `,`Your one-time code:`,` `,(0,X.jsx)($,{color:`brightyellow`,bold:!0,children:r.userCode})]}),(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Waiting for authentication...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):r.type===`success`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`green`,children:[` `,`✓ Logged in successfully!`]}),(0,X.jsx)($,{})]}):r.type===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`red`,children:[` `,`✗ `,r.message]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,r.canRetry?`Enter to retry · `:``,`Esc to close`]})]}):null});v6.displayName=`LoginOverlay`;const y6=(0,Z.memo)(({serverName:e,authenticate:t,onDismiss:n,onSuccess:r})=>{let[i,a]=(0,Z.useState)({type:`connecting`}),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(n);d.current=n;let f=(0,Z.useRef)(r);f.current=r;let p=(0,Z.useRef)(t);p.current=t,(0,Z.useEffect)(()=>{(async()=>{try{if(await p.current(e=>{u.current||(a({type:`waiting`,authUrl:e}),p6(e).then(e=>{u.current||s(e)}))}),u.current)return;a({type:`success`}),f.current?.()}catch(e){if(u.current)return;a({type:`error`,message:e instanceof Error?e.message:`Authentication failed`})}})()},[]),(0,Z.useEffect)(()=>{if(i.type===`success`){let e=setTimeout(()=>d.current(),1500);return()=>clearTimeout(e)}},[i.type]);let m=(0,Z.useCallback)(()=>{i.type===`waiting`&&m6(i.authUrl).then(e=>{e&&l(!0)})},[i]);return bZ((0,Z.useCallback)((e,t)=>{if(t.escape){u.current=!0,d.current();return}i.type===`waiting`&&e===`c`&&m()},[i,m]),{isActive:!0}),i.type===`connecting`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Authenticating MCP server '${e}'...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):i.type===`waiting`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{children:[` `,o?(0,X.jsx)($,{color:`yellow`,children:`Browser opened for MCP authentication`}):(0,X.jsx)(_6,{text:`Opening browser for MCP authentication...`})]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Browser didn't open? Use the URL below`,` `,(0,X.jsxs)($,{dimColor:!1,color:c?`green`:`gray`,children:[`(`,c?`copied!`:`c to copy`,`)`]})]}),(0,X.jsxs)($,{color:`cyan`,children:[` `,i.authUrl]}),(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Waiting for authorization...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):i.type===`success`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`green`,children:[` `,i.message??`Authenticated '${e}' successfully!`]}),(0,X.jsx)($,{})]}):i.type===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`red`,children:[` `,i.message]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to close`]})]}):null});y6.displayName=`McpAuthOverlay`;const b6=(0,Z.memo)(({serverName:e,addServer:t,mcp:n,onDismiss:r,onSuccess:i})=>{let[a,o]=(0,Z.useState)({type:`adding`}),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(r);f.current=r;let p=(0,Z.useRef)(i);p.current=i;let m=(0,Z.useRef)(t);m.current=t,(0,Z.useEffect)(()=>{(async()=>{try{if(await m.current(),d.current)return;let t=n.listServers().find(t=>t.config.id===e||t.config.name===e);if(!t||t.status!==`auth-required`){o({type:`success`,message:`Added MCP server '${e}'`}),p.current?.();return}if(o({type:`adding`}),await n.authenticateServer(e,async e=>d.current?e:(o({type:`auth-waiting`,authUrl:e}),p6(e).then(e=>{d.current||c(e)}),e)),d.current)return;o({type:`success`,message:`Added and authenticated MCP server '${e}'`}),p.current?.()}catch(e){if(d.current)return;o({type:`error`,message:`Failed to add server: ${e instanceof Error?e.message:String(e)}`})}})()},[n,e]),(0,Z.useEffect)(()=>{if(a.type===`success`){let e=setTimeout(()=>f.current(),1500);return()=>clearTimeout(e)}},[a.type]);let h=(0,Z.useCallback)(()=>{a.type===`auth-waiting`&&m6(a.authUrl).then(e=>{e&&u(!0)})},[a]);return bZ((0,Z.useCallback)((e,t)=>{if(t.escape){d.current=!0,f.current();return}a.type===`auth-waiting`&&e===`c`&&h()},[a,h]),{isActive:!0}),a.type===`adding`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Adding MCP server '${e}'...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):a.type===`auth-waiting`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`green`,children:[` `,`Added MCP server '`,e,`'`]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{children:[` `,s?(0,X.jsx)($,{color:`yellow`,children:`Browser opened for authentication`}):(0,X.jsx)(_6,{text:`Opening browser for authentication...`})]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Browser didn't open? Use the URL below`,` `,(0,X.jsxs)($,{dimColor:!1,color:l?`green`:`gray`,children:[`(`,l?`copied!`:`c to copy`,`)`]})]}),(0,X.jsxs)($,{color:`cyan`,children:[` `,a.authUrl]}),(0,X.jsx)($,{}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)(_6,{text:`Waiting for authorization...`})]}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to cancel`]})]}):a.type===`success`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`green`,children:[` `,a.message]}),(0,X.jsx)($,{})]}):a.type===`error`?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{}),(0,X.jsxs)($,{color:`red`,children:[` `,a.message]}),(0,X.jsx)($,{}),(0,X.jsxs)($,{dimColor:!0,children:[` `,`Esc to close`]})]}):null});b6.displayName=`McpAddOverlay`;const x6=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 _H(n,{selector:e=>`${e.id} ${e.description}`}).find(e).map(e=>e.item):n}searchSubcommands(e,t){return e.subcommands?t?new _H(e.subcommands,{selector:e=>`${e.id} ${e.description}`}).find(t).map(e=>e.item):e.subcommands:[]}},S6=(0,Z.memo)(({cwd:e,onDismiss:t})=>{let[n,r]=(0,Z.useState)(!0),[i,a]=(0,Z.useState)([]),o=(0,Z.useRef)(t);return o.current=t,(0,Z.useEffect)(()=>{sWe(e).then(e=>{a(e),r(!1)})},[e]),bZ((0,Z.useCallback)((e,t)=>{(t.escape||e===`q`)&&o.current()},[]),{isActive:!0}),n?(0,X.jsx)($,{dimColor:!0,children:` Loading diff…`}):i.length===0?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{children:` No changes detected`}),(0,X.jsx)($,{dimColor:!0,children:` Press Esc or q to close`})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(l2,{files:i}),(0,X.jsx)($,{dimColor:!0,children:` q/Esc: close`})]})});S6.displayName=`GitDiffView`;const C6=(0,Z.memo)(({listTerminalSessions:e,getTerminalSessionOutput:t,stopTerminalSession:n,onDismiss:r})=>{let[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(r);f.current=r,(0,Z.useEffect)(()=>{let t=()=>{a(e?.()??[])};t();let n=setInterval(t,1e3);return()=>clearInterval(n)},[e]),(0,Z.useEffect)(()=>{if(c===null)return;let e=()=>{d((t?.(c)??``).split(`
75322
75322
  `).slice(-10).join(`
75323
75323
  `))};e();let n=setInterval(e,500);return()=>clearInterval(n)},[c,t]);let p=i.filter(e=>e.isRunning),m=i.filter(e=>!e.isRunning&&(e.exitCode??0)===0),h=i.filter(e=>!e.isRunning&&(e.exitCode??0)!==0),g=[...p,...m.slice(-5),...h.slice(-5)];if(bZ((0,Z.useCallback)((e,t)=>{if(c!==null){(t.escape||e===`q`)&&l(null);return}if(t.escape||e===`q`)f.current();else if(t.upArrow)s(e=>Math.max(0,e-1));else if(t.downArrow)s(e=>Math.min(g.length-1,e+1));else if(t.return){let e=g[o];e&&l(e.id)}else if(e===`x`){let e=g[o];e?.isRunning&&n?.(e.id)}},[g,o,c,n]),{isActive:!0}),i.length===0)return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{children:` No background tasks found`}),(0,X.jsx)($,{dimColor:!0,children:` Press Esc or q to close`})]});if(c!==null){let e=i.find(e=>e.id===c),t=e?.command??`task ${c}`,n=t.length>60?t.substring(0,57)+`...`:t,r=e?.isRunning?`running`:`stopped`;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{bold:!0,children:` Shell details`}),(0,X.jsx)($,{children:` `}),(0,X.jsxs)($,{children:[` Status: `,r]}),e?.isRunning&&(0,X.jsxs)($,{children:[` Runtime: `,h3(Date.now()-(e?.startTime??Date.now()))]}),(0,X.jsxs)($,{children:[` Command: `,n]}),(0,X.jsx)($,{children:` `}),(0,X.jsx)($,{bold:!0,children:` Output:`}),(0,X.jsx)($,{children:u||` (no output)`}),(0,X.jsx)($,{children:` `}),(0,X.jsxs)($,{dimColor:!0,children:[` q/Esc: back`,e?.isRunning?` | x: stop`:``]})]})}let _=0,v=(e,t,n)=>{if(t.length===0)return null;let r=t.map(e=>{let t=_++===o,r=t?`>`:` `,i=e.command.length>50?e.command.substring(0,47)+`...`:e.command;return(0,X.jsx)($,{color:t?`cyan`:void 0,children:` ${r} [${e.id}] ${i} (${n(e)})`},e.id)});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{bold:!0,children:` ${e} (${t.length}):`}),r,(0,X.jsx)($,{children:` `})]})};return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)($,{bold:!0,children:` Background tasks`}),(0,X.jsx)($,{children:` `}),v(`In progress`,p,e=>h3(Date.now()-e.startTime)),v(`Completed`,m.slice(-5),()=>`ok`),v(`Failed`,h.slice(-5),e=>`exit ${e.exitCode}`),(0,X.jsxs)($,{dimColor:!0,children:[` `,`↑/↓ to select · Enter to view · x to stop · q/Esc to close`]})]})});C6.displayName=`TasksView`;function hWe(){let e=x6.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(`
75324
- `)}function gWe(e){let t=e.mcp?new YUe(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 ${DZ.default.version} (${t.latestVersion} available)`:`Abacus.AI CLI version ${DZ.default.version}`,`info`)}},{id:`exit`,description:`Exit the application`,usage:`/exit`,alias:{[B0.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:{[B0.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===Sd.Submitted||e.agentStatus===Sd.Streaming||e.agentStatus===Sd.ExecutingTool||e.agentStatus===Sd.WaitingForToolPermission,execute:async()=>{let t=e.getAgentStatus?.(),r=t===Sd.Submitted||t===Sd.Streaming||t===Sd.ExecutingTool||t===Sd.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:{[B0.Prompt]:[`help`]},execute:()=>{e.onHelp?e.onHelp():n(hWe(),`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 _H(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)}}],i=null,a=null;r.push({id:`resume`,description:`Resume a previous chat conversation`,usage:`/resume <chat_id_or_title>`,requiresArgument:!0,completionProvider:async t=>{if(i&&=(clearTimeout(i.timer),i.abort(),null),!e.getChatTitles)return[];let n=e=>({label:e.title,id:e.id,description:e.messageCount?`${e.messageCount} msgs`:void 0});if(!a){let r=await e.getChatTitles();if(!r?.length&&!t.trim())return[];a=r.map(n)}let r=a,o=r;if(t.trim()&&(o=new _H(r,{selector:e=>`${e.label} ${e.description??``}`}).find(t).map(e=>e.item)),!t.trim()||!e.searchChatTitles)return o;let s=o;return new Promise(r=>{i={timer:setTimeout(async()=>{try{let i=await e.searchChatTitles(t);if(i?.length){let e=i.map(n),t=new Set(s.map(e=>e.id));r([...s,...e.filter(e=>!t.has(e.id))])}else r(s)}catch{r(s)}i=null},300),abort:()=>r(s)}})},execute:t=>{a=null;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 ${hn.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,X.jsx)(v6,{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 ${hn.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 ${hn.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:`org`,description:`Switch to a different organization`,usage:`/org <org_name>`,requiresArgument:!0,completionProvider:async t=>{if(!e.getOrganizations)return[];let n=await e.getOrganizations();if(!n?.length)return[];let r=n.map(e=>({label:e.name,id:e.id,description:e.workspace}));return t.trim()?new _H(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 an organization name`,`error`);return}if(!e.getOrganizations||!e.onOrgSwitch){n(`Organization switching not available`,`error`);return}let i=await e.getOrganizations();if(!i||i.length===0){n(`No organizations available`,`error`);return}let a=i.find(e=>e.name.toLowerCase()===r.toLowerCase()||e.id===r||e.workspace.toLowerCase()===r.toLowerCase());if(!a){n(`Organization "${r}" not found`,`error`);return}n(`Switching to ${a.name}...`,`info`,!0),await e.onOrgSwitch(a.id)?n(`Switched to ${a.name}`,`info`):n(`Failed to switch to ${a.name}`,`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 aWe();if(e.success){let t=e.message;e.backupPath&&(t+=`\n\nBackup created: ${e.backupPath}`),e.requiresRestart&&(t+=`
75324
+ `)}function w6(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(`
75325
+ `)}function gWe(e){let t=e.mcp?new YUe(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 ${DZ.default.version} (${t.latestVersion} available)`:`Abacus.AI CLI version ${DZ.default.version}`,`info`)}},{id:`exit`,description:`Exit the application`,usage:`/exit`,alias:{[B0.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:{[B0.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===Sd.Submitted||e.agentStatus===Sd.Streaming||e.agentStatus===Sd.ExecutingTool||e.agentStatus===Sd.WaitingForToolPermission,execute:async()=>{let t=e.getAgentStatus?.(),r=t===Sd.Submitted||t===Sd.Streaming||t===Sd.ExecutingTool||t===Sd.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:{[B0.Prompt]:[`help`]},execute:()=>{e.onHelp?e.onHelp():n(hWe(),`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 _H(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)}}],i=null,a=null;r.push({id:`resume`,description:`Resume a previous chat conversation`,usage:`/resume <chat_id_or_title>`,requiresArgument:!0,completionProvider:async t=>{if(i&&=(clearTimeout(i.timer),i.abort(),null),!e.getChatTitles)return[];let n=e=>({label:e.title,id:e.id,description:e.messageCount?`${e.messageCount} msgs`:void 0});if(!a){let r=await e.getChatTitles();if(!r?.length&&!t.trim())return[];a=r.map(n)}let r=a,o=r;if(t.trim()&&(o=new _H(r,{selector:e=>`${e.label} ${e.description??``}`}).find(t).map(e=>e.item)),!t.trim()||!e.searchChatTitles)return o;let s=o;return new Promise(r=>{i={timer:setTimeout(async()=>{try{let i=await e.searchChatTitles(t);if(i?.length){let e=i.map(n),t=new Set(s.map(e=>e.id));r([...s,...e.filter(e=>!t.has(e.id))])}else r(s)}catch{r(s)}i=null},300),abort:()=>r(s)}})},execute:t=>{a=null;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 ${hn.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,X.jsx)(v6,{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 ${hn.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 ${hn.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:`org`,description:`Switch to a different organization`,usage:`/org <org_name>`,requiresArgument:!0,completionProvider:async t=>{if(!e.getOrganizations)return[];let n=await e.getOrganizations();if(!n?.length)return[];let r=n.map(e=>({label:e.name,id:e.id,description:e.workspace}));return t.trim()?new _H(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 an organization name`,`error`);return}if(!e.getOrganizations||!e.onOrgSwitch){n(`Organization switching not available`,`error`);return}let i=await e.getOrganizations();if(!i||i.length===0){n(`No organizations available`,`error`);return}let a=i.find(e=>e.name.toLowerCase()===r.toLowerCase()||e.id===r||e.workspace.toLowerCase()===r.toLowerCase());if(!a){n(`Organization "${r}" not found`,`error`);return}n(`Switching to ${a.name}...`,`info`,!0),await e.onOrgSwitch(a.id)?n(`Switched to ${a.name}`,`info`):n(`Failed to switch to ${a.name}`,`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:`context`,description:`Show context window usage for the current conversation`,usage:`/context`,execute:()=>{if(!e.getContextInfo){n(`Context information not available`,`error`);return}let t=e.getContextInfo();if(t.contextPercent===null||t.contextTokensUsed===null||t.contextWindowMax===null){n(`No context information yet — send a message first`,`info`);return}let r=Math.round(t.contextPercent*10)/10,i=t.contextTokensUsed.toLocaleString(),a=t.contextWindowMax.toLocaleString();n([`Context Window Usage`,``,` Percentage used: ${r}%`,` Tokens used: ${i}`,` Window size: ${a}`].join(`
75326
+ `),`info`)}},{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 aWe();if(e.success){let t=e.message;e.backupPath&&(t+=`\n\nBackup created: ${e.backupPath}`),e.requiresRestart&&(t+=`
75325
75327
 
75326
75328
  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:`mcp`,description:`MCP server management`,usage:`/mcp <subcommand>`,uiProvider:(r,i)=>{let a=r[0],o=e.mcp;if(a===`auth`){let a=r[1];return!a||!t?(n(t?`Usage: /mcp auth <name>`:`MCP service not available`,`error`),i.onDismiss(),null):o?(0,X.jsx)(y6,{serverName:a,authenticate:async e=>{await o.authenticateServer(a,async t=>(e(t),t))},onDismiss:i.onDismiss,onSuccess:()=>{e.refreshMcpTools?.(!0)}}):(n(`MCP manager not available`,`error`),i.onDismiss(),null)}if(a===`add`){if(!t||!o)return n(`MCP service not available`,`error`),i.onDismiss(),null;if(r.length<3)return null;let[,a,s,...c]=r;return s.trim().startsWith(`{`)?null:(0,X.jsx)(b6,{serverName:a,addServer:async()=>{await t.addServer(a,s,c)},mcp:o,onDismiss:i.onDismiss,onSuccess:()=>{e.refreshMcpTools?.(!0)}})}if(a===`add-json`){if(!t||!o)return n(`MCP service not available`,`error`),i.onDismiss(),null;if(r.length<3)return null;let a=r[1],s=r.slice(2).join(` `);return(0,X.jsx)(b6,{serverName:a,addServer:async()=>{await t.addServerFromJson(a,s)},mcp:o,onDismiss:i.onDismiss,onSuccess:()=>{e.refreshMcpTools?.(!0)}})}return null},subcommands:[{id:`auth`,description:`Authenticate with an MCP server that requires OAuth`,usage:`/mcp auth <name>`,requiresArgument:!0,ghostProvider:e=>e?null:`my-server`,execute:async e=>{if(!t){n(`MCP service not available`,`error`);return}if(e.length!==1){n(`Usage: /mcp auth <name>`,`error`);return}n(`Use the interactive UI: type /mcp auth ${e[0]} and press Enter`,`info`)}},{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 _H(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 _H(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=M((e.trim()||`.`).replace(/^~/,te())),n,r;try{(await Te.stat(t)).isDirectory()?(n=t,r=``):(n=O.dirname(t),r=O.basename(t))}catch{n=O.dirname(t),r=O.basename(t)}let i=(await Te.readdir(n,{withFileTypes:!0})).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(e=>{let t=O.join(n,e.name);return{label:O.relative(process.cwd(),t)||e.name,description:t}});return r?new _H(i,{selector:e=>e.label}).find(r).map(e=>e.item):i}catch{return[]}},uiProvider:(t,r)=>{let i=t.join(` `).trim();if(!i)return null;let a=M(i.replace(/^~/,te()));if(e.isDirectoryAllowed){let t=e.isDirectoryAllowed(a);if(t.allowed)return n(`'${a}' is already accessible (covered by ${t.coveredBy})`,`info`),r.onDismiss(),null}return(0,X.jsx)(f6,{title:`Add ${a} to workspace`,subtitle:`${hn.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(a),n(`Added '${a}' 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(a,{persist:!0}),n(`Added '${a}' 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=M(r.replace(/^~/,te()));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:`tasks`,description:`Show and manage background tasks`,usage:`/tasks`,alias:[`ps`],subcommands:[{id:`stop`,description:`Stop a running task`,usage:`/tasks stop <id>`,requiresArgument:!0,execute:async t=>{let r=parseInt(t[0]??``,10);if(isNaN(r)){n(`Usage: /tasks stop <id>`,`warning`);return}if(!e.stopTerminalSession){n(`Stop not available`,`error`);return}await e.stopTerminalSession(r)?n(`Task [${r}] stopped`,`info`):n(`Task [${r}] not found or already stopped`,`warning`)}},{id:`output`,description:`Show output of a task`,usage:`/tasks output <id>`,requiresArgument:!0,execute:t=>{let r=parseInt(t[0]??``,10);if(isNaN(r)){n(`Usage: /tasks output <id>`,`warning`);return}if(!e.getTerminalSessionOutput){n(`Output retrieval not available`,`error`);return}let i=e.getTerminalSessionOutput(r);if(!i){n(`No output for task [${r}]`,`info`);return}n(`Output [${r}]:\n${i.split(`
75327
75329
  `).slice(-20).join(`
75328
75330
  `)}`,`info`)}}],uiProvider:(t,n)=>(0,X.jsx)(C6,{listTerminalSessions:e.listTerminalSessions,getTerminalSessionOutput:e.getTerminalSessionOutput,stopTerminalSession:e.stopTerminalSession,onDismiss:n.onDismiss}),execute:()=>{if(!e.listTerminalSessions){n(`Terminal sessions not available`,`error`);return}let t=e.listTerminalSessions();if(t.length===0){n(`No background tasks found`,`info`);return}let r=t.filter(e=>e.isRunning),i=t.filter(e=>!e.isRunning&&(e.exitCode??0)===0),a=t.filter(e=>!e.isRunning&&(e.exitCode??0)!==0),o=[];if(o.push(`Tasks:`),o.push(``),r.length>0){o.push(`In progress (${r.length}):`);for(let e of r){let t=h3(Date.now()-e.startTime),n=e.command.length>50?e.command.substring(0,47)+`...`:e.command;o.push(` [${e.id}] ${n} (${t})`)}o.push(``)}if(i.length>0){o.push(`Completed (${i.length}):`);for(let e of i.slice(-5)){let t=e.command.length>50?e.command.substring(0,47)+`...`:e.command;o.push(` [${e.id}] ${t} (ok)`)}i.length>5&&o.push(` ... and ${i.length-5} more`),o.push(``)}if(a.length>0){o.push(`Failed (${a.length}):`);for(let e of a.slice(-5)){let t=e.command.length>50?e.command.substring(0,47)+`...`:e.command;o.push(` [${e.id}] ${t} (exit ${e.exitCode})`)}a.length>5&&o.push(` ... and ${a.length-5} more`),o.push(``)}o.push(`Use /tasks output <id> to inspect logs`),o.push(`Use /tasks stop <id> to terminate`),n(o.join(`
75329
- `),`info`)}},{id:`diff`,description:`Show git diff of all changes in an interactive viewer`,usage:`/diff`,uiProvider:(t,n)=>(0,X.jsx)(S6,{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}v2(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(`
75330
- `)};return(0,X.jsx)(f6,{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}v2(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=O.join(a,`conversation.txt`);try{await Te.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,X.jsx)(h6,{version:DZ.default.version,cwd:r,onDismiss:n.onDismiss})},execute:async()=>{n(`Use /feedback in interactive mode to submit feedback`,`info`)}}),x6.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=>x6.register(e))})()}const w6=(0,Z.createContext)(null);function T6(){let e=(0,Z.use)(w6);if(!e)throw Error(`${T6.name} must be used within ${E6.name}`);return e}function E6({children:e}){let[t,n]=(0,Z.useState)(``),[r,i]=(0,Z.useState)(B0.Prompt),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(`idle`),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),{queuedMessages:f,nq:p,dq:m,removeFromQueue:h,setQueuedMessageContent:g,clearQueue:_}=d3(),[v,y]=(0,Z.useState)([]),b=(0,Z.useCallback)(e=>{y(t=>[...t,e])},[]),x=(0,Z.useCallback)(()=>{y([])},[]),S=(0,Z.useMemo)(()=>({prompt:t,setPrompt:n,mode:r,setMode:i,bufferRef:a,activity:o,setActivity:s,queuedMessages:f,nq:p,dq:m,removeFromQueue:h,setQueuedMessageContent:g,clearQueue:_,attachments:v,setAttachments:y,addAttachment:b,clearAttachments:x,ghostText:c,setGhostText:l,commandOverlay:u,setCommandOverlay:d}),[t,r,o,f,p,m,h,g,_,v,b,x,c,u]);return(0,X.jsx)(w6.Provider,{value:S,children:e})}const D6=/[A-Za-z0-9_.~/\\-]/;function O6(e,t){let[n,r]=t,i=e.split(`
75331
- `)[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(!D6.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&&D6.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 _We(){return[{regex:RegExp(`(?:^|\\s)@(?:'[^']*'|(?:[A-Za-z0-9_.~/-]|\\\\ )+)`,`gm`),color:`brightcyan`},{regex:RegExp(`^/[A-Za-z0-9_./\\-]+`,`gm`),color:`brightmagenta`},{regex:RegExp(`\\[Pasted text #\\d+ \\+\\d+ lines\\]`,`g`),color:`brightyellow`}]}const k6=(0,Z.memo)(()=>{let{queuedMessages:e}=T6(),t=e.filter(e=>!e.hidden);return t.length===0?null:(0,X.jsx)(Q,{flexDirection:`column`,children:t.map((e,t)=>(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:XQ,children:`❯`}),(0,X.jsx)($,{color:XQ,italic:!0,children:e.message.trim()})]},e.id||t))})});k6.displayName=`MessageQueue`;const A6=(0,Z.memo)(({mode:e,prompt:t,handler:n,onExitFilesMode:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})=>n?(0,X.jsx)(X.Fragment,{children:n.render({prompt:t,onExit:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})}):null);A6.displayName=`ModePanel`;function vWe(e){return typeof e==`string`?{label:e}:e}const j6=(0,Z.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,Z.useState)(Math.max(0,Math.min(r,Math.max(0,p-1)))),[g,_]=(0,Z.useState)(0),v=(0,Z.useMemo)(()=>e.map(vWe),[e]),y=(0,Z.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,Z.useEffect)(()=>{m>=p&&(h(p===0?0:p-1),_(0))},[p,m]);let S=(0,Z.useEffectEvent)(e=>{typeof s==`function`&&p>0&&s(v[e].label,e)});(0,Z.useEffect)(()=>{S(m)},[m]);let C=(0,Z.useCallback)(e=>{let t=Math.max(0,p-b);return Math.max(0,Math.min(e,t))},[p,b]),w=(0,Z.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,Z.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]);bZ((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,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[O&&p>0&&g>0&&(0,X.jsxs)($,{dimColor:!0,children:[`▲ `,k&&p>1&&`(${m+1}/${p})`]}),p===0?(0,X.jsx)($,{dimColor:!0,children:`No matches`}):E.map((e,t)=>{let n=g+t,r=n===m;return f?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:r?`brightcyan`:void 0,children:r?`> `:` `}),f(e,r)]},`${e.label}-${n}`):(0,X.jsxs)($,{color:r?`brightcyan`:void 0,wrap:`truncate-end`,children:[r?`> `:` `,e.label,e.description?(0,X.jsxs)($,{dimColor:!0,children:[` `,e.description]}):null,e.badge?(0,X.jsxs)($,{color:`yellow`,children:[` [`,e.badge,`]`]}):null]},`${e.label}-${n}`)}),O&&p>0&&g+b<p&&(0,X.jsxs)($,{dimColor:!0,children:[`▼ `,k&&p>1&&`(${m+1}/${p})`]}),!O&&k&&p>1&&(0,X.jsx)($,{dimColor:!0,children:`(${m+1}/${p})`})]})});j6.displayName=`Select`;const M6=(0,Z.memo)(({prompt:e,onAccept:t,onCancel:n,availableHeight:r,onLoadingChange:i,commandContext:a,onSubmitPrompt:o})=>{let{bufferRef:s,setGhostText:c,setCommandOverlay:l}=T6(),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(!1),g=(0,Z.useCallback)(()=>{s.current?.setText(``)},[s]),_=(0,Z.useDeferredValue)((0,Z.useMemo)(()=>{let t=e.trim();return t.startsWith(`/`)?t.slice(1):``},[e])),v=(0,Z.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,Z.useEffect)(()=>{let t=e.trimStart();if(!t.startsWith(`/`)){d(null);return}d(x6.match(t))},[e]),(0,Z.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,Z.useEffect)(()=>{if(u)return;let t=e.trimStart();if(!t.startsWith(`/`))return;let n=cq.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,Z.useEffect)(()=>(i?.(m),()=>{i?.(!1)}),[m,i]),(0,Z.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,Z.useMemo)(()=>{if(!v)return[];if(v.type===`subcommands`&&u?.command.subcommands)return x6.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=x6.search(_,a).map((e,t)=>({type:`command`,display:`${e.id} - ${e.description}`,commandIdx:t})),t=cq.search(_).map(e=>({type:`skill`,display:`${e.id} - ${e.frontmatter.description} [skill]`,skill:e}));return[...e,...t]},[v,u,f,m,_,a]),b=(0,Z.useMemo)(()=>y.map(e=>e.display),[y]),x=(0,Z.useCallback)((e,t)=>{if(!v)return null;let n=y[t];if(!n)return null;if(n.type===`subcommand`&&u?.command.subcommands){let e=x6.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=x6.search(_,a)[n.commandIdx];return e?`/${e.id} `:null}return n.type===`skill`?`/${n.skill.id} `:null},[v,u,_,m,a,y]),S=(0,Z.useCallback)((e,t)=>{let n=s.current;if(!n)return;let r=x(e,t);r&&n.setText(r)},[s,x]),C=(0,Z.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=x6.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=u.subcommand?[u.subcommand.id,i.value]:[i.value],r=e.uiProvider(n,t);if(r){l(r);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=x6.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 bZ((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=x6.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=a.subcommand?[a.subcommand.id,...e]:e,n={onDismiss:()=>{l(null),g()},clearBuffer:g},r=a.command.uiProvider(t,n);if(r){l(r);return}}(async()=>{await x6.execute(a)&&(r.setText(``),t())})()}},{isActive:!w}),w?(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(j6,{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});M6.displayName=`CommandPicker`;function yWe(e){let{setCommandOverlay:t}=T6(),n=(0,Z.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,Z.useCallback)(async t=>{let r=t.trimStart();if(!r.startsWith(`/`))return;let i=x6.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),t=i.subcommand?[i.subcommand.id,...e]:e;if(n(i.command,t))return}try{await x6.execute(i)&&e()}catch{}},[e,n]),showCommandUI:n,renderer:(0,Z.useCallback)(({prompt:e,onExit:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a})=>(0,X.jsx)(M6,{prompt:e,onAccept:t,onCancel:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a}),[]),shouldPreventDefault:(0,Z.useCallback)((e,t)=>!!(t.return||t.upArrow||t.downArrow||t.escape||t.tab),[])}}function N6({output:e,command:t,truncate:n=!1,maxLines:r=10}){let i=e.split(`
75332
- `),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,X.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,X.jsx)($,{dimColor:!0,children:`${M0(process.cwd())}$ ${t}`}),e&&a.map((e,t)=>o&&t===Math.floor(a.length/2)?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)($,{dimColor:!0,children:[`... (`,i.length-r,` lines hidden) ...`]}),(0,X.jsx)($,{children:e.line})]},`trunc-${e.originalIndex}`):(0,X.jsx)($,{children:e.line},`line-${e.originalIndex}`))]})}const bWe=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];function xWe(){let e=P.platform(),t={};for(let[e,n]of Object.entries(process.env))n!==void 0&&(t[e]=n);return e===`win32`?{command:process.env.COMSPEC||`cmd.exe`,args:[],env:t}:{command:process.env.SHELL||`/bin/bash`,args:[],env:{...t,BASH_SILENCE_DEPRECATION_WARNING:`1`,PS1:``}}}var SWe=class{shell=null;queue=[];notify=null;isProcessing=!1;destroyed=!1;isWindows;signalHandlers=new Map;constructor(){this.isWindows=P.platform()===`win32`,this.startShell(),this.setupSignalForwarding()}setupSignalForwarding(){for(let e of bWe){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}=xWe();this.shell=ue(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 P6=null;function CWe(){return P6||=new SWe,P6}function wWe({state:e,setState:t,onCommandComplete:n,commandHistory:r,currentPrompt:i,availableHeight:a}){let{submittedCommand:o,runId:s}=e,c=(0,Z.useMemo)(()=>o?.trim()||``,[o]),l=(0,Z.useRef)(-1),u=(0,Z.useRef)(null);(0,Z.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:``})),TWe({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,X.jsxs)(Q,{flexDirection:`column`,children:[p.map((e,t)=>{let n=m+t;return(0,X.jsx)(N6,{output:e.output,command:e.command,truncate:v,maxLines:_},`history-${n}`)}),o&&(0,X.jsx)(N6,{output:e.output,command:c||o,truncate:v,maxLines:_},`submitted-${s}`)]})}async function TWe({command:e,setOutput:t,signal:n}){let{stream:r,exit:i}=await CWe().executeCommand(e),a=``;try{for await(let e of r){if(n.aborted)return;a+=PUe(e.data),n.aborted||t(a)}return n.aborted?void 0:(await i,a)}catch(e){if(n.aborted)return;throw e}}var EWe=Xe({parseShellHistory:()=>I6,shellHistory:()=>OWe,shellHistoryPath:()=>L6});function DWe(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 F6(e){return I6(DWe(c.readFileSync(e)).toString(`utf8`))}function I6(e){let t=/^: \d+:0;/;return e.trim().split(`
75333
- `).map(e=>t.test(e)?e.split(`;`).slice(1).join(`;`):e)}function L6({extraPaths:e=[]}={}){if(process.env.HISTFILE)return process.env.HISTFILE;let t=ee.homedir(),n=new Set([O.join(t,`.bash_history`),O.join(t,`.zsh_history`),O.join(t,`.history`)]);for(let t of e)n.add(t);return(()=>{let e,t=0;for(let r of n)c.existsSync(r)&&c.statSync(r).size>t&&(t=c.statSync(r).size,e=r);return e})()}function OWe(e={}){if(process.platform===`win32`){let t=L6(e);if(t)return F6(t);let{stdout:n}=ae.spawnSync(`doskey`,[`/history`],{encoding:`utf8`});return n.trim().split(`\r
75334
- `)}return F6(L6(e))}var kWe=W((()=>{}));const R6=1e3;function AWe(){let[e,t]=(0,Z.useState)({submittedCommand:null,runId:0,output:``,isRunning:!1}),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{c.current||(c.current=!0,Promise.resolve().then(()=>(kWe(),EWe)).then(e=>{let t=e.shellHistory??e.default;a((typeof t==`function`?t():[]).slice(-R6))}).catch(()=>{}))},[]);let l=(0,Z.useCallback)(e=>{let n=e.trim();n&&(a(e=>e.length>0&&e[e.length-1]===n?e:[...e,n].slice(-R6)),s(-1),t(e=>({submittedCommand:n,runId:e.runId+1,output:``,isRunning:!0})))},[]),u=(0,Z.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,Z.useCallback)(r=>(0,X.jsx)(wWe,{state:e,setState:t,onCommandComplete:u,commandHistory:n,currentPrompt:r.prompt,availableHeight:r.availableHeight}),[e,u,n]),navigateHistory:(0,Z.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`}}const jWe=[`no pull requests found`,`no open pull requests`];function MWe(){return new Promise((e,t)=>{se(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,state`],{timeout:1e4},(n,r,i)=>{if(n){let r=(i||n.message).toLowerCase();jWe.some(e=>r.includes(e))?e(null):t(n);return}try{let t=JSON.parse(r.trim());if(typeof t.number==`number`&&typeof t.url==`string`&&t.number>0){let n=`pending`;t.state===`MERGED`?n=`merged`:t.state===`CLOSED`?n=`closed`:t.isDraft?n=`draft`:t.reviewDecision===`APPROVED`?n=`approved`:t.reviewDecision===`CHANGES_REQUESTED`&&(n=`changes_requested`),e({number:t.number,url:t.url,reviewState:n});return}}catch{t(Error(`Malformed JSON from gh pr view`))}e(null)})})}const z6=6e4;function NWe(){let{data:e}=qQ({queryKey:[S3.PrInfo],queryFn:MWe,staleTime:z6,refetchInterval:z6,retry:!1,refetchOnMount:!0,refetchOnWindowFocus:!1});return e??null}function B6({href:e,children:t,color:n}){let r=mZ(e),i=hZ();return(0,X.jsx)($,{color:n??WNe,underline:!0,transform:e=>`${r}${e}${i}`,children:t})}B6.displayName=`Link`;const PWe={approved:`green`,pending:`yellow`,changes_requested:`red`,draft:`brightblack`,merged:`magenta`,closed:`brightblack`},V6=(0,Z.memo)(({hints:e,availableHeight:t})=>{let{agentMode:n,isWaitingForYoloConfirm:r}=H0(),i=NWe();if(t!==void 0&&t<1)return null;let a;if(e?.exitKey)a=(0,X.jsxs)($,{dimColor:!0,children:[`Press `,e.exitKey===`c`?`Ctrl+C`:`Ctrl+D`,` again to exit`]});else if(r)a=(0,X.jsxs)($,{dimColor:!0,children:[`Press `,(0,X.jsx)($,{color:`brightred`,children:`shift+tab`}),` again to enable YOLO mode (dangerous)`]});else switch(n){case xd.Normal:a=(0,X.jsx)($,{dimColor:!0,children:`? for shortcuts • shift+tab to cycle modes`});break;case xd.AcceptEdits:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightcyan`,children:`⏵⏵`}),` accept edits on (shift+tab to cycle)`]});break;case xd.PlanMode:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightcyan`,children:`⏸`}),` plan mode on (shift+tab to cycle)`]});break;case xd.Yolo:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightred`,children:`⚠`}),` YOLO mode - all tools auto-accepted (shift+tab to cycle)`]});break;default:a=(0,X.jsx)($,{dimColor:!0,children:`? for shortcuts`})}return i?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsxs)(B6,{href:i.url,color:PWe[i.reviewState],children:[`PR #`,i.number]}),(0,X.jsx)($,{dimColor:!0,children:`•`}),a]}):a});V6.displayName=`AgentModeIndicator`;const H6=15e3,FWe=/^(node_modules|\.git|dist|build|out|coverage|\.vscode|\.idea|\.DS_Store)$/;let U6=null;function W6(e,t){let n=e.replace(/\\/g,`/`);return{path:n,name:O.posix.basename(n),isDirectory:t}}function IWe(e){return e.name.startsWith(`.`)||e.path.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`)}async function LWe(e){try{let t=await RWe(`git`,[`rev-parse`,`--show-toplevel`],e);if(!t)return null;let[n,r]=await Promise.all([G6(`git`,[`ls-files`],t),G6(`git`,[`ls-files`,`--others`,`--exclude-standard`],t)]),i=[],a=new Set;for(let e of[...n,...r]){if(!e)continue;let n=O.resolve(t,e);i.push(W6(n,!1));let r=O.posix.dirname(e);for(;r&&r!==`.`;){let e=O.resolve(t,r);if(a.has(e))break;a.add(e),i.push(W6(e,!0)),r=O.posix.dirname(r)}}return i}catch{return null}}function RWe(e,t,n){return new Promise((r,i)=>{let a=ue(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 G6(e,t,n){return new Promise(r=>{let i=[],a=ue(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:a.stdout}).on(`line`,e=>i.push(e.trim())),a.on(`close`,()=>r(i)),a.on(`error`,()=>r(i))})}async function zWe(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=ue(Ve,n,{cwd:e,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:i.stdout}).on(`line`,t=>{let n=fBe(t.trim());n&&r.push(W6(O.resolve(e,n),!1))}),i.on(`close`,()=>t(r)),i.on(`error`,()=>t(r))})}async function K6(e,t){let n=[],r=async(e,i)=>{if(!(i>12||n.length>=H6))try{let a=await m.readdir(e,{withFileTypes:!0}),o=[];for(let r of a){if(!t&&r.name.startsWith(`.`))continue;let i=O.join(e,r.name);r.isDirectory()?FWe.test(r.name)||(n.push(W6(i,!0)),o.push(i)):r.isFile()&&n.push(W6(i,!1))}await Promise.all(o.map(e=>r(e,i+1)))}catch{}};return await r(e,0),n}function BWe(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>=H6||s.has(e.path)||(s.add(e.path),!(!t&&IWe(e))&&c.push(e))},u=i&&a&&n.length===0&&r.length===0;return{docs:c,ready:(async()=>{if(u){let e=await LWe(o);if(e){for(let t of e)l(t);return}}if(i){let e=await zWe(o,{includeHidden:t,globs:n,ignoreGlobs:r,useGitignore:a});for(let t of e)l(t);let i=await K6(o,t);for(let e of i)e.isDirectory&&l(e)}else{let e=await K6(o,t);for(let t of e)l(t)}})()}}function VWe(e){let t=O.resolve(e.root);if(U6&&U6.key===t&&Date.now()-U6.at<6e4)return U6.index;let n=BWe(e);return U6={key:t,index:n,at:Date.now()},n}async function HWe(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=O.isAbsolute(e.path)?e.path:O.resolve(t,e.path),i=await m.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 UWe(e,t){let n=t.root,r=t.maxResults??100;if(!(await m.stat(n).catch(()=>null))?.isDirectory())return{paths:[],isDirectory:[]};let i=VWe(t);await i.ready;let a=e.trim();if(!a)return HWe(i.docs,n,r);let o=new _H(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 WWe(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)([]),a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null);return(0,Z.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 UWe(e,{root:process.cwd()});if(t.signal.aborted)return;n(r.paths.map(mBe)),i(r.isDirectory)}catch{}})()},100),()=>{o.current&&clearTimeout(o.current),a.current&&a.current.abort()}),[e]),{results:t,isDirectory:r}}const q6=(0,Z.memo)(({onAccept:e,onCancel:t,availableHeight:n})=>{let{prompt:r,bufferRef:i}=T6(),[a,o]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=i.current;if(!e){o(``);return}let t=O6(e.text,e.cursor)?.query??``;o(e=>e===t?e:t)},[i,r]);let s=(0,Z.useDeferredValue)(a),{results:c,isDirectory:l}=WWe(s),u=a!==s,d=c.map((e,t)=>l[t]?`${e}/`:e),f=(0,Z.useCallback)((t,n)=>{let r=i.current;if(!r)return e();let a=O6(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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(j6,{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,X.jsx)(Q,{marginTop:0,children:(0,X.jsx)($,{dimColor:!0,children:`Searching...`})})]})});q6.displayName=`FileMentionPicker`;const J6=[[`! for terminal/bash mode`,`/ for commands`,`@ for file paths`],[`esc esc to clear input`,`shift + tab to cycle agent modes`,`${ZUe().toLowerCase()} for newline`],[`ctrl + z to undo`,`ctrl + v to paste images`]],Y6=(0,Z.memo)(({availableHeight:e})=>e!==void 0&&e<3?null:(0,X.jsx)(Q,{flexDirection:`row`,columnGap:5,rowGap:1,flexWrap:`wrap`,children:(e!==void 0&&e<6?J6.slice(0,1):e!==void 0&&e<9?J6.slice(0,2):J6).map((e,t)=>(0,X.jsx)(Q,{flexDirection:`column`,children:e.map(e=>(0,X.jsx)($,{dimColor:!0,children:e},e))},t))}));Y6.displayName=`Help`;function GWe(){return{mode:B0.Prompt,render:({prompt:e,hints:t,availableHeight:n})=>(0,X.jsx)(V6,{hints:t,availableHeight:n})}}function KWe(){return{mode:B0.Help,render:({availableHeight:e})=>(0,X.jsx)(Y6,{availableHeight:e})}}function qWe(e){return{mode:B0.Files,render:({prompt:t,availableHeight:n})=>(0,X.jsx)(q6,{onAccept:e,onCancel:e,availableHeight:n}),shouldPreventDefault:(e,t)=>t.upArrow||t.downArrow||t.escape||t.return||t.tab}}function JWe(e,t){let n=AWe(),r=yWe(t);return{handlers:(0,Z.useMemo)(()=>{let t={mode:B0.Bash,render:n.renderer,onSubmit:n.submitCommand},i={mode:B0.Command,render:r.renderer,onSubmit:r.executeCommand,shouldPreventDefault:r.shouldPreventDefault};return new Map([[B0.Prompt,GWe()],[B0.Help,KWe()],[B0.Bash,t],[B0.Command,i],[B0.Files,qWe(e)]])},[n,r,e]),getActivity:n.getActivity,bashNavigateHistory:n.navigateHistory}}const YWe={[B0.Prompt]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[B0.Help]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[B0.Bash]:{color:`brightgreen`,placeholder:vUe()?`Try "dir"`:`Try "ls -la"`,prefix:`!`},[B0.Command]:{color:`brightmagenta`,placeholder:`Try "/resume <chat title>"`,prefix:`❯`},[B0.Files]:{color:`brightcyan`,placeholder:`Try "@help.md"`,prefix:`@`}},XWe={"!":{mode:B0.Bash,preventDefault:!0,atStartOnly:!0},"?":{mode:B0.Help,preventDefault:!0,atStartOnly:!0},"@":{mode:B0.Files,preventDefault:!1,atStartOnly:!1}},X6=(0,Z.memo)(({hints:e,composerRef:t})=>{let{prompt:n,setPrompt:r,mode:i,setMode:a,bufferRef:o,activity:s,setActivity:c,queuedMessages:l,nq:u,clearQueue:d,addAttachment:f,clearAttachments:p,ghostText:m,commandOverlay:h}=T6(),g=(0,Z.useCallback)(()=>{let e=l.filter(e=>!e.hidden);if(e.length===0)return;let t=e.map(e=>e.message).join(`
75335
- `);o.current?.setText(t),d()},[l,o,d]),{updateInfo:_,autoUpdate:v}=mUe(),y=(0,Z.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),b=(0,Z.useCallback)(()=>{},[]),x=(0,Z.useRef)({text:``,timer:null}),S=(0,Z.useRef)(null);S.current||(S.current=new yq(`cli-repl`),S.current.load());let C=S.current,w=(0,Z.useRef)(``),T=(0,Z.useRef)(0),E=(0,Z.useRef)(null),D=(0,Z.useCallback)(e=>{if(!new Set([B0.Prompt,B0.Help]).has(i))return!1;let t=e.trim();if(!t.startsWith(`/`))return!0;let n=t.slice(1).split(/\s/)[0]||``;return!(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))},[i]);(0,Z.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.some(e=>!e.hidden),saveAndClear:()=>{let e=n.trimStart();e&&D(e)&&(C.append(e),C.resetNavigation()),o.current?.setText(``),b(),p()},clear:()=>{o.current?.setText(``),b(),p()},clearQueue:()=>d(),dequeueAllToComposer:()=>g()}));let{currentFile:k,selectionStartLine:A,selectionEndLine:j}=t3(),{sendMessage:M,segments:N,clearSegments:P,clearSegmentsOnly:ee,clearTempSegments:F,stop:te,addNotification:I,mcp:L,isDirectoryAllowed:R,addAllowedDirectory:z,refreshMcpTools:ne,loadConversation:re,agentStatus:ie,segmentsLength:ae,conversationId:oe,dequeuedOnStop:se,clearDequeuedOnStop:ce,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,totalCredits:fe}=d3(),{apiClient:B,authManager:pe}=o3(),{data:me=[],refetch:he}=_Ue(B),ge=WQ(),{cycleAgentMode:_e,resetToNormal:ve,isWaitingForYoloConfirm:ye}=H0(),be=(0,Z.useContext)(G0),V=gUe(),{requestFullRedraw:xe}=zMe(),{handlers:Se,getActivity:Ce,bashNavigateHistory:we}=JWe(()=>a(B0.Prompt),(0,Z.useCallback)(()=>{o.current?.setText(``)},[o])),Ee=Se.get(i)||null,[De,Oe]=(0,Z.useState)([]),ke=(0,Z.useRef)([]),[Ae,je]=(0,Z.useState)(``),[Me,Ne]=(0,Z.useState)(null),[Pe,Fe]=(0,Z.useState)(!1),[Ie,Le]=(0,Z.useState)(!1),Re=(0,Z.useMemo)(()=>({agentStatus:ie,segmentsLength:ae,isLoggedIn:Me??!1}),[ie,ae,Me]),ze=(0,Z.useCallback)(async()=>{try{let e=await B.getConversationsList(hn.agentType,process.cwd());if(e?.result){let t=e.result.slice(0,25);Oe(t),ke.current=t}}catch{}},[B]);(0,Z.useEffect)(()=>{ze()},[ze]),(0,Z.useEffect)(()=>{B.getUserInfo().then(e=>Ne(!!e?.result?.email)).catch(()=>{Ne(pe.isAuthenticated())})},[B,pe]),(0,Z.useEffect)(()=>{se&&(o.current?.setText(se),ce())},[se,ce,o]);let Be=Ae||me[0]?.llmName||``;(0,Z.useEffect)(()=>{if(!Pe){Le(!1);return}let e=setInterval(()=>Le(e=>!e),500);return()=>clearInterval(e)},[Pe]),(0,Z.useEffect)(()=>{gWe({onExit:()=>{QZ(0)},onNewChat:()=>{P(),d(),o.current?.setText(``),xe()},onClearChat:()=>{ee(),o.current?.setText(``),xe()},onStop:()=>{te()},onModelChange:e=>{let t=me.find(t=>t.llmName===e);t?(je(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=ke.current.find(t=>t.deploymentConversationId===e);if(t||=ke.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase())),t||(await ze(),t=ke.current.find(t=>t.deploymentConversationId===e),t||=ke.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()))),!t)try{let n=(await B.searchConversations(e,hn.agentType))?.result??[];if(n.length>0&&(t=n.find(t=>t.deploymentConversationId===e),!t)){let r=e.toLowerCase();t=n.find(e=>(e.name||e.deploymentConversationId||`Untitled`).toLowerCase().includes(r))}}catch{}if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await re(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(pe.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 FJ(),r=await B.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 yUe(e);try{let e=await B.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await pe.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);B.setChatWebDomain(e)}I(`Authentication successful!`,`info`),Ne(!0),await ze(),await he();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await pe.loginWithApiKey(e);try{(await B.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),Ne(!0),await ze(),await he()):(await pe.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await pe.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(pe.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await pe.logout(),Ne(!1)},getUserInfo:async()=>{try{let e=await B.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=pe.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()=>me.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>(await ze(),ke.current.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))),searchChatTitles:async e=>{try{let t=await B.searchConversations(e,hn.agentType);if(t?.result)return t.result.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))}catch{}return[]},addNotification:I,mcp:L,isDirectoryAllowed:R,addAllowedDirectory:z,refreshMcpTools:ne,getAgentStatus:()=>ie,getTotalCredits:fe>0?()=>Promise.resolve(fe):void 0,loginAuth:{initiateDeviceCode:async e=>{let t=await FJ(),n=await B.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 B.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 pe.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);B.setChatWebDomain(e)}Ne(!0),await ze(),await he()},loginWithApiKey:async e=>{if(await pe.loginWithApiKey(e),!(await B.getUserInfo())?.result?.email)throw await pe.logout(),Error(`Invalid API key — authentication failed`);Ne(!0),await ze(),await he()},isEnvAuth:()=>pe.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:pe.isEnvAuth(),shouldHide:pe.isEnvAuth()}),getUpdateInfo:()=>_,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,getLastAssistantMessage:()=>{for(let e=N.length-1;e>=0;e--){let t=N[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=C3(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>N,getOrganizations:async()=>{try{let e=await B.listOrganizations();return!e?.success||!e.result?[]:e.result.map(e=>({id:e.organizationId,name:e.name,workspace:e.workspace}))}catch{return[]}},onOrgSwitch:async e=>{try{let t=await B.switchOrganization(e);return t&&(await ze(),await he(),ge.invalidateQueries({queryKey:[S3.UserInfo]})),t}catch{return!1}}})},[me,N,P,ee,xe,d,o,B,he,te,I,L,R,z,ne,re,De,ze,ie,oe,pe,_,le,ue,de,fe,ge]);let Ve=(0,Z.useCallback)(async e=>{try{let t=await Te.stat(e),n=await Te.readFile(e),r=O.extname(e).toLowerCase(),i={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`}[r]??`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:O.resolve(e),fileName:O.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]),H=(0,Z.useCallback)(async()=>{if(await g2()){let e=await _2();if(e){let t=y2(b2(e));o.current?.insert(`@${t} `),await Ve(e);return}}let e=await cVe();if(!e)return;let t=x2(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ve(e);return}f2(e.trim())||o.current?.insert(e,{isPaste:!0})},[o,Ve]),He=(0,Z.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){H(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=x2(t.trim());if(n){o.current?.insert(n.mentionText);for(let e of n.persistedImagePaths)Ve(e);e.preventDefault();return}if(f2(t.trim())){e.preventDefault();return}(async()=>{if(await g2()){let e=await _2();if(e){let t=y2(b2(e));o.current?.insert(`@${t} `),await Ve(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){x.current.text+=e.input,x.current.timer&&clearTimeout(x.current.timer),x.current.timer=setTimeout(()=>{let e=x.current.text;x.current={text:``,timer:null};let t=x2(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ve(e);return}f2(e.trim())||o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===B0.Prompt&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.some(e=>!e.hidden)&&n.trim()===``){g(),e.preventDefault();return}if(Ee?.shouldPreventDefault&&Ee.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===B0.Prompt||i===B0.Help||i===B0.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(C.getEntries().length>0){C.isNavigating()||(w.current=n);let t=C.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!C.isNavigating()){e.preventDefault();return}let t=C.navigateDown();t?o.current?.setText(t.message):o.current?.setText(w.current),e.preventDefault();return}}if(i===B0.Bash&&we){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=we(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(ye){ve(),e.preventDefault();return}i!==B0.Prompt&&(a(B0.Prompt),C.resetNavigation(),w.current=``,e.preventDefault());return}if(i===B0.Prompt&&e.key.shift&&e.key.tab){_e(),e.preventDefault();return}let r=XWe[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==B0.Command&&e.preventDefault();return}},[i,a,Ee,we,o,H,Ve,l,n,d,g,ye,ve,_e,C]);(0,Z.useEffect)(()=>{if(i===B0.Prompt)return;let e=n.trim();if(i===B0.Files){let e=o.current;e&&(O6(e.text,e.cursor)||a(B0.Prompt))}else if(i===B0.Command)if(e.length===0)a(B0.Prompt);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(B0.Prompt)}},[i,n,o,a]),(0,Z.useEffect)(()=>{if(i!==B0.Help)return;let e=setTimeout(()=>{a(B0.Prompt)},3e4);return()=>clearTimeout(e)},[i,a]);let Ue=(0,Z.useCallback)((e,t)=>{let n=T.current;T.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=ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission;e.length>0&&!l&&!u&&F();let d=O6(e,t.cursor);if(o.length===0&&n>0&&(i===B0.Command||i===B0.Bash||i===B0.Help)){a(B0.Prompt);return}if(d){i!==B0.Files&&a(B0.Files);return}if(i===B0.Files){d||a(B0.Prompt);return}i===B0.Help&&o.length>0&&a(B0.Prompt),E.current&&=(clearTimeout(E.current),null),!l&&i===B0.Command&&o.length>0?a(B0.Prompt):l&&i!==B0.Command&&(E.current=setTimeout(()=>{E.current=null,a(B0.Command)},80))},[i,r,a,F,ie]),U=(0,Z.useCallback)(async e=>{let t=e.trim(),n=x6.match(t,i);if(n&&await x6.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=cq.matchSkill(t);if(e){if(Me===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=y(t);if(ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission){u(n),o.current?.setText(``),b();return}M({message:n,selectedModel:Ae||me[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),b(),p();return}}if(Ee?.onSubmit){Ee.onSubmit(e),i===B0.Bash?(o.current?.setText(``),c(Ce())):i===B0.Command&&a(B0.Prompt),p();return}switch(i){case B0.Prompt:if(Me===!1){let t=e.trimStart();t&&D(t)&&(C.append(t),C.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission){let t=y(e.trimStart());u(t),D(t)&&(C.append(t),C.resetNavigation()),w.current=``,b(),o.current?.setText(``);return}let t=Ae||me[0]?.llmName||void 0,n=y(e);D(n)&&(C.append(n),C.resetNavigation()),w.current=``,M({message:n,selectedModel:t}),b(),p();return;default:}},[i,Ee,M,Ce,c,Ae,a,o,ie,u,I,p,Me,y,b,C,me]),{color:We,placeholder:Ge,prefix:Ke}=YWe[i],qe=ae>0?``:Ge,Je=(0,Z.useMemo)(()=>_We(),[]),Ye=(i===B0.Bash?Ce():s)===`pending`||ie===Sd.WaitingForToolPermission,W=M0(process.cwd()),G=(0,Z.useMemo)(()=>(0,X.jsx)(Q,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,X.jsxs)(X.Fragment,{children:[h,(0,X.jsx)(Z.Activity,{mode:h?`hidden`:`visible`,children:(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(k6,{}),(0,X.jsxs)(Q,{flexDirection:`row`,alignItems:`flex-end`,children:[be&&(0,X.jsxs)($,{color:`brightmagenta`,bold:!0,children:[`EXPANDED`,` `]}),G,Me===!1&&(0,X.jsx)($,{dimColor:!0,children:` Not logged in`}),Me===!1&&Be&&(0,X.jsx)($,{dimColor:!0,children:` •`}),Be&&(0,X.jsxs)($,{children:[` `,me.find(e=>e.llmName===Be)?.name||Be]}),(Me===!1||Be)&&(0,X.jsx)($,{dimColor:!0,children:` •`}),(0,X.jsxs)($,{color:`brightyellow`,children:[` `,W]})]}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:We,dimColor:Ie,children:Ke}),(0,X.jsx)(t6,{ref:o,onChange:Ue,onKeyDown:He,onSubmit:U,placeholder:qe,grammar:Je,disabled:Ye,ghostText:m??void 0})]}),(0,X.jsx)(Q,{flexDirection:`row`,children:G}),(0,X.jsxs)(Q,{justifyContent:`space-between`,children:[(0,X.jsx)(A6,{mode:i,prompt:n,handler:Ee,onExitFilesMode:()=>a(B0.Prompt),onSubmitPrompt:U,hints:e,availableHeight:V,onLoadingChange:Fe,commandContext:Re}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[k&&A!==void 0&&j!==void 0?(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsxs)($,{color:`cyan`,children:[j-A+1,` lines selected`]}),` `,`in `,(0,X.jsx)($,{color:`cyan`,children:O.basename(k)})]}):k&&(0,X.jsxs)($,{dimColor:!0,children:[`in `,(0,X.jsx)($,{color:`cyan`,children:O.basename(k)})]}),e?.escClear&&(0,X.jsx)($,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&_&&(0,X.jsx)($,{dimColor:!0,children:`·`}),_&&(0,X.jsxs)($,{wrap:`truncate-middle`,dimColor:!0,children:[`Update available (${_.latestVersion})`,!_.isEphemeral&&(_.installationType===`native`&&v?` · Restart to auto-update`:` · Run: ${RZ(_)}`)]})]})]})]})})]})});X6.displayName=`ComposerInner`;const Z6=(0,Z.memo)(({hints:e,composerRef:t})=>(0,X.jsx)(E6,{children:(0,X.jsx)(X6,{hints:e,composerRef:t})}));Z6.displayName=`Composer`;var Q6=class extends Z.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){Dl(e,{componentStack:t.componentStack??void 0}),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,X.jsxs)(Q,{flexDirection:`column`,padding:1,children:[(0,X.jsx)($,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,X.jsxs)(Q,{marginTop:1,flexDirection:`column`,children:[(0,X.jsx)($,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,X.jsx)($,{color:`brightblack`,children:n.componentStack})]})]}):i}};const $6=(0,Z.memo)(({duration:e,credits:t,conversationId:n})=>(0,X.jsxs)(Q,{flexDirection:`column`,paddingY:1,children:[(0,X.jsx)($,{color:QQ,children:`
75331
+ `),`info`)}},{id:`diff`,description:`Show git diff of all changes in an interactive viewer`,usage:`/diff`,uiProvider:(t,n)=>(0,X.jsx)(S6,{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}v2(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 [path]`,ghostProvider:e=>e?null:`/path/to/export.md`,uiProvider:(t,r)=>t.join(` `).trim()?null:(0,X.jsx)(f6,{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=w6(t);if(!r.trim()){n(`No text content to export`,`warning`);return}v2(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=w6(t);if(!r.trim()){n(`No text content to export`,`warning`);return}let i=e.getCwd?.()??process.cwd(),a=O.join(i,`conversation.txt`);try{await Te.writeFile(a,r,`utf-8`),n(`Conversation saved to ${a}`,`info`)}catch(e){n(`Failed to save file: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}}],onDismiss:r.onDismiss}),execute:async t=>{let r=t.join(` `).trim();if(!r){n(`Use /export in interactive mode to export conversation`,`info`);return}let i=e.getSegmentsForExport?.()??[];if(i.length===0){n(`No conversation to export`,`warning`);return}let a=w6(i);if(!a.trim()){n(`No text content to export`,`warning`);return}let o=oF(r),s=e.getCwd?.()??process.cwd(),c=cF(O.isAbsolute(o)?o:O.resolve(s,o));try{let e=O.dirname(c);await Te.mkdir(e,{recursive:!0}),await Te.writeFile(c,a,`utf-8`),n(`Conversation saved to ${c}`,`info`)}catch(e){n(`Failed to save file: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}},{id:`feedback`,description:`Submit feedback about Abacus.AI CLI`,usage:`/feedback`,uiProvider:(t,n)=>{let r=e.getCwd?.()??process.cwd();return(0,X.jsx)(h6,{version:DZ.default.version,cwd:r,onDismiss:n.onDismiss})},execute:async()=>{n(`Use /feedback in interactive mode to submit feedback`,`info`)}}),x6.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=>x6.register(e))})()}const T6=(0,Z.createContext)(null);function E6(){let e=(0,Z.use)(T6);if(!e)throw Error(`${E6.name} must be used within ${D6.name}`);return e}function D6({children:e}){let[t,n]=(0,Z.useState)(``),[r,i]=(0,Z.useState)(B0.Prompt),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(`idle`),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),{queuedMessages:f,nq:p,dq:m,removeFromQueue:h,setQueuedMessageContent:g,clearQueue:_}=d3(),[v,y]=(0,Z.useState)([]),b=(0,Z.useCallback)(e=>{y(t=>[...t,e])},[]),x=(0,Z.useCallback)(()=>{y([])},[]),S=(0,Z.useMemo)(()=>({prompt:t,setPrompt:n,mode:r,setMode:i,bufferRef:a,activity:o,setActivity:s,queuedMessages:f,nq:p,dq:m,removeFromQueue:h,setQueuedMessageContent:g,clearQueue:_,attachments:v,setAttachments:y,addAttachment:b,clearAttachments:x,ghostText:c,setGhostText:l,commandOverlay:u,setCommandOverlay:d}),[t,r,o,f,p,m,h,g,_,v,b,x,c,u]);return(0,X.jsx)(T6.Provider,{value:S,children:e})}const O6=/[A-Za-z0-9_.~/\\-]/;function k6(e,t){let[n,r]=t,i=e.split(`
75332
+ `)[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(!O6.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&&O6.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 _We(){return[{regex:RegExp(`(?:^|\\s)@(?:'[^']*'|(?:[A-Za-z0-9_.~/-]|\\\\ )+)`,`gm`),color:`brightcyan`},{regex:RegExp(`^/[A-Za-z0-9_./\\-]+`,`gm`),color:`brightmagenta`},{regex:RegExp(`\\[Pasted text #\\d+ \\+\\d+ lines\\]`,`g`),color:`brightyellow`}]}const A6=(0,Z.memo)(()=>{let{queuedMessages:e}=E6(),t=e.filter(e=>!e.hidden);return t.length===0?null:(0,X.jsx)(Q,{flexDirection:`column`,children:t.map((e,t)=>(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:XQ,children:`❯`}),(0,X.jsx)($,{color:XQ,italic:!0,children:e.message.trim()})]},e.id||t))})});A6.displayName=`MessageQueue`;const j6=(0,Z.memo)(({mode:e,prompt:t,handler:n,onExitFilesMode:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})=>n?(0,X.jsx)(X.Fragment,{children:n.render({prompt:t,onExit:r,onSubmitPrompt:i,hints:a,availableHeight:o,onLoadingChange:s,commandContext:c})}):null);j6.displayName=`ModePanel`;function vWe(e){return typeof e==`string`?{label:e}:e}const M6=(0,Z.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,Z.useState)(Math.max(0,Math.min(r,Math.max(0,p-1)))),[g,_]=(0,Z.useState)(0),v=(0,Z.useMemo)(()=>e.map(vWe),[e]),y=(0,Z.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,Z.useEffect)(()=>{m>=p&&(h(p===0?0:p-1),_(0))},[p,m]);let S=(0,Z.useEffectEvent)(e=>{typeof s==`function`&&p>0&&s(v[e].label,e)});(0,Z.useEffect)(()=>{S(m)},[m]);let C=(0,Z.useCallback)(e=>{let t=Math.max(0,p-b);return Math.max(0,Math.min(e,t))},[p,b]),w=(0,Z.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,Z.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]);bZ((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,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[O&&p>0&&g>0&&(0,X.jsxs)($,{dimColor:!0,children:[`▲ `,k&&p>1&&`(${m+1}/${p})`]}),p===0?(0,X.jsx)($,{dimColor:!0,children:`No matches`}):E.map((e,t)=>{let n=g+t,r=n===m;return f?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:r?`brightcyan`:void 0,children:r?`> `:` `}),f(e,r)]},`${e.label}-${n}`):(0,X.jsxs)($,{color:r?`brightcyan`:void 0,wrap:`truncate-end`,children:[r?`> `:` `,e.label,e.description?(0,X.jsxs)($,{dimColor:!0,children:[` `,e.description]}):null,e.badge?(0,X.jsxs)($,{color:`yellow`,children:[` [`,e.badge,`]`]}):null]},`${e.label}-${n}`)}),O&&p>0&&g+b<p&&(0,X.jsxs)($,{dimColor:!0,children:[`▼ `,k&&p>1&&`(${m+1}/${p})`]}),!O&&k&&p>1&&(0,X.jsx)($,{dimColor:!0,children:`(${m+1}/${p})`})]})});M6.displayName=`Select`;const N6=(0,Z.memo)(({prompt:e,onAccept:t,onCancel:n,availableHeight:r,onLoadingChange:i,commandContext:a,onSubmitPrompt:o})=>{let{bufferRef:s,setGhostText:c,setCommandOverlay:l}=E6(),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(!1),g=(0,Z.useCallback)(()=>{s.current?.setText(``)},[s]),_=(0,Z.useDeferredValue)((0,Z.useMemo)(()=>{let t=e.trim();return t.startsWith(`/`)?t.slice(1):``},[e])),v=(0,Z.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,Z.useEffect)(()=>{let t=e.trimStart();if(!t.startsWith(`/`)){d(null);return}d(x6.match(t))},[e]),(0,Z.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,Z.useEffect)(()=>{if(u)return;let t=e.trimStart();if(!t.startsWith(`/`))return;let n=cq.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,Z.useEffect)(()=>(i?.(m),()=>{i?.(!1)}),[m,i]),(0,Z.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,Z.useMemo)(()=>{if(!v)return[];if(v.type===`subcommands`&&u?.command.subcommands)return x6.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=x6.search(_,a).map((e,t)=>({type:`command`,display:`${e.id} - ${e.description}`,commandIdx:t})),t=cq.search(_).map(e=>({type:`skill`,display:`${e.id} - ${e.frontmatter.description} [skill]`,skill:e}));return[...e,...t]},[v,u,f,m,_,a]),b=(0,Z.useMemo)(()=>y.map(e=>e.display),[y]),x=(0,Z.useCallback)((e,t)=>{if(!v)return null;let n=y[t];if(!n)return null;if(n.type===`subcommand`&&u?.command.subcommands){let e=x6.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=x6.search(_,a)[n.commandIdx];return e?`/${e.id} `:null}return n.type===`skill`?`/${n.skill.id} `:null},[v,u,_,m,a,y]),S=(0,Z.useCallback)((e,t)=>{let n=s.current;if(!n)return;let r=x(e,t);r&&n.setText(r)},[s,x]),C=(0,Z.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=x6.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=u.subcommand?[u.subcommand.id,i.value]:[i.value],r=e.uiProvider(n,t);if(r){l(r);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=x6.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 bZ((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=x6.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=a.subcommand?[a.subcommand.id,...e]:e,n={onDismiss:()=>{l(null),g()},clearBuffer:g},r=a.command.uiProvider(t,n);if(r){l(r);return}}(async()=>{await x6.execute(a)&&(r.setText(``),t())})()}},{isActive:!w}),w?(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)(M6,{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});N6.displayName=`CommandPicker`;function yWe(e){let{setCommandOverlay:t}=E6(),n=(0,Z.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,Z.useCallback)(async t=>{let r=t.trimStart();if(!r.startsWith(`/`))return;let i=x6.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),t=i.subcommand?[i.subcommand.id,...e]:e;if(n(i.command,t))return}try{await x6.execute(i)&&e()}catch{}},[e,n]),showCommandUI:n,renderer:(0,Z.useCallback)(({prompt:e,onExit:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a})=>(0,X.jsx)(N6,{prompt:e,onAccept:t,onCancel:t,availableHeight:n,onLoadingChange:r,commandContext:i,onSubmitPrompt:a}),[]),shouldPreventDefault:(0,Z.useCallback)((e,t)=>!!(t.return||t.upArrow||t.downArrow||t.escape||t.tab),[])}}function P6({output:e,command:t,truncate:n=!1,maxLines:r=10}){let i=e.split(`
75333
+ `),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,X.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,X.jsx)($,{dimColor:!0,children:`${M0(process.cwd())}$ ${t}`}),e&&a.map((e,t)=>o&&t===Math.floor(a.length/2)?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)($,{dimColor:!0,children:[`... (`,i.length-r,` lines hidden) ...`]}),(0,X.jsx)($,{children:e.line})]},`trunc-${e.originalIndex}`):(0,X.jsx)($,{children:e.line},`line-${e.originalIndex}`))]})}const bWe=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];function xWe(){let e=P.platform(),t={};for(let[e,n]of Object.entries(process.env))n!==void 0&&(t[e]=n);return e===`win32`?{command:process.env.COMSPEC||`cmd.exe`,args:[],env:t}:{command:process.env.SHELL||`/bin/bash`,args:[],env:{...t,BASH_SILENCE_DEPRECATION_WARNING:`1`,PS1:``}}}var SWe=class{shell=null;queue=[];notify=null;isProcessing=!1;destroyed=!1;isWindows;signalHandlers=new Map;constructor(){this.isWindows=P.platform()===`win32`,this.startShell(),this.setupSignalForwarding()}setupSignalForwarding(){for(let e of bWe){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}=xWe();this.shell=ue(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 F6=null;function CWe(){return F6||=new SWe,F6}function wWe({state:e,setState:t,onCommandComplete:n,commandHistory:r,currentPrompt:i,availableHeight:a}){let{submittedCommand:o,runId:s}=e,c=(0,Z.useMemo)(()=>o?.trim()||``,[o]),l=(0,Z.useRef)(-1),u=(0,Z.useRef)(null);(0,Z.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:``})),TWe({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,X.jsxs)(Q,{flexDirection:`column`,children:[p.map((e,t)=>{let n=m+t;return(0,X.jsx)(P6,{output:e.output,command:e.command,truncate:v,maxLines:_},`history-${n}`)}),o&&(0,X.jsx)(P6,{output:e.output,command:c||o,truncate:v,maxLines:_},`submitted-${s}`)]})}async function TWe({command:e,setOutput:t,signal:n}){let{stream:r,exit:i}=await CWe().executeCommand(e),a=``;try{for await(let e of r){if(n.aborted)return;a+=PUe(e.data),n.aborted||t(a)}return n.aborted?void 0:(await i,a)}catch(e){if(n.aborted)return;throw e}}var EWe=Xe({parseShellHistory:()=>L6,shellHistory:()=>OWe,shellHistoryPath:()=>R6});function DWe(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 I6(e){return L6(DWe(c.readFileSync(e)).toString(`utf8`))}function L6(e){let t=/^: \d+:0;/;return e.trim().split(`
75334
+ `).map(e=>t.test(e)?e.split(`;`).slice(1).join(`;`):e)}function R6({extraPaths:e=[]}={}){if(process.env.HISTFILE)return process.env.HISTFILE;let t=ee.homedir(),n=new Set([O.join(t,`.bash_history`),O.join(t,`.zsh_history`),O.join(t,`.history`)]);for(let t of e)n.add(t);return(()=>{let e,t=0;for(let r of n)c.existsSync(r)&&c.statSync(r).size>t&&(t=c.statSync(r).size,e=r);return e})()}function OWe(e={}){if(process.platform===`win32`){let t=R6(e);if(t)return I6(t);let{stdout:n}=ae.spawnSync(`doskey`,[`/history`],{encoding:`utf8`});return n.trim().split(`\r
75335
+ `)}return I6(R6(e))}var kWe=W((()=>{}));const z6=1e3;function AWe(){let[e,t]=(0,Z.useState)({submittedCommand:null,runId:0,output:``,isRunning:!1}),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{c.current||(c.current=!0,Promise.resolve().then(()=>(kWe(),EWe)).then(e=>{let t=e.shellHistory??e.default;a((typeof t==`function`?t():[]).slice(-z6))}).catch(()=>{}))},[]);let l=(0,Z.useCallback)(e=>{let n=e.trim();n&&(a(e=>e.length>0&&e[e.length-1]===n?e:[...e,n].slice(-z6)),s(-1),t(e=>({submittedCommand:n,runId:e.runId+1,output:``,isRunning:!0})))},[]),u=(0,Z.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,Z.useCallback)(r=>(0,X.jsx)(wWe,{state:e,setState:t,onCommandComplete:u,commandHistory:n,currentPrompt:r.prompt,availableHeight:r.availableHeight}),[e,u,n]),navigateHistory:(0,Z.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`}}const jWe=[`no pull requests found`,`no open pull requests`];function MWe(){return new Promise((e,t)=>{se(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,state`],{timeout:1e4},(n,r,i)=>{if(n){let r=(i||n.message).toLowerCase();jWe.some(e=>r.includes(e))?e(null):t(n);return}try{let t=JSON.parse(r.trim());if(typeof t.number==`number`&&typeof t.url==`string`&&t.number>0){let n=`pending`;t.state===`MERGED`?n=`merged`:t.state===`CLOSED`?n=`closed`:t.isDraft?n=`draft`:t.reviewDecision===`APPROVED`?n=`approved`:t.reviewDecision===`CHANGES_REQUESTED`&&(n=`changes_requested`),e({number:t.number,url:t.url,reviewState:n});return}}catch{t(Error(`Malformed JSON from gh pr view`))}e(null)})})}const B6=6e4;function NWe(){let{data:e}=qQ({queryKey:[S3.PrInfo],queryFn:MWe,staleTime:B6,refetchInterval:B6,retry:!1,refetchOnMount:!0,refetchOnWindowFocus:!1});return e??null}function V6({href:e,children:t,color:n}){let r=mZ(e),i=hZ();return(0,X.jsx)($,{color:n??WNe,underline:!0,transform:e=>`${r}${e}${i}`,children:t})}V6.displayName=`Link`;const PWe={approved:`green`,pending:`yellow`,changes_requested:`red`,draft:`brightblack`,merged:`magenta`,closed:`brightblack`},H6=(0,Z.memo)(({hints:e,availableHeight:t})=>{let{agentMode:n,isWaitingForYoloConfirm:r}=H0(),i=NWe();if(t!==void 0&&t<1)return null;let a;if(e?.exitKey)a=(0,X.jsxs)($,{dimColor:!0,children:[`Press `,e.exitKey===`c`?`Ctrl+C`:`Ctrl+D`,` again to exit`]});else if(r)a=(0,X.jsxs)($,{dimColor:!0,children:[`Press `,(0,X.jsx)($,{color:`brightred`,children:`shift+tab`}),` again to enable YOLO mode (dangerous)`]});else switch(n){case xd.Normal:a=(0,X.jsx)($,{dimColor:!0,children:`? for shortcuts • shift+tab to cycle modes`});break;case xd.AcceptEdits:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightcyan`,children:`⏵⏵`}),` accept edits on (shift+tab to cycle)`]});break;case xd.PlanMode:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightcyan`,children:`⏸`}),` plan mode on (shift+tab to cycle)`]});break;case xd.Yolo:a=(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsx)($,{color:`brightred`,children:`⚠`}),` YOLO mode - all tools auto-accepted (shift+tab to cycle)`]});break;default:a=(0,X.jsx)($,{dimColor:!0,children:`? for shortcuts`})}return i?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsxs)(V6,{href:i.url,color:PWe[i.reviewState],children:[`PR #`,i.number]}),(0,X.jsx)($,{dimColor:!0,children:`•`}),a]}):a});H6.displayName=`AgentModeIndicator`;const U6=15e3,FWe=/^(node_modules|\.git|dist|build|out|coverage|\.vscode|\.idea|\.DS_Store)$/;let W6=null;function G6(e,t){let n=e.replace(/\\/g,`/`);return{path:n,name:O.posix.basename(n),isDirectory:t}}function IWe(e){return e.name.startsWith(`.`)||e.path.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`)}async function LWe(e){try{let t=await RWe(`git`,[`rev-parse`,`--show-toplevel`],e);if(!t)return null;let[n,r]=await Promise.all([K6(`git`,[`ls-files`],t),K6(`git`,[`ls-files`,`--others`,`--exclude-standard`],t)]),i=[],a=new Set;for(let e of[...n,...r]){if(!e)continue;let n=O.resolve(t,e);i.push(G6(n,!1));let r=O.posix.dirname(e);for(;r&&r!==`.`;){let e=O.resolve(t,r);if(a.has(e))break;a.add(e),i.push(G6(e,!0)),r=O.posix.dirname(r)}}return i}catch{return null}}function RWe(e,t,n){return new Promise((r,i)=>{let a=ue(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 K6(e,t,n){return new Promise(r=>{let i=[],a=ue(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:a.stdout}).on(`line`,e=>i.push(e.trim())),a.on(`close`,()=>r(i)),a.on(`error`,()=>r(i))})}async function zWe(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=ue(Ve,n,{cwd:e,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:i.stdout}).on(`line`,t=>{let n=fBe(t.trim());n&&r.push(G6(O.resolve(e,n),!1))}),i.on(`close`,()=>t(r)),i.on(`error`,()=>t(r))})}async function q6(e,t){let n=[],r=async(e,i)=>{if(!(i>12||n.length>=U6))try{let a=await m.readdir(e,{withFileTypes:!0}),o=[];for(let r of a){if(!t&&r.name.startsWith(`.`))continue;let i=O.join(e,r.name);r.isDirectory()?FWe.test(r.name)||(n.push(G6(i,!0)),o.push(i)):r.isFile()&&n.push(G6(i,!1))}await Promise.all(o.map(e=>r(e,i+1)))}catch{}};return await r(e,0),n}function BWe(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>=U6||s.has(e.path)||(s.add(e.path),!(!t&&IWe(e))&&c.push(e))},u=i&&a&&n.length===0&&r.length===0;return{docs:c,ready:(async()=>{if(u){let e=await LWe(o);if(e){for(let t of e)l(t);return}}if(i){let e=await zWe(o,{includeHidden:t,globs:n,ignoreGlobs:r,useGitignore:a});for(let t of e)l(t);let i=await q6(o,t);for(let e of i)e.isDirectory&&l(e)}else{let e=await q6(o,t);for(let t of e)l(t)}})()}}function VWe(e){let t=O.resolve(e.root);if(W6&&W6.key===t&&Date.now()-W6.at<6e4)return W6.index;let n=BWe(e);return W6={key:t,index:n,at:Date.now()},n}async function HWe(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=O.isAbsolute(e.path)?e.path:O.resolve(t,e.path),i=await m.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 UWe(e,t){let n=t.root,r=t.maxResults??100;if(!(await m.stat(n).catch(()=>null))?.isDirectory())return{paths:[],isDirectory:[]};let i=VWe(t);await i.ready;let a=e.trim();if(!a)return HWe(i.docs,n,r);let o=new _H(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 WWe(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)([]),a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null);return(0,Z.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 UWe(e,{root:process.cwd()});if(t.signal.aborted)return;n(r.paths.map(mBe)),i(r.isDirectory)}catch{}})()},100),()=>{o.current&&clearTimeout(o.current),a.current&&a.current.abort()}),[e]),{results:t,isDirectory:r}}const J6=(0,Z.memo)(({onAccept:e,onCancel:t,availableHeight:n})=>{let{prompt:r,bufferRef:i}=E6(),[a,o]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=i.current;if(!e){o(``);return}let t=k6(e.text,e.cursor)?.query??``;o(e=>e===t?e:t)},[i,r]);let s=(0,Z.useDeferredValue)(a),{results:c,isDirectory:l}=WWe(s),u=a!==s,d=c.map((e,t)=>l[t]?`${e}/`:e),f=(0,Z.useCallback)((t,n)=>{let r=i.current;if(!r)return e();let a=k6(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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(M6,{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,X.jsx)(Q,{marginTop:0,children:(0,X.jsx)($,{dimColor:!0,children:`Searching...`})})]})});J6.displayName=`FileMentionPicker`;const Y6=[[`! for terminal/bash mode`,`/ for commands`,`@ for file paths`],[`esc esc to clear input`,`shift + tab to cycle agent modes`,`${ZUe().toLowerCase()} for newline`],[`ctrl + z to undo`,`ctrl + v to paste images`]],X6=(0,Z.memo)(({availableHeight:e})=>e!==void 0&&e<3?null:(0,X.jsx)(Q,{flexDirection:`row`,columnGap:5,rowGap:1,flexWrap:`wrap`,children:(e!==void 0&&e<6?Y6.slice(0,1):e!==void 0&&e<9?Y6.slice(0,2):Y6).map((e,t)=>(0,X.jsx)(Q,{flexDirection:`column`,children:e.map(e=>(0,X.jsx)($,{dimColor:!0,children:e},e))},t))}));X6.displayName=`Help`;function GWe(){return{mode:B0.Prompt,render:({prompt:e,hints:t,availableHeight:n})=>(0,X.jsx)(H6,{hints:t,availableHeight:n})}}function KWe(){return{mode:B0.Help,render:({availableHeight:e})=>(0,X.jsx)(X6,{availableHeight:e})}}function qWe(e){return{mode:B0.Files,render:({prompt:t,availableHeight:n})=>(0,X.jsx)(J6,{onAccept:e,onCancel:e,availableHeight:n}),shouldPreventDefault:(e,t)=>t.upArrow||t.downArrow||t.escape||t.return||t.tab}}function JWe(e,t){let n=AWe(),r=yWe(t);return{handlers:(0,Z.useMemo)(()=>{let t={mode:B0.Bash,render:n.renderer,onSubmit:n.submitCommand},i={mode:B0.Command,render:r.renderer,onSubmit:r.executeCommand,shouldPreventDefault:r.shouldPreventDefault};return new Map([[B0.Prompt,GWe()],[B0.Help,KWe()],[B0.Bash,t],[B0.Command,i],[B0.Files,qWe(e)]])},[n,r,e]),getActivity:n.getActivity,bashNavigateHistory:n.navigateHistory}}const YWe={[B0.Prompt]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[B0.Help]:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},[B0.Bash]:{color:`brightgreen`,placeholder:vUe()?`Try "dir"`:`Try "ls -la"`,prefix:`!`},[B0.Command]:{color:`brightmagenta`,placeholder:`Try "/resume <chat title>"`,prefix:`❯`},[B0.Files]:{color:`brightcyan`,placeholder:`Try "@help.md"`,prefix:`@`}},XWe={"!":{mode:B0.Bash,preventDefault:!0,atStartOnly:!0},"?":{mode:B0.Help,preventDefault:!0,atStartOnly:!0},"@":{mode:B0.Files,preventDefault:!1,atStartOnly:!1}},Z6=(0,Z.memo)(({hints:e,composerRef:t})=>{let{prompt:n,setPrompt:r,mode:i,setMode:a,bufferRef:o,activity:s,setActivity:c,queuedMessages:l,nq:u,clearQueue:d,addAttachment:f,clearAttachments:p,ghostText:m,commandOverlay:h}=E6(),g=(0,Z.useCallback)(()=>{let e=l.filter(e=>!e.hidden);if(e.length===0)return;let t=e.map(e=>e.message).join(`
75336
+ `);o.current?.setText(t),d()},[l,o,d]),{updateInfo:_,autoUpdate:v}=mUe(),y=(0,Z.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),b=(0,Z.useCallback)(()=>{},[]),x=(0,Z.useRef)({text:``,timer:null}),S=(0,Z.useRef)(null);S.current||(S.current=new yq(`cli-repl`),S.current.load());let C=S.current,w=(0,Z.useRef)(``),T=(0,Z.useRef)(0),E=(0,Z.useRef)(null),D=(0,Z.useCallback)(e=>{if(!new Set([B0.Prompt,B0.Help]).has(i))return!1;let t=e.trim();if(!t.startsWith(`/`))return!0;let n=t.slice(1).split(/\s/)[0]||``;return!(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))},[i]);(0,Z.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.some(e=>!e.hidden),saveAndClear:()=>{let e=n.trimStart();e&&D(e)&&(C.append(e),C.resetNavigation()),o.current?.setText(``),b(),p()},clear:()=>{o.current?.setText(``),b(),p()},clearQueue:()=>d(),dequeueAllToComposer:()=>g()}));let{currentFile:k,selectionStartLine:A,selectionEndLine:j}=t3(),{sendMessage:M,segments:N,clearSegments:P,clearSegmentsOnly:ee,clearTempSegments:F,stop:te,addNotification:I,mcp:L,isDirectoryAllowed:R,addAllowedDirectory:z,refreshMcpTools:ne,loadConversation:re,agentStatus:ie,segmentsLength:ae,conversationId:oe,dequeuedOnStop:se,clearDequeuedOnStop:ce,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,totalCredits:fe,contextPercent:B,contextTokensUsed:pe,contextWindowMax:me}=d3(),{apiClient:he,authManager:ge}=o3(),{data:_e=[],refetch:ve}=_Ue(he),ye=WQ(),{cycleAgentMode:be,resetToNormal:V,isWaitingForYoloConfirm:xe}=H0(),Se=(0,Z.useContext)(G0),Ce=gUe(),{requestFullRedraw:we}=zMe(),{handlers:Ee,getActivity:De,bashNavigateHistory:Oe}=JWe(()=>a(B0.Prompt),(0,Z.useCallback)(()=>{o.current?.setText(``)},[o])),ke=Ee.get(i)||null,[Ae,je]=(0,Z.useState)([]),Me=(0,Z.useRef)([]),[Ne,Pe]=(0,Z.useState)(``),[Fe,Ie]=(0,Z.useState)(null),[Le,Re]=(0,Z.useState)(!1),[ze,Be]=(0,Z.useState)(!1),Ve=(0,Z.useMemo)(()=>({agentStatus:ie,segmentsLength:ae,isLoggedIn:Fe??!1}),[ie,ae,Fe]),H=(0,Z.useCallback)(async()=>{try{let e=await he.getConversationsList(hn.agentType,process.cwd());if(e?.result){let t=e.result.slice(0,25);je(t),Me.current=t}}catch{}},[he]);(0,Z.useEffect)(()=>{H()},[H]),(0,Z.useEffect)(()=>{he.getUserInfo().then(e=>Ie(!!e?.result?.email)).catch(()=>{Ie(ge.isAuthenticated())})},[he,ge]),(0,Z.useEffect)(()=>{se&&(o.current?.setText(se),ce())},[se,ce,o]);let He=Ne||_e[0]?.llmName||``;(0,Z.useEffect)(()=>{if(!Le){Be(!1);return}let e=setInterval(()=>Be(e=>!e),500);return()=>clearInterval(e)},[Le]),(0,Z.useEffect)(()=>{gWe({onExit:()=>{QZ(0)},onNewChat:()=>{P(),d(),o.current?.setText(``),we()},onClearChat:()=>{ee(),o.current?.setText(``),we()},onStop:()=>{te()},onModelChange:e=>{let t=_e.find(t=>t.llmName===e);t?(Pe(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=Me.current.find(t=>t.deploymentConversationId===e);if(t||=Me.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase())),t||(await H(),t=Me.current.find(t=>t.deploymentConversationId===e),t||=Me.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()))),!t)try{let n=(await he.searchConversations(e,hn.agentType))?.result??[];if(n.length>0&&(t=n.find(t=>t.deploymentConversationId===e),!t)){let r=e.toLowerCase();t=n.find(e=>(e.name||e.deploymentConversationId||`Untitled`).toLowerCase().includes(r))}}catch{}if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await re(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(ge.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 FJ(),r=await he.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 yUe(e);try{let e=await he.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await ge.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);he.setChatWebDomain(e)}I(`Authentication successful!`,`info`),Ie(!0),await H(),await ve();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await ge.loginWithApiKey(e);try{(await he.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),Ie(!0),await H(),await ve()):(await ge.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await ge.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(ge.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await ge.logout(),Ie(!1)},getUserInfo:async()=>{try{let e=await he.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=ge.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()=>_e.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>(await H(),Me.current.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))),searchChatTitles:async e=>{try{let t=await he.searchConversations(e,hn.agentType);if(t?.result)return t.result.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))}catch{}return[]},addNotification:I,mcp:L,isDirectoryAllowed:R,addAllowedDirectory:z,refreshMcpTools:ne,getAgentStatus:()=>ie,getTotalCredits:fe>0?()=>Promise.resolve(fe):void 0,getContextInfo:()=>({contextPercent:B,contextTokensUsed:pe,contextWindowMax:me}),loginAuth:{initiateDeviceCode:async e=>{let t=await FJ(),n=await he.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 he.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 ge.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);he.setChatWebDomain(e)}Ie(!0),await H(),await ve()},loginWithApiKey:async e=>{if(await ge.loginWithApiKey(e),!(await he.getUserInfo())?.result?.email)throw await ge.logout(),Error(`Invalid API key — authentication failed`);Ie(!0),await H(),await ve()},isEnvAuth:()=>ge.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:ge.isEnvAuth(),shouldHide:ge.isEnvAuth()}),getUpdateInfo:()=>_,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,getLastAssistantMessage:()=>{for(let e=N.length-1;e>=0;e--){let t=N[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=C3(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>N,getOrganizations:async()=>{try{let e=await he.listOrganizations();return!e?.success||!e.result?[]:e.result.map(e=>({id:e.organizationId,name:e.name,workspace:e.workspace}))}catch{return[]}},onOrgSwitch:async e=>{try{let t=await he.switchOrganization(e);return t&&(await H(),await ve(),ye.invalidateQueries({queryKey:[S3.UserInfo]})),t}catch{return!1}}})},[_e,N,P,ee,we,d,o,he,ve,te,I,L,R,z,ne,re,Ae,H,ie,oe,ge,_,le,ue,de,fe,B,pe,me,ye]);let Ue=(0,Z.useCallback)(async e=>{try{let t=await Te.stat(e),n=await Te.readFile(e),r=O.extname(e).toLowerCase(),i={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`}[r]??`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:O.resolve(e),fileName:O.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]),U=(0,Z.useCallback)(async()=>{if(await g2()){let e=await _2();if(e){let t=y2(b2(e));o.current?.insert(`@${t} `),await Ue(e);return}}let e=await cVe();if(!e)return;let t=x2(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ue(e);return}f2(e.trim())||o.current?.insert(e,{isPaste:!0})},[o,Ue]),We=(0,Z.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){U(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=x2(t.trim());if(n){o.current?.insert(n.mentionText);for(let e of n.persistedImagePaths)Ue(e);e.preventDefault();return}if(f2(t.trim())){e.preventDefault();return}(async()=>{if(await g2()){let e=await _2();if(e){let t=y2(b2(e));o.current?.insert(`@${t} `),await Ue(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){x.current.text+=e.input,x.current.timer&&clearTimeout(x.current.timer),x.current.timer=setTimeout(()=>{let e=x.current.text;x.current={text:``,timer:null};let t=x2(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ue(e);return}f2(e.trim())||o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===B0.Prompt&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.some(e=>!e.hidden)&&n.trim()===``){g(),e.preventDefault();return}if(ke?.shouldPreventDefault&&ke.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===B0.Prompt||i===B0.Help||i===B0.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(C.getEntries().length>0){C.isNavigating()||(w.current=n);let t=C.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!C.isNavigating()){e.preventDefault();return}let t=C.navigateDown();t?o.current?.setText(t.message):o.current?.setText(w.current),e.preventDefault();return}}if(i===B0.Bash&&Oe){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=Oe(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(xe){V(),e.preventDefault();return}i!==B0.Prompt&&(a(B0.Prompt),C.resetNavigation(),w.current=``,e.preventDefault());return}if(i===B0.Prompt&&e.key.shift&&e.key.tab){be(),e.preventDefault();return}let r=XWe[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==B0.Command&&e.preventDefault();return}},[i,a,ke,Oe,o,U,Ue,l,n,d,g,xe,V,be,C]);(0,Z.useEffect)(()=>{if(i===B0.Prompt)return;let e=n.trim();if(i===B0.Files){let e=o.current;e&&(k6(e.text,e.cursor)||a(B0.Prompt))}else if(i===B0.Command)if(e.length===0)a(B0.Prompt);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(B0.Prompt)}},[i,n,o,a]),(0,Z.useEffect)(()=>{if(i!==B0.Help)return;let e=setTimeout(()=>{a(B0.Prompt)},3e4);return()=>clearTimeout(e)},[i,a]);let Ge=(0,Z.useCallback)((e,t)=>{let n=T.current;T.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=ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission;e.length>0&&!l&&!u&&F();let d=k6(e,t.cursor);if(o.length===0&&n>0&&(i===B0.Command||i===B0.Bash||i===B0.Help)){a(B0.Prompt);return}if(d){i!==B0.Files&&a(B0.Files);return}if(i===B0.Files){d||a(B0.Prompt);return}i===B0.Help&&o.length>0&&a(B0.Prompt),E.current&&=(clearTimeout(E.current),null),!l&&i===B0.Command&&o.length>0?a(B0.Prompt):l&&i!==B0.Command&&(E.current=setTimeout(()=>{E.current=null,a(B0.Command)},80))},[i,r,a,F,ie]),Ke=(0,Z.useCallback)(async e=>{let t=e.trim(),n=x6.match(t,i);if(n&&await x6.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=cq.matchSkill(t);if(e){if(Fe===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=y(t);if(ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission){u(n),o.current?.setText(``),b();return}M({message:n,selectedModel:Ne||_e[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),b(),p();return}}if(ke?.onSubmit){ke.onSubmit(e),i===B0.Bash?(o.current?.setText(``),c(De())):i===B0.Command&&a(B0.Prompt),p();return}switch(i){case B0.Prompt:if(Fe===!1){let t=e.trimStart();t&&D(t)&&(C.append(t),C.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ie===Sd.Submitted||ie===Sd.Streaming||ie===Sd.ExecutingTool||ie===Sd.WaitingForToolPermission){let t=y(e.trimStart());u(t),D(t)&&(C.append(t),C.resetNavigation()),w.current=``,b(),o.current?.setText(``);return}let t=Ne||_e[0]?.llmName||void 0,n=y(e);D(n)&&(C.append(n),C.resetNavigation()),w.current=``,M({message:n,selectedModel:t}),b(),p();return;default:}},[i,ke,M,De,c,Ne,a,o,ie,u,I,p,Fe,y,b,C,_e]),{color:qe,placeholder:Je,prefix:Ye}=YWe[i],W=ae>0?``:Je,G=(0,Z.useMemo)(()=>_We(),[]),Xe=(i===B0.Bash?De():s)===`pending`||ie===Sd.WaitingForToolPermission,Ze=M0(process.cwd()),Qe=(0,Z.useMemo)(()=>(0,X.jsx)(Q,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,X.jsxs)(X.Fragment,{children:[h,(0,X.jsx)(Z.Activity,{mode:h?`hidden`:`visible`,children:(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(A6,{}),(0,X.jsxs)(Q,{flexDirection:`row`,alignItems:`flex-end`,children:[Se&&(0,X.jsxs)($,{color:`brightmagenta`,bold:!0,children:[`EXPANDED`,` `]}),Qe,Fe===!1&&(0,X.jsx)($,{dimColor:!0,children:` Not logged in`}),Fe===!1&&He&&(0,X.jsx)($,{dimColor:!0,children:` •`}),He&&(0,X.jsxs)($,{children:[` `,_e.find(e=>e.llmName===He)?.name||He]}),(Fe===!1||He)&&(0,X.jsx)($,{dimColor:!0,children:` •`}),(0,X.jsxs)($,{color:`brightyellow`,children:[` `,Ze]})]}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:qe,dimColor:ze,children:Ye}),(0,X.jsx)(t6,{ref:o,onChange:Ge,onKeyDown:We,onSubmit:Ke,placeholder:W,grammar:G,disabled:Xe,ghostText:m??void 0})]}),(0,X.jsxs)(Q,{flexDirection:`row`,justifyContent:`space-between`,gap:1,children:[(0,X.jsx)(Q,{flexGrow:1,children:Qe}),B!==null&&B>60&&(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:B>=80?`red`:`yellow`,children:`●`}),(0,X.jsxs)($,{color:B>=80?`red`:`yellow`,children:[Math.round(B),`%`]})]})]}),(0,X.jsxs)(Q,{justifyContent:`space-between`,children:[(0,X.jsx)(j6,{mode:i,prompt:n,handler:ke,onExitFilesMode:()=>a(B0.Prompt),onSubmitPrompt:Ke,hints:e,availableHeight:Ce,onLoadingChange:Re,commandContext:Ve}),(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[k&&A!==void 0&&j!==void 0?(0,X.jsxs)($,{dimColor:!0,children:[(0,X.jsxs)($,{color:`cyan`,children:[j-A+1,` lines selected`]}),` `,`in `,(0,X.jsx)($,{color:`cyan`,children:O.basename(k)})]}):k&&(0,X.jsxs)($,{dimColor:!0,children:[`in `,(0,X.jsx)($,{color:`cyan`,children:O.basename(k)})]}),e?.escClear&&(0,X.jsx)($,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&_&&(0,X.jsx)($,{dimColor:!0,children:`·`}),_&&(0,X.jsxs)($,{wrap:`truncate-middle`,dimColor:!0,children:[`Update available (${_.latestVersion})`,!_.isEphemeral&&(_.installationType===`native`&&v?` · Restart to auto-update`:` · Run: ${RZ(_)}`)]})]})]})]})})]})});Z6.displayName=`ComposerInner`;const Q6=(0,Z.memo)(({hints:e,composerRef:t})=>(0,X.jsx)(D6,{children:(0,X.jsx)(Z6,{hints:e,composerRef:t})}));Q6.displayName=`Composer`;var $6=class extends Z.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){Dl(e,{componentStack:t.componentStack??void 0}),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,X.jsxs)(Q,{flexDirection:`column`,padding:1,children:[(0,X.jsx)($,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,X.jsxs)(Q,{marginTop:1,flexDirection:`column`,children:[(0,X.jsx)($,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,X.jsx)($,{color:`brightblack`,children:n.componentStack})]})]}):i}};const e8=(0,Z.memo)(({duration:e,credits:t,conversationId:n})=>(0,X.jsxs)(Q,{flexDirection:`column`,paddingY:1,children:[(0,X.jsx)($,{color:QQ,children:`
75336
75337
  ▞▀▖▌ ▞▀▖▜▘ ▞▀▖▌ ▜▘
75337
75338
  ▙▄▌▛▀▖▝▀▖▞▀▖▌ ▌▞▀▘ ▙▄▌▐ ▌ ▌ ▐
75338
75339
  ▌ ▌▌ ▌▞▀▌▌ ▖▌ ▌▝▀▖▗▖▌ ▌▐ ▌ ▖▌ ▐
75339
75340
  ▘ ▘▀▀ ▝▀▘▝▀ ▝▀▘▀▀ ▝▘▘ ▘▀▘ ▝▀ ▀▀▘▀▘
75340
- `}),(0,X.jsx)(Q,{height:1}),(0,X.jsx)($,{color:e$,children:`https://desktop.abacus.ai`}),(0,X.jsx)(Q,{height:1}),(0,X.jsxs)($,{dimColor:!0,children:[`Spent `,e,` in the CLI`]}),t>0&&(0,X.jsxs)($,{dimColor:!0,children:[`Total credits used: `,Math.floor(t*100)/100]}),n&&(0,X.jsxs)($,{dimColor:!0,children:[`abacusai --resume `,n]})]}));$6.displayName=`ExitMessage`;const e8=(e=0)=>t=>`\u001B[${t+e}m`,t8=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,n8=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,r8={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r8.modifier);const ZWe=Object.keys(r8.color),QWe=Object.keys(r8.bgColor);[...ZWe,...QWe];function $We(){let e=new Map;for(let[t,n]of Object.entries(r8)){for(let[t,r]of Object.entries(n))r8[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=r8[t],e.set(r[0],r[1]);Object.defineProperty(r8,t,{value:n,enumerable:!1})}return Object.defineProperty(r8,`codes`,{value:e,enumerable:!1}),r8.color.close=`\x1B[39m`,r8.bgColor.close=`\x1B[49m`,r8.color.ansi=e8(),r8.color.ansi256=t8(),r8.color.ansi16m=n8(),r8.bgColor.ansi=e8(10),r8.bgColor.ansi256=t8(10),r8.bgColor.ansi16m=n8(10),Object.defineProperties(r8,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>r8.rgbToAnsi256(...r8.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>r8.ansi256ToAnsi(r8.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>r8.ansi256ToAnsi(r8.hexToAnsi256(e)),enumerable:!1}}),r8}const i8=$We();function a8(e,t=globalThis.Deno?globalThis.Deno.args:H.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:o8}=H;let s8;a8(`no-color`)||a8(`no-colors`)||a8(`color=false`)||a8(`color=never`)?s8=0:(a8(`color`)||a8(`colors`)||a8(`color=true`)||a8(`color=always`))&&(s8=1);function eGe(){if(`FORCE_COLOR`in o8)return o8.FORCE_COLOR===`true`?1:o8.FORCE_COLOR===`false`?0:o8.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(o8.FORCE_COLOR,10),3)}function tGe(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function nGe(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=eGe();r!==void 0&&(s8=r);let i=n?s8:r;if(i===0)return 0;if(n){if(a8(`color=16m`)||a8(`color=full`)||a8(`color=truecolor`))return 3;if(a8(`color=256`))return 2}if(`TF_BUILD`in o8&&`AGENT_NAME`in o8)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(o8.TERM===`dumb`)return a;if(H.platform===`win32`){let e=ee.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in o8)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in o8)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in o8)||o8.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in o8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o8.TEAMCITY_VERSION)?1:0;if(o8.COLORTERM===`truecolor`||o8.TERM===`xterm-kitty`||o8.TERM===`xterm-ghostty`||o8.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in o8){let e=Number.parseInt((o8.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(o8.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(o8.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o8.TERM)||`COLORTERM`in o8?1:a}function c8(e,t={}){return tGe(nGe(e,{streamIsTTY:e&&e.isTTY,...t}))}const rGe={stdout:c8({isTTY:U.isatty(1)}),stderr:c8({isTTY:U.isatty(2)})};function iGe(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function aGe(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
75341
+ `}),(0,X.jsx)(Q,{height:1}),(0,X.jsx)($,{color:e$,children:`https://desktop.abacus.ai`}),(0,X.jsx)(Q,{height:1}),(0,X.jsxs)($,{dimColor:!0,children:[`Spent `,e,` in the CLI`]}),t>0&&(0,X.jsxs)($,{dimColor:!0,children:[`Total credits used: `,Math.floor(t*100)/100]}),n&&(0,X.jsxs)($,{dimColor:!0,children:[`abacusai --resume `,n]})]}));e8.displayName=`ExitMessage`;const t8=(e=0)=>t=>`\u001B[${t+e}m`,n8=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r8=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,i8={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(i8.modifier);const ZWe=Object.keys(i8.color),QWe=Object.keys(i8.bgColor);[...ZWe,...QWe];function $We(){let e=new Map;for(let[t,n]of Object.entries(i8)){for(let[t,r]of Object.entries(n))i8[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=i8[t],e.set(r[0],r[1]);Object.defineProperty(i8,t,{value:n,enumerable:!1})}return Object.defineProperty(i8,`codes`,{value:e,enumerable:!1}),i8.color.close=`\x1B[39m`,i8.bgColor.close=`\x1B[49m`,i8.color.ansi=t8(),i8.color.ansi256=n8(),i8.color.ansi16m=r8(),i8.bgColor.ansi=t8(10),i8.bgColor.ansi256=n8(10),i8.bgColor.ansi16m=r8(10),Object.defineProperties(i8,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>i8.rgbToAnsi256(...i8.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>i8.ansi256ToAnsi(i8.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>i8.ansi256ToAnsi(i8.hexToAnsi256(e)),enumerable:!1}}),i8}const a8=$We();function o8(e,t=globalThis.Deno?globalThis.Deno.args:H.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:s8}=H;let c8;o8(`no-color`)||o8(`no-colors`)||o8(`color=false`)||o8(`color=never`)?c8=0:(o8(`color`)||o8(`colors`)||o8(`color=true`)||o8(`color=always`))&&(c8=1);function eGe(){if(`FORCE_COLOR`in s8)return s8.FORCE_COLOR===`true`?1:s8.FORCE_COLOR===`false`?0:s8.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(s8.FORCE_COLOR,10),3)}function tGe(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function nGe(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=eGe();r!==void 0&&(c8=r);let i=n?c8:r;if(i===0)return 0;if(n){if(o8(`color=16m`)||o8(`color=full`)||o8(`color=truecolor`))return 3;if(o8(`color=256`))return 2}if(`TF_BUILD`in s8&&`AGENT_NAME`in s8)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(s8.TERM===`dumb`)return a;if(H.platform===`win32`){let e=ee.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in s8)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in s8)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in s8)||s8.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in s8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s8.TEAMCITY_VERSION)?1:0;if(s8.COLORTERM===`truecolor`||s8.TERM===`xterm-kitty`||s8.TERM===`xterm-ghostty`||s8.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in s8){let e=Number.parseInt((s8.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(s8.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(s8.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s8.TERM)||`COLORTERM`in s8?1:a}function l8(e,t={}){return tGe(nGe(e,{streamIsTTY:e&&e.isTTY,...t}))}const rGe={stdout:l8({isTTY:U.isatty(1)}),stderr:l8({isTTY:U.isatty(2)})};function iGe(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function aGe(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
75341
75342
  `:`
75342
75343
  `)+n,i=r+1,r=e.indexOf(`
75343
- `,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:l8,stderr:u8}=rGe,d8=Symbol(`GENERATOR`),f8=Symbol(`STYLER`),p8=Symbol(`IS_EMPTY`),m8=[`ansi`,`ansi`,`ansi256`,`ansi16m`],h8=Object.create(null),oGe=(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=l8?l8.level:0;e.level=t.level===void 0?n:t.level},sGe=e=>{let t=(...e)=>e.join(` `);return oGe(t,e),Object.setPrototypeOf(t,g8.prototype),t};function g8(e){return sGe(e)}Object.setPrototypeOf(g8.prototype,Function.prototype);for(let[e,t]of Object.entries(i8))h8[e]={get(){let n=y8(this,v8(t.open,t.close,this[f8]),this[p8]);return Object.defineProperty(this,e,{value:n}),n}};h8.visible={get(){let e=y8(this,this[f8],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const _8=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?i8[n].ansi16m(...r):t===`ansi256`?i8[n].ansi256(i8.rgbToAnsi256(...r)):i8[n].ansi(i8.rgbToAnsi(...r)):e===`hex`?_8(`rgb`,t,n,...i8.hexToRgb(...r)):i8[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){h8[e]={get(){let{level:t}=this;return function(...n){let r=v8(_8(e,m8[t],`color`,...n),i8.color.close,this[f8]);return y8(this,r,this[p8])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);h8[t]={get(){let{level:t}=this;return function(...n){let r=v8(_8(e,m8[t],`bgColor`,...n),i8.bgColor.close,this[f8]);return y8(this,r,this[p8])}}}}const cGe=Object.defineProperties(()=>{},{...h8,level:{enumerable:!0,get(){return this[d8].level},set(e){this[d8].level=e}}}),v8=(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}},y8=(e,t,n)=>{let r=(...e)=>lGe(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,cGe),r[d8]=e,r[f8]=t,r[p8]=n,r},lGe=(e,t)=>{if(e.level<=0||!t)return e[p8]?``:t;let n=e[f8];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=iGe(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
75344
- `);return a!==-1&&(t=aGe(t,i,r,a)),r+t+i};Object.defineProperties(g8.prototype,h8);const b8=g8();g8({level:u8?u8.level:0});var uGe=G(((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]=ee(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=R(t)),e(t)==`object`&&(L(t.r)&&L(t.g)&&L(t.b)?(n=a(t.r,t.g,t.b),u=!0,d=String(t.r).substr(-1)===`%`?`prgb`:`rgb`):L(t.h)&&L(t.s)&&L(t.v)?(i=ee(t.s),o=ee(t.v),n=l(t.h,i,o),u=!0,d=`hsv`):L(t.h)&&L(t.s)&&L(t.l)&&(i=ee(t.s),c=ee(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(F(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(F(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=z(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 ee(e){return e<=1&&(e=e*100+`%`),e}function F(e){return Math.round(parseFloat(e)*255).toString(16)}function te(e){return j(e)/255}var I=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 L(e){return!!I.CSS_UNIT.exec(e)}function R(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=I.rgb.exec(e))?{r:i[1],g:i[2],b:i[3]}:(i=I.rgba.exec(e))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=I.hsl.exec(e))?{h:i[1],s:i[2],l:i[3]}:(i=I.hsla.exec(e))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=I.hsv.exec(e))?{h:i[1],s:i[2],v:i[3]}:(i=I.hsva.exec(e))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=I.hex8.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),a:te(i[4]),format:r?`name`:`hex8`}:(i=I.hex6.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),format:r?`name`:`hex`}:(i=I.hex4.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),a:te(i[4]+``+i[4]),format:r?`name`:`hex8`}:(i=I.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 z(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}))})),dGe=G(((e,t)=>{let n=uGe(),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)}})),fGe=Xe({atlas:()=>O8,cristal:()=>k8,default:()=>S8,fruit:()=>F8,instagram:()=>I8,mind:()=>j8,morning:()=>M8,multiline:()=>w8,passion:()=>P8,pastel:()=>B8,rainbow:()=>z8,retro:()=>L8,summer:()=>R8,teen:()=>A8,vice:()=>N8}),x8=Qe(dGe(),1);const S8=(...e)=>{let t,n;if(e.length===0)throw Error(`Missing gradient colors`);if(Array.isArray(e[0]))t=(0,x8.default)(e[0]),n=T8(e[1]);else{if(e.length===1)throw Error(`Expected an array of colors, received ${JSON.stringify(e[0])}`);t=(0,x8.default)(...e)}let r=(e,r)=>pGe(e?e.toString():``,t,r??n);return r.multiline=(e,r)=>w8(e?e.toString():``,t,r??n),r},C8=(e,t,n)=>t.interpolation?.toLowerCase()===`hsv`?e.hsv(n,t.hsvSpin?.toLowerCase()||!1):e.rgb(n);function pGe(e,t,n){let r=C8(t,T8(n),Math.max(e.replace(/\s/g,``).length,t.stops.length)),i=``;for(let t of e)i+=t.match(/\s/g)?t:b8.hex(r.shift()?.toHex()||`#000`)(t);return i}function w8(e,t,n){let r=T8(n),i=e.split(`
75345
- `),a=C8(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+=b8.hex(t.shift()?.toHex()||`#000`)(r);o.push(n)}return o.join(`
75346
- `)}function T8(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 E8={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 D8(e){let t=t=>S8(...e.colors)(t,e.options);return t.multiline=(t=``)=>S8(...e.colors).multiline(t,e.options),t}const O8=D8(E8.atlas),k8=D8(E8.cristal),A8=D8(E8.teen),j8=D8(E8.mind),M8=D8(E8.morning),N8=D8(E8.vice),P8=D8(E8.passion),F8=D8(E8.fruit),I8=D8(E8.instagram),L8=D8(E8.retro),R8=D8(E8.summer),z8=D8(E8.rainbow),B8=D8(E8.pastel);S8.atlas=O8,S8.cristal=k8,S8.teen=A8,S8.mind=j8,S8.morning=M8,S8.vice=N8,S8.passion=P8,S8.fruit=F8,S8.instagram=I8,S8.retro=L8,S8.summer=R8,S8.rainbow=z8,S8.pastel=B8;const V8=(0,Z.memo)(e=>{let t=(0,Z.useMemo)(()=>e.name?fGe[e.name]:S8(...e.colors),[e.name,e.colors]);return(0,X.jsx)($,{transform:e=>t.multiline(w3(e)),children:e.children})});V8.displayName=`Gradient`;const H8=(0,Z.memo)(()=>{let{width:e}=b3(),{apiClient:t}=o3(),{data:n}=qQ({queryKey:[S3.UserInfo],queryFn:async()=>(await t.getUserInfo())?.result?.organization?.name??null,staleTime:300*1e3,retry:1}),r=(0,Z.useMemo)(()=>[JQ(GNe),JQ(KNe),JQ(qNe)],[]),i=n?`v${DZ.default.version} · ${n}`:`v${DZ.default.version}`;return e<=50?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,flexWrap:`wrap`,children:[(0,X.jsx)(V8,{colors:r,children:(0,X.jsx)($,{children:`Abacus.AI`})}),(0,X.jsx)($,{color:XQ,children:i})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(V8,{colors:r,children:(0,X.jsx)($,{children:` ▗▄▖ ▗▄▄▖ ▗▄▖ ▗▄▄▖▗▖ ▗▖ ▗▄▄▖ ▗▄▖ ▗▄▄▄▖ ▗▄▄▖▗▖ ▗▄▄▄▖
75344
+ `,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:u8,stderr:d8}=rGe,f8=Symbol(`GENERATOR`),p8=Symbol(`STYLER`),m8=Symbol(`IS_EMPTY`),h8=[`ansi`,`ansi`,`ansi256`,`ansi16m`],g8=Object.create(null),oGe=(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=u8?u8.level:0;e.level=t.level===void 0?n:t.level},sGe=e=>{let t=(...e)=>e.join(` `);return oGe(t,e),Object.setPrototypeOf(t,_8.prototype),t};function _8(e){return sGe(e)}Object.setPrototypeOf(_8.prototype,Function.prototype);for(let[e,t]of Object.entries(a8))g8[e]={get(){let n=b8(this,y8(t.open,t.close,this[p8]),this[m8]);return Object.defineProperty(this,e,{value:n}),n}};g8.visible={get(){let e=b8(this,this[p8],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const v8=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?a8[n].ansi16m(...r):t===`ansi256`?a8[n].ansi256(a8.rgbToAnsi256(...r)):a8[n].ansi(a8.rgbToAnsi(...r)):e===`hex`?v8(`rgb`,t,n,...a8.hexToRgb(...r)):a8[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){g8[e]={get(){let{level:t}=this;return function(...n){let r=y8(v8(e,h8[t],`color`,...n),a8.color.close,this[p8]);return b8(this,r,this[m8])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);g8[t]={get(){let{level:t}=this;return function(...n){let r=y8(v8(e,h8[t],`bgColor`,...n),a8.bgColor.close,this[p8]);return b8(this,r,this[m8])}}}}const cGe=Object.defineProperties(()=>{},{...g8,level:{enumerable:!0,get(){return this[f8].level},set(e){this[f8].level=e}}}),y8=(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}},b8=(e,t,n)=>{let r=(...e)=>lGe(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,cGe),r[f8]=e,r[p8]=t,r[m8]=n,r},lGe=(e,t)=>{if(e.level<=0||!t)return e[m8]?``:t;let n=e[p8];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=iGe(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
75345
+ `);return a!==-1&&(t=aGe(t,i,r,a)),r+t+i};Object.defineProperties(_8.prototype,g8);const x8=_8();_8({level:d8?d8.level:0});var uGe=G(((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]=ee(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=R(t)),e(t)==`object`&&(L(t.r)&&L(t.g)&&L(t.b)?(n=a(t.r,t.g,t.b),u=!0,d=String(t.r).substr(-1)===`%`?`prgb`:`rgb`):L(t.h)&&L(t.s)&&L(t.v)?(i=ee(t.s),o=ee(t.v),n=l(t.h,i,o),u=!0,d=`hsv`):L(t.h)&&L(t.s)&&L(t.l)&&(i=ee(t.s),c=ee(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(F(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(F(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=z(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 ee(e){return e<=1&&(e=e*100+`%`),e}function F(e){return Math.round(parseFloat(e)*255).toString(16)}function te(e){return j(e)/255}var I=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 L(e){return!!I.CSS_UNIT.exec(e)}function R(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=I.rgb.exec(e))?{r:i[1],g:i[2],b:i[3]}:(i=I.rgba.exec(e))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=I.hsl.exec(e))?{h:i[1],s:i[2],l:i[3]}:(i=I.hsla.exec(e))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=I.hsv.exec(e))?{h:i[1],s:i[2],v:i[3]}:(i=I.hsva.exec(e))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=I.hex8.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),a:te(i[4]),format:r?`name`:`hex8`}:(i=I.hex6.exec(e))?{r:j(i[1]),g:j(i[2]),b:j(i[3]),format:r?`name`:`hex`}:(i=I.hex4.exec(e))?{r:j(i[1]+``+i[1]),g:j(i[2]+``+i[2]),b:j(i[3]+``+i[3]),a:te(i[4]+``+i[4]),format:r?`name`:`hex8`}:(i=I.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 z(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}))})),dGe=G(((e,t)=>{let n=uGe(),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)}})),fGe=Xe({atlas:()=>k8,cristal:()=>A8,default:()=>C8,fruit:()=>I8,instagram:()=>L8,mind:()=>M8,morning:()=>N8,multiline:()=>T8,passion:()=>F8,pastel:()=>V8,rainbow:()=>B8,retro:()=>R8,summer:()=>z8,teen:()=>j8,vice:()=>P8}),S8=Qe(dGe(),1);const C8=(...e)=>{let t,n;if(e.length===0)throw Error(`Missing gradient colors`);if(Array.isArray(e[0]))t=(0,S8.default)(e[0]),n=E8(e[1]);else{if(e.length===1)throw Error(`Expected an array of colors, received ${JSON.stringify(e[0])}`);t=(0,S8.default)(...e)}let r=(e,r)=>pGe(e?e.toString():``,t,r??n);return r.multiline=(e,r)=>T8(e?e.toString():``,t,r??n),r},w8=(e,t,n)=>t.interpolation?.toLowerCase()===`hsv`?e.hsv(n,t.hsvSpin?.toLowerCase()||!1):e.rgb(n);function pGe(e,t,n){let r=w8(t,E8(n),Math.max(e.replace(/\s/g,``).length,t.stops.length)),i=``;for(let t of e)i+=t.match(/\s/g)?t:x8.hex(r.shift()?.toHex()||`#000`)(t);return i}function T8(e,t,n){let r=E8(n),i=e.split(`
75346
+ `),a=w8(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+=x8.hex(t.shift()?.toHex()||`#000`)(r);o.push(n)}return o.join(`
75347
+ `)}function E8(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 D8={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 O8(e){let t=t=>C8(...e.colors)(t,e.options);return t.multiline=(t=``)=>C8(...e.colors).multiline(t,e.options),t}const k8=O8(D8.atlas),A8=O8(D8.cristal),j8=O8(D8.teen),M8=O8(D8.mind),N8=O8(D8.morning),P8=O8(D8.vice),F8=O8(D8.passion),I8=O8(D8.fruit),L8=O8(D8.instagram),R8=O8(D8.retro),z8=O8(D8.summer),B8=O8(D8.rainbow),V8=O8(D8.pastel);C8.atlas=k8,C8.cristal=A8,C8.teen=j8,C8.mind=M8,C8.morning=N8,C8.vice=P8,C8.passion=F8,C8.fruit=I8,C8.instagram=L8,C8.retro=R8,C8.summer=z8,C8.rainbow=B8,C8.pastel=V8;const H8=(0,Z.memo)(e=>{let t=(0,Z.useMemo)(()=>e.name?fGe[e.name]:C8(...e.colors),[e.name,e.colors]);return(0,X.jsx)($,{transform:e=>t.multiline(w3(e)),children:e.children})});H8.displayName=`Gradient`;const U8=(0,Z.memo)(()=>{let{width:e}=b3(),{apiClient:t}=o3(),{data:n}=qQ({queryKey:[S3.UserInfo],queryFn:async()=>(await t.getUserInfo())?.result?.organization?.name??null,staleTime:300*1e3,retry:1}),r=(0,Z.useMemo)(()=>[JQ(GNe),JQ(KNe),JQ(qNe)],[]),i=n?`v${DZ.default.version} · ${n}`:`v${DZ.default.version}`;return e<=50?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,flexWrap:`wrap`,children:[(0,X.jsx)(H8,{colors:r,children:(0,X.jsx)($,{children:`Abacus.AI`})}),(0,X.jsx)($,{color:XQ,children:i})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(H8,{colors:r,children:(0,X.jsx)($,{children:` ▗▄▖ ▗▄▄▖ ▗▄▖ ▗▄▄▖▗▖ ▗▖ ▗▄▄▖ ▗▄▖ ▗▄▄▄▖ ▗▄▄▖▗▖ ▗▄▄▄▖
75347
75348
  ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ ▐▌▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
75348
75349
  ▐▛▀▜▌▐▛▀▚▖▐▛▀▜▌▐▌ ▐▌ ▐▌ ▝▀▚▖ ▐▛▀▜▌ █ ▐▌ ▐▌ █
75349
- ▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▗▖▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `})}),(0,X.jsx)($,{color:XQ,children:i})]})});H8.displayName=`Header`;function U8(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var W8=U8();function G8(e){W8=e}var K8={exec:()=>null};function q8(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(J8.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var mGe=(()=>{try{return!0}catch{return!1}})(),J8={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)}}>`)},hGe=/^(?:[ \t]*(?:\n|$))+/,gGe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_Ge=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Y8=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vGe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,X8=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Z8=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Q8=q8(Z8).replace(/bull/g,X8).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(),yGe=q8(Z8).replace(/bull/g,X8).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(),$8=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,bGe=/^[^\n]+/,e5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xGe=q8(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,e5).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),SGe=q8(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X8).getRegex(),t5=`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`,n5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CGe=q8(`^ {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`,n5).replace(`tag`,t5).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),r5=q8($8).replace(`hr`,Y8).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`,t5).getRegex(),i5={blockquote:q8(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,r5).getRegex(),code:gGe,def:xGe,fences:_Ge,heading:vGe,hr:Y8,html:CGe,lheading:Q8,list:SGe,newline:hGe,paragraph:r5,table:K8,text:bGe},a5=q8(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Y8).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`,t5).getRegex(),wGe={...i5,lheading:yGe,table:a5,paragraph:q8($8).replace(`hr`,Y8).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,a5).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`,t5).getRegex()},TGe={...i5,html:q8(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,n5).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:K8,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q8($8).replace(`hr`,Y8).replace(`heading`,` *#{1,6} *[^
75350
- ]`).replace(`lheading`,Q8).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},EGe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,DGe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,o5=/^( {2,}|\\)\n(?!\s*$)/,OGe=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,s5=/[\p{P}\p{S}]/u,c5=/[\s\p{P}\p{S}]/u,l5=/[^\s\p{P}\p{S}]/u,kGe=q8(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,c5).getRegex(),u5=/(?!~)[\p{P}\p{S}]/u,AGe=/(?!~)[\s\p{P}\p{S}]/u,jGe=/(?:[^\s\p{P}\p{S}]|~)/u,d5=/(?![*_])[\p{P}\p{S}]/u,MGe=/(?![*_])[\s\p{P}\p{S}]/u,NGe=/(?:[^\s\p{P}\p{S}]|[*_])/u,PGe=q8(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,mGe?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),f5=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,FGe=q8(f5,`u`).replace(/punct/g,s5).getRegex(),IGe=q8(f5,`u`).replace(/punct/g,u5).getRegex(),p5=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,LGe=q8(p5,`gu`).replace(/notPunctSpace/g,l5).replace(/punctSpace/g,c5).replace(/punct/g,s5).getRegex(),RGe=q8(p5,`gu`).replace(/notPunctSpace/g,jGe).replace(/punctSpace/g,AGe).replace(/punct/g,u5).getRegex(),zGe=q8(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,l5).replace(/punctSpace/g,c5).replace(/punct/g,s5).getRegex(),BGe=q8(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,d5).getRegex(),VGe=q8(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,NGe).replace(/punctSpace/g,MGe).replace(/punct/g,d5).getRegex(),HGe=q8(/\\(punct)/,`gu`).replace(/punct/g,s5).getRegex(),UGe=q8(/^<(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(),WGe=q8(n5).replace(`(?:-->|$)`,`-->`).getRegex(),GGe=q8(`^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`,WGe).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),m5=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,KGe=q8(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,m5).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),h5=q8(/^!?\[(label)\]\[(ref)\]/).replace(`label`,m5).replace(`ref`,e5).getRegex(),g5=q8(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,e5).getRegex(),qGe=q8(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,h5).replace(`nolink`,g5).getRegex(),_5=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,v5={_backpedal:K8,anyPunctuation:HGe,autolink:UGe,blockSkip:PGe,br:o5,code:DGe,del:K8,delLDelim:K8,delRDelim:K8,emStrongLDelim:FGe,emStrongRDelimAst:LGe,emStrongRDelimUnd:zGe,escape:EGe,link:KGe,nolink:g5,punctuation:kGe,reflink:h5,reflinkSearch:qGe,tag:GGe,text:OGe,url:K8},JGe={...v5,link:q8(/^!?\[(label)\]\((.*?)\)/).replace(`label`,m5).getRegex(),reflink:q8(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,m5).getRegex()},y5={...v5,emStrongRDelimAst:RGe,emStrongLDelim:IGe,delLDelim:BGe,delRDelim:VGe,url:q8(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,_5).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:q8(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,_5).getRegex()},YGe={...y5,br:q8(o5).replace(`{2,}`,`*`).getRegex(),text:q8(y5.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},b5={normal:i5,gfm:wGe,pedantic:TGe},x5={normal:v5,gfm:y5,breaks:YGe,pedantic:JGe},XGe={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},S5=e=>XGe[e];function C5(e,t){if(t){if(J8.escapeTest.test(e))return e.replace(J8.escapeReplace,S5)}else if(J8.escapeTestNoEncode.test(e))return e.replace(J8.escapeReplaceNoEncode,S5);return e}function w5(e){try{e=encodeURI(e).replace(J8.percentDecode,`%`)}catch{return null}return e}function T5(e,t){let n=e.replace(J8.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(J8.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(J8.slashPipe,`|`);return n}function E5(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 ZGe(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 QGe(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 D5(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 $Ge(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
75350
+ ▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▗▖▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `})}),(0,X.jsx)($,{color:XQ,children:i})]})});U8.displayName=`Header`;function W8(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var G8=W8();function K8(e){G8=e}var q8={exec:()=>null};function J8(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(Y8.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var mGe=(()=>{try{return!0}catch{return!1}})(),Y8={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)}}>`)},hGe=/^(?:[ \t]*(?:\n|$))+/,gGe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_Ge=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,X8=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vGe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Z8=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Q8=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$8=J8(Q8).replace(/bull/g,Z8).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(),yGe=J8(Q8).replace(/bull/g,Z8).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(),e5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,bGe=/^[^\n]+/,t5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xGe=J8(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,t5).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),SGe=J8(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Z8).getRegex(),n5=`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`,r5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,CGe=J8(`^ {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`,r5).replace(`tag`,n5).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),i5=J8(e5).replace(`hr`,X8).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`,n5).getRegex(),a5={blockquote:J8(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,i5).getRegex(),code:gGe,def:xGe,fences:_Ge,heading:vGe,hr:X8,html:CGe,lheading:$8,list:SGe,newline:hGe,paragraph:i5,table:q8,text:bGe},o5=J8(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,X8).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`,n5).getRegex(),wGe={...a5,lheading:yGe,table:o5,paragraph:J8(e5).replace(`hr`,X8).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,o5).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`,n5).getRegex()},TGe={...a5,html:J8(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,r5).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:q8,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J8(e5).replace(`hr`,X8).replace(`heading`,` *#{1,6} *[^
75351
+ ]`).replace(`lheading`,$8).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},EGe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,DGe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,s5=/^( {2,}|\\)\n(?!\s*$)/,OGe=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,c5=/[\p{P}\p{S}]/u,l5=/[\s\p{P}\p{S}]/u,u5=/[^\s\p{P}\p{S}]/u,kGe=J8(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,l5).getRegex(),d5=/(?!~)[\p{P}\p{S}]/u,AGe=/(?!~)[\s\p{P}\p{S}]/u,jGe=/(?:[^\s\p{P}\p{S}]|~)/u,f5=/(?![*_])[\p{P}\p{S}]/u,MGe=/(?![*_])[\s\p{P}\p{S}]/u,NGe=/(?:[^\s\p{P}\p{S}]|[*_])/u,PGe=J8(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,mGe?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),p5=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,FGe=J8(p5,`u`).replace(/punct/g,c5).getRegex(),IGe=J8(p5,`u`).replace(/punct/g,d5).getRegex(),m5=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,LGe=J8(m5,`gu`).replace(/notPunctSpace/g,u5).replace(/punctSpace/g,l5).replace(/punct/g,c5).getRegex(),RGe=J8(m5,`gu`).replace(/notPunctSpace/g,jGe).replace(/punctSpace/g,AGe).replace(/punct/g,d5).getRegex(),zGe=J8(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,u5).replace(/punctSpace/g,l5).replace(/punct/g,c5).getRegex(),BGe=J8(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,f5).getRegex(),VGe=J8(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,NGe).replace(/punctSpace/g,MGe).replace(/punct/g,f5).getRegex(),HGe=J8(/\\(punct)/,`gu`).replace(/punct/g,c5).getRegex(),UGe=J8(/^<(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(),WGe=J8(r5).replace(`(?:-->|$)`,`-->`).getRegex(),GGe=J8(`^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`,WGe).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),h5=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,KGe=J8(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,h5).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),g5=J8(/^!?\[(label)\]\[(ref)\]/).replace(`label`,h5).replace(`ref`,t5).getRegex(),_5=J8(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,t5).getRegex(),qGe=J8(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,g5).replace(`nolink`,_5).getRegex(),v5=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,y5={_backpedal:q8,anyPunctuation:HGe,autolink:UGe,blockSkip:PGe,br:s5,code:DGe,del:q8,delLDelim:q8,delRDelim:q8,emStrongLDelim:FGe,emStrongRDelimAst:LGe,emStrongRDelimUnd:zGe,escape:EGe,link:KGe,nolink:_5,punctuation:kGe,reflink:g5,reflinkSearch:qGe,tag:GGe,text:OGe,url:q8},JGe={...y5,link:J8(/^!?\[(label)\]\((.*?)\)/).replace(`label`,h5).getRegex(),reflink:J8(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,h5).getRegex()},b5={...y5,emStrongRDelimAst:RGe,emStrongLDelim:IGe,delLDelim:BGe,delRDelim:VGe,url:J8(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,v5).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:J8(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,v5).getRegex()},YGe={...b5,br:J8(s5).replace(`{2,}`,`*`).getRegex(),text:J8(b5.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},x5={normal:a5,gfm:wGe,pedantic:TGe},S5={normal:y5,gfm:b5,breaks:YGe,pedantic:JGe},XGe={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},C5=e=>XGe[e];function w5(e,t){if(t){if(Y8.escapeTest.test(e))return e.replace(Y8.escapeReplace,C5)}else if(Y8.escapeTestNoEncode.test(e))return e.replace(Y8.escapeReplaceNoEncode,C5);return e}function T5(e){try{e=encodeURI(e).replace(Y8.percentDecode,`%`)}catch{return null}return e}function E5(e,t){let n=e.replace(Y8.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Y8.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(Y8.slashPipe,`|`);return n}function D5(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 ZGe(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 QGe(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 O5(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 $Ge(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
75351
75352
  `).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(`
75352
- `)}var O5=class{options;rules;lexer;constructor(e){this.options=e||W8}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:E5(e,`
75353
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=$Ge(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=E5(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:E5(t[0],`
75354
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=E5(t[0],`
75353
+ `)}var k5=class{options;rules;lexer;constructor(e){this.options=e||G8}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:D5(e,`
75354
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=$Ge(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=D5(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:D5(t[0],`
75355
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=D5(t[0],`
75355
75356
  `).split(`
75356
75357
  `),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(`
75357
75358
  `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -75369,10 +75370,10 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
75369
75370
  `,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+=`
75370
75371
  `+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+=`
75371
75372
  `+l}u=!l.trim(),r+=p+`
75372
- `,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=T5(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
75373
- `):[],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(T5(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)===`
75374
- `?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=E5(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=ZGe(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)),D5(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 D5(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}}}},k5=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||W8,this.options.tokenizer=this.options.tokenizer||new O5,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:J8,block:b5.normal,inline:x5.normal};this.options.pedantic?(t.block=b5.pedantic,t.inline=x5.pedantic):this.options.gfm&&(t.block=b5.gfm,this.options.breaks?t.inline=x5.breaks:t.inline=x5.gfm),this.tokenizer.rules=t}static get rules(){return{block:b5,inline:x5}}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(J8.carriageReturn,`
75375
- `),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(J8.tabCharGlobal,` `).replace(J8.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+=`
75373
+ `,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=E5(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
75374
+ `):[],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(E5(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)===`
75375
+ `?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=D5(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=ZGe(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)),O5(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 O5(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}}}},A5=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||G8,this.options.tokenizer=this.options.tokenizer||new k5,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:Y8,block:x5.normal,inline:S5.normal};this.options.pedantic?(t.block=x5.pedantic,t.inline=S5.pedantic):this.options.gfm&&(t.block=x5.gfm,this.options.breaks?t.inline=S5.breaks:t.inline=S5.gfm),this.tokenizer.rules=t}static get rules(){return{block:x5,inline:S5}}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(Y8.carriageReturn,`
75376
+ `),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(Y8.tabCharGlobal,` `).replace(Y8.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+=`
75376
75377
  `: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(`
75377
75378
  `)?``:`
75378
75379
  `)+r.raw,n.text+=`
@@ -75385,9 +75386,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
75385
75386
  `+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(`
75386
75387
  `)?``:`
75387
75388
  `)+r.raw,n.text+=`
75388
- `+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}},A5=class{options;parser;constructor(e){this.options=e||W8}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(J8.notSpaceStart)?.[0],i=e.replace(J8.endingNewline,``)+`
75389
- `;return r?`<pre><code class="language-`+C5(r)+`">`+(n?i:C5(i,!0))+`</code></pre>
75390
- `:`<pre><code>`+(n?i:C5(i,!0))+`</code></pre>
75389
+ `+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}},j5=class{options;parser;constructor(e){this.options=e||G8}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Y8.notSpaceStart)?.[0],i=e.replace(Y8.endingNewline,``)+`
75390
+ `;return r?`<pre><code class="language-`+w5(r)+`">`+(n?i:w5(i,!0))+`</code></pre>
75391
+ `:`<pre><code>`+(n?i:w5(i,!0))+`</code></pre>
75391
75392
  `}blockquote({tokens:e}){return`<blockquote>
75392
75393
  ${this.parser.parse(e)}</blockquote>
75393
75394
  `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -75403,101 +75404,101 @@ ${this.parser.parse(e)}</blockquote>
75403
75404
  `}tablerow({text:e}){return`<tr>
75404
75405
  ${e}</tr>
75405
75406
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
75406
- `}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>${C5(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=w5(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+C5(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=w5(e);if(i===null)return C5(n);e=i;let a=`<img src="${e}" alt="${C5(n)}"`;return t&&(a+=` title="${C5(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:C5(e.text)}},j5=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}},M5=class e{options;renderer;textRenderer;constructor(e){this.options=e||W8,this.options.renderer=this.options.renderer||new A5,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new j5}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}},N5=class{options;block;constructor(e){this.options=e||W8}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?k5.lex:k5.lexInline}provideParser(){return this.block?M5.parse:M5.parseInline}},P5=new class{defaults=U8();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=M5;Renderer=A5;TextRenderer=j5;Lexer=k5;Tokenizer=O5;Hooks=N5;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 A5(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 O5(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 N5;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];N5.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&N5.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 k5.lex(e,t??this.defaults)}parser(e,t){return M5.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?k5.lex:k5.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?M5.parse:M5.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?k5.lex:k5.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?M5.parse:M5.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+=`
75407
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+C5(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F5(e,t){return P5.parse(e,t)}F5.options=F5.setOptions=function(e){return P5.setOptions(e),F5.defaults=P5.defaults,G8(F5.defaults),F5},F5.getDefaults=U8,F5.defaults=W8,F5.use=function(...e){return P5.use(...e),F5.defaults=P5.defaults,G8(F5.defaults),F5},F5.walkTokens=function(e,t){return P5.walkTokens(e,t)},F5.parseInline=P5.parseInline,F5.Parser=M5,F5.parser=M5.parse,F5.Renderer=A5,F5.TextRenderer=j5,F5.Lexer=k5,F5.lexer=k5.lex,F5.Tokenizer=O5,F5.Hooks=N5,F5.parse=F5,F5.options,F5.setOptions,F5.use,F5.walkTokens,F5.parseInline,M5.parse,k5.lex;var eKe=Object.defineProperty,tKe=Object.defineProperties,nKe=Object.getOwnPropertyDescriptors,I5=Object.getOwnPropertySymbols,rKe=Object.prototype.hasOwnProperty,iKe=Object.prototype.propertyIsEnumerable,L5=(e,t,n)=>t in e?eKe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R5=(e,t)=>{for(var n in t||={})rKe.call(t,n)&&L5(e,n,t[n]);if(I5)for(var n of I5(t))iKe.call(t,n)&&L5(e,n,t[n]);return e},z5=(e,t)=>tKe(e,nKe(t)),B5=(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},aKe=(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},oKe=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]==="`"&&!aKe(e,n)&&(t+=1)}return t},V5=(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},sKe=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,cKe=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(sKe,(t,n,r,i)=>B5(e,i)?t:`${n}\\>${r}`),lKe=/(\*\*)([^*]*\*?)$/,uKe=/(__)([^_]*?)$/,dKe=/(\*\*\*)([^*]*?)$/,fKe=/(\*)([^*]*?)$/,pKe=/(_)([^_]*?)$/,mKe=/(`)([^`]*?)$/,hKe=/(~~)([^~]*?)$/,H5=/^[\s_~*`]*$/,U5=/^[\s]*[-*+][\s]+$/,gKe=/[\p{L}\p{N}_]/u,_Ke=/^```[^`\n]*```?$/,vKe=/^\*{4,}$/,yKe=/(__)([^_]+)_$/,bKe=/(~~)([^~]+)~$/,W5=/~~/g,G5=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:gKe.test(e)},xKe=(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},K5=(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},q5=(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},SKe=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
75408
- `)return!1}return!1},J5=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`?SKe(e,t):!1;if(e[n]===`
75407
+ `}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>${w5(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=T5(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+w5(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=T5(e);if(i===null)return w5(n);e=i;let a=`<img src="${e}" alt="${w5(n)}"`;return t&&(a+=` title="${w5(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:w5(e.text)}},M5=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}},N5=class e{options;renderer;textRenderer;constructor(e){this.options=e||G8,this.options.renderer=this.options.renderer||new j5,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new M5}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}},P5=class{options;block;constructor(e){this.options=e||G8}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?A5.lex:A5.lexInline}provideParser(){return this.block?N5.parse:N5.parseInline}},F5=new class{defaults=W8();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=N5;Renderer=j5;TextRenderer=M5;Lexer=A5;Tokenizer=k5;Hooks=P5;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 j5(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 k5(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 P5;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];P5.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&P5.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 A5.lex(e,t??this.defaults)}parser(e,t){return N5.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?A5.lex:A5.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?N5.parse:N5.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?A5.lex:A5.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?N5.parse:N5.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+=`
75408
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+w5(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function I5(e,t){return F5.parse(e,t)}I5.options=I5.setOptions=function(e){return F5.setOptions(e),I5.defaults=F5.defaults,K8(I5.defaults),I5},I5.getDefaults=W8,I5.defaults=G8,I5.use=function(...e){return F5.use(...e),I5.defaults=F5.defaults,K8(I5.defaults),I5},I5.walkTokens=function(e,t){return F5.walkTokens(e,t)},I5.parseInline=F5.parseInline,I5.Parser=N5,I5.parser=N5.parse,I5.Renderer=j5,I5.TextRenderer=M5,I5.Lexer=A5,I5.lexer=A5.lex,I5.Tokenizer=k5,I5.Hooks=P5,I5.parse=I5,I5.options,I5.setOptions,I5.use,I5.walkTokens,I5.parseInline,N5.parse,A5.lex;var eKe=Object.defineProperty,tKe=Object.defineProperties,nKe=Object.getOwnPropertyDescriptors,L5=Object.getOwnPropertySymbols,rKe=Object.prototype.hasOwnProperty,iKe=Object.prototype.propertyIsEnumerable,R5=(e,t,n)=>t in e?eKe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,z5=(e,t)=>{for(var n in t||={})rKe.call(t,n)&&R5(e,n,t[n]);if(L5)for(var n of L5(t))iKe.call(t,n)&&R5(e,n,t[n]);return e},B5=(e,t)=>tKe(e,nKe(t)),V5=(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},aKe=(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},oKe=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]==="`"&&!aKe(e,n)&&(t+=1)}return t},H5=(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},sKe=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,cKe=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(sKe,(t,n,r,i)=>V5(e,i)?t:`${n}\\>${r}`),lKe=/(\*\*)([^*]*\*?)$/,uKe=/(__)([^_]*?)$/,dKe=/(\*\*\*)([^*]*?)$/,fKe=/(\*)([^*]*?)$/,pKe=/(_)([^_]*?)$/,mKe=/(`)([^`]*?)$/,hKe=/(~~)([^~]*?)$/,U5=/^[\s_~*`]*$/,W5=/^[\s]*[-*+][\s]+$/,gKe=/[\p{L}\p{N}_]/u,_Ke=/^```[^`\n]*```?$/,vKe=/^\*{4,}$/,yKe=/(__)([^_]+)_$/,bKe=/(~~)([^~]+)~$/,G5=/~~/g,K5=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:gKe.test(e)},xKe=(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},q5=(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},J5=(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},SKe=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
75409
+ `)return!1}return!1},Y5=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`?SKe(e,t):!1;if(e[n]===`
75409
75410
  `)return!1}return!1},CKe=(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]===`
75410
- `)return!1}return!1},Y5=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
75411
+ `)return!1}return!1},X5=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
75411
75412
  `){r=n+1;break}let i=e.length;for(let n=t;n<e.length;n+=1)if(e[n]===`
75412
- `){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},wKe=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&q5(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&G5(n)&&G5(r)||(!n||n===` `||n===` `||n===`
75413
+ `){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},wKe=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&J5(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&K5(n)&&K5(r)||(!n||n===` `||n===` `||n===`
75413
75414
  `)&&(!r||r===` `||r===` `||r===`
75414
- `)),X5=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]:``;wKe(e,i,a,o)||(t+=1)}return t},TKe=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&q5(e,t)||J5(e,t)||CKe(e,t)||n===`_`||r===`_`||n&&r&&G5(n)&&G5(r)),EKe=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]:``;TKe(e,i,a,o)||(t+=1)}return t},DKe=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},Z5=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},Q5=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},OKe=(e,t,n)=>{if(!t||H5.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
75415
- `),i=r===-1?0:r+1,a=e.substring(i,n);return U5.test(a)&&t.includes(`
75416
- `)?!0:Y5(e,n,`*`)},kKe=e=>{let t=e.match(lKe);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return B5(e,r)||V5(e,r)||OKe(e,n,r)?e:Z5(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},AKe=(e,t,n)=>{if(!t||H5.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
75417
- `),i=r===-1?0:r+1,a=e.substring(i,n);return U5.test(a)&&t.includes(`
75418
- `)?!0:Y5(e,n,`_`)},jKe=e=>{let t=e.match(uKe);if(!t){let t=e.match(yKe);if(t){let n=e.lastIndexOf(t[1]);if(!(B5(e,n)||V5(e,n))&&Q5(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return B5(e,r)||V5(e,r)||AKe(e,n,r)?e:Q5(e)%2==1?`${e}__`:e},MKe=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]!==`\\`&&!q5(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
75415
+ `)),Z5=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]:``;wKe(e,i,a,o)||(t+=1)}return t},TKe=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&J5(e,t)||Y5(e,t)||CKe(e,t)||n===`_`||r===`_`||n&&r&&K5(n)&&K5(r)),EKe=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]:``;TKe(e,i,a,o)||(t+=1)}return t},DKe=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},Q5=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},$5=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},OKe=(e,t,n)=>{if(!t||U5.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
75416
+ `),i=r===-1?0:r+1,a=e.substring(i,n);return W5.test(a)&&t.includes(`
75417
+ `)?!0:X5(e,n,`*`)},kKe=e=>{let t=e.match(lKe);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return V5(e,r)||H5(e,r)||OKe(e,n,r)?e:Q5(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},AKe=(e,t,n)=>{if(!t||U5.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
75418
+ `),i=r===-1?0:r+1,a=e.substring(i,n);return W5.test(a)&&t.includes(`
75419
+ `)?!0:X5(e,n,`_`)},jKe=e=>{let t=e.match(uKe);if(!t){let t=e.match(yKe);if(t){let n=e.lastIndexOf(t[1]);if(!(V5(e,n)||H5(e,n))&&$5(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return V5(e,r)||H5(e,r)||AKe(e,n,r)?e:$5(e)%2==1?`${e}__`:e},MKe=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]!==`\\`&&!J5(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
75419
75420
  `)&&(!r||r===` `||r===` `||r===`
75420
- `)||t&&r&&G5(t)&&G5(r))continue;return n}}return-1},NKe=e=>{if(!e.match(fKe))return e;let t=MKe(e);if(t===-1||B5(e,t)||V5(e,t))return e;let n=e.substring(t+1);return!n||H5.test(n)?e:X5(e)%2==1?`${e}*`:e},$5=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]!==`\\`&&!q5(e,n)&&!J5(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&G5(t)&&G5(r))continue;return n}}return-1},PKe=e=>{let t=e.length;for(;t>0&&e[t-1]===`
75421
- `;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},FKe=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(Z5(t)%2!=1)return null;let n=t.indexOf(`**`),r=$5(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},IKe=e=>{if(!e.match(pKe))return e;let t=$5(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||H5.test(n)||B5(e,t)||V5(e,t))return e;if(EKe(e)%2==1){let t=FKe(e);return t===null?PKe(e):t}return e},LKe=e=>{let t=Z5(e),n=X5(e);return t%2==0&&n%2==0},RKe=(e,t,n)=>!t||H5.test(t)||B5(e,n)||V5(e,n)?!0:Y5(e,n,`*`),zKe=e=>{if(vKe.test(e))return e;let t=e.match(dKe);if(!t)return e;let n=t[2];return RKe(e,n,e.lastIndexOf(t[1]))?e:DKe(e)%2==1?LKe(e)?e:`${e}***`:e},BKe=/<[a-zA-Z/][^>]*$/,VKe=e=>{let t=e.match(BKe);return!t||t.index===void 0||B5(e,t.index)?e:e.substring(0,t.index).trimEnd()},HKe=e=>!e.match(_Ke)||e.includes(`
75422
- `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,UKe=e=>(e.match(/```/g)||[]).length%2==1,WKe=e=>{let t=HKe(e);if(t!==null)return t;let n=e.match(mKe);if(n&&!UKe(e)){let t=n[2];if(!t||H5.test(t))return e;if(oKe(e)%2==1)return`${e}\``}return e},GKe=(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)==="```",KKe=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!GKe(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},qKe=e=>{let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
75421
+ `)||t&&r&&K5(t)&&K5(r))continue;return n}}return-1},NKe=e=>{if(!e.match(fKe))return e;let t=MKe(e);if(t===-1||V5(e,t)||H5(e,t))return e;let n=e.substring(t+1);return!n||U5.test(n)?e:Z5(e)%2==1?`${e}*`:e},e7=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]!==`\\`&&!J5(e,n)&&!Y5(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&K5(t)&&K5(r))continue;return n}}return-1},PKe=e=>{let t=e.length;for(;t>0&&e[t-1]===`
75422
+ `;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},FKe=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(Q5(t)%2!=1)return null;let n=t.indexOf(`**`),r=e7(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},IKe=e=>{if(!e.match(pKe))return e;let t=e7(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||U5.test(n)||V5(e,t)||H5(e,t))return e;if(EKe(e)%2==1){let t=FKe(e);return t===null?PKe(e):t}return e},LKe=e=>{let t=Q5(e),n=Z5(e);return t%2==0&&n%2==0},RKe=(e,t,n)=>!t||U5.test(t)||V5(e,n)||H5(e,n)?!0:X5(e,n,`*`),zKe=e=>{if(vKe.test(e))return e;let t=e.match(dKe);if(!t)return e;let n=t[2];return RKe(e,n,e.lastIndexOf(t[1]))?e:DKe(e)%2==1?LKe(e)?e:`${e}***`:e},BKe=/<[a-zA-Z/][^>]*$/,VKe=e=>{let t=e.match(BKe);return!t||t.index===void 0||V5(e,t.index)?e:e.substring(0,t.index).trimEnd()},HKe=e=>!e.match(_Ke)||e.includes(`
75423
+ `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,UKe=e=>(e.match(/```/g)||[]).length%2==1,WKe=e=>{let t=HKe(e);if(t!==null)return t;let n=e.match(mKe);if(n&&!UKe(e)){let t=n[2];if(!t||U5.test(t))return e;if(oKe(e)%2==1)return`${e}\``}return e},GKe=(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)==="```",KKe=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!GKe(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},qKe=e=>{let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
75423
75424
  `,t)!==-1&&!e.endsWith(`
75424
75425
  `)?`${e}
75425
- $$`:`${e}$$`},JKe=e=>KKe(e)%2==0?e:qKe(e),YKe=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=xKe(e,t);if(r===-1||B5(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)`},e7=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!B5(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=K5(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},XKe=(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=e7(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(K5(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=e7(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},t7=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!B5(e,n)){let r=YKe(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!B5(e,n)){let r=XKe(e,n,t);if(r!==null)return r}return e},ZKe=/^-{1,2}$/,QKe=/^[\s]*-{1,2}[\s]+$/,$Ke=/^={1,2}$/,eqe=/^[\s]*={1,2}[\s]+$/,tqe=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
75426
+ $$`:`${e}$$`},JKe=e=>KKe(e)%2==0?e:qKe(e),YKe=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=xKe(e,t);if(r===-1||V5(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)`},t7=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!V5(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=q5(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},XKe=(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=t7(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(q5(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=t7(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},n7=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!V5(e,n)){let r=YKe(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!V5(e,n)){let r=XKe(e,n,t);if(r!==null)return r}return e},ZKe=/^-{1,2}$/,QKe=/^[\s]*-{1,2}[\s]+$/,$Ke=/^={1,2}$/,eqe=/^[\s]*={1,2}[\s]+$/,tqe=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
75426
75427
  `);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(ZKe.test(i)&&!n.match(QKe)){let t=r.split(`
75427
75428
  `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if($Ke.test(i)&&!n.match(eqe)){let t=r.split(`
75428
- `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},nqe=e=>{let t=e.match(hKe);if(t){let n=t[2];if(!n||H5.test(n))return e;let r=e.lastIndexOf(t[1]);if(B5(e,r)||V5(e,r))return e;if(e.match(W5)?.length%2==1)return`${e}~~`}else{let t=e.match(bKe);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(B5(e,n)||V5(e,n))return e;if(e.match(W5)?.length%2==1)return`${e}~`}}return e},n7=e=>e!==!1,r7={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},rqe=[{handler:{name:`comparisonOperators`,handle:cKe,priority:r7.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:VKe,priority:r7.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:tqe,priority:r7.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:t7,priority:r7.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:zKe,priority:r7.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:kKe,priority:r7.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:jKe,priority:r7.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:NKe,priority:r7.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:IKe,priority:r7.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:WKe,priority:r7.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:nqe,priority:r7.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:JKe,priority:r7.KATEX},optionKey:`katex`}],iqe=e=>{let t=e?.linkMode??`protocol`;return rqe.filter(({handler:t,optionKey:n})=>t.name===`links`?n7(e?.links)||n7(e?.images):n7(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:z5(R5({},e),{handle:e=>t7(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},aqe=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=iqe(t),i=(t?.handlers??[]).map(e=>({handler:z5(R5({},e),{priority:e.priority??r7.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 oqe(e){if(!e)return!1;let t=e.toLowerCase().trim();return t===`mermaid`||t===`mmd`}function sqe(e){try{return a0(e)}catch{return null}}function i7({children:e,language:t}){let n=(0,Z.useMemo)(()=>S0(),[]);if(oqe(t)){let t=sqe(e||``);if(t!==null)return(0,X.jsx)(Q,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,X.jsx)($,{children:t})})}let r=e;if(t&&(0,b0.supportsLanguage)(t))try{r=(0,b0.highlight)(e||``,{language:t,theme:n})}catch{}return(0,X.jsx)(Q,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,X.jsx)($,{children:r})})}i7.displayName=`CodeBlock`;function a7(e){return`text`in e&&typeof e.text==`string`?e.text:`tokens`in e&&Array.isArray(e.tokens)?e.tokens.map(e=>a7(e)).join(``):``}function cqe(e,t){let n=e.length;if(n===0)return e;if(t<=n*5)return e.map(()=>3);let r=t-n*2,i=e.map(e=>Math.max(3,Math.floor(e))),a=i.reduce((e,t)=>e+t,0);for(;a>r;){let e=!1;for(let t=0;t<i.length&&a>r;t++)i[t]>3&&(--i[t],--a,e=!0);if(!e)break}return i}function lqe(e){return`checked`in e&&typeof e.checked==`boolean`}function o7(e,t=!1){return e?e.map((e,n)=>(0,X.jsx)(Z.Fragment,{children:s7(e,t)},n)):null}function s7(e,t=!1){let n=e=>t?(0,X.jsx)($,{dimColor:!0,italic:!0,children:e}):e;switch(e.type){case`strong`:return(0,X.jsx)($,{bold:!0,children:o7(e.tokens,t)});case`em`:return(0,X.jsx)($,{italic:!0,children:o7(e.tokens,t)});case`del`:return(0,X.jsx)($,{strikethrough:!0,children:o7(e.tokens,t)});case`codespan`:return n((0,X.jsx)($,{color:QQ,dimColor:!0,children:e.text}));case`link`:return n((0,X.jsx)(B6,{href:e.href,children:a7(e)}));case`image`:{let t=e,r=t.text||t.href;return n((0,X.jsxs)($,{dimColor:!0,children:[r,` `,t.href!==r&&`(${t.href})`]}))}case`checkbox`:{let t=lqe(e)&&e.checked===!0;return n((0,X.jsx)($,{color:$Q,children:t?`[✓]`:`[ ]`}))}case`text`:return e.tokens?o7(e.tokens,t):n(e.text);case`br`:return`
75429
- `;default:return n(a7(e))}}function c7(e,t=0,n=!1,r){switch(e.type){case`heading`:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{bold:!0,color:e.depth<=2?QQ:$Q,dimColor:e.depth>2,children:o7(e.tokens,n)})},`heading-${e.depth}`);case`paragraph`:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{children:o7(e.tokens,n)})},`paragraph`);case`code`:return(0,X.jsx)(i7,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,X.jsx)(Q,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:r$,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,n)=>(0,X.jsx)(Q,{children:c7(e,t,!0,r)},n))},`blockquote`);case`list`:return(0,X.jsx)(Q,{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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:$Q,dimColor:!0,children:s?c?`[✓] `:`[ ] `:o===null?`• `:`${o}. `}),(0,X.jsx)(Q,{flexGrow:1,flexDirection:`column`,children:l.map((e,i)=>(0,X.jsx)(Q,{children:c7(e,t+1,n,r)},i))})]},a)})},`list`);case`table`:{let t=e,i=t.header.map((e,n)=>{let r=M3(a7(e));for(let e of t.rows)r=Math.max(r,M3(a7(e[n])));return Math.max(r,3)}),a=i.reduce((e,t)=>e+t+2,0),o=cqe(i,r===void 0?a:Math.max(10,Math.min(r,a)));return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(Q,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:r$,alignSelf:`flex-start`,children:t.header.map((e,r)=>{let i=t.align?.[r]||null;return(0,X.jsx)(Q,{width:o[r]+2,paddingX:1,justifyContent:i===`center`?`center`:i===`right`?`flex-end`:`flex-start`,children:(0,X.jsx)($,{bold:!0,color:QQ,wrap:`wrap`,children:o7(e.tokens,n)})},r)})}),t.rows.map((e,r)=>(0,X.jsx)(Q,{flexDirection:`row`,children:e.map((e,r)=>{let i=t.align?.[r]||null;return(0,X.jsx)(Q,{width:o[r]+2,paddingX:1,justifyContent:i===`center`?`center`:i===`right`?`flex-end`:`flex-start`,children:(0,X.jsx)($,{wrap:`wrap`,children:o7(e.tokens,n)})},r)})},r))]},`table`)}case`hr`:return(0,X.jsx)(Q,{children:(0,X.jsx)($,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{children:s7(e,n)})})}}function l7({children:e}){let{width:t}=b3(),n=(0,Z.useMemo)(()=>{try{let t=aqe(e);return F5.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,Z.useMemo)(()=>{let e=[],r=n.length;return n.forEach((n,i)=>{let a=i===r-1;if(n.type===`space`){e.push((0,X.jsx)(Q,{height:1},`space-${i}`));return}e.push((0,X.jsx)(Q,{flexDirection:`column`,children:c7(n,0,!1,t)},i)),n.type===`heading`&&!a&&e.push((0,X.jsx)(Q,{height:1},`heading-space-${i}`))}),e},[n,t])})}l7.displayName=`Markdown`;const u7=`Pondering...,Thinking...,Processing...,Analyzing...,Exploring...,Crafting...,Building...,Searching...,Connecting...,Reflecting...,Considering...,Examining...,Synthesizing...,Computing...,Reasoning...,Contemplating...,Assembling...,Formulating...,Generating...,Compiling...,Decoding...,Unraveling...,Mapping...,Weaving...,Brewing...,Sculpting...,Distilling...,Parsing...,Digesting...,Conjuring...`.split(`,`);function uqe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function dqe(){return u7[Math.floor(Math.random()*u7.length)]}const fqe=dt([`codellm`,`cli`,`tools`]);function d7(e){let t=g3[e.name];if(t||=(dUe(e.name),g3[e.name]),!t)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsxs)($,{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 fqe.error`Error rendering tool ${e.name}: ${r}`,(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:t.displayName,params:i,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error rendering tool`})]})}}const f7=(0,Z.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,Z.useMemo)(()=>C3(n),[n]);return a?.trim()?i===`user`?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:XQ,children:`❯`}),(0,X.jsx)($,{color:XQ,italic:!0,children:a})]}):r?(0,X.jsx)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,X.jsx)(_6,{text:a})}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`white`,children:`⏺`}),(0,X.jsx)(l7,{children:a.trimStart()})]})}):null});f7.displayName=`TextSegment`;const p7=(0,Z.memo)(e=>{let{segment:t}=e,n=(0,Z.useMemo)(()=>C3(t),[t]);return(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,X.jsx)($,{color:ZQ,children:`✳`}),(0,X.jsx)(Q,{flexDirection:`column`,gap:0,children:n&&(0,X.jsx)($,{color:ZQ,wrap:`wrap`,children:n})})]})});p7.displayName=`ExpandedThinkingSegment`;const m7=(0,Z.memo)(e=>(0,Z.useContext)(G0)?(0,X.jsx)(p7,{...e}):null);m7.displayName=`ThinkingSegment`;const h7=(0,Z.memo)(e=>{let{toolUseRequest:t,toolUseResult:n,toolDisplayData:r,parsedResult:i,isStreamingArgs:a}=e;if(!t)return null;if(a){let e=Array.isArray(t)?t[0]?.name:t.name;return e===`todo_write`?null:(0,X.jsx)(T0,{name:g3[e??``]?.displayName??e??`Tool`,showSpinner:!0})}return Array.isArray(t)?(0,X.jsx)(X.Fragment,{children:t.map((e,t)=>(0,X.jsx)(d7,{...e,result:n,displayData:r,parsedResult:i},e.id??t))}):(0,X.jsx)(d7,{...t,result:n,displayData:r,parsedResult:i})});h7.displayName=`ToolCallSegment`;const g7=(0,Z.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,a=(0,Z.useRef)(dqe());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let o=(0,Z.useMemo)(()=>C3(n),[n]);if(!o&&!r)throw Error(`Collapsible component segment must have content or title`);let s=r||uqe(a.current);return(0,X.jsxs)(Q,{borderStyle:o?`single`:void 0,borderColor:r$,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[s&&(0,X.jsx)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_6,{text:`${s}...`}),(0,X.jsx)($,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)($,{color:XQ,children:s})]})}),o&&(0,X.jsx)(l7,{children:o})]})});g7.displayName=`CollapsibleComponentSegment`;const _7=(0,Z.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e;if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(a);if((0,Z.useEffect)(()=>{if(a!==c.current&&a!=null){c.current=a,s(!0);let e=setTimeout(()=>s(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let l=(0,Z.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),u=(0,Z.useMemo)(()=>{switch(l){case`info`:return e$;case`success`:return t$;case`warning`:return n$;case`error`:return zNe;default:return e$}},[l]),d=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(` `),f=(0,Z.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,X.jsxs)(Q,{flexDirection:`column`,gap:0,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:u,children:o?`◉`:`●`}),(0,X.jsx)($,{color:u,bold:o,inverse:o,children:o?` ${n} `:n})]}),f.length>0&&(0,X.jsx)(Q,{marginLeft:2,flexDirection:`row`,gap:1,children:f.map((e,t)=>(0,X.jsxs)(Z.Fragment,{children:[t>0&&(0,X.jsx)($,{children:` | `}),(0,X.jsx)($,{color:`cyan`,underline:!0,children:d(e.type)})]},t))})]})});_7.displayName=`NotificationSegment`;const v7=(0,Z.memo)(e=>{let t=e.creditsUsed??0;return t<=0?null:(0,X.jsx)(Q,{justifyContent:`flex-end`,children:(0,X.jsxs)($,{dimColor:!0,children:[`Credits used: `,t.toFixed(2)]})})});v7.displayName=`CreditsSegment`;const y7=(0,Z.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,X.jsx)(f7,{...e});case`thinking`:return(0,X.jsx)(m7,{...e});case`code_llm_tool_call`:return(0,X.jsx)(h7,{...e});case`collapsible_component`:return(0,X.jsx)(g7,{...e});case`code_llm_agent_tool_request`:return(0,X.jsx)(h7,{...e});case`code_llm_notification`:return(0,X.jsx)(_7,{...e});case`code_llm_credits`:return(0,X.jsx)(v7,{...e});default:return null}});y7.displayName=`SegmentBase`;function pqe(e,t){return(0,X.jsx)(_7,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function b7({segment:e}){return(0,X.jsx)(Q6,{fallback:pqe,children:(0,X.jsx)(y7,{segment:e})})}const x7=`pondering.thinking.processing.analyzing.exploring.crafting.building.searching.connecting.reflecting.considering.examining.synthesizing.computing.reasoning.contemplating.assembling.formulating.generating.compiling.decoding.unraveling.mapping.weaving.brewing.sculpting.distilling.parsing.digesting.conjuring`.split(`.`);function mqe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function S7(){return x7[Math.floor(Math.random()*x7.length)]}function hqe(e,t){let[n,r]=(0,Z.useState)(0),i=(0,Z.useRef)(null);if((0,Z.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 ${h3(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${h3(o)}`}function gqe(e){let[,t]=(0,Z.useState)(0);if((0,Z.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:h3(n)}const _qe=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=r3(),[a,o]=(0,Z.useState)(()=>S7()),s=(0,Z.useRef)(Sd.Idle);(0,Z.useEffect)(()=>{s.current===Sd.Idle&&e!==Sd.Idle&&o(S7()),s.current=e},[e]);let c=hqe(t,n),l=gqe(r);if(!(e!==Sd.Idle&&e!==Sd.WaitingForToolPermission))return null;let u=e===Sd.LoadingConversation?`Resuming`:mqe(a);return(0,X.jsxs)(Q,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,X.jsx)(_6,{text:`${u}...`}),c&&(0,X.jsxs)($,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,X.jsx)($,{dimColor:!0,children:l}),e!==Sd.LoadingConversation&&(0,X.jsx)($,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})};function vqe(e){switch(e){case`completed`:return`✔`;case`in_progress`:return`◼`;default:return`◻`}}function yqe(e){switch(e){case`completed`:return t$;case`in_progress`:return QQ;default:return XQ}}const C7=(0,Z.memo)(({state:e})=>{let t=(0,Z.useContext)(G0);if(e.total===0||t)return null;let{todos:n,total:r,completed:i,inProgress:a,pending:o}=e,s=[];i>0&&s.push(`${i} done`),a>0&&s.push(`${a} in progress`),o>0&&s.push(`${o} open`);let c=s.length>0?`${r} task${r===1?``:`s`} (${s.join(`, `)})`:`${r} task${r===1?``:`s`}`,l=n.slice(0,5),u=r-l.length;return(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)($,{dimColor:!0,children:c}),l.map(e=>(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:yqe(e.status),children:vqe(e.status)}),(0,X.jsx)($,{color:e.status===`completed`?XQ:void 0,dimColor:e.status===`completed`,strikethrough:e.status===`completed`,children:e.content})]},e.id)),u>0&&(0,X.jsxs)($,{dimColor:!0,children:[` `,`+`,u,` more task`,u===1?``:`s`]})]})});C7.displayName=`TodoList`;const w7=new Set([`read`,`grep`,`glob`,`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 T7(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function bqe(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function xqe(e){if(e.isStreamingArgs)return``;let t=T7(e),n=bqe(e),r=g3[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function Sqe(e){switch(e){case`read`:return`read`;case`grep`:case`glob`: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_output`;case`kill_shell`:return`terminal_kill`;case`get_diagnostics`:return`diag`;default:return`other`}}function Cqe(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_output`:a=`getting terminal output`;break;case`terminal_kill`:a=i===1?`killing 1 shell`:`killing ${i} shells`;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_output`:a=`got terminal output`;break;case`terminal_kill`:a=n===1?`killed 1 shell`:`killed ${n} shells`;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_output`,`terminal_kill`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const E7=(0,Z.memo)(({segments:e})=>{let t={},n=null,r=!1,i=!1;for(let a of e){let e=Sqe(T7(a)),o=!a.toolUseResult;if(t[e]||(t[e]={completed:0,executing:0}),o)t[e].executing++,n=a,r=!0;else{t[e].completed++;let n=a.toolUseResult;(n?.rejected||n?.content?.startsWith(`Error:`))&&(i=!0)}}let a=Cqe(t),o=a.charAt(0).toUpperCase()+a.slice(1),s=n?xqe(n):null;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,alignItems:`center`,children:[r?(0,X.jsx)(w0,{}):(0,X.jsx)($,{color:i?`red`:r?`white`:`green`,children:`⏺`}),(0,X.jsxs)($,{children:[o,r?`…`:``]}),(0,X.jsx)($,{color:XQ,dimColor:!0,children:`(ctrl+o to expand)`})]}),s&&(0,X.jsxs)(Q,{flexDirection:`row`,paddingLeft:2,children:[(0,X.jsxs)($,{color:ZQ,dimColor:!0,children:[`⎿`,` `]}),(0,X.jsx)($,{color:ZQ,children:s})]})]})});E7.displayName=`ToolGroupSummary`;const D7=(0,Z.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,Z.useState)(0),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(()=>new Map),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(()=>new Map),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,Z.useRef)(i);g.current=i;let _=(0,Z.useRef)(n);_.current=n;let v=(0,Z.useRef)(c);v.current=c;let y=(0,Z.useRef)(e);y.current=e;let b=(0,Z.useRef)(o);b.current=o;let x=(0,Z.useRef)(u);x.current=u;let S=(0,Z.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,Z.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,Z.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,Z.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,Z.useRef)(T);E.current=T;let D=(0,Z.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,Z.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(bZ((0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:m.question})}),(0,X.jsx)(Q,{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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:r?`green`:n?void 0:`brightblack`,children:[a,e.label]}),e.description?(0,X.jsxs)($,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{dimColor:!0,children:`Note: `}),(0,X.jsx)(t6,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,X.jsxs)($,{dimColor:!0,children:[`Note: `,(0,X.jsx)($,{italic:!0,children:k})]})}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter save note`}),(0,X.jsx)($,{dimColor:!0,children:`esc discard note`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ option`}),(0,X.jsx)($,{dimColor:!0,children:`space select`}),(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,X.jsx)($,{dimColor:!0,children:`←→ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),(0,X.jsx)($,{dimColor:!0,children:`esc skip`})]})})]})});D7.displayName=`AskUserQuestionPermissionUI`;const O7=(0,Z.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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. `}),(0,X.jsx)(t6,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. ${o||``}`}),(0,X.jsx)(t6,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:n?void 0:`brightblack`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,X.jsxs)($,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));O7.displayName=`PermissionOptionItem`;const k7=(0,Z.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,Z.useCallback)(()=>{},[]),h=(0,Z.useRef)(``),g=(0,Z.useRef)(``),_=(0,Z.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),v=s,y=(0,Z.useRef)(a);y.current=a;let b=(0,Z.useRef)(_.length);b.current=_.length;let x=(0,Z.useRef)(v);x.current=v;let S=(0,Z.useRef)(l);S.current=l;let C=(0,Z.useRef)(t);C.current=t;let w=(0,Z.useRef)(r);w.current=r;let T=(0,Z.useRef)(_);T.current=_;let E=(0,Z.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,Z.useRef)(E);D.current=E;let O=(0,Z.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,Z.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,Z.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,Z.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);bZ((0,Z.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,Z.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,Z.useRef)(!1);(0,Z.useEffect)(()=>{s&&(M.current=!0)},[s]),(0,Z.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,ee=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,F=!s&&!l&&N&&(N.value===`accept`||N.value===`reject`),te=!s&&!l&&!!N?.rules?.length,I=_.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,X.jsxs)(Q,{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,X.jsx)(O7,{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:ee(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:O,onInputKeyDown:k},t)}),(0,X.jsx)(Q,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),(0,X.jsx)($,{dimColor:!0,children:`esc cancel`})]}):s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter submit`}),(0,X.jsx)($,{dimColor:!0,children:`tab discard note`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`enter select`}),F&&(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),te&&(0,X.jsx)($,{dimColor:!0,children:`e edit rule`}),i&&(0,X.jsxs)($,{dimColor:!0,children:[`shift+tab `,i]}),!i&&I&&(0,X.jsx)($,{dimColor:!0,children:`shift+tab don't ask again`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]})})]})});k7.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 j7=(0,Z.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=H0(),s=[{label:`Yes, apply changes`,value:`accept`},...o===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{i(A7(e))};return r?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${a?`Create`:`Update`} file ${e}`}),a?a2(e)?(0,X.jsx)(u2,{content:n,maxLinesPerCell:100}):(0,X.jsx)(k0,{filePath:e,content:n,maxLines:100}):a2(e)?(0,X.jsx)(c2,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(Q0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});j7.displayName=`EditFilePermissionUI`;const M7=(0,Z.memo)(({filePath:e,originalContent:t,content:n,isNewFile:r,diffShownInEditor:i,onResolve:a})=>{let{agentMode:o}=H0(),s=[{label:`Yes, apply changes`,value:`accept`},...o===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{a(A7(e))};return i?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${r?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${r?`Create`:`Update`} file ${e}`}),r?a2(e)?(0,X.jsx)(u2,{content:n,maxLinesPerCell:100}):(0,X.jsx)(k0,{filePath:e,content:n,maxLines:100}):a2(e)?(0,X.jsx)(c2,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(Q0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});M7.displayName=`WriteFilePermissionUI`;const N7=(0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Browser action: ${e}`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),t&&(0,X.jsxs)($,{dimColor:!0,children:[`URL: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:i,onSelect:e=>{r(A7(e))}})})]})});N7.displayName=`BrowserActionPermissionUI`;const P7=(0,Z.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let i=(0,Z.useMemo)(()=>S0(),[]),a=FF(e),o=(0,Z.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(${a})`,value:`allowAlwaysWithRule`,rules:[`Bash(${a})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,a]);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Bash command`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:(0,b0.supportsLanguage)(`bash`)?(()=>{try{return(0,b0.highlight)(e,{language:`bash`,theme:i})}catch{return e}})():e}),t&&(0,X.jsx)(Q,{paddingTop:1,children:(0,X.jsx)($,{dimColor:!0,children:`(Running in background)`})})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:o,onSelect:e=>{r(A7(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});P7.displayName=`RunTerminalPermissionUI`;const F7=(0,Z.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let i=(0,Z.useMemo)(()=>S0(),[]),a=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:e}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:(0,b0.supportsLanguage)(`json`)?(()=>{try{return(0,b0.highlight)(t,{language:`json`,theme:i})}catch{return t}})():t})}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:a,onSelect:e=>{r(A7(e))}})})]})});F7.displayName=`GenericPermissionUI`;const I7=(0,Z.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,X.jsx)(l7,{children:t})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{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:`Yes, implement the plan (full permissions granted)`,value:`allowYolo`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(A7(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));I7.displayName=`ExitPlanModePermissionUI`;const L7=(0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Read file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:r,onSelect:e=>{n(A7(e))}})})]})});L7.displayName=`ReadOutsideDirectoryPermissionUI`;const R7=(0,Z.memo)(({filePath:e,deducedDirectory:t,isNewFile:n,onResolve:r})=>{let i=[{label:`Yes, allow write`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny write`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${n?`Create`:`Write`} file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:i,onSelect:e=>{r(A7(e))}})})]})});R7.displayName=`WriteOutsideDirectoryPermissionUI`;const z7=(0,Z.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny edit`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:r,onSelect:e=>{n(A7(e))}})})]})});z7.displayName=`EditOutsideDirectoryPermissionUI`;const B7=(0,Z.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow notebook edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny notebook edit`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit notebook outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:r,onSelect:e=>{n(A7(e))}})})]})});B7.displayName=`NotebookEditOutsideDirectoryPermissionUI`;const V7=(0,Z.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{agentMode:l}=H0(),u=[{label:`Yes, apply changes`,value:`accept`},...l===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit notebook`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)($,{dimColor:!0,children:e}),(0,X.jsx)($,{dimColor:!0,children:c})]}),s===`delete`?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,X.jsx)(Q0,{filePath:i2(r===`markdown`?`markdown`:`python`),originalContent:``,newContent:a,showHeader:!1,paddingLeft:1}):(0,X.jsx)(s2,{cellIndex:0,cellType:r??`code`,cellId:t,language:r===`markdown`?`markdown`:`python`,originalSource:i,newSource:a,status:`modified`}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(k7,{options:u,onSelect:e=>{o(A7(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});V7.displayName=`NotebookEditPermissionUI`;const H7=(0,Z.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,X.jsx)(j7,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`write_file`:return(0,X.jsx)(M7,{filePath:t.filePath,originalContent:t.originalContent,content:t.content,isNewFile:t.isNewFile,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`run_terminal`:return(0,X.jsx)(P7,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,X.jsx)(N7,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,X.jsx)(F7,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,X.jsx)(L7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`write_outside_directory`:return(0,X.jsx)(R7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,isNewFile:t.isNewFile,onResolve:n});case`edit_outside_directory`:return(0,X.jsx)(z7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`notebook_edit_outside_directory`:return(0,X.jsx)(B7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,X.jsx)(I7,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,X.jsx)(D7,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,X.jsx)(V7,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});H7.displayName=`ToolPermissionUI`;function wqe(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{n.current=e},[e]),(0,Z.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 U7=(0,Z.createContext)(null),W7=()=>{let e=(0,Z.use)(U7);if(!e)throw Error(`${W7.name} must be used within a ${G7.name}`);return e};function G7({children:e}){let t=(0,Z.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(TZ(t))},[]);wqe(()=>{process.stdout.write(TZ(``))});let n=(0,Z.useMemo)(()=>({setTitle:t}),[t]);return(0,X.jsx)(U7.Provider,{value:n,children:e})}const K7=2e3;function q7(e,t,n){return e===Sd.ExecutingTool?`tool-executing`:e===Sd.Submitted||e===Sd.Streaming?`streaming`:e===Sd.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function Tqe(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueAllToComposer:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,Z.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,Z.useCallback)(()=>{y(),b()},[y,b]),S=q7(t,n,i),C=(0,Z.useRef)(S);return(0,Z.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),bZ((0,Z.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=q7(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},K7));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},K7);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},K7);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},K7);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},K7)}}),{isActive:!0}),(0,Z.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}const Eqe={todos:[],completed:0,inProgress:0,pending:0,total:0};function Dqe(e){let t=e.toolUseRequest;if(!t)return null;let n;if(Array.isArray(t)){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r&&r.name===`todo_write`){n=r;break}}if(!n)return null}else if(n=t,n.name!==`todo_write`)return null;let r=n.input;if(!r)return null;let i=r.todos;if(typeof i==`string`)try{i=JSON.parse(i)}catch{return null}return Array.isArray(i)?i.filter(e=>typeof e==`object`&&!!e&&typeof e.content==`string`&&typeof e.status==`string`).map((e,t)=>({id:e.id??`todo-${t}`,content:e.content,status:e.status})):null}function Oqe(e){return(0,Z.useMemo)(()=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`code_llm_tool_call`&&n.type!==`code_llm_agent_tool_request`)continue;let r=Dqe(n);if(!r)continue;let i=r.filter(e=>e.status!==`cancelled`);return{todos:i,completed:i.filter(e=>e.status===`completed`).length,inProgress:i.filter(e=>e.status===`in_progress`).length,pending:i.filter(e=>e.status===`pending`).length,total:i.length}}return Eqe},[e])}var kqe=G(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Aqe=G(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),J7=kqe(),Y7=Qe(Aqe(),1);function jqe({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const Mqe=jqe();function X7(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Mqe,``)}function Z7(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Q7={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(Q7);var Nqe=Q7.exports;const Pqe=Z7(Nqe),Fqe=Z7(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function $7(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=X7(e),e.length===0))return 0;e=e.replace(Fqe(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Pqe.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const e9=(e=0)=>t=>`\x1B[${t+e}m`,t9=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,n9=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,r9={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r9.modifier);const Iqe=Object.keys(r9.color),Lqe=Object.keys(r9.bgColor);[...Iqe,...Lqe];function Rqe(){let e=new Map;for(let[t,n]of Object.entries(r9)){for(let[t,r]of Object.entries(n))r9[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=r9[t],e.set(r[0],r[1]);Object.defineProperty(r9,t,{value:n,enumerable:!1})}return Object.defineProperty(r9,`codes`,{value:e,enumerable:!1}),r9.color.close=`\x1B[39m`,r9.bgColor.close=`\x1B[49m`,r9.color.ansi=e9(),r9.color.ansi256=t9(),r9.color.ansi16m=n9(),r9.bgColor.ansi=e9(10),r9.bgColor.ansi256=t9(10),r9.bgColor.ansi16m=n9(10),Object.defineProperties(r9,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>r9.rgbToAnsi256(...r9.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>r9.ansi256ToAnsi(r9.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>r9.ansi256ToAnsi(r9.hexToAnsi256(e)),enumerable:!1}}),r9}const zqe=Rqe(),i9=new Set([`\x1B`,`›`]),a9=`]8;;`,o9=e=>`${i9.values().next().value}[${e}m`,s9=e=>`${i9.values().next().value}${a9}${e}`,Bqe=e=>e.split(` `).map(e=>$7(e)),c9=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=$7(X7(e[e.length-1]));for(let[t,s]of r.entries()){let c=$7(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),i9.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(a9)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vqe=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!($7(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Hqe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Bqe(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=$7(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),c9(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){c9(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){c9(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Vqe(e)));let c=[...s.join(`
75430
- `)];for(let[e,t]of c.entries()){if(r+=t,i9.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${a9}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=zqe.codes.get(Number(i));c[e+1]===`
75431
- `?(a&&(r+=s9(``)),i&&n&&(r+=o9(n))):t===`
75432
- `&&(i&&n&&(r+=o9(i)),a&&(r+=s9(a)))}return r};function l9(e,t,n){return String(e).normalize().replace(/\r\n/g,`
75429
+ `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},nqe=e=>{let t=e.match(hKe);if(t){let n=t[2];if(!n||U5.test(n))return e;let r=e.lastIndexOf(t[1]);if(V5(e,r)||H5(e,r))return e;if(e.match(G5)?.length%2==1)return`${e}~~`}else{let t=e.match(bKe);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(V5(e,n)||H5(e,n))return e;if(e.match(G5)?.length%2==1)return`${e}~`}}return e},r7=e=>e!==!1,i7={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},rqe=[{handler:{name:`comparisonOperators`,handle:cKe,priority:i7.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:VKe,priority:i7.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:tqe,priority:i7.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:n7,priority:i7.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:zKe,priority:i7.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:kKe,priority:i7.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:jKe,priority:i7.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:NKe,priority:i7.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:IKe,priority:i7.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:WKe,priority:i7.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:nqe,priority:i7.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:JKe,priority:i7.KATEX},optionKey:`katex`}],iqe=e=>{let t=e?.linkMode??`protocol`;return rqe.filter(({handler:t,optionKey:n})=>t.name===`links`?r7(e?.links)||r7(e?.images):r7(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:B5(z5({},e),{handle:e=>n7(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},aqe=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=iqe(t),i=(t?.handlers??[]).map(e=>({handler:B5(z5({},e),{priority:e.priority??i7.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 oqe(e){if(!e)return!1;let t=e.toLowerCase().trim();return t===`mermaid`||t===`mmd`}function sqe(e){try{return a0(e)}catch{return null}}function a7({children:e,language:t}){let n=(0,Z.useMemo)(()=>S0(),[]);if(oqe(t)){let t=sqe(e||``);if(t!==null)return(0,X.jsx)(Q,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,X.jsx)($,{children:t})})}let r=e;if(t&&(0,b0.supportsLanguage)(t))try{r=(0,b0.highlight)(e||``,{language:t,theme:n})}catch{}return(0,X.jsx)(Q,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,X.jsx)($,{children:r})})}a7.displayName=`CodeBlock`;function o7(e){return`text`in e&&typeof e.text==`string`?e.text:`tokens`in e&&Array.isArray(e.tokens)?e.tokens.map(e=>o7(e)).join(``):``}function cqe(e,t){let n=e.length;if(n===0)return e;if(t<=n*5)return e.map(()=>3);let r=t-n*2,i=e.map(e=>Math.max(3,Math.floor(e))),a=i.reduce((e,t)=>e+t,0);for(;a>r;){let e=!1;for(let t=0;t<i.length&&a>r;t++)i[t]>3&&(--i[t],--a,e=!0);if(!e)break}return i}function lqe(e){return`checked`in e&&typeof e.checked==`boolean`}function s7(e,t=!1){return e?e.map((e,n)=>(0,X.jsx)(Z.Fragment,{children:c7(e,t)},n)):null}function c7(e,t=!1){let n=e=>t?(0,X.jsx)($,{dimColor:!0,italic:!0,children:e}):e;switch(e.type){case`strong`:return(0,X.jsx)($,{bold:!0,children:s7(e.tokens,t)});case`em`:return(0,X.jsx)($,{italic:!0,children:s7(e.tokens,t)});case`del`:return(0,X.jsx)($,{strikethrough:!0,children:s7(e.tokens,t)});case`codespan`:return n((0,X.jsx)($,{color:QQ,dimColor:!0,children:e.text}));case`link`:return n((0,X.jsx)(V6,{href:e.href,children:o7(e)}));case`image`:{let t=e,r=t.text||t.href;return n((0,X.jsxs)($,{dimColor:!0,children:[r,` `,t.href!==r&&`(${t.href})`]}))}case`checkbox`:{let t=lqe(e)&&e.checked===!0;return n((0,X.jsx)($,{color:$Q,children:t?`[✓]`:`[ ]`}))}case`text`:return e.tokens?s7(e.tokens,t):n(e.text);case`br`:return`
75430
+ `;default:return n(o7(e))}}function l7(e,t=0,n=!1,r){switch(e.type){case`heading`:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{bold:!0,color:e.depth<=2?QQ:$Q,dimColor:e.depth>2,children:s7(e.tokens,n)})},`heading-${e.depth}`);case`paragraph`:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{children:s7(e.tokens,n)})},`paragraph`);case`code`:return(0,X.jsx)(a7,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,X.jsx)(Q,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:r$,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,n)=>(0,X.jsx)(Q,{children:l7(e,t,!0,r)},n))},`blockquote`);case`list`:return(0,X.jsx)(Q,{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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:$Q,dimColor:!0,children:s?c?`[✓] `:`[ ] `:o===null?`• `:`${o}. `}),(0,X.jsx)(Q,{flexGrow:1,flexDirection:`column`,children:l.map((e,i)=>(0,X.jsx)(Q,{children:l7(e,t+1,n,r)},i))})]},a)})},`list`);case`table`:{let t=e,i=t.header.map((e,n)=>{let r=M3(o7(e));for(let e of t.rows)r=Math.max(r,M3(o7(e[n])));return Math.max(r,3)}),a=i.reduce((e,t)=>e+t+2,0),o=cqe(i,r===void 0?a:Math.max(10,Math.min(r,a)));return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(Q,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:r$,alignSelf:`flex-start`,children:t.header.map((e,r)=>{let i=t.align?.[r]||null;return(0,X.jsx)(Q,{width:o[r]+2,paddingX:1,justifyContent:i===`center`?`center`:i===`right`?`flex-end`:`flex-start`,children:(0,X.jsx)($,{bold:!0,color:QQ,wrap:`wrap`,children:s7(e.tokens,n)})},r)})}),t.rows.map((e,r)=>(0,X.jsx)(Q,{flexDirection:`row`,children:e.map((e,r)=>{let i=t.align?.[r]||null;return(0,X.jsx)(Q,{width:o[r]+2,paddingX:1,justifyContent:i===`center`?`center`:i===`right`?`flex-end`:`flex-start`,children:(0,X.jsx)($,{wrap:`wrap`,children:s7(e.tokens,n)})},r)})},r))]},`table`)}case`hr`:return(0,X.jsx)(Q,{children:(0,X.jsx)($,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsx)($,{children:c7(e,n)})})}}function u7({children:e}){let{width:t}=b3(),n=(0,Z.useMemo)(()=>{try{let t=aqe(e);return I5.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,Z.useMemo)(()=>{let e=[],r=n.length;return n.forEach((n,i)=>{let a=i===r-1;if(n.type===`space`){e.push((0,X.jsx)(Q,{height:1},`space-${i}`));return}e.push((0,X.jsx)(Q,{flexDirection:`column`,children:l7(n,0,!1,t)},i)),n.type===`heading`&&!a&&e.push((0,X.jsx)(Q,{height:1},`heading-space-${i}`))}),e},[n,t])})}u7.displayName=`Markdown`;const d7=`Pondering...,Thinking...,Processing...,Analyzing...,Exploring...,Crafting...,Building...,Searching...,Connecting...,Reflecting...,Considering...,Examining...,Synthesizing...,Computing...,Reasoning...,Contemplating...,Assembling...,Formulating...,Generating...,Compiling...,Decoding...,Unraveling...,Mapping...,Weaving...,Brewing...,Sculpting...,Distilling...,Parsing...,Digesting...,Conjuring...`.split(`,`);function uqe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function dqe(){return d7[Math.floor(Math.random()*d7.length)]}const fqe=dt([`codellm`,`cli`,`tools`]);function f7(e){let t=g3[e.name];if(t||=(dUe(e.name),g3[e.name]),!t)return(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsxs)($,{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 fqe.error`Error rendering tool ${e.name}: ${r}`,(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(T0,{name:t.displayName,params:i,status:`error`}),(0,X.jsx)(E0,{color:`red`,children:`Error rendering tool`})]})}}const p7=(0,Z.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,Z.useMemo)(()=>C3(n),[n]);return a?.trim()?i===`user`?(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:XQ,children:`❯`}),(0,X.jsx)($,{color:XQ,italic:!0,children:a})]}):r?(0,X.jsx)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,X.jsx)(_6,{text:a})}):(0,X.jsx)(Q,{flexDirection:`column`,children:(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`white`,children:`●`}),(0,X.jsx)(u7,{children:a.trimStart()})]})}):null});p7.displayName=`TextSegment`;const m7=(0,Z.memo)(e=>{let{segment:t}=e,n=(0,Z.useMemo)(()=>C3(t),[t]);return(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,X.jsx)($,{color:ZQ,children:`✳`}),(0,X.jsx)(Q,{flexDirection:`column`,gap:0,children:n&&(0,X.jsx)($,{color:ZQ,wrap:`wrap`,children:n})})]})});m7.displayName=`ExpandedThinkingSegment`;const h7=(0,Z.memo)(e=>(0,Z.useContext)(G0)?(0,X.jsx)(m7,{...e}):null);h7.displayName=`ThinkingSegment`;const g7=(0,Z.memo)(e=>{let{status:t,toolUseRequest:n,toolUseResult:r,toolDisplayData:i,parsedResult:a,isStreamingArgs:o}=e;if(!n)return null;if(t===`transient`&&o){let e=Array.isArray(n)?n[0]?.name:n.name;return e===`todo_write`?null:(0,X.jsx)(T0,{name:g3[e??``]?.displayName??e??`Tool`,showSpinner:!0})}return Array.isArray(n)?(0,X.jsx)(X.Fragment,{children:n.map((e,t)=>(0,X.jsx)(f7,{...e,result:r,displayData:i,parsedResult:a},e.id??t))}):(0,X.jsx)(f7,{...n,result:r,displayData:i,parsedResult:a})});g7.displayName=`ToolCallSegment`;const _7=(0,Z.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,a=(0,Z.useRef)(dqe());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let o=(0,Z.useMemo)(()=>C3(n),[n]);if(!o&&!r)throw Error(`Collapsible component segment must have content or title`);let s=r||uqe(a.current);return(0,X.jsxs)(Q,{borderStyle:o?`single`:void 0,borderColor:r$,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[s&&(0,X.jsx)(Q,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_6,{text:`${s}...`}),(0,X.jsx)($,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{children:` `}),(0,X.jsx)($,{color:XQ,children:s})]})}),o&&(0,X.jsx)(u7,{children:o})]})});_7.displayName=`CollapsibleComponentSegment`;const v7=(0,Z.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e;if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(a);if((0,Z.useEffect)(()=>{if(a!==c.current&&a!=null){c.current=a,s(!0);let e=setTimeout(()=>s(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let l=(0,Z.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),u=(0,Z.useMemo)(()=>{switch(l){case`info`:return e$;case`success`:return t$;case`warning`:return n$;case`error`:return zNe;default:return e$}},[l]),d=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(` `),f=(0,Z.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,X.jsxs)(Q,{flexDirection:`column`,gap:0,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:u,children:o?`◉`:`●`}),(0,X.jsx)($,{color:u,bold:o,inverse:o,children:o?` ${n} `:n})]}),f.length>0&&(0,X.jsx)(Q,{marginLeft:2,flexDirection:`row`,gap:1,children:f.map((e,t)=>(0,X.jsxs)(Z.Fragment,{children:[t>0&&(0,X.jsx)($,{children:` | `}),(0,X.jsx)($,{color:`cyan`,underline:!0,children:d(e.type)})]},t))})]})});v7.displayName=`NotificationSegment`;const y7=(0,Z.memo)(e=>{let t=e.creditsUsed??0;return t<=0?null:(0,X.jsx)(Q,{justifyContent:`flex-end`,children:(0,X.jsxs)($,{dimColor:!0,children:[`Credits used: `,t.toFixed(2)]})})});y7.displayName=`CreditsSegment`;const b7=(0,Z.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,X.jsx)(p7,{...e});case`thinking`:return(0,X.jsx)(h7,{...e});case`code_llm_tool_call`:return(0,X.jsx)(g7,{...e});case`collapsible_component`:return(0,X.jsx)(_7,{...e});case`code_llm_agent_tool_request`:return(0,X.jsx)(g7,{...e});case`code_llm_notification`:return(0,X.jsx)(v7,{...e});case`code_llm_credits`:return(0,X.jsx)(y7,{...e});default:return null}});b7.displayName=`SegmentBase`;function pqe(e,t){return(0,X.jsx)(v7,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function x7({segment:e}){return(0,X.jsx)($6,{fallback:pqe,children:(0,X.jsx)(b7,{segment:e})})}const S7=`pondering.thinking.processing.analyzing.exploring.crafting.building.searching.connecting.reflecting.considering.examining.synthesizing.computing.reasoning.contemplating.assembling.formulating.generating.compiling.decoding.unraveling.mapping.weaving.brewing.sculpting.distilling.parsing.digesting.conjuring`.split(`.`);function mqe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function C7(){return S7[Math.floor(Math.random()*S7.length)]}function hqe(e,t){let[n,r]=(0,Z.useState)(0),i=(0,Z.useRef)(null);if((0,Z.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 ${h3(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${h3(o)}`}function gqe(e){let[,t]=(0,Z.useState)(0);if((0,Z.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:h3(n)}const _qe=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=r3(),[a,o]=(0,Z.useState)(()=>C7()),s=(0,Z.useRef)(Sd.Idle);(0,Z.useEffect)(()=>{s.current===Sd.Idle&&e!==Sd.Idle&&o(C7()),s.current=e},[e]);let c=hqe(t,n),l=gqe(r);if(!(e!==Sd.Idle&&e!==Sd.WaitingForToolPermission))return null;let u=e===Sd.LoadingConversation?`Resuming`:mqe(a);return(0,X.jsxs)(Q,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,X.jsx)(_6,{text:`${u}...`}),c&&(0,X.jsxs)($,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,X.jsx)($,{dimColor:!0,children:l}),e!==Sd.LoadingConversation&&(0,X.jsx)($,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})};function vqe(e){switch(e){case`completed`:return`✔`;case`in_progress`:return`◼`;default:return`◻`}}function yqe(e){switch(e){case`completed`:return t$;case`in_progress`:return QQ;default:return XQ}}function bqe(e,t){if(e.length<=t)return e;let n=[],r=[],i=[];for(let t of e)switch(t.status){case`completed`:n.push(t);break;case`in_progress`:r.push(t);break;default:i.push(t);break}let a=[],o=e=>{let t=e.shift();t&&a.push(t)};n.length>0&&o(n),r.length>0&&o(r),i.length>0&&o(i);let s=[r,i,n];for(;a.length<t;){let e=!1;for(let n of s){if(a.length>=t)break;n.length!==0&&(o(n),e=!0)}if(!e)break}return a}const w7=(0,Z.memo)(({state:e})=>{if(e.total===0)return null;let{todos:t,total:n,completed:r,inProgress:i,pending:a}=e,o=bqe(t,5),s=n-o.length,c=[];return r>0&&c.push(`${r} done`),i>0&&c.push(`${i} in progress`),a>0&&c.push(`${a} open`),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)($,{dimColor:!0,children:c.length>0?`${n} task${n===1?``:`s`} (${c.join(`, `)})`:`${n} task${n===1?``:`s`}`}),o.map(e=>(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:yqe(e.status),children:vqe(e.status)}),(0,X.jsx)($,{color:e.status===`completed`?XQ:void 0,dimColor:e.status===`completed`,strikethrough:e.status===`completed`,children:e.content})]},e.id)),s>0&&(0,X.jsxs)($,{dimColor:!0,children:[` `,`+`,s,` more task`,s===1?``:`s`]})]})});w7.displayName=`TodoList`;const T7=new Set([`read`,`grep`,`glob`,`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 E7(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function xqe(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function Sqe(e){if(e.status===`transient`&&e.isStreamingArgs)return``;let t=E7(e),n=xqe(e),r=g3[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function Cqe(e){switch(e){case`read`:return`read`;case`grep`:case`glob`: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_output`;case`kill_shell`:return`terminal_kill`;case`get_diagnostics`:return`diag`;default:return`other`}}function wqe(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_output`:a=`getting terminal output`;break;case`terminal_kill`:a=i===1?`killing 1 shell`:`killing ${i} shells`;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_output`:a=`got terminal output`;break;case`terminal_kill`:a=n===1?`killed 1 shell`:`killed ${n} shells`;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_output`,`terminal_kill`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const D7=(0,Z.memo)(({segments:e})=>{let t={},n=null,r=!1,i=!1;for(let a of e){let e=Cqe(E7(a)),o=a.status===`transient`&&!a.toolUseResult;if(t[e]||(t[e]={completed:0,executing:0}),o)t[e].executing++,n=a,r=!0;else{t[e].completed++;let n=a.toolUseResult;(n?.rejected||n?.content?.startsWith(`Error:`))&&(i=!0)}}let a=wqe(t),o=a.charAt(0).toUpperCase()+a.slice(1),s=n?Sqe(n):null;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,alignItems:`center`,children:[r?(0,X.jsx)(w0,{}):(0,X.jsx)($,{color:i?`red`:r?`white`:`green`,children:`●`}),(0,X.jsxs)($,{children:[o,r?`…`:``]}),(0,X.jsx)($,{color:XQ,dimColor:!0,children:`(ctrl+o to expand)`})]}),s&&(0,X.jsxs)(Q,{flexDirection:`row`,paddingLeft:2,children:[(0,X.jsxs)($,{color:ZQ,dimColor:!0,children:[`⎿`,` `]}),(0,X.jsx)($,{color:ZQ,children:s})]})]})});D7.displayName=`ToolGroupSummary`;const O7=(0,Z.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,Z.useState)(0),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(()=>new Map),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(()=>new Map),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,Z.useRef)(i);g.current=i;let _=(0,Z.useRef)(n);_.current=n;let v=(0,Z.useRef)(c);v.current=c;let y=(0,Z.useRef)(e);y.current=e;let b=(0,Z.useRef)(o);b.current=o;let x=(0,Z.useRef)(u);x.current=u;let S=(0,Z.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,Z.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,Z.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,Z.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,Z.useRef)(T);E.current=T;let D=(0,Z.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,Z.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(bZ((0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:m.question})}),(0,X.jsx)(Q,{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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:r?`green`:n?void 0:`brightblack`,children:[a,e.label]}),e.description?(0,X.jsxs)($,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{dimColor:!0,children:`Note: `}),(0,X.jsx)(t6,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,X.jsxs)($,{dimColor:!0,children:[`Note: `,(0,X.jsx)($,{italic:!0,children:k})]})}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter save note`}),(0,X.jsx)($,{dimColor:!0,children:`esc discard note`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ option`}),(0,X.jsx)($,{dimColor:!0,children:`space select`}),(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,X.jsx)($,{dimColor:!0,children:`←→ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),(0,X.jsx)($,{dimColor:!0,children:`esc skip`})]})})]})});O7.displayName=`AskUserQuestionPermissionUI`;const k7=(0,Z.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,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. `}),(0,X.jsx)(t6,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. ${o||``}`}),(0,X.jsx)(t6,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:n?void 0:`brightblack`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,X.jsxs)($,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));k7.displayName=`PermissionOptionItem`;const A7=(0,Z.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,Z.useCallback)(()=>{},[]),h=(0,Z.useRef)(``),g=(0,Z.useRef)(``),_=(0,Z.useRef)(e);_.current=e;let v=(0,Z.useMemo)(()=>_.current.filter(e=>e.value!==`input`),[JSON.stringify(e.map(({label:e,value:t,hint:n,rules:r})=>[e,t,n??null,r??null]))]),y=s,b=(0,Z.useRef)(a);b.current=a;let x=(0,Z.useRef)(v.length);x.current=v.length;let S=(0,Z.useRef)(y);S.current=y;let C=(0,Z.useRef)(l);C.current=l;let w=(0,Z.useRef)(t);w.current=t;let T=(0,Z.useRef)(r);T.current=r;let E=(0,Z.useRef)(v);E.current=v;let D=(0,Z.useCallback)(()=>{let e=E.current[b.current];if(e)if(S.current){let t=d.current?.text?.trim();if(t){let n=p(t),r=e.value===`accept`?`accept`:`reject`;w.current({decision:r,userMessage:n,rules:e.rules}),m()}}else e.value!==`input`&&w.current({decision:e.value,rules:e.rules})},[p,m]),O=(0,Z.useRef)(D);O.current=D;let k=(0,Z.useCallback)(e=>{if(e.trim()){let t=E.current[b.current],n=p(e.trim()),r=t?.value===`accept`?`accept`:`reject`;w.current({decision:r,userMessage:n,rules:t?.rules}),m()}},[p,m]),A=(0,Z.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=E.current[b.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(x.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=E.current[b.current];t?.value===`accept`?h.current=``:t?.value===`reject`&&(g.current=``),m(),c(!1),e.preventDefault();return}if(e.key.escape){m(),c(!1),w.current({decision:`reject`}),e.preventDefault();return}},[m]),j=(0,Z.useCallback)(e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);t.length!==0&&E.current[b.current]&&(t.length===1?w.current({decision:`allowAlwaysWithRule`,rules:t}):w.current({decision:`allowAlwaysWithRules`,rules:t}),u(!1))},[]),M=(0,Z.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);bZ((0,Z.useCallback)((e,t)=>{if(!S.current&&!C.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(x.current-1,e+1));return}if(t.escape){w.current({decision:`reject`});return}if(t.tab&&t.shift){if(T.current){T.current();return}let e=E.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{w.current({decision:`allowAlways`})},0));return}if(t.tab){let e=E.current[b.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=E.current[b.current];if(e?.rules?.length){u(!0),setTimeout(()=>{f.current?.setText(e.rules.join(`, `))},0);return}}if(t.return){O.current();return}}},[]),{isActive:!0}),(0,Z.useEffect)(()=>{let e=v[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?h.current:g.current)&&!s&&c(!0))},[a,v,s]);let N=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{s&&(N.current=!0)},[s]),(0,Z.useEffect)(()=>{if(!s||!N.current)return;let e=v[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),N.current=!1},0):N.current=!1},[s,a,v]);let P=v[a],ee=s&&P,F=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,te=!s&&!l&&P&&(P.value===`accept`||P.value===`reject`),I=!s&&!l&&!!P?.rules?.length,L=v.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[v.map((e,t)=>{let r=t===a,i=ee&&r,o=e.value===`accept`?h.current:e.value===`reject`?g.current:``;return(0,X.jsx)(k7,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,showAsEdit:l&&r,editBufferRef:f,onEditSubmit:j,onEditKeyDown:M,inputPrefix:F(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:k,onInputKeyDown:A},t)}),(0,X.jsx)(Q,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),(0,X.jsx)($,{dimColor:!0,children:`esc cancel`})]}):s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter submit`}),(0,X.jsx)($,{dimColor:!0,children:`tab discard note`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`enter select`}),te&&(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),I&&(0,X.jsx)($,{dimColor:!0,children:`e edit rule`}),i&&(0,X.jsxs)($,{dimColor:!0,children:[`shift+tab `,i]}),!i&&L&&(0,X.jsx)($,{dimColor:!0,children:`shift+tab don't ask again`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]})})]})});A7.displayName=`PermissionOptions`;function j7(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 M7=(0,Z.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=H0(),s=[{label:`Yes, apply changes`,value:`accept`},...o===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{i(j7(e))};return r?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${a?`Create`:`Update`} file ${e}`}),a?a2(e)?(0,X.jsx)(u2,{content:n,maxLinesPerCell:100}):(0,X.jsx)(k0,{filePath:e,content:n,maxLines:100}):a2(e)?(0,X.jsx)(c2,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(Q0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});M7.displayName=`EditFilePermissionUI`;const N7=(0,Z.memo)(({filePath:e,originalContent:t,content:n,isNewFile:r,diffShownInEditor:i,onResolve:a})=>{let{agentMode:o}=H0(),s=[{label:`Yes, apply changes`,value:`accept`},...o===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{a(j7(e))};return i?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${r?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${r?`Create`:`Update`} file ${e}`}),r?a2(e)?(0,X.jsx)(u2,{content:n,maxLinesPerCell:100}):(0,X.jsx)(k0,{filePath:e,content:n,maxLines:100}):a2(e)?(0,X.jsx)(c2,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(Q0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});N7.displayName=`WriteFilePermissionUI`;const P7=(0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Browser action: ${e}`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),t&&(0,X.jsxs)($,{dimColor:!0,children:[`URL: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:i,onSelect:e=>{r(j7(e))}})})]})});P7.displayName=`BrowserActionPermissionUI`;const F7=(0,Z.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let i=(0,Z.useMemo)(()=>S0(),[]),a=FF(e),o=(0,Z.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(${a})`,value:`allowAlwaysWithRule`,rules:[`Bash(${a})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,a]);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Bash command`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:(0,b0.supportsLanguage)(`bash`)?(()=>{try{return(0,b0.highlight)(e,{language:`bash`,theme:i})}catch{return e}})():e}),t&&(0,X.jsx)(Q,{paddingTop:1,children:(0,X.jsx)($,{dimColor:!0,children:`(Running in background)`})})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:o,onSelect:e=>{r(j7(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});F7.displayName=`RunTerminalPermissionUI`;const I7=(0,Z.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let i=(0,Z.useMemo)(()=>S0(),[]),a=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:e}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:(0,b0.supportsLanguage)(`json`)?(()=>{try{return(0,b0.highlight)(t,{language:`json`,theme:i})}catch{return t}})():t})}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:a,onSelect:e=>{r(j7(e))}})})]})});I7.displayName=`GenericPermissionUI`;const L7=(0,Z.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,X.jsx)(u7,{children:t})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{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:`Yes, implement the plan (full permissions granted)`,value:`allowYolo`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(j7(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));L7.displayName=`ExitPlanModePermissionUI`;const R7=(0,Z.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,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Read file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:r,onSelect:e=>{n(j7(e))}})})]})});R7.displayName=`ReadOutsideDirectoryPermissionUI`;const z7=(0,Z.memo)(({filePath:e,deducedDirectory:t,isNewFile:n,onResolve:r})=>{let i=[{label:`Yes, allow write`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny write`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`${n?`Create`:`Write`} file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:i,onSelect:e=>{r(j7(e))}})})]})});z7.displayName=`WriteOutsideDirectoryPermissionUI`;const B7=(0,Z.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny edit`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:r,onSelect:e=>{n(j7(e))}})})]})});B7.displayName=`EditOutsideDirectoryPermissionUI`;const V7=(0,Z.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow notebook edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny notebook edit`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit notebook outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:r,onSelect:e=>{n(j7(e))}})})]})});V7.displayName=`NotebookEditOutsideDirectoryPermissionUI`;const H7=(0,Z.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{agentMode:l}=H0(),u=[{label:`Yes, apply changes`,value:`accept`},...l===xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(d6,{title:`Edit notebook`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)($,{dimColor:!0,children:e}),(0,X.jsx)($,{dimColor:!0,children:c})]}),s===`delete`?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,X.jsx)(Q0,{filePath:i2(r===`markdown`?`markdown`:`python`),originalContent:``,newContent:a,showHeader:!1,paddingLeft:1}):(0,X.jsx)(s2,{cellIndex:0,cellType:r??`code`,cellId:t,language:r===`markdown`?`markdown`:`python`,originalSource:i,newSource:a,status:`modified`}),(0,X.jsx)(Q,{borderStyle:u6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(A7,{options:u,onSelect:e=>{o(j7(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});H7.displayName=`NotebookEditPermissionUI`;const U7=(0,Z.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,X.jsx)(M7,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`write_file`:return(0,X.jsx)(N7,{filePath:t.filePath,originalContent:t.originalContent,content:t.content,isNewFile:t.isNewFile,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`run_terminal`:return(0,X.jsx)(F7,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,X.jsx)(P7,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,X.jsx)(I7,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,X.jsx)(R7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`write_outside_directory`:return(0,X.jsx)(z7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,isNewFile:t.isNewFile,onResolve:n});case`edit_outside_directory`:return(0,X.jsx)(B7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`notebook_edit_outside_directory`:return(0,X.jsx)(V7,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,X.jsx)(L7,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,X.jsx)(O7,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,X.jsx)(H7,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});U7.displayName=`ToolPermissionUI`;function Tqe(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{n.current=e},[e]),(0,Z.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 W7=(0,Z.createContext)(null),G7=()=>{let e=(0,Z.use)(W7);if(!e)throw Error(`${G7.name} must be used within a ${K7.name}`);return e};function K7({children:e}){let t=(0,Z.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(TZ(t))},[]);Tqe(()=>{process.stdout.write(TZ(``))});let n=(0,Z.useMemo)(()=>({setTitle:t}),[t]);return(0,X.jsx)(W7.Provider,{value:n,children:e})}const q7=2e3;function J7(e,t,n){return e===Sd.ExecutingTool?`tool-executing`:e===Sd.Submitted||e===Sd.Streaming?`streaming`:e===Sd.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function Eqe(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueAllToComposer:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,Z.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,Z.useCallback)(()=>{y(),b()},[y,b]),S=J7(t,n,i),C=(0,Z.useRef)(S);return(0,Z.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),bZ((0,Z.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=J7(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},q7));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},q7);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q7);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},q7);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q7)}}),{isActive:!0}),(0,Z.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}const Dqe={todos:[],completed:0,inProgress:0,pending:0,total:0};function Oqe(e){let t=e.toolUseRequest;if(!t)return null;let n;if(Array.isArray(t)){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r&&r.name===`todo_write`){n=r;break}}if(!n)return null}else if(n=t,n.name!==`todo_write`)return null;let r=n.input;if(!r)return null;let i=r.todos;if(typeof i==`string`)try{i=JSON.parse(i)}catch{return null}return Array.isArray(i)?i.filter(e=>typeof e==`object`&&!!e&&typeof e.content==`string`&&typeof e.status==`string`).map((e,t)=>({id:e.id??`todo-${t}`,content:e.content,status:e.status})):null}function kqe(e){return(0,Z.useMemo)(()=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`code_llm_tool_call`&&n.type!==`code_llm_agent_tool_request`)continue;let r=Oqe(n);if(!r)continue;let i=r.filter(e=>e.status!==`cancelled`);return{todos:i,completed:i.filter(e=>e.status===`completed`).length,inProgress:i.filter(e=>e.status===`in_progress`).length,pending:i.filter(e=>e.status===`pending`).length,total:i.length}}return Dqe},[e])}var Aqe=G(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),jqe=G(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Y7=Aqe(),X7=Qe(jqe(),1);function Mqe({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const Nqe=Mqe();function Z7(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Nqe,``)}function Q7(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var $7={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})($7);var Pqe=$7.exports;const Fqe=Q7(Pqe),Iqe=Q7(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function e9(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Z7(e),e.length===0))return 0;e=e.replace(Iqe(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Fqe.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const t9=(e=0)=>t=>`\x1B[${t+e}m`,n9=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,r9=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,i9={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(i9.modifier);const Lqe=Object.keys(i9.color),Rqe=Object.keys(i9.bgColor);[...Lqe,...Rqe];function zqe(){let e=new Map;for(let[t,n]of Object.entries(i9)){for(let[t,r]of Object.entries(n))i9[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=i9[t],e.set(r[0],r[1]);Object.defineProperty(i9,t,{value:n,enumerable:!1})}return Object.defineProperty(i9,`codes`,{value:e,enumerable:!1}),i9.color.close=`\x1B[39m`,i9.bgColor.close=`\x1B[49m`,i9.color.ansi=t9(),i9.color.ansi256=n9(),i9.color.ansi16m=r9(),i9.bgColor.ansi=t9(10),i9.bgColor.ansi256=n9(10),i9.bgColor.ansi16m=r9(10),Object.defineProperties(i9,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>i9.rgbToAnsi256(...i9.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>i9.ansi256ToAnsi(i9.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>i9.ansi256ToAnsi(i9.hexToAnsi256(e)),enumerable:!1}}),i9}const Bqe=zqe(),a9=new Set([`\x1B`,`›`]),o9=`]8;;`,s9=e=>`${a9.values().next().value}[${e}m`,c9=e=>`${a9.values().next().value}${o9}${e}`,Vqe=e=>e.split(` `).map(e=>e9(e)),l9=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=e9(Z7(e[e.length-1]));for(let[t,s]of r.entries()){let c=e9(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),a9.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(o9)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Hqe=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(e9(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Uqe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Vqe(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=e9(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),l9(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){l9(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){l9(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Hqe(e)));let c=[...s.join(`
75431
+ `)];for(let[e,t]of c.entries()){if(r+=t,a9.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${o9}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Bqe.codes.get(Number(i));c[e+1]===`
75432
+ `?(a&&(r+=c9(``)),i&&n&&(r+=s9(n))):t===`
75433
+ `&&(i&&n&&(r+=s9(i)),a&&(r+=c9(a)))}return r};function u9(e,t,n){return String(e).normalize().replace(/\r\n/g,`
75433
75434
  `).split(`
75434
- `).map(e=>Hqe(e,t,n)).join(`
75435
- `)}const u9={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]])};function d9(e,t){if(typeof e==`string`)return u9.aliases.get(e)===t;for(let n of e)if(n!==void 0&&d9(n,t))return!0;return!1}function Uqe(e,t){if(e===t)return;let n=e.split(`
75435
+ `).map(e=>Uqe(e,t,n)).join(`
75436
+ `)}const d9={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]])};function f9(e,t){if(typeof e==`string`)return d9.aliases.get(e)===t;for(let n of e)if(n!==void 0&&f9(n,t))return!0;return!1}function Wqe(e,t){if(e===t)return;let n=e.split(`
75436
75437
  `),r=t.split(`
75437
- `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}const Wqe=globalThis.process.platform.startsWith(`win`),f9=Symbol(`clack:cancel`);function p9(e){return e===f9}function m9(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Gqe({input:e=He,output:t=Ue,overwrite:n=!0,hideCursor:r=!0}={}){let i=fe.createInterface({input:e,output:t,prompt:``,tabSize:1});fe.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if(d9([String(i),o,s],`cancel`)){r&&t.write(J7.cursor.show),process.exit(0);return}if(!n)return;let c=o===`return`?0:-1,l=o===`return`?-1:0;fe.moveCursor(t,c,l,()=>{fe.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(J7.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(J7.cursor.show),e.isTTY&&!Wqe&&e.setRawMode(!1),i.terminal=!1,i.close()}}var Kqe=Object.defineProperty,qqe=(e,t,n)=>t in e?Kqe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h9=(e,t,n)=>(qqe(e,typeof t==`symbol`?t:t+``,n),n),g9=class{constructor(e,t=!0){h9(this,`input`),h9(this,`output`),h9(this,`_abortSignal`),h9(this,`rl`),h9(this,`opts`),h9(this,`_render`),h9(this,`_track`,!1),h9(this,`_prevFrame`,``),h9(this,`_subscribers`,new Map),h9(this,`_cursor`,0),h9(this,`state`,`initial`),h9(this,`error`,``),h9(this,`value`);let{input:n=He,output:r=Ue,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(f9);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}let n=new E;n._write=(e,t,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,``),this._cursor=this.rl?.cursor??0,this.emit(`value`,this.value)),n()},this.input.pipe(n),this.rl=B.createInterface({input:this.input,output:n,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),B.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),m9(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(J7.cursor.show),this.output.off(`resize`,this.render),m9(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(J7.cursor.show),this.output.off(`resize`,this.render),m9(this.input,!1),e(f9)})})}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&u9.aliases.has(t.name)&&this.emit(`cursor`,u9.aliases.get(t.name)),u9.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.value))}this.state!==`error`&&(this.state=`submit`)}d9([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
75438
- `),m9(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=l9(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
75439
- `).length-1;this.output.write(J7.cursor.move(-999,e*-1))}render(){let e=l9(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(J7.cursor.hide);else{let t=Uqe(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(J7.cursor.move(0,n)),this.output.write(J7.erase.lines(1));let r=e.split(`
75440
- `);this.output.write(r[n]),this._prevFrame=e,this.output.write(J7.cursor.move(0,r.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(J7.cursor.move(0,n)),this.output.write(J7.erase.down());let r=e.split(`
75438
+ `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}const Gqe=globalThis.process.platform.startsWith(`win`),p9=Symbol(`clack:cancel`);function m9(e){return e===p9}function h9(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Kqe({input:e=He,output:t=Ue,overwrite:n=!0,hideCursor:r=!0}={}){let i=fe.createInterface({input:e,output:t,prompt:``,tabSize:1});fe.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if(f9([String(i),o,s],`cancel`)){r&&t.write(Y7.cursor.show),process.exit(0);return}if(!n)return;let c=o===`return`?0:-1,l=o===`return`?-1:0;fe.moveCursor(t,c,l,()=>{fe.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(Y7.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(Y7.cursor.show),e.isTTY&&!Gqe&&e.setRawMode(!1),i.terminal=!1,i.close()}}var qqe=Object.defineProperty,Jqe=(e,t,n)=>t in e?qqe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g9=(e,t,n)=>(Jqe(e,typeof t==`symbol`?t:t+``,n),n),_9=class{constructor(e,t=!0){g9(this,`input`),g9(this,`output`),g9(this,`_abortSignal`),g9(this,`rl`),g9(this,`opts`),g9(this,`_render`),g9(this,`_track`,!1),g9(this,`_prevFrame`,``),g9(this,`_subscribers`,new Map),g9(this,`_cursor`,0),g9(this,`state`,`initial`),g9(this,`error`,``),g9(this,`value`);let{input:n=He,output:r=Ue,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(p9);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}let n=new E;n._write=(e,t,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,``),this._cursor=this.rl?.cursor??0,this.emit(`value`,this.value)),n()},this.input.pipe(n),this.rl=B.createInterface({input:this.input,output:n,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),B.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),h9(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(Y7.cursor.show),this.output.off(`resize`,this.render),h9(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(Y7.cursor.show),this.output.off(`resize`,this.render),h9(this.input,!1),e(p9)})})}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&d9.aliases.has(t.name)&&this.emit(`cursor`,d9.aliases.get(t.name)),d9.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.value))}this.state!==`error`&&(this.state=`submit`)}f9([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
75439
+ `),h9(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=u9(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
75440
+ `).length-1;this.output.write(Y7.cursor.move(-999,e*-1))}render(){let e=u9(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(Y7.cursor.hide);else{let t=Wqe(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(Y7.cursor.move(0,n)),this.output.write(Y7.erase.lines(1));let r=e.split(`
75441
+ `);this.output.write(r[n]),this._prevFrame=e,this.output.write(Y7.cursor.move(0,r.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(Y7.cursor.move(0,n)),this.output.write(Y7.erase.down());let r=e.split(`
75441
75442
  `).slice(n);this.output.write(r.join(`
75442
- `)),this._prevFrame=e;return}this.output.write(J7.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Jqe=class extends g9{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(J7.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}};Object.defineProperty,Object.defineProperty;var Yqe=Object.defineProperty,Xqe=(e,t,n)=>t in e?Yqe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_9=(e,t,n)=>(Xqe(e,typeof t==`symbol`?t:t+``,n),n),Zqe=class extends g9{constructor({mask:e,...t}){super(t),_9(this,`valueWithCursor`,``),_9(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${Y7.default.inverse(Y7.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${Y7.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},Qqe=Object.defineProperty,$qe=(e,t,n)=>t in e?Qqe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v9=(e,t,n)=>($qe(e,typeof t==`symbol`?t:t+``,n),n),eJe=class extends g9{constructor(e){super(e,!1),v9(this,`options`),v9(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};Object.defineProperty;var tJe=class extends g9{get valueWithCursor(){if(this.state===`submit`)return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${Y7.default.inverse(t)}${n.join(``)}`}get cursor(){return this._cursor}constructor(e){super(e),this.on(`finalize`,()=>{this.value||=e.defaultValue})}};function nJe(){return H.platform===`win32`?!!H.env.CI||!!H.env.WT_SESSION||!!H.env.TERMINUS_SUBLIME||H.env.ConEmuTask===`{cmd::Cmder}`||H.env.TERM_PROGRAM===`Terminus-Sublime`||H.env.TERM_PROGRAM===`vscode`||H.env.TERM===`xterm-256color`||H.env.TERM===`alacritty`||H.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:H.env.TERM!==`linux`}const y9=nJe(),b9=(e,t)=>y9?e:t,rJe=b9(`◆`,`*`),x9=b9(`■`,`x`),S9=b9(`▲`,`x`),C9=b9(`◇`,`o`),iJe=b9(`┌`,`T`),w9=b9(`│`,`|`),T9=b9(`└`,`—`),E9=b9(`●`,`>`),D9=b9(`○`,` `),aJe=b9(`▪`,`•`),O9=b9(`─`,`-`),oJe=b9(`╮`,`+`),sJe=b9(`├`,`+`),cJe=b9(`╯`,`+`),k9=b9(`●`,`•`),A9=b9(`◆`,`*`),j9=b9(`▲`,`!`),M9=b9(`■`,`x`),N9=e=>{switch(e){case`initial`:case`active`:return Y7.default.cyan(rJe);case`cancel`:return Y7.default.red(x9);case`error`:return Y7.default.yellow(S9);case`submit`:return Y7.default.green(C9)}},lJe=e=>{let{cursor:t,options:n,style:r}=e,i=e.maxItems??1/0,a=Math.max(process.stdout.rows-4,0),o=Math.min(a,Math.max(i,5)),s=0;t>=s+o-3?s=Math.max(Math.min(t-o+3,n.length-o),0):t<s+2&&(s=Math.max(t-2,0));let c=o<n.length&&s>0,l=o<n.length&&s+o<n.length;return n.slice(s,s+o).map((e,n,i)=>{let a=n===0&&c,o=n===i.length-1&&l;return a||o?Y7.default.dim(`...`):r(e,n+s===t)})},uJe=e=>new tJe({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${Y7.default.gray(w9)}
75443
- ${N9(this.state)} ${e.message}
75444
- `,n=e.placeholder?Y7.default.inverse(e.placeholder[0])+Y7.default.dim(e.placeholder.slice(1)):Y7.default.inverse(Y7.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
75445
- ${Y7.default.yellow(w9)} ${r}
75446
- ${Y7.default.yellow(T9)} ${Y7.default.yellow(this.error)}
75447
- `;case`submit`:return`${t}${Y7.default.gray(w9)} ${Y7.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${Y7.default.gray(w9)} ${Y7.default.strikethrough(Y7.default.dim(this.value??``))}${this.value?.trim()?`
75448
- ${Y7.default.gray(w9)}`:``}`;default:return`${t}${Y7.default.cyan(w9)} ${r}
75449
- ${Y7.default.cyan(T9)}
75450
- `}}}).prompt(),dJe=e=>new Zqe({validate:e.validate,mask:e.mask??aJe,render(){let t=`${Y7.default.gray(w9)}
75451
- ${N9(this.state)} ${e.message}
75443
+ `)),this._prevFrame=e;return}this.output.write(Y7.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Yqe=class extends _9{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(Y7.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}};Object.defineProperty,Object.defineProperty;var Xqe=Object.defineProperty,Zqe=(e,t,n)=>t in e?Xqe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v9=(e,t,n)=>(Zqe(e,typeof t==`symbol`?t:t+``,n),n),Qqe=class extends _9{constructor({mask:e,...t}){super(t),v9(this,`valueWithCursor`,``),v9(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${X7.default.inverse(X7.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${X7.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},$qe=Object.defineProperty,eJe=(e,t,n)=>t in e?$qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y9=(e,t,n)=>(eJe(e,typeof t==`symbol`?t:t+``,n),n),tJe=class extends _9{constructor(e){super(e,!1),y9(this,`options`),y9(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};Object.defineProperty;var nJe=class extends _9{get valueWithCursor(){if(this.state===`submit`)return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${X7.default.inverse(t)}${n.join(``)}`}get cursor(){return this._cursor}constructor(e){super(e),this.on(`finalize`,()=>{this.value||=e.defaultValue})}};function rJe(){return H.platform===`win32`?!!H.env.CI||!!H.env.WT_SESSION||!!H.env.TERMINUS_SUBLIME||H.env.ConEmuTask===`{cmd::Cmder}`||H.env.TERM_PROGRAM===`Terminus-Sublime`||H.env.TERM_PROGRAM===`vscode`||H.env.TERM===`xterm-256color`||H.env.TERM===`alacritty`||H.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:H.env.TERM!==`linux`}const b9=rJe(),x9=(e,t)=>b9?e:t,iJe=x9(`◆`,`*`),S9=x9(`■`,`x`),C9=x9(`▲`,`x`),w9=x9(`◇`,`o`),aJe=x9(`┌`,`T`),T9=x9(`│`,`|`),E9=x9(`└`,`—`),D9=x9(`●`,`>`),O9=x9(`○`,` `),oJe=x9(`▪`,`•`),k9=x9(`─`,`-`),sJe=x9(`╮`,`+`),cJe=x9(`├`,`+`),lJe=x9(`╯`,`+`),A9=x9(`●`,`•`),j9=x9(`◆`,`*`),M9=x9(`▲`,`!`),N9=x9(`■`,`x`),P9=e=>{switch(e){case`initial`:case`active`:return X7.default.cyan(iJe);case`cancel`:return X7.default.red(S9);case`error`:return X7.default.yellow(C9);case`submit`:return X7.default.green(w9)}},uJe=e=>{let{cursor:t,options:n,style:r}=e,i=e.maxItems??1/0,a=Math.max(process.stdout.rows-4,0),o=Math.min(a,Math.max(i,5)),s=0;t>=s+o-3?s=Math.max(Math.min(t-o+3,n.length-o),0):t<s+2&&(s=Math.max(t-2,0));let c=o<n.length&&s>0,l=o<n.length&&s+o<n.length;return n.slice(s,s+o).map((e,n,i)=>{let a=n===0&&c,o=n===i.length-1&&l;return a||o?X7.default.dim(`...`):r(e,n+s===t)})},dJe=e=>new nJe({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${X7.default.gray(T9)}
75444
+ ${P9(this.state)} ${e.message}
75445
+ `,n=e.placeholder?X7.default.inverse(e.placeholder[0])+X7.default.dim(e.placeholder.slice(1)):X7.default.inverse(X7.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
75446
+ ${X7.default.yellow(T9)} ${r}
75447
+ ${X7.default.yellow(E9)} ${X7.default.yellow(this.error)}
75448
+ `;case`submit`:return`${t}${X7.default.gray(T9)} ${X7.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${X7.default.gray(T9)} ${X7.default.strikethrough(X7.default.dim(this.value??``))}${this.value?.trim()?`
75449
+ ${X7.default.gray(T9)}`:``}`;default:return`${t}${X7.default.cyan(T9)} ${r}
75450
+ ${X7.default.cyan(E9)}
75451
+ `}}}).prompt(),fJe=e=>new Qqe({validate:e.validate,mask:e.mask??oJe,render(){let t=`${X7.default.gray(T9)}
75452
+ ${P9(this.state)} ${e.message}
75452
75453
  `,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
75453
- ${Y7.default.yellow(w9)} ${r}
75454
- ${Y7.default.yellow(T9)} ${Y7.default.yellow(this.error)}
75455
- `;case`submit`:return`${t}${Y7.default.gray(w9)} ${Y7.default.dim(r)}`;case`cancel`:return`${t}${Y7.default.gray(w9)} ${Y7.default.strikethrough(Y7.default.dim(r??``))}${r?`
75456
- ${Y7.default.gray(w9)}`:``}`;default:return`${t}${Y7.default.cyan(w9)} ${n}
75457
- ${Y7.default.cyan(T9)}
75458
- `}}}).prompt(),P9=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Jqe({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${Y7.default.gray(w9)}
75459
- ${N9(this.state)} ${e.message}
75460
- `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${Y7.default.gray(w9)} ${Y7.default.dim(i)}`;case`cancel`:return`${r}${Y7.default.gray(w9)} ${Y7.default.strikethrough(Y7.default.dim(i))}
75461
- ${Y7.default.gray(w9)}`;default:return`${r}${Y7.default.cyan(w9)} ${this.value?`${Y7.default.green(E9)} ${t}`:`${Y7.default.dim(D9)} ${Y7.default.dim(t)}`} ${Y7.default.dim(`/`)} ${this.value?`${Y7.default.dim(D9)} ${Y7.default.dim(n)}`:`${Y7.default.green(E9)} ${n}`}
75462
- ${Y7.default.cyan(T9)}
75463
- `}}}).prompt()},F9=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`selected`:return`${Y7.default.dim(n)}`;case`active`:return`${Y7.default.green(E9)} ${n} ${e.hint?Y7.default.dim(`(${e.hint})`):``}`;case`cancelled`:return`${Y7.default.strikethrough(Y7.default.dim(n))}`;default:return`${Y7.default.dim(D9)} ${Y7.default.dim(n)}`}};return new eJe({options:e.options,initialValue:e.initialValue,render(){let n=`${Y7.default.gray(w9)}
75464
- ${N9(this.state)} ${e.message}
75465
- `;switch(this.state){case`submit`:return`${n}${Y7.default.gray(w9)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${n}${Y7.default.gray(w9)} ${t(this.options[this.cursor],`cancelled`)}
75466
- ${Y7.default.gray(w9)}`;default:return`${n}${Y7.default.cyan(w9)} ${lJe({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(e,n)=>t(e,n?`active`:`inactive`)}).join(`
75467
- ${Y7.default.cyan(w9)} `)}
75468
- ${Y7.default.cyan(T9)}
75469
- `}}}).prompt()},I9=(e=``,t=``)=>{let n=`
75454
+ ${X7.default.yellow(T9)} ${r}
75455
+ ${X7.default.yellow(E9)} ${X7.default.yellow(this.error)}
75456
+ `;case`submit`:return`${t}${X7.default.gray(T9)} ${X7.default.dim(r)}`;case`cancel`:return`${t}${X7.default.gray(T9)} ${X7.default.strikethrough(X7.default.dim(r??``))}${r?`
75457
+ ${X7.default.gray(T9)}`:``}`;default:return`${t}${X7.default.cyan(T9)} ${n}
75458
+ ${X7.default.cyan(E9)}
75459
+ `}}}).prompt(),F9=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Yqe({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${X7.default.gray(T9)}
75460
+ ${P9(this.state)} ${e.message}
75461
+ `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${X7.default.gray(T9)} ${X7.default.dim(i)}`;case`cancel`:return`${r}${X7.default.gray(T9)} ${X7.default.strikethrough(X7.default.dim(i))}
75462
+ ${X7.default.gray(T9)}`;default:return`${r}${X7.default.cyan(T9)} ${this.value?`${X7.default.green(D9)} ${t}`:`${X7.default.dim(O9)} ${X7.default.dim(t)}`} ${X7.default.dim(`/`)} ${this.value?`${X7.default.dim(O9)} ${X7.default.dim(n)}`:`${X7.default.green(D9)} ${n}`}
75463
+ ${X7.default.cyan(E9)}
75464
+ `}}}).prompt()},I9=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`selected`:return`${X7.default.dim(n)}`;case`active`:return`${X7.default.green(D9)} ${n} ${e.hint?X7.default.dim(`(${e.hint})`):``}`;case`cancelled`:return`${X7.default.strikethrough(X7.default.dim(n))}`;default:return`${X7.default.dim(O9)} ${X7.default.dim(n)}`}};return new tJe({options:e.options,initialValue:e.initialValue,render(){let n=`${X7.default.gray(T9)}
75465
+ ${P9(this.state)} ${e.message}
75466
+ `;switch(this.state){case`submit`:return`${n}${X7.default.gray(T9)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${n}${X7.default.gray(T9)} ${t(this.options[this.cursor],`cancelled`)}
75467
+ ${X7.default.gray(T9)}`;default:return`${n}${X7.default.cyan(T9)} ${uJe({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(e,n)=>t(e,n?`active`:`inactive`)}).join(`
75468
+ ${X7.default.cyan(T9)} `)}
75469
+ ${X7.default.cyan(E9)}
75470
+ `}}}).prompt()},L9=(e=``,t=``)=>{let n=`
75470
75471
  ${e}
75471
75472
  `.split(`
75472
- `),r=o(t).length,i=Math.max(n.reduce((e,t)=>{let n=o(t);return n.length>e?n.length:e},0),r)+2,a=n.map(e=>`${Y7.default.gray(w9)} ${Y7.default.dim(e)}${` `.repeat(i-o(e).length)}${Y7.default.gray(w9)}`).join(`
75473
- `);process.stdout.write(`${Y7.default.gray(w9)}
75474
- ${Y7.default.green(C9)} ${Y7.default.reset(t)} ${Y7.default.gray(O9.repeat(Math.max(i-r-1,1))+oJe)}
75473
+ `),r=o(t).length,i=Math.max(n.reduce((e,t)=>{let n=o(t);return n.length>e?n.length:e},0),r)+2,a=n.map(e=>`${X7.default.gray(T9)} ${X7.default.dim(e)}${` `.repeat(i-o(e).length)}${X7.default.gray(T9)}`).join(`
75474
+ `);process.stdout.write(`${X7.default.gray(T9)}
75475
+ ${X7.default.green(w9)} ${X7.default.reset(t)} ${X7.default.gray(k9.repeat(Math.max(i-r-1,1))+sJe)}
75475
75476
  ${a}
75476
- ${Y7.default.gray(sJe+O9.repeat(i+2)+cJe)}
75477
- `)},L9=(e=``)=>{process.stdout.write(`${Y7.default.gray(T9)} ${Y7.default.red(e)}
75477
+ ${X7.default.gray(cJe+k9.repeat(i+2)+lJe)}
75478
+ `)},R9=(e=``)=>{process.stdout.write(`${X7.default.gray(E9)} ${X7.default.red(e)}
75478
75479
 
75479
- `)},R9=(e=``)=>{process.stdout.write(`${Y7.default.gray(iJe)} ${e}
75480
- `)},z9=(e=``)=>{process.stdout.write(`${Y7.default.gray(w9)}
75481
- ${Y7.default.gray(T9)} ${e}
75480
+ `)},z9=(e=``)=>{process.stdout.write(`${X7.default.gray(aJe)} ${e}
75481
+ `)},B9=(e=``)=>{process.stdout.write(`${X7.default.gray(T9)}
75482
+ ${X7.default.gray(E9)} ${e}
75482
75483
 
75483
- `)},B9={message:(e=``,{symbol:t=Y7.default.gray(w9)}={})=>{let n=[`${Y7.default.gray(w9)}`];if(e){let[r,...i]=e.split(`
75484
- `);n.push(`${t} ${r}`,...i.map(e=>`${Y7.default.gray(w9)} ${e}`))}process.stdout.write(`${n.join(`
75484
+ `)},V9={message:(e=``,{symbol:t=X7.default.gray(T9)}={})=>{let n=[`${X7.default.gray(T9)}`];if(e){let[r,...i]=e.split(`
75485
+ `);n.push(`${t} ${r}`,...i.map(e=>`${X7.default.gray(T9)} ${e}`))}process.stdout.write(`${n.join(`
75485
75486
  `)}
75486
- `)},info:e=>{B9.message(e,{symbol:Y7.default.blue(k9)})},success:e=>{B9.message(e,{symbol:Y7.default.green(A9)})},step:e=>{B9.message(e,{symbol:Y7.default.green(C9)})},warn:e=>{B9.message(e,{symbol:Y7.default.yellow(j9)})},warning:e=>{B9.warn(e)},error:e=>{B9.message(e,{symbol:Y7.default.red(M9)})}},V9=`${Y7.default.gray(w9)} `,H9={message:async(e,{symbol:t=Y7.default.gray(w9)}={})=>{process.stdout.write(`${Y7.default.gray(w9)}
75487
+ `)},info:e=>{V9.message(e,{symbol:X7.default.blue(A9)})},success:e=>{V9.message(e,{symbol:X7.default.green(j9)})},step:e=>{V9.message(e,{symbol:X7.default.green(w9)})},warn:e=>{V9.message(e,{symbol:X7.default.yellow(M9)})},warning:e=>{V9.warn(e)},error:e=>{V9.message(e,{symbol:X7.default.red(N9)})}},H9=`${X7.default.gray(T9)} `,U9={message:async(e,{symbol:t=X7.default.gray(T9)}={})=>{process.stdout.write(`${X7.default.gray(T9)}
75487
75488
  ${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
75488
- ${V9}`),t.includes(`
75489
+ ${H9}`),t.includes(`
75489
75490
  `)&&(n=3+o(t.slice(t.lastIndexOf(`
75490
75491
  `))).length);let e=o(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
75491
- ${V9}${t.trimStart()}`),n=3+o(t.trimStart()).length)}process.stdout.write(`
75492
- `)},info:e=>H9.message(e,{symbol:Y7.default.blue(k9)}),success:e=>H9.message(e,{symbol:Y7.default.green(A9)}),step:e=>H9.message(e,{symbol:Y7.default.green(C9)}),warn:e=>H9.message(e,{symbol:Y7.default.yellow(j9)}),warning:e=>H9.warn(e),error:e=>H9.message(e,{symbol:Y7.default.red(M9)})},U9=({indicator:e=`dots`}={})=>{let t=y9?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],n=y9?80:120,r=process.env.CI===`true`,i,a,o=!1,s=``,c,l=performance.now(),u=e=>{o&&y(e>1?`Something went wrong`:`Canceled`,e)},d=()=>u(2),f=()=>u(1),p=()=>{process.on(`uncaughtExceptionMonitor`,d),process.on(`unhandledRejection`,d),process.on(`SIGINT`,f),process.on(`SIGTERM`,f),process.on(`exit`,u)},m=()=>{process.removeListener(`uncaughtExceptionMonitor`,d),process.removeListener(`unhandledRejection`,d),process.removeListener(`SIGINT`,f),process.removeListener(`SIGTERM`,f),process.removeListener(`exit`,u)},h=()=>{if(c===void 0)return;r&&process.stdout.write(`
75492
+ ${H9}${t.trimStart()}`),n=3+o(t.trimStart()).length)}process.stdout.write(`
75493
+ `)},info:e=>U9.message(e,{symbol:X7.default.blue(A9)}),success:e=>U9.message(e,{symbol:X7.default.green(j9)}),step:e=>U9.message(e,{symbol:X7.default.green(w9)}),warn:e=>U9.message(e,{symbol:X7.default.yellow(M9)}),warning:e=>U9.warn(e),error:e=>U9.message(e,{symbol:X7.default.red(N9)})},W9=({indicator:e=`dots`}={})=>{let t=b9?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],n=b9?80:120,r=process.env.CI===`true`,i,a,o=!1,s=``,c,l=performance.now(),u=e=>{o&&y(e>1?`Something went wrong`:`Canceled`,e)},d=()=>u(2),f=()=>u(1),p=()=>{process.on(`uncaughtExceptionMonitor`,d),process.on(`unhandledRejection`,d),process.on(`SIGINT`,f),process.on(`SIGTERM`,f),process.on(`exit`,u)},m=()=>{process.removeListener(`uncaughtExceptionMonitor`,d),process.removeListener(`unhandledRejection`,d),process.removeListener(`SIGINT`,f),process.removeListener(`SIGTERM`,f),process.removeListener(`exit`,u)},h=()=>{if(c===void 0)return;r&&process.stdout.write(`
75493
75494
  `);let e=c.split(`
75494
- `);process.stdout.write(J7.cursor.move(-999,e.length-1)),process.stdout.write(J7.erase.down(e.length))},g=e=>e.replace(/\.+$/,``),_=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},v=(u=``)=>{o=!0,i=Gqe(),s=g(u),l=performance.now(),process.stdout.write(`${Y7.default.gray(w9)}
75495
- `);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=Y7.default.magenta(t[d]);if(r)process.stdout.write(`${n} ${s}...`);else if(e===`timer`)process.stdout.write(`${n} ${s} ${_(l)}`);else{let e=`.`.repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${n} ${s}${e}`)}d=d+1<t.length?d+1:0,f=f<t.length?f+.125:0},n)},y=(t=``,n=0)=>{o=!1,clearInterval(a),h();let r=n===0?Y7.default.green(C9):n===1?Y7.default.red(x9):Y7.default.red(S9);s=g(t??s),e===`timer`?process.stdout.write(`${r} ${s} ${_(l)}
75495
+ `);process.stdout.write(Y7.cursor.move(-999,e.length-1)),process.stdout.write(Y7.erase.down(e.length))},g=e=>e.replace(/\.+$/,``),_=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},v=(u=``)=>{o=!0,i=Kqe(),s=g(u),l=performance.now(),process.stdout.write(`${X7.default.gray(T9)}
75496
+ `);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=X7.default.magenta(t[d]);if(r)process.stdout.write(`${n} ${s}...`);else if(e===`timer`)process.stdout.write(`${n} ${s} ${_(l)}`);else{let e=`.`.repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${n} ${s}${e}`)}d=d+1<t.length?d+1:0,f=f<t.length?f+.125:0},n)},y=(t=``,n=0)=>{o=!1,clearInterval(a),h();let r=n===0?X7.default.green(w9):n===1?X7.default.red(S9):X7.default.red(C9);s=g(t??s),e===`timer`?process.stdout.write(`${r} ${s} ${_(l)}
75496
75497
  `):process.stdout.write(`${r} ${s}
75497
- `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}};async function W9(e){let{authManager:t,apiClient:n,reason:r,version:i}=e;if(t.isEnvAuth()||r===`welcome`&&t.isAuthenticated())return{success:!0};for(R9(r===`welcome`?`Welcome to Abacus.AI CLI v${i}`:r===`expired`?`Session expired — please log in again`:`Invalid credentials — please log in again`);;){let e=await F9({message:`How would you like to log in?`,options:[{value:`email`,label:`Log in with email`},{value:`apikey`,label:`Log in with API key`}]});if(p9(e))return L9(`Login cancelled`),{success:!1};if(e===`email`){let e=await fJe(t,n);if(e===`cancel`)return L9(`Login cancelled`),{success:!1};if(e===`success`)return z9(`You're all set!`),{success:!0}}else{let e=await pJe(t,n);if(e===`cancel`)return L9(`Login cancelled`),{success:!1};if(e===`success`)return z9(`You're all set!`),{success:!0}}}}async function fJe(e,t){let n=await uJe({message:`Enter your email address`,placeholder:`you@example.com`,validate:e=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return`Please enter a valid email address`}});if(p9(n))return`cancel`;let r=U9();r.start(`Initiating device code login...`);let i,a,o;try{let e=await FJ(),s=await t.authenticateDeviceForCodeLlm(n,e);if(!s?.success||!s?.result)return r.stop(`Failed to initiate login`),B9.error(s?.error??`Failed to start device code login`),`retry`;i=s.result.verificationUri,a=s.result.userCode,o=s.result.pollingInterval??5,r.stop(`Device code ready`)}catch(e){return r.stop(`Connection failed`),B9.error(e instanceof Error?e.message:`Failed to connect`),`retry`}I9(`URL: ${i}\nCode: ${a}`,`Open the URL and enter the code to log in`);let[s,c]=await Promise.all([p6(i),m6(a)]);s&&c?B9.info(`Opening browser... (code copied to clipboard)`):s?B9.info(`Opening browser...`):c?B9.info(`Code copied to clipboard. Please open the URL manually.`):B9.info(`Please open the URL above and enter the code to log in.`);let l=U9();l.start(`Waiting for authentication...`);let u=Date.now()+600*1e3,d=o*1e3;for(;Date.now()<u;){await new Promise(e=>setTimeout(e,d));try{let n=await t.pollDeviceCode(a);if(n?.success&&n.result?.deviceCode){if(await e.loginWithDeviceCode(n.result.deviceCode),n.result.chatWebUrl){let e=n.result.chatWebUrl.replace(/^https?:\/\//,``);t.setChatWebDomain(e)}return l.stop(`Authenticated!`),B9.success(`Logged in successfully`),`success`}}catch{}}return l.stop(`Timed out`),B9.error(`Authentication timed out. Please try again.`),`retry`}async function pJe(e,t){let n=await dJe({message:`Enter your API key`});if(p9(n))return`cancel`;let r=U9();r.start(`Validating API key...`);try{await e.loginWithApiKey(n);let i=await t.getUserInfo();return i?.result?.email?(r.stop(`Authenticated!`),B9.success(`Logged in as ${i.result.email}`),`success`):(await e.logout(),r.stop(`Invalid API key`),B9.error(`Invalid API key — authentication failed`),`retry`)}catch(t){return await e.logout(),r.stop(`Login failed`),B9.error(t instanceof Error?t.message:`API key login failed`),`retry`}}function G9(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function mJe(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function hJe(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function gJe(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 _Je(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function vJe(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(hJe(o)){let e=gJe(n);t=_Je(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=yJe(n);return a.push(...o),a}function yJe(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(G9(r)&&w7.has(K9(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(mJe(i[i.length-1]))break;if(G9(t)&&w7.has(K9(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 K9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function bJe(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 xJe({timing:e}){let{setTitle:t}=W7(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,clearQueue:u,totalCredits:d}=d3(),f=(0,Z.useRef)(null),{authExpired:p,clearAuthExpired:m}=o3();(0,Z.useEffect)(()=>{p&&(s(`Session expired — use /login to authenticate again.`,`error`),m())},[p,s,m]);let[h,g]=(0,Z.useState)(!1);bZ((e,t)=>{(t.ctrl||t.super)&&e===`o`&&g(e=>!e)});let _=Oqe(n),{lastItem:v,prevItems:y}=(0,Z.useMemo)(()=>{let e=vJe(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:b,thinkingEndTime:x}=(0,Z.useMemo)(()=>bJe(n),[n]),S=(0,Z.useRef)(Sd.Idle),[C,w]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let e=S.current===Sd.Idle,t=r!==Sd.Idle&&r!==Sd.WaitingForToolPermission;e&&t?w(Date.now()):r===Sd.Idle&&w(null),S.current=r},[r]);let T=r===Sd.WaitingForToolPermission&&i!==null,[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(`0`),[A,j]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,Z.useEffect)(()=>ZZ(async()=>{let t=e.getFormattedDuration();j(d),k(t),D(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,d]);let M=Tqe({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:h,composerHasText:()=>f.current?.hasText()??!1,hasQueuedMessages:()=>f.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>f.current?.saveAndClear(),clearComposer:()=>f.current?.clear(),dequeueAllToComposer:()=>f.current?.dequeueAllToComposer(),clearQueue:u,exitApp:()=>QZ(0)}),N=r!==Sd.Idle&&r!==Sd.WaitingForToolPermission,P=i?.request.tool.id??null;return(0,X.jsx)(G0.Provider,{value:h,children:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Q,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,X.jsx)(H8,{}),(0,X.jsxs)(C0.Provider,{value:P,children:[y.map(e=>e.kind===`compacted`?h?e.segments.map(e=>(0,X.jsx)(b7,{segment:e},e.id)):(0,X.jsx)(_3,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,X.jsx)(b7,{segment:e.segment},e.segment.id):h?e.segments.map(e=>(0,X.jsx)(b7,{segment:e},e.id)):(0,X.jsx)(E7,{segments:e.segments},e.id)),v&&(v.kind===`compacted`?h?v.segments.map(e=>(0,X.jsx)(b7,{segment:e},e.id)):(0,X.jsx)(_3,{counts:v.counts,segments:v.segments},v.id):v.kind===`segment`?(0,X.jsx)(b7,{segment:v.segment},v.segment.id):h?v.segments.map(e=>(0,X.jsx)(b7,{segment:e},e.id)):(0,X.jsx)(E7,{segments:v.segments},v.id))]}),[`1`,`true`,`yes`].includes((process.env[`${hn.internalEnvPrefix}TODO_TOOL_UI`]??``).trim().toLowerCase())&&(0,X.jsx)(C7,{state:_}),N&&(0,X.jsx)(Q6,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(_qe,{status:r,thinkingStartTime:b,thinkingEndTime:x,runStartTime:C})})]}),E?(0,X.jsx)($6,{duration:O,credits:A,conversationId:o}):(0,X.jsxs)(X.Fragment,{children:[T&&(0,X.jsx)(Q6,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(H7,{pendingTool:i})}),(0,X.jsx)(Z.Activity,{mode:T?`hidden`:`visible`,children:(0,X.jsx)(Q6,{fallback:e=>(0,X.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,X.jsx)($,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,X.jsx)($,{color:`yellow`,children:e.message}),(0,X.jsxs)($,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,hn.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(Z6,{hints:M,composerRef:f})})})]})]})})}async function SJe({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=xd.Yolo;break;case`accept-edits`:i=xd.AcceptEdits;break;case`plan`:i=xd.PlanMode;break;default:i=xd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=xd.Yolo:r?.[`auto-accept-edits`]?i=xd.AcceptEdits:r?.[`plan-mode`]&&(i=xd.PlanMode);await iMe();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(uZ),l=()=>s(lZ),u=!1;for(;;){u=!1;let a=new ENe,o=new rUe,s=null,d=()=>{u=!0,s?.unmount()};c();let f=IMe((0,X.jsx)(s3,{client:e,authManager:t,onAuthExpired:d,children:(0,X.jsx)(DNe,{client:a,children:(0,X.jsx)(x3,{children:(0,X.jsx)(G7,{children:(0,X.jsx)(HHe,{children:(0,X.jsx)(hUe,{configService:n,children:(0,X.jsx)(zHe,{children:(0,X.jsx)(W0,{initialMode:i,children:(0,X.jsx)(BHe,{children:(0,X.jsx)(u3,{apiClient:e,configService:n,agentArgs:r,children:(0,X.jsx)(xJe,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
75498
+ `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}};async function G9(e){let{authManager:t,apiClient:n,reason:r,version:i}=e;if(t.isEnvAuth()||r===`welcome`&&t.isAuthenticated())return{success:!0};for(z9(r===`welcome`?`Welcome to Abacus.AI CLI v${i}`:r===`expired`?`Session expired — please log in again`:`Invalid credentials — please log in again`);;){let e=await I9({message:`How would you like to log in?`,options:[{value:`email`,label:`Log in with email`},{value:`apikey`,label:`Log in with API key`}]});if(m9(e))return R9(`Login cancelled`),{success:!1};if(e===`email`){let e=await pJe(t,n);if(e===`cancel`)return R9(`Login cancelled`),{success:!1};if(e===`success`)return B9(`You're all set!`),{success:!0}}else{let e=await mJe(t,n);if(e===`cancel`)return R9(`Login cancelled`),{success:!1};if(e===`success`)return B9(`You're all set!`),{success:!0}}}}async function pJe(e,t){let n=await dJe({message:`Enter your email address`,placeholder:`you@example.com`,validate:e=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return`Please enter a valid email address`}});if(m9(n))return`cancel`;let r=W9();r.start(`Initiating device code login...`);let i,a,o;try{let e=await FJ(),s=await t.authenticateDeviceForCodeLlm(n,e);if(!s?.success||!s?.result)return r.stop(`Failed to initiate login`),V9.error(s?.error??`Failed to start device code login`),`retry`;i=s.result.verificationUri,a=s.result.userCode,o=s.result.pollingInterval??5,r.stop(`Device code ready`)}catch(e){return r.stop(`Connection failed`),V9.error(e instanceof Error?e.message:`Failed to connect`),`retry`}L9(`URL: ${i}\nCode: ${a}`,`Open the URL and enter the code to log in`);let[s,c]=await Promise.all([p6(i),m6(a)]);s&&c?V9.info(`Opening browser... (code copied to clipboard)`):s?V9.info(`Opening browser...`):c?V9.info(`Code copied to clipboard. Please open the URL manually.`):V9.info(`Please open the URL above and enter the code to log in.`);let l=W9();l.start(`Waiting for authentication...`);let u=Date.now()+600*1e3,d=o*1e3;for(;Date.now()<u;){await new Promise(e=>setTimeout(e,d));try{let n=await t.pollDeviceCode(a);if(n?.success&&n.result?.deviceCode){if(await e.loginWithDeviceCode(n.result.deviceCode),n.result.chatWebUrl){let e=n.result.chatWebUrl.replace(/^https?:\/\//,``);t.setChatWebDomain(e)}return l.stop(`Authenticated!`),V9.success(`Logged in successfully`),`success`}}catch{}}return l.stop(`Timed out`),V9.error(`Authentication timed out. Please try again.`),`retry`}async function mJe(e,t){let n=await fJe({message:`Enter your API key`});if(m9(n))return`cancel`;let r=W9();r.start(`Validating API key...`);try{await e.loginWithApiKey(n);let i=await t.getUserInfo();return i?.result?.email?(r.stop(`Authenticated!`),V9.success(`Logged in as ${i.result.email}`),`success`):(await e.logout(),r.stop(`Invalid API key`),V9.error(`Invalid API key — authentication failed`),`retry`)}catch(t){return await e.logout(),r.stop(`Login failed`),V9.error(t instanceof Error?t.message:`API key login failed`),`retry`}}function K9(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function hJe(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function gJe(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function _Je(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 vJe(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function yJe(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(gJe(o)){let e=_Je(n);t=vJe(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=bJe(n);return a.push(...o),a}function bJe(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(K9(r)&&T7.has(q9(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(hJe(i[i.length-1]))break;if(K9(t)&&T7.has(q9(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 q9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function xJe(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 SJe({timing:e}){let{setTitle:t}=G7(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,clearQueue:u,totalCredits:d}=d3(),f=(0,Z.useRef)(null),{authExpired:p,clearAuthExpired:m}=o3();(0,Z.useEffect)(()=>{p&&(s(`Session expired — use /login to authenticate again.`,`error`),m())},[p,s,m]);let[h,g]=(0,Z.useState)(!1);bZ((e,t)=>{(t.ctrl||t.super)&&e===`o`&&g(e=>!e)});let _=kqe(n),{lastItem:v,prevItems:y}=(0,Z.useMemo)(()=>{let e=yJe(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:b,thinkingEndTime:x}=(0,Z.useMemo)(()=>xJe(n),[n]),S=(0,Z.useRef)(Sd.Idle),[C,w]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let e=S.current===Sd.Idle,t=r!==Sd.Idle&&r!==Sd.WaitingForToolPermission;e&&t?w(Date.now()):r===Sd.Idle&&w(null),S.current=r},[r]);let T=r===Sd.WaitingForToolPermission&&i!==null,[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(`0`),[A,j]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,Z.useEffect)(()=>ZZ(async()=>{let t=e.getFormattedDuration();j(d),k(t),D(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,d]);let M=Eqe({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:h,composerHasText:()=>f.current?.hasText()??!1,hasQueuedMessages:()=>f.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>f.current?.saveAndClear(),clearComposer:()=>f.current?.clear(),dequeueAllToComposer:()=>f.current?.dequeueAllToComposer(),clearQueue:u,exitApp:()=>QZ(0)}),N=r!==Sd.Idle&&r!==Sd.WaitingForToolPermission,P=i?.request.tool.id??null;return(0,X.jsx)(G0.Provider,{value:h,children:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Q,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,X.jsx)(U8,{}),(0,X.jsxs)(C0.Provider,{value:P,children:[y.map(e=>e.kind===`compacted`?h?e.segments.map(e=>(0,X.jsx)(x7,{segment:e},e.id)):(0,X.jsx)(_3,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,X.jsx)(x7,{segment:e.segment},e.segment.id):h?e.segments.map(e=>(0,X.jsx)(x7,{segment:e},e.id)):(0,X.jsx)(D7,{segments:e.segments},e.id)),v&&(v.kind===`compacted`?h?v.segments.map(e=>(0,X.jsx)(x7,{segment:e},e.id)):(0,X.jsx)(_3,{counts:v.counts,segments:v.segments},v.id):v.kind===`segment`?(0,X.jsx)(x7,{segment:v.segment},v.segment.id):h?v.segments.map(e=>(0,X.jsx)(x7,{segment:e},e.id)):(0,X.jsx)(D7,{segments:v.segments},v.id))]}),!h&&(0,X.jsx)(w7,{state:_}),N&&(0,X.jsx)($6,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(_qe,{status:r,thinkingStartTime:b,thinkingEndTime:x,runStartTime:C})})]}),E?(0,X.jsx)(e8,{duration:O,credits:A,conversationId:o}):(0,X.jsxs)(X.Fragment,{children:[T&&(0,X.jsx)($6,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(U7,{pendingTool:i})}),(0,X.jsx)(Z.Activity,{mode:T?`hidden`:`visible`,children:(0,X.jsx)($6,{fallback:e=>(0,X.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,X.jsx)($,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,X.jsx)($,{color:`yellow`,children:e.message}),(0,X.jsxs)($,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,hn.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(Q6,{hints:M,composerRef:f})})})]})]})})}async function CJe({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=xd.Yolo;break;case`accept-edits`:i=xd.AcceptEdits;break;case`plan`:i=xd.PlanMode;break;default:i=xd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=xd.Yolo:r?.[`auto-accept-edits`]?i=xd.AcceptEdits:r?.[`plan-mode`]&&(i=xd.PlanMode);await iMe();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(uZ),l=()=>s(lZ),u=!1;for(;;){u=!1;let a=new ENe,o=new rUe,s=null,d=()=>{u=!0,s?.unmount()};c();let f=IMe((0,X.jsx)(s3,{client:e,authManager:t,onAuthExpired:d,children:(0,X.jsx)(DNe,{client:a,children:(0,X.jsx)(x3,{children:(0,X.jsx)(K7,{children:(0,X.jsx)(HHe,{children:(0,X.jsx)(hUe,{configService:n,children:(0,X.jsx)(zHe,{children:(0,X.jsx)(W0,{initialMode:i,children:(0,X.jsx)(BHe,{children:(0,X.jsx)(u3,{apiClient:e,configService:n,agentArgs:r,children:(0,X.jsx)(SJe,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
75498
75499
  Abacus.AI has been suspended. Run \`fg\` to bring Abacus back.
75499
- `)}});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 W9({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Qe(EZ()))).default.version})).success)break}}const CJe=dt([`codellm`,`cli`,`auth`]);async function wJe(e){let t=await PJ.create(),n=new Ul(t,Sn(),gn.userAgentNames.cli,DZ.default.version),r=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await r.load();let i=r.get(`baseUrl`);if(typeof i==`string`&&i)try{new URL(i),n.setUrl(i),n.resetEndpoints(),await n.getApiEndpoint()}catch{CJe.error`Invalid base URL: ${i}`,process.exit(1)}let a=!0;switch(e){case`login`:await TJe(t,n);break;case`logout`:a=await EJe(t);break;case`status`:await DJe(t,n);break;case`switch`:a=await OJe(t,n);break}process.exit(a?0:1)}async function TJe(e,t){if(e.isEnvAuth()){B9.warn(`Currently authenticated via environment variable. Login is not needed.`);return}if(e.isAuthenticated()){let n=(await t.getUserInfo().catch(()=>null))?.result?.email;n&&B9.info(`Already logged in as ${iZ().bold().render(n)}`);let r=await P9({message:`Do you want to log in with a different account?`});if(p9(r)||!r)return;await e.logout()}await W9({authManager:e,apiClient:t,reason:`welcome`,version:DZ.default.version})}async function EJe(e){return e.isEnvAuth()?(B9.warn(`Currently authenticated via environment variable. Unset the environment variable to log out.`),!0):e.isAuthenticated()?await e.logout()?(B9.success(`Logged out successfully.`),!0):(B9.error(`Failed to log out.`),!1):(B9.info(`Not currently logged in.`),!0)}async function DJe(e,t){let n=e.getAuthKind();if(n.type===`logged_out`){console.log(aZ(`yellow`)(`Not logged in`));return}let r=n.type===`env_api_key`||n.type===`env_device_code`?`environment variable`:n.type===`api_key`?`API key`:n.type===`device_code`?`device code`:`OAuth token`;console.log(iZ().bold().render(`Authentication Status`)),console.log(` Method: ${r}`);try{let e=await t.getUserInfo();if(e?.result){let{email:t,name:n,organization:r}=e.result;n&&console.log(` Name: ${n}`),t&&console.log(` Email: ${t}`),r?.name&&console.log(` Org: ${r.name}`)}}catch{console.log(iZ().dim().render(` (Could not fetch user details)`))}}async function OJe(e,t){if(!e.isAuthenticated())return B9.error("Not logged in. Run `auth login` first."),!1;let n=U9();n.start(`Fetching organizations...`);let r;try{let e=await t.listOrganizations();if(!e?.success||!e.result)return n.stop(`Failed to fetch organizations`),B9.error(`Could not retrieve organizations.`),!1;r=e.result,n.stop(`Organizations loaded`)}catch{return n.stop(`Failed`),B9.error(`Could not fetch organizations.`),!1}if(r.length===0)return B9.info(`No organizations available.`),!0;let i;try{i=(await t.getUserInfo())?.result?.organization?.organizationId}catch{}let a=await F9({message:`Select an organization to switch to`,options:r.map(e=>({value:e.organizationId,label:e.name,hint:e.organizationId===i?`current`:e.workspace}))});if(p9(a))return L9(`Cancelled`),!0;if(a===i)return B9.info(`Already on this organization.`),!0;let o=U9();o.start(`Switching organization...`);try{if(await t.switchOrganization(a)){let e=r.find(e=>e.organizationId===a)?.name??a;return o.stop(`Done`),B9.success(`Switched to ${iZ().bold().render(e)}`),!0}else return o.stop(`Failed`),B9.error(`Failed to switch organization.`),!1}catch{return o.stop(`Failed`),B9.error(`Failed to switch organization.`),!1}}async function q9(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&IZ()||!n&&!r)return{action:`skipped`};let o;try{o=await LZ(t,i,a,{includeDev:n})}catch{return n?(B9.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&B9.success(`Already up to date (${t})`),{action:`skipped`};if(!n&&o.isEphemeral)return{action:`skipped`};let s=o.installationType===`native`,c=s?`Download v${o.latestVersion}`:RZ(o);R9(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||I9(c,`Install command`);let l=await P9({message:`Would you like to update now?`,initialValue:!0});if(p9(l))return L9(`Update cancelled`),{action:`exit`};if(l){let e=U9();e.start(`Updating...`);let{ok:t,output:n}=s?await BZ(o):zZ(o);if(t)return e.stop(`Updated to ${o.latestVersion}`),n&&I9(n,`Install output`),z9(`Restarting...`),{action:`updated`,version:o.latestVersion};{e.stop(`Update failed`),n&&I9(n,`Error output`),B9.error(`Update failed. You can try manually running the command above.`);let t=await P9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return p9(t)||!t?(L9(`Exiting`),{action:`exit`}):(z9(`Continuing with v${o.currentVersion}`),{action:`continue`})}}let u=await P9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return p9(u)||!u?(L9(`Exiting`),{action:`exit`}):(z9(`Continuing with v${o.currentVersion}`),{action:`continue`})}function kJe(e,t){switch(e){case`bash`:return jJe(t);case`zsh`:return MJe(t);case`fish`:return NJe(t);case`pwsh`:return PJe(t)}}function J9(){if(process.env.PSModulePath!==void 0)return`pwsh`;let e=process.env.SHELL??``;return e.endsWith(`zsh`)?`zsh`:e.endsWith(`bash`)?`bash`:e.endsWith(`fish`)?`fish`:process.platform===`win32`?`pwsh`:null}function AJe(e,t,n){switch(e){case`bash`:return n===`darwin`?[`${t}/.bash_profile`,`${t}/.bashrc`]:[`${t}/.bashrc`,`${t}/.bash_profile`];case`zsh`:return[`${t}/.zshrc`];case`fish`:return[`${t}/.config/fish/config.fish`];case`pwsh`:{let e=n===`win32`?te():t;return n===`win32`?[`${e}\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1`,`${e}\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1`]:[`${t}/.config/powershell/Microsoft.PowerShell_profile.ps1`,`${t}/.config/powershell/profile.ps1`]}}}const Y9=`# Abacus AI shell integration`;function jJe(e){return`\
75500
- ${Y9}
75500
+ `)}});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 G9({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Qe(EZ()))).default.version})).success)break}}const wJe=dt([`codellm`,`cli`,`auth`]);async function TJe(e){let t=await PJ.create(),n=new Ul(t,Sn(),gn.userAgentNames.cli,DZ.default.version),r=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await r.load();let i=r.get(`baseUrl`);if(typeof i==`string`&&i)try{new URL(i),n.setUrl(i),n.resetEndpoints(),await n.getApiEndpoint()}catch{wJe.error`Invalid base URL: ${i}`,process.exit(1)}let a=!0;switch(e){case`login`:await EJe(t,n);break;case`logout`:a=await DJe(t);break;case`status`:await OJe(t,n);break;case`switch`:a=await kJe(t,n);break}process.exit(a?0:1)}async function EJe(e,t){if(e.isEnvAuth()){V9.warn(`Currently authenticated via environment variable. Login is not needed.`);return}if(e.isAuthenticated()){let n=(await t.getUserInfo().catch(()=>null))?.result?.email;n&&V9.info(`Already logged in as ${iZ().bold().render(n)}`);let r=await F9({message:`Do you want to log in with a different account?`});if(m9(r)||!r)return;await e.logout()}await G9({authManager:e,apiClient:t,reason:`welcome`,version:DZ.default.version})}async function DJe(e){return e.isEnvAuth()?(V9.warn(`Currently authenticated via environment variable. Unset the environment variable to log out.`),!0):e.isAuthenticated()?await e.logout()?(V9.success(`Logged out successfully.`),!0):(V9.error(`Failed to log out.`),!1):(V9.info(`Not currently logged in.`),!0)}async function OJe(e,t){let n=e.getAuthKind();if(n.type===`logged_out`){console.log(aZ(`yellow`)(`Not logged in`));return}let r=n.type===`env_api_key`||n.type===`env_device_code`?`environment variable`:n.type===`api_key`?`API key`:n.type===`device_code`?`device code`:`OAuth token`;console.log(iZ().bold().render(`Authentication Status`)),console.log(` Method: ${r}`);try{let e=await t.getUserInfo();if(e?.result){let{email:t,name:n,organization:r}=e.result;n&&console.log(` Name: ${n}`),t&&console.log(` Email: ${t}`),r?.name&&console.log(` Org: ${r.name}`)}}catch{console.log(iZ().dim().render(` (Could not fetch user details)`))}}async function kJe(e,t){if(!e.isAuthenticated())return V9.error("Not logged in. Run `auth login` first."),!1;let n=W9();n.start(`Fetching organizations...`);let r;try{let e=await t.listOrganizations();if(!e?.success||!e.result)return n.stop(`Failed to fetch organizations`),V9.error(`Could not retrieve organizations.`),!1;r=e.result,n.stop(`Organizations loaded`)}catch{return n.stop(`Failed`),V9.error(`Could not fetch organizations.`),!1}if(r.length===0)return V9.info(`No organizations available.`),!0;let i;try{i=(await t.getUserInfo())?.result?.organization?.organizationId}catch{}let a=await I9({message:`Select an organization to switch to`,options:r.map(e=>({value:e.organizationId,label:e.name,hint:e.organizationId===i?`current`:e.workspace}))});if(m9(a))return R9(`Cancelled`),!0;if(a===i)return V9.info(`Already on this organization.`),!0;let o=W9();o.start(`Switching organization...`);try{if(await t.switchOrganization(a)){let e=r.find(e=>e.organizationId===a)?.name??a;return o.stop(`Done`),V9.success(`Switched to ${iZ().bold().render(e)}`),!0}else return o.stop(`Failed`),V9.error(`Failed to switch organization.`),!1}catch{return o.stop(`Failed`),V9.error(`Failed to switch organization.`),!1}}async function J9(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&IZ()||!n&&!r)return{action:`skipped`};let o;try{o=await LZ(t,i,a,{includeDev:n})}catch{return n?(V9.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&V9.success(`Already up to date (${t})`),{action:`skipped`};if(!n&&o.isEphemeral)return{action:`skipped`};let s=o.installationType===`native`,c=s?`Download v${o.latestVersion}`:RZ(o);z9(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||L9(c,`Install command`);let l=await F9({message:`Would you like to update now?`,initialValue:!0});if(m9(l))return R9(`Update cancelled`),{action:`exit`};if(l){let e=W9();e.start(`Updating...`);let{ok:t,output:n}=s?await BZ(o):zZ(o);if(t)return e.stop(`Updated to ${o.latestVersion}`),n&&L9(n,`Install output`),B9(`Restarting...`),{action:`updated`,version:o.latestVersion};{e.stop(`Update failed`),n&&L9(n,`Error output`),V9.error(`Update failed. You can try manually running the command above.`);let t=await F9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return m9(t)||!t?(R9(`Exiting`),{action:`exit`}):(B9(`Continuing with v${o.currentVersion}`),{action:`continue`})}}let u=await F9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return m9(u)||!u?(R9(`Exiting`),{action:`exit`}):(B9(`Continuing with v${o.currentVersion}`),{action:`continue`})}function AJe(e,t){switch(e){case`bash`:return MJe(t);case`zsh`:return NJe(t);case`fish`:return PJe(t);case`pwsh`:return FJe(t)}}function Y9(){if(process.env.PSModulePath!==void 0)return`pwsh`;let e=process.env.SHELL??``;return e.endsWith(`zsh`)?`zsh`:e.endsWith(`bash`)?`bash`:e.endsWith(`fish`)?`fish`:process.platform===`win32`?`pwsh`:null}function jJe(e,t,n){switch(e){case`bash`:return n===`darwin`?[`${t}/.bash_profile`,`${t}/.bashrc`]:[`${t}/.bashrc`,`${t}/.bash_profile`];case`zsh`:return[`${t}/.zshrc`];case`fish`:return[`${t}/.config/fish/config.fish`];case`pwsh`:{let e=n===`win32`?te():t;return n===`win32`?[`${e}\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1`,`${e}\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1`]:[`${t}/.config/powershell/Microsoft.PowerShell_profile.ps1`,`${t}/.config/powershell/profile.ps1`]}}}const X9=`# Abacus AI shell integration`;function MJe(e){return`\
75501
+ ${X9}
75501
75502
 
75502
75503
  # ── command-not-found hook ──────────────────────────────────────────────────
75503
75504
  # Routes unrecognised multi-word commands through ${e} --print so natural
@@ -75603,8 +75604,8 @@ _${e}_completions() {
75603
75604
  fi ;;
75604
75605
  esac
75605
75606
  }
75606
- complete -o default -F _${e}_completions ${e}`}function MJe(e){return`\
75607
- ${Y9}
75607
+ complete -o default -F _${e}_completions ${e}`}function NJe(e){return`\
75608
+ ${X9}
75608
75609
 
75609
75610
  # ── command-not-found hook ──────────────────────────────────────────────────
75610
75611
  _${e}_looks_like_nl() {
@@ -75685,8 +75686,8 @@ _${e}() {
75685
75686
  esac ;;
75686
75687
  esac
75687
75688
  }
75688
- compdef _${e} ${e}`}function NJe(e){return`\
75689
- ${Y9}
75689
+ compdef _${e} ${e}`}function PJe(e){return`\
75690
+ ${X9}
75690
75691
 
75691
75692
  # ── command-not-found hook ──────────────────────────────────────────────────
75692
75693
  function _${e}_looks_like_nl
@@ -75748,8 +75749,8 @@ complete -c ${e} -n "__fish_seen_subcommand_from shell-integration" -l shel
75748
75749
  complete -c ${e} -n "__fish_seen_subcommand_from shell-integration" -l dry-run -d 'Show changes without writing'
75749
75750
 
75750
75751
  # shell-integration init shells
75751
- complete -c ${e} -n "__fish_seen_subcommand_from init" -a "bash zsh fish pwsh"`}function PJe(e){return`\
75752
- ${Y9}
75752
+ complete -c ${e} -n "__fish_seen_subcommand_from init" -a "bash zsh fish pwsh"`}function FJe(e){return`\
75753
+ ${X9}
75753
75754
 
75754
75755
  # ── command-not-found hook ──────────────────────────────────────────────────
75755
75756
  function _${e}_LooksLikeNL {
@@ -75852,12 +75853,12 @@ Register-ArgumentCompleter -Native -CommandName @('${e}') -ScriptBlock {
75852
75853
  }
75853
75854
  }
75854
75855
  }
75855
- }`}const FJe=[`bash`,`zsh`,`fish`,`pwsh`];function X9(e){return FJe.includes(e)}function IJe(e,t){switch(e){case`bash`:case`zsh`:return`eval "$(${t} shell-integration init ${e})"`;case`fish`:return`${t} shell-integration init fish | source`;case`pwsh`:return`Invoke-Expression (& ${t} shell-integration init pwsh)`}}function LJe(e){let t=pe({input:process.stdin,output:process.stdout});return new Promise(n=>{t.question(e,e=>{t.close(),n(e.trim())})})}function RJe(e){let t=AJe(e,te(),process.platform);for(let e of t)if(f(e)||f(k(M(e))))return e;return t[0]??null}function zJe(e){if(!f(e))return!1;try{return g(e,`utf8`).includes(Y9)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to read shell profile at "${e}": ${n}`)}}function BJe(e,t){let n=k(M(e));try{f(n)||p(n,{recursive:!0}),S(e,`\n${Y9}\n${t}\n`,{flag:`a`,encoding:`utf8`})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to update shell profile at "${e}": ${n}`)}}async function VJe(e){let t=hn.binName,[n,r]=e.positionals;if(n===`init`){let n=r??e.shell??J9();(!n||!X9(n))&&(process.stderr.write(`shell-integration init: unknown shell "${n??``}". Supported: bash, zsh, fish, pwsh\n`),process.exit(1)),process.stdout.write(kJe(n,t)+`
75856
- `);return}let i=e.shell??J9();if(!i||!X9(i)){let e=i?`Unsupported shell: "${i}".`:`Could not detect your current shell.`;process.stderr.write(`${e}\nSpecify one with --shell <bash|zsh|fish|pwsh>\n`),process.exit(1)}let a=i,o=RJe(a);o||(process.stderr.write(`Could not determine a profile path for ${a}.\n`),process.exit(1));let s=IJe(a,t);if(zJe(o)){process.stdout.write(`Shell integration is already installed in ${o}\n\n`),process.stdout.write(`To activate in the current session run:\n\n ${s}\n\n`);return}if(process.stdout.write(`\nShell : ${a}\n`),process.stdout.write(`Profile : ${o}\n\n`),process.stdout.write(`The following line will be appended:
75856
+ }`}const IJe=[`bash`,`zsh`,`fish`,`pwsh`];function Z9(e){return IJe.includes(e)}function LJe(e,t){switch(e){case`bash`:case`zsh`:return`eval "$(${t} shell-integration init ${e})"`;case`fish`:return`${t} shell-integration init fish | source`;case`pwsh`:return`Invoke-Expression (& ${t} shell-integration init pwsh)`}}function RJe(e){let t=pe({input:process.stdin,output:process.stdout});return new Promise(n=>{t.question(e,e=>{t.close(),n(e.trim())})})}function zJe(e){let t=jJe(e,te(),process.platform);for(let e of t)if(f(e)||f(k(M(e))))return e;return t[0]??null}function BJe(e){if(!f(e))return!1;try{return g(e,`utf8`).includes(X9)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to read shell profile at "${e}": ${n}`)}}function VJe(e,t){let n=k(M(e));try{f(n)||p(n,{recursive:!0}),S(e,`\n${X9}\n${t}\n`,{flag:`a`,encoding:`utf8`})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to update shell profile at "${e}": ${n}`)}}async function HJe(e){let t=hn.binName,[n,r]=e.positionals;if(n===`init`){let n=r??e.shell??Y9();(!n||!Z9(n))&&(process.stderr.write(`shell-integration init: unknown shell "${n??``}". Supported: bash, zsh, fish, pwsh\n`),process.exit(1)),process.stdout.write(AJe(n,t)+`
75857
+ `);return}let i=e.shell??Y9();if(!i||!Z9(i)){let e=i?`Unsupported shell: "${i}".`:`Could not detect your current shell.`;process.stderr.write(`${e}\nSpecify one with --shell <bash|zsh|fish|pwsh>\n`),process.exit(1)}let a=i,o=zJe(a);o||(process.stderr.write(`Could not determine a profile path for ${a}.\n`),process.exit(1));let s=LJe(a,t);if(BJe(o)){process.stdout.write(`Shell integration is already installed in ${o}\n\n`),process.stdout.write(`To activate in the current session run:\n\n ${s}\n\n`);return}if(process.stdout.write(`\nShell : ${a}\n`),process.stdout.write(`Profile : ${o}\n\n`),process.stdout.write(`The following line will be appended:
75857
75858
 
75858
- `),process.stdout.write(` ${Y9}\n`),process.stdout.write(` ${s}\n\n`),e.dryRun){process.stdout.write(`Dry run — no changes written.
75859
- `);return}if(process.stdin.isTTY&&process.stdout.isTTY){let e=await LJe(`Proceed? [Y/n] `);if(e!==``&&e.toLowerCase()!==`y`){process.stdout.write(`Aborted.
75860
- `);return}}BJe(o,s),process.stdout.write(`\nInstalled to ${o}\n\n`),process.stdout.write(`Restart your shell, or activate now:\n\n ${s}\n\n`),process.stdout.write(`Once active, unrecognized commands will be routed through \`${t} --print\`.\n`)}const HJe=`${hn.internalEnvPrefix}IPC`;function UJe(){return process.env[HJe]?.trim().toLowerCase()===`ndjson`}const Z9=cn();un(Z9),await xn({sessionId:Z9}),IZ()||(zee(Tl({runtime:`cli`,version:DZ.default.version})),wl(`cli`,`cli`)),process.on(`uncaughtException`,e=>{Dl(e,{handler:`uncaughtException`})}),process.on(`unhandledRejection`,e=>{Dl(e instanceof Error?e:Error(String(e)),{handler:`unhandledRejection`})});for(let e of[process.stdout,process.stderr,process.stdin])e.on?.(`error`,t=>{if(t.code===`EIO`||t.code===`EPIPE`||t.code===`ENOTCONN`)return;let n=e===process.stdin?`stdin`:e===process.stdout?`stdout`:`stderr`;Dl(t,{handler:`streamError`,stream:n});try{console.error(aZ(`red`)(`Fatal ${n} stream error: ${t.message??t.code??String(t)}`))}catch{}QZ(1)});function Q9(e,t=1){throw console.error(aZ(`red`)(e)),QZ(t),Error(e)}function WJe(e){try{return new URL(e)}catch{Q9(`Invalid ${hn.envPrefix}BASE_URL: ${e}`)}}function GJe(e){(e?.[`output-format`]||e?.[`input-format`])&&!e?.print&&Q9(`--output-format and --input-format flags can only be used with --print mode`)}async function KJe(){let e=process.stdin;e.isTTY&&Q9(`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||Q9(`No input provided`),n}async function qJe(e){return e?.prompt?e.prompt:KJe()}async function JJe(e,t){let n=t.get(`baseUrl`);n&&(WJe(n),e.setUrl(n),e.resetEndpoints(),await e.getApiEndpoint())}async function YJe(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(hn.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 XJe(e,t){if(t?.version){console.log(`Abacus.AI CLI version ${DZ.default.version}`),QZ(0);return}if(GJe(t),UJe()){kl(`client_kind`,`ndjson-ipc`),await eNe({agentArgs:t});return}else if(t?.print){kl(`client_kind`,`print`);let e=await qJe(t);await aNe({agentArgs:{...t,prompt:e}})}else{kl(`client_kind`,`cli`);let n=await PJ.create(),r=new Ul(n,Sn(),gn.userAgentNames.cli,DZ.default.version);if(await JJe(r,e),!n.isAuthenticated()&&!n.isEnvAuth()&&((!process.stdin.isTTY||!process.stdout.isTTY)&&Q9(`Not authenticated. Set ${hn.envPrefix}API_KEY environment variable or run interactively to log in.`),!(await W9({authManager:n,apiClient:r,reason:`welcome`,version:DZ.default.version})).success)){QZ(0);return}let i=await YJe(t,r);await SJe({apiClient:r,authManager:n,configService:e,agentArgs:{...t,...i&&{conversationId:i}}})}}const ZJe=`
75859
+ `),process.stdout.write(` ${X9}\n`),process.stdout.write(` ${s}\n\n`),e.dryRun){process.stdout.write(`Dry run — no changes written.
75860
+ `);return}if(process.stdin.isTTY&&process.stdout.isTTY){let e=await RJe(`Proceed? [Y/n] `);if(e!==``&&e.toLowerCase()!==`y`){process.stdout.write(`Aborted.
75861
+ `);return}}VJe(o,s),process.stdout.write(`\nInstalled to ${o}\n\n`),process.stdout.write(`Restart your shell, or activate now:\n\n ${s}\n\n`),process.stdout.write(`Once active, unrecognized commands will be routed through \`${t} --print\`.\n`)}const UJe=`${hn.internalEnvPrefix}IPC`;function WJe(){return process.env[UJe]?.trim().toLowerCase()===`ndjson`}const GJe=cn();un(GJe),await xn({sessionId:GJe}),IZ()||(zee(Tl({runtime:`cli`,version:DZ.default.version})),wl(`cli`,`cli`)),process.on(`uncaughtException`,e=>{Dl(e,{handler:`uncaughtException`})}),process.on(`unhandledRejection`,e=>{Dl(e instanceof Error?e:Error(String(e)),{handler:`unhandledRejection`})});for(let e of[process.stdout,process.stderr,process.stdin])e.on?.(`error`,t=>{if(t.code===`EIO`||t.code===`EPIPE`||t.code===`ENOTCONN`)return;let n=e===process.stdin?`stdin`:e===process.stdout?`stdout`:`stderr`;Dl(t,{handler:`streamError`,stream:n});try{console.error(aZ(`red`)(`Fatal ${n} stream error: ${t.message??t.code??String(t)}`))}catch{}QZ(1)});function Q9(e,t=1){throw console.error(aZ(`red`)(e)),QZ(t),Error(e)}function KJe(e){try{return new URL(e)}catch{Q9(`Invalid ${hn.envPrefix}BASE_URL: ${e}`)}}function qJe(e){(e?.[`output-format`]||e?.[`input-format`])&&!e?.print&&Q9(`--output-format and --input-format flags can only be used with --print mode`)}async function JJe(){let e=process.stdin;e.isTTY&&Q9(`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||Q9(`No input provided`),n}async function YJe(e){return e?.prompt?e.prompt:JJe()}async function XJe(e,t){let n=t.get(`baseUrl`);n&&(KJe(n),e.setUrl(n),e.resetEndpoints(),await e.getApiEndpoint())}async function ZJe(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(hn.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 QJe(e,t){if(t?.version){console.log(`Abacus.AI CLI version ${DZ.default.version}`),QZ(0);return}if(qJe(t),WJe()){kl(`client_kind`,`ndjson-ipc`),await eNe({agentArgs:t});return}else if(t?.print){kl(`client_kind`,`print`);let e=await YJe(t);await aNe({agentArgs:{...t,prompt:e}})}else{kl(`client_kind`,`cli`);let n=await PJ.create(),r=new Ul(n,Sn(),gn.userAgentNames.cli,DZ.default.version);if(await XJe(r,e),!n.isAuthenticated()&&!n.isEnvAuth()&&((!process.stdin.isTTY||!process.stdout.isTTY)&&Q9(`Not authenticated. Set ${hn.envPrefix}API_KEY environment variable or run interactively to log in.`),!(await G9({authManager:n,apiClient:r,reason:`welcome`,version:DZ.default.version})).success)){QZ(0);return}let i=await ZJe(t,r);await CJe({apiClient:r,authManager:n,configService:e,agentArgs:{...t,...i&&{conversationId:i}}})}}const $Je=`
75861
75862
  Usage: ${hn.binName} [options] [prompt]
75862
75863
 
75863
75864
  Examples:
@@ -75892,5 +75893,5 @@ Options:
75892
75893
  --allowed-tools <pattern> Auto-allow tool patterns (can repeat)
75893
75894
  --disallowed-tools <pattern> Auto-deny tool patterns (can repeat)
75894
75895
  --add-dir <path> Additional allowed directory (can repeat)
75895
- `.trim();function QJe(){try{let e=le(`${process.platform===`win32`?`where`:`which`} ${hn.binName}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim().split(`
75896
- `)[0]?.trim();if(e)return e}catch{}return hn.binName}function $9(e){let t=QJe();return new Promise(n=>{let r=ue(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 "${hn.binName}" manually.\n`),n(1)}),r.on(`exit`,e=>n(e??0))})}async function $Je(){let e=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await e.load();let t=await q9({currentVersion:DZ.default.version,explicit:!0,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(3));process.exit(e)}process.exit(t.action===`exit`?1:0)}async function eYe(e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let t=await q9({currentVersion:DZ.default.version,autoUpdate:e.get(`autoUpdate`)!==!1,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(2));process.exit(e)}t.action===`exit`&&process.exit(0)}if(Al(`command: ${process.argv[2]??`repl`}`,`cli`),process.argv[2]===`upgrade`)await $Je();else if(process.argv[2]===`shell-integration`){let{values:e,positionals:t}=i({args:process.argv.slice(3),options:{shell:{type:`string`},"dry-run":{type:`boolean`}},allowPositionals:!0,strict:!1});await VJe({positionals:t,shell:typeof e.shell==`string`?e.shell:void 0,dryRun:typeof e[`dry-run`]==`boolean`?e[`dry-run`]:void 0})}else if(process.argv[2]===`auth`){let e=process.argv[3];(!e||e===`--help`||e===`-h`)&&(console.log(`Usage: ${hn.binName} auth <login|logout|status|switch>`),process.exit(0)),[`login`,`logout`,`status`,`switch`].includes(e)||(console.log(`Usage: ${hn.binName} auth <login|logout|status|switch>`),process.exit(1)),await wJe(e)}else{let e,t;try{({values:e,positionals:t}=i({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}},allowPositionals:!0,strict:!0}))}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}e.help&&(console.log(ZJe),process.exit(0));let n=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await n.load(),await eYe(n),await XJe(n,{...e,prompt:t.length>0?t.join(` `):null}).catch(e=>{console.error(e),process.exit(1)})}export{};
75896
+ `.trim();function eYe(){try{let e=le(`${process.platform===`win32`?`where`:`which`} ${hn.binName}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim().split(`
75897
+ `)[0]?.trim();if(e)return e}catch{}return hn.binName}function $9(e){let t=eYe();return new Promise(n=>{let r=ue(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 "${hn.binName}" manually.\n`),n(1)}),r.on(`exit`,e=>n(e??0))})}async function tYe(){let e=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await e.load();let t=await J9({currentVersion:DZ.default.version,explicit:!0,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(3));process.exit(e)}process.exit(t.action===`exit`?1:0)}async function nYe(e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let t=await J9({currentVersion:DZ.default.version,autoUpdate:e.get(`autoUpdate`)!==!1,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(2));process.exit(e)}t.action===`exit`&&process.exit(0)}if(Al(`command: ${process.argv[2]??`repl`}`,`cli`),process.argv[2]===`upgrade`)await tYe();else if(process.argv[2]===`shell-integration`){let{values:e,positionals:t}=i({args:process.argv.slice(3),options:{shell:{type:`string`},"dry-run":{type:`boolean`}},allowPositionals:!0,strict:!1});await HJe({positionals:t,shell:typeof e.shell==`string`?e.shell:void 0,dryRun:typeof e[`dry-run`]==`boolean`?e[`dry-run`]:void 0})}else if(process.argv[2]===`auth`){let e=process.argv[3];(!e||e===`--help`||e===`-h`)&&(console.log(`Usage: ${hn.binName} auth <login|logout|status|switch>`),process.exit(0)),[`login`,`logout`,`status`,`switch`].includes(e)||(console.log(`Usage: ${hn.binName} auth <login|logout|status|switch>`),process.exit(1)),await TJe(e)}else{let e,t;try{({values:e,positionals:t}=i({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}},allowPositionals:!0,strict:!0}))}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}e.help&&(console.log($Je),process.exit(0));let n=new vq({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await n.load(),await nYe(n),await QJe(n,{...e,prompt:t.length>0?t.join(` `):null}).catch(e=>{console.error(e),process.exit(1)})}export{};