@psnext/slingcli 2.5.20260722-3 → 2.5.20260723-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/package.json +2 -2
  2. package/slingshot/index.js +27 -27
@@ -35,7 +35,7 @@ ${s}`),i.push({type:"error",reason:o.stopReason,error:o}),i.end()}})(),i},nU=(t,
35
35
  `).find(n=>n.startsWith("data:"))?.slice(5).trim();return e&&e!=="[DONE]"?JSON.parse(e):void 0}function OU(t,e,n){let i=n?"aborted":"error",o={role:"assistant",content:[],api:t.api,provider:t.provider,model:t.id,usage:VT(),stopReason:i,errorMessage:e instanceof Error?e.message:String(e),timestamp:Date.now()};return!n&&e instanceof Rc&&kc(o,Hd("pi_messages_response_failure",e,e.diagnosticDetails)),{type:"error",reason:i,error:o}}function LU(t,e){return t||(Oe("PI_CACHE_RETENTION",e)==="long"?"long":void 0)}var Rc,QT,WU,JT=Ae(()=>{"use strict";Vd();Fn();Xi();Cr();Zi();Rc=class extends Error{constructor(e,n,i){super(e),this.name="PiMessagesResponseError",this.code=n,this.diagnosticDetails=i}};QT=(t,e,n)=>{let i=new st,o=AU(t);return(async()=>{try{let r=n?.apiKey;if(!r)throw new Error(`No API key provided for provider "${t.provider}"`);let s=new URL(`${t.baseUrl.replace(/\/+$/u,"")}/messages`);n?.debug&&s.searchParams.set("debug","1");let a={model:t.id,context:e,options:{temperature:n?.temperature,maxTokens:n?.maxTokens,reasoning:n?.reasoning,cacheRetention:LU(n?.cacheRetention,n?.env),sessionId:n?.sessionId,toolChoice:n?.toolChoice}},l=await n?.onPayload?.(a,t);l!==void 0&&(a=l);let c=await fetch(s,{method:"POST",headers:{authorization:`Bearer ${r}`,accept:"text/event-stream","content-type":"application/json",...Ma(n?.headers)},body:JSON.stringify(a),signal:n?.signal});if(await n?.onResponse?.({status:c.status,headers:Cn(c.headers)},t),!c.ok){let u=await c.text();throw EU(t,s,c,u)}if(!c.body)throw new Error(`${t.provider} response has no body`);for await(let u of _U(c.body)){let d=o(u);if(i.push(d),d.type==="done"||d.type==="error")return}throw new Error(`${t.provider} stream ended without a terminal event`)}catch(r){i.push(OU(t,r,n?.signal?.aborted??!1))}})(),i},WU=(t,e,n)=>{let i=n;return QT(t,e,{...n,reasoning:n?.reasoning,toolChoice:i?.toolChoice,debug:i?.debug})}});var Yt=C(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.HasPropertyKey=J9;Pt.IsAsyncIterator=X9;Pt.IsArray=wx;Pt.IsBigInt=Z9;Pt.IsBoolean=eQ;Pt.IsDate=tQ;Pt.IsFunction=nQ;Pt.IsIterator=iQ;Pt.IsNull=oQ;Pt.IsNumber=rQ;Pt.IsObject=kx;Pt.IsRegExp=sQ;Pt.IsString=aQ;Pt.IsSymbol=lQ;Pt.IsUint8Array=Sx;Pt.IsUndefined=cQ;function J9(t,e){return e in t}function X9(t){return kx(t)&&!wx(t)&&!Sx(t)&&Symbol.asyncIterator in t}function wx(t){return Array.isArray(t)}function Z9(t){return typeof t=="bigint"}function eQ(t){return typeof t=="boolean"}function tQ(t){return t instanceof globalThis.Date}function nQ(t){return typeof t=="function"}function iQ(t){return kx(t)&&!wx(t)&&!Sx(t)&&Symbol.iterator in t}function oQ(t){return t===null}function rQ(t){return typeof t=="number"}function kx(t){return typeof t=="object"&&t!==null}function sQ(t){return t instanceof globalThis.RegExp}function aQ(t){return typeof t=="string"}function lQ(t){return typeof t=="symbol"}function Sx(t){return t instanceof globalThis.Uint8Array}function cQ(t){return t===void 0}});var cn=C(go=>{"use strict";var uQ=go&&go.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),dQ=go&&go.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),pQ=go&&go.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&uQ(n,e,i[o]);return dQ(n,e),n}})();Object.defineProperty(go,"__esModule",{value:!0});go.Clone=bQ;var Xu=pQ(Yt());function mQ(t){return t.map(e=>Oh(e))}function hQ(t){return new Date(t.getTime())}function gQ(t){return new Uint8Array(t)}function fQ(t){return new RegExp(t.source,t.flags)}function vQ(t){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=Oh(t[n]);for(let n of Object.getOwnPropertySymbols(t))e[n]=Oh(t[n]);return e}function Oh(t){return Xu.IsArray(t)?mQ(t):Xu.IsDate(t)?hQ(t):Xu.IsUint8Array(t)?gQ(t):Xu.IsRegExp(t)?fQ(t):Xu.IsObject(t)?vQ(t):t}function bQ(t){return Oh(t)}});var Wh=C(Lh=>{"use strict";Object.defineProperty(Lh,"__esModule",{value:!0});Lh.CloneRest=xQ;Lh.CloneType=N_;var $_=cn();function xQ(t){return t.map(e=>N_(e))}function N_(t,e){return e===void 0?(0,$_.Clone)(t):(0,$_.Clone)({...e,...t})}});var Tx=C(ur=>{"use strict";var yQ=ur&&ur.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),B_=ur&&ur.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&yQ(e,t,n)};Object.defineProperty(ur,"__esModule",{value:!0});B_(Wh(),ur);B_(cn(),ur)});var J_=C(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.IsAsyncIterator=wQ;Ee.IsIterator=kQ;Ee.IsStandardObject=SQ;Ee.IsInstanceObject=TQ;Ee.IsPromise=CQ;Ee.IsDate=MQ;Ee.IsMap=RQ;Ee.IsSet=PQ;Ee.IsRegExp=IQ;Ee.IsTypedArray=EQ;Ee.IsInt8Array=AQ;Ee.IsUint8Array=_Q;Ee.IsUint8ClampedArray=OQ;Ee.IsInt16Array=LQ;Ee.IsUint16Array=WQ;Ee.IsInt32Array=FQ;Ee.IsUint32Array=DQ;Ee.IsFloat32Array=UQ;Ee.IsFloat64Array=$Q;Ee.IsBigInt64Array=NQ;Ee.IsBigUint64Array=BQ;Ee.HasPropertyKey=jQ;Ee.IsObject=Zu;Ee.IsArray=j_;Ee.IsUndefined=q_;Ee.IsNull=K_;Ee.IsBoolean=G_;Ee.IsNumber=z_;Ee.IsInteger=qQ;Ee.IsBigInt=H_;Ee.IsString=V_;Ee.IsFunction=Q_;Ee.IsSymbol=Y_;Ee.IsValueType=KQ;function wQ(t){return Zu(t)&&globalThis.Symbol.asyncIterator in t}function kQ(t){return Zu(t)&&globalThis.Symbol.iterator in t}function SQ(t){return Zu(t)&&(globalThis.Object.getPrototypeOf(t)===Object.prototype||globalThis.Object.getPrototypeOf(t)===null)}function TQ(t){return Zu(t)&&!j_(t)&&Q_(t.constructor)&&t.constructor.name!=="Object"}function CQ(t){return t instanceof globalThis.Promise}function MQ(t){return t instanceof Date&&globalThis.Number.isFinite(t.getTime())}function RQ(t){return t instanceof globalThis.Map}function PQ(t){return t instanceof globalThis.Set}function IQ(t){return t instanceof globalThis.RegExp}function EQ(t){return globalThis.ArrayBuffer.isView(t)}function AQ(t){return t instanceof globalThis.Int8Array}function _Q(t){return t instanceof globalThis.Uint8Array}function OQ(t){return t instanceof globalThis.Uint8ClampedArray}function LQ(t){return t instanceof globalThis.Int16Array}function WQ(t){return t instanceof globalThis.Uint16Array}function FQ(t){return t instanceof globalThis.Int32Array}function DQ(t){return t instanceof globalThis.Uint32Array}function UQ(t){return t instanceof globalThis.Float32Array}function $Q(t){return t instanceof globalThis.Float64Array}function NQ(t){return t instanceof globalThis.BigInt64Array}function BQ(t){return t instanceof globalThis.BigUint64Array}function jQ(t,e){return e in t}function Zu(t){return t!==null&&typeof t=="object"}function j_(t){return globalThis.Array.isArray(t)&&!globalThis.ArrayBuffer.isView(t)}function q_(t){return t===void 0}function K_(t){return t===null}function G_(t){return typeof t=="boolean"}function z_(t){return typeof t=="number"}function qQ(t){return globalThis.Number.isInteger(t)}function H_(t){return typeof t=="bigint"}function V_(t){return typeof t=="string"}function Q_(t){return typeof t=="function"}function Y_(t){return typeof t=="symbol"}function KQ(t){return H_(t)||G_(t)||K_(t)||z_(t)||V_(t)||Y_(t)||q_(t)}});var X_=C(ps=>{"use strict";var GQ=ps&&ps.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),zQ=ps&&ps.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&GQ(e,t,n)};Object.defineProperty(ps,"__esModule",{value:!0});zQ(J_(),ps)});var e2=C(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});Dh.TypeSystemPolicy=void 0;var Fh=X_(),Z_;(function(t){t.InstanceMode="default",t.ExactOptionalPropertyTypes=!1,t.AllowArrayObject=!1,t.AllowNaN=!1,t.AllowNullVoid=!1;function e(s,a){return t.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}t.IsExactOptionalProperty=e;function n(s){let a=(0,Fh.IsObject)(s);return t.AllowArrayObject?a:a&&!(0,Fh.IsArray)(s)}t.IsObjectLike=n;function i(s){return n(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}t.IsRecordLike=i;function o(s){return t.AllowNaN?(0,Fh.IsNumber)(s):Number.isFinite(s)}t.IsNumberLike=o;function r(s){let a=(0,Fh.IsUndefined)(s);return t.AllowNullVoid?a||s===null:a}t.IsVoidLike=r})(Z_||(Dh.TypeSystemPolicy=Z_={}))});var t2=C(fo=>{"use strict";var HQ=fo&&fo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),VQ=fo&&fo.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),QQ=fo&&fo.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&HQ(n,e,i[o]);return VQ(n,e),n}})();Object.defineProperty(fo,"__esModule",{value:!0});fo.Immutable=Uh;var ed=QQ(Yt());function YQ(t){return globalThis.Object.freeze(t).map(e=>Uh(e))}function JQ(t){let e={};for(let n of Object.getOwnPropertyNames(t))e[n]=Uh(t[n]);for(let n of Object.getOwnPropertySymbols(t))e[n]=Uh(t[n]);return globalThis.Object.freeze(e)}function Uh(t){return ed.IsArray(t)?YQ(t):ed.IsDate(t)?t:ed.IsUint8Array(t)?t:ed.IsRegExp(t)?t:ed.IsObject(t)?JQ(t):t}});var me=C(Cx=>{"use strict";Object.defineProperty(Cx,"__esModule",{value:!0});Cx.CreateType=tY;var XQ=e2(),ZQ=t2(),eY=cn();function tY(t,e){let n=e!==void 0?{...e,...t}:t;switch(XQ.TypeSystemPolicy.InstanceMode){case"freeze":return(0,ZQ.Immutable)(n);case"clone":return(0,eY.Clone)(n);default:return n}}});var vo=C(ms=>{"use strict";var nY=ms&&ms.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),iY=ms&&ms.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&nY(e,t,n)};Object.defineProperty(ms,"__esModule",{value:!0});iY(me(),ms)});var n2=C($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});$h.TypeBoxError=void 0;var Mx=class extends Error{constructor(e){super(e)}};$h.TypeBoxError=Mx});var Wi=C(hs=>{"use strict";var oY=hs&&hs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),rY=hs&&hs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&oY(e,t,n)};Object.defineProperty(hs,"__esModule",{value:!0});rY(n2(),hs)});var td=C(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.Kind=Xn.Hint=Xn.OptionalKind=Xn.ReadonlyKind=Xn.TransformKind=void 0;Xn.TransformKind=Symbol.for("TypeBox.Transform");Xn.ReadonlyKind=Symbol.for("TypeBox.Readonly");Xn.OptionalKind=Symbol.for("TypeBox.Optional");Xn.Hint=Symbol.for("TypeBox.Hint");Xn.Kind=Symbol.for("TypeBox.Kind")});var pe=C(gs=>{"use strict";var sY=gs&&gs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),aY=gs&&gs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&sY(e,t,n)};Object.defineProperty(gs,"__esModule",{value:!0});aY(td(),gs)});var Le=C(ue=>{"use strict";var lY=ue&&ue.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),cY=ue&&ue.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),uY=ue&&ue.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&lY(n,e,i[o]);return cY(n,e),n}})();Object.defineProperty(ue,"__esModule",{value:!0});ue.IsReadonly=dY;ue.IsOptional=pY;ue.IsAny=i2;ue.IsArgument=o2;ue.IsArray=r2;ue.IsAsyncIterator=s2;ue.IsBigInt=a2;ue.IsBoolean=l2;ue.IsComputed=c2;ue.IsConstructor=u2;ue.IsDate=d2;ue.IsFunction=p2;ue.IsImport=mY;ue.IsInteger=m2;ue.IsProperties=hY;ue.IsIntersect=h2;ue.IsIterator=g2;ue.IsKindOf=Pe;ue.IsLiteralString=gY;ue.IsLiteralNumber=fY;ue.IsLiteralBoolean=vY;ue.IsLiteralValue=bY;ue.IsLiteral=nd;ue.IsMappedKey=f2;ue.IsMappedResult=v2;ue.IsNever=b2;ue.IsNot=x2;ue.IsNull=y2;ue.IsNumber=w2;ue.IsObject=k2;ue.IsPromise=S2;ue.IsRecord=T2;ue.IsRecursive=xY;ue.IsRef=C2;ue.IsRegExp=M2;ue.IsString=R2;ue.IsSymbol=P2;ue.IsTemplateLiteral=I2;ue.IsThis=E2;ue.IsTransform=yY;ue.IsTuple=A2;ue.IsUndefined=_2;ue.IsUnion=O2;ue.IsUint8Array=L2;ue.IsUnknown=W2;ue.IsUnsafe=F2;ue.IsVoid=D2;ue.IsKind=U2;ue.IsSchema=wY;var un=uY(Yt()),bo=pe();function dY(t){return un.IsObject(t)&&t[bo.ReadonlyKind]==="Readonly"}function pY(t){return un.IsObject(t)&&t[bo.OptionalKind]==="Optional"}function i2(t){return Pe(t,"Any")}function o2(t){return Pe(t,"Argument")}function r2(t){return Pe(t,"Array")}function s2(t){return Pe(t,"AsyncIterator")}function a2(t){return Pe(t,"BigInt")}function l2(t){return Pe(t,"Boolean")}function c2(t){return Pe(t,"Computed")}function u2(t){return Pe(t,"Constructor")}function d2(t){return Pe(t,"Date")}function p2(t){return Pe(t,"Function")}function mY(t){return Pe(t,"Import")}function m2(t){return Pe(t,"Integer")}function hY(t){return un.IsObject(t)}function h2(t){return Pe(t,"Intersect")}function g2(t){return Pe(t,"Iterator")}function Pe(t,e){return un.IsObject(t)&&bo.Kind in t&&t[bo.Kind]===e}function gY(t){return nd(t)&&un.IsString(t.const)}function fY(t){return nd(t)&&un.IsNumber(t.const)}function vY(t){return nd(t)&&un.IsBoolean(t.const)}function bY(t){return un.IsBoolean(t)||un.IsNumber(t)||un.IsString(t)}function nd(t){return Pe(t,"Literal")}function f2(t){return Pe(t,"MappedKey")}function v2(t){return Pe(t,"MappedResult")}function b2(t){return Pe(t,"Never")}function x2(t){return Pe(t,"Not")}function y2(t){return Pe(t,"Null")}function w2(t){return Pe(t,"Number")}function k2(t){return Pe(t,"Object")}function S2(t){return Pe(t,"Promise")}function T2(t){return Pe(t,"Record")}function xY(t){return un.IsObject(t)&&bo.Hint in t&&t[bo.Hint]==="Recursive"}function C2(t){return Pe(t,"Ref")}function M2(t){return Pe(t,"RegExp")}function R2(t){return Pe(t,"String")}function P2(t){return Pe(t,"Symbol")}function I2(t){return Pe(t,"TemplateLiteral")}function E2(t){return Pe(t,"This")}function yY(t){return un.IsObject(t)&&bo.TransformKind in t}function A2(t){return Pe(t,"Tuple")}function _2(t){return Pe(t,"Undefined")}function O2(t){return Pe(t,"Union")}function L2(t){return Pe(t,"Uint8Array")}function W2(t){return Pe(t,"Unknown")}function F2(t){return Pe(t,"Unsafe")}function D2(t){return Pe(t,"Void")}function U2(t){return un.IsObject(t)&&bo.Kind in t&&un.IsString(t[bo.Kind])}function wY(t){return i2(t)||o2(t)||r2(t)||l2(t)||a2(t)||s2(t)||c2(t)||u2(t)||d2(t)||p2(t)||m2(t)||h2(t)||g2(t)||nd(t)||f2(t)||v2(t)||b2(t)||x2(t)||y2(t)||w2(t)||k2(t)||S2(t)||T2(t)||C2(t)||M2(t)||R2(t)||P2(t)||I2(t)||E2(t)||A2(t)||_2(t)||O2(t)||L2(t)||W2(t)||F2(t)||D2(t)||U2(t)}});var RO=C(ae=>{"use strict";var kY=ae&&ae.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),SY=ae&&ae.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),TY=ae&&ae.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&kY(n,e,i[o]);return SY(n,e),n}})();Object.defineProperty(ae,"__esModule",{value:!0});ae.TypeGuardUnknownTypeError=void 0;ae.IsReadonly=IY;ae.IsOptional=EY;ae.IsAny=j2;ae.IsArgument=q2;ae.IsArray=K2;ae.IsAsyncIterator=G2;ae.IsBigInt=z2;ae.IsBoolean=H2;ae.IsComputed=V2;ae.IsConstructor=Q2;ae.IsDate=Y2;ae.IsFunction=J2;ae.IsImport=AY;ae.IsInteger=X2;ae.IsProperties=Nh;ae.IsIntersect=Z2;ae.IsIterator=eO;ae.IsKindOf=Ie;ae.IsLiteralString=tO;ae.IsLiteralNumber=nO;ae.IsLiteralBoolean=_Y;ae.IsLiteral=od;ae.IsLiteralValue=iO;ae.IsMappedKey=oO;ae.IsMappedResult=rO;ae.IsNever=sO;ae.IsNot=aO;ae.IsNull=lO;ae.IsNumber=cO;ae.IsObject=uO;ae.IsPromise=dO;ae.IsRecord=pO;ae.IsRecursive=OY;ae.IsRef=mO;ae.IsRegExp=hO;ae.IsString=gO;ae.IsSymbol=fO;ae.IsTemplateLiteral=vO;ae.IsThis=bO;ae.IsTransform=xO;ae.IsTuple=yO;ae.IsUndefined=wO;ae.IsUnionLiteral=LY;ae.IsUnion=Ex;ae.IsUint8Array=kO;ae.IsUnknown=SO;ae.IsUnsafe=TO;ae.IsVoid=CO;ae.IsKind=MO;ae.IsSchema=It;var ce=TY(Yt()),Fi=pe(),CY=Wi(),Rx=class extends CY.TypeBoxError{};ae.TypeGuardUnknownTypeError=Rx;var MY=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function $2(t){try{return new RegExp(t),!0}catch{return!1}}function Px(t){if(!ce.IsString(t))return!1;for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function N2(t){return Ix(t)||It(t)}function id(t){return ce.IsUndefined(t)||ce.IsBigInt(t)}function ze(t){return ce.IsUndefined(t)||ce.IsNumber(t)}function Ix(t){return ce.IsUndefined(t)||ce.IsBoolean(t)}function Be(t){return ce.IsUndefined(t)||ce.IsString(t)}function RY(t){return ce.IsUndefined(t)||ce.IsString(t)&&Px(t)&&$2(t)}function PY(t){return ce.IsUndefined(t)||ce.IsString(t)&&Px(t)}function B2(t){return ce.IsUndefined(t)||It(t)}function IY(t){return ce.IsObject(t)&&t[Fi.ReadonlyKind]==="Readonly"}function EY(t){return ce.IsObject(t)&&t[Fi.OptionalKind]==="Optional"}function j2(t){return Ie(t,"Any")&&Be(t.$id)}function q2(t){return Ie(t,"Argument")&&ce.IsNumber(t.index)}function K2(t){return Ie(t,"Array")&&t.type==="array"&&Be(t.$id)&&It(t.items)&&ze(t.minItems)&&ze(t.maxItems)&&Ix(t.uniqueItems)&&B2(t.contains)&&ze(t.minContains)&&ze(t.maxContains)}function G2(t){return Ie(t,"AsyncIterator")&&t.type==="AsyncIterator"&&Be(t.$id)&&It(t.items)}function z2(t){return Ie(t,"BigInt")&&t.type==="bigint"&&Be(t.$id)&&id(t.exclusiveMaximum)&&id(t.exclusiveMinimum)&&id(t.maximum)&&id(t.minimum)&&id(t.multipleOf)}function H2(t){return Ie(t,"Boolean")&&t.type==="boolean"&&Be(t.$id)}function V2(t){return Ie(t,"Computed")&&ce.IsString(t.target)&&ce.IsArray(t.parameters)&&t.parameters.every(e=>It(e))}function Q2(t){return Ie(t,"Constructor")&&t.type==="Constructor"&&Be(t.$id)&&ce.IsArray(t.parameters)&&t.parameters.every(e=>It(e))&&It(t.returns)}function Y2(t){return Ie(t,"Date")&&t.type==="Date"&&Be(t.$id)&&ze(t.exclusiveMaximumTimestamp)&&ze(t.exclusiveMinimumTimestamp)&&ze(t.maximumTimestamp)&&ze(t.minimumTimestamp)&&ze(t.multipleOfTimestamp)}function J2(t){return Ie(t,"Function")&&t.type==="Function"&&Be(t.$id)&&ce.IsArray(t.parameters)&&t.parameters.every(e=>It(e))&&It(t.returns)}function AY(t){return Ie(t,"Import")&&ce.HasPropertyKey(t,"$defs")&&ce.IsObject(t.$defs)&&Nh(t.$defs)&&ce.HasPropertyKey(t,"$ref")&&ce.IsString(t.$ref)&&t.$ref in t.$defs}function X2(t){return Ie(t,"Integer")&&t.type==="integer"&&Be(t.$id)&&ze(t.exclusiveMaximum)&&ze(t.exclusiveMinimum)&&ze(t.maximum)&&ze(t.minimum)&&ze(t.multipleOf)}function Nh(t){return ce.IsObject(t)&&Object.entries(t).every(([e,n])=>Px(e)&&It(n))}function Z2(t){return Ie(t,"Intersect")&&!(ce.IsString(t.type)&&t.type!=="object")&&ce.IsArray(t.allOf)&&t.allOf.every(e=>It(e)&&!xO(e))&&Be(t.type)&&(Ix(t.unevaluatedProperties)||B2(t.unevaluatedProperties))&&Be(t.$id)}function eO(t){return Ie(t,"Iterator")&&t.type==="Iterator"&&Be(t.$id)&&It(t.items)}function Ie(t,e){return ce.IsObject(t)&&Fi.Kind in t&&t[Fi.Kind]===e}function tO(t){return od(t)&&ce.IsString(t.const)}function nO(t){return od(t)&&ce.IsNumber(t.const)}function _Y(t){return od(t)&&ce.IsBoolean(t.const)}function od(t){return Ie(t,"Literal")&&Be(t.$id)&&iO(t.const)}function iO(t){return ce.IsBoolean(t)||ce.IsNumber(t)||ce.IsString(t)}function oO(t){return Ie(t,"MappedKey")&&ce.IsArray(t.keys)&&t.keys.every(e=>ce.IsNumber(e)||ce.IsString(e))}function rO(t){return Ie(t,"MappedResult")&&Nh(t.properties)}function sO(t){return Ie(t,"Never")&&ce.IsObject(t.not)&&Object.getOwnPropertyNames(t.not).length===0}function aO(t){return Ie(t,"Not")&&It(t.not)}function lO(t){return Ie(t,"Null")&&t.type==="null"&&Be(t.$id)}function cO(t){return Ie(t,"Number")&&t.type==="number"&&Be(t.$id)&&ze(t.exclusiveMaximum)&&ze(t.exclusiveMinimum)&&ze(t.maximum)&&ze(t.minimum)&&ze(t.multipleOf)}function uO(t){return Ie(t,"Object")&&t.type==="object"&&Be(t.$id)&&Nh(t.properties)&&N2(t.additionalProperties)&&ze(t.minProperties)&&ze(t.maxProperties)}function dO(t){return Ie(t,"Promise")&&t.type==="Promise"&&Be(t.$id)&&It(t.item)}function pO(t){return Ie(t,"Record")&&t.type==="object"&&Be(t.$id)&&N2(t.additionalProperties)&&ce.IsObject(t.patternProperties)&&(e=>{let n=Object.getOwnPropertyNames(e.patternProperties);return n.length===1&&$2(n[0])&&ce.IsObject(e.patternProperties)&&It(e.patternProperties[n[0]])})(t)}function OY(t){return ce.IsObject(t)&&Fi.Hint in t&&t[Fi.Hint]==="Recursive"}function mO(t){return Ie(t,"Ref")&&Be(t.$id)&&ce.IsString(t.$ref)}function hO(t){return Ie(t,"RegExp")&&Be(t.$id)&&ce.IsString(t.source)&&ce.IsString(t.flags)&&ze(t.maxLength)&&ze(t.minLength)}function gO(t){return Ie(t,"String")&&t.type==="string"&&Be(t.$id)&&ze(t.minLength)&&ze(t.maxLength)&&RY(t.pattern)&&PY(t.format)}function fO(t){return Ie(t,"Symbol")&&t.type==="symbol"&&Be(t.$id)}function vO(t){return Ie(t,"TemplateLiteral")&&t.type==="string"&&ce.IsString(t.pattern)&&t.pattern[0]==="^"&&t.pattern[t.pattern.length-1]==="$"}function bO(t){return Ie(t,"This")&&Be(t.$id)&&ce.IsString(t.$ref)}function xO(t){return ce.IsObject(t)&&Fi.TransformKind in t}function yO(t){return Ie(t,"Tuple")&&t.type==="array"&&Be(t.$id)&&ce.IsNumber(t.minItems)&&ce.IsNumber(t.maxItems)&&t.minItems===t.maxItems&&(ce.IsUndefined(t.items)&&ce.IsUndefined(t.additionalItems)&&t.minItems===0||ce.IsArray(t.items)&&t.items.every(e=>It(e)))}function wO(t){return Ie(t,"Undefined")&&t.type==="undefined"&&Be(t.$id)}function LY(t){return Ex(t)&&t.anyOf.every(e=>tO(e)||nO(e))}function Ex(t){return Ie(t,"Union")&&Be(t.$id)&&ce.IsObject(t)&&ce.IsArray(t.anyOf)&&t.anyOf.every(e=>It(e))}function kO(t){return Ie(t,"Uint8Array")&&t.type==="Uint8Array"&&Be(t.$id)&&ze(t.minByteLength)&&ze(t.maxByteLength)}function SO(t){return Ie(t,"Unknown")&&Be(t.$id)}function TO(t){return Ie(t,"Unsafe")}function CO(t){return Ie(t,"Void")&&t.type==="void"&&Be(t.$id)}function MO(t){return ce.IsObject(t)&&Fi.Kind in t&&ce.IsString(t[Fi.Kind])&&!MY.includes(t[Fi.Kind])}function It(t){return ce.IsObject(t)&&(j2(t)||q2(t)||K2(t)||H2(t)||z2(t)||G2(t)||V2(t)||Q2(t)||Y2(t)||J2(t)||X2(t)||Z2(t)||eO(t)||od(t)||oO(t)||rO(t)||sO(t)||aO(t)||lO(t)||cO(t)||uO(t)||dO(t)||pO(t)||mO(t)||hO(t)||gO(t)||fO(t)||vO(t)||bO(t)||yO(t)||wO(t)||Ex(t)||kO(t)||SO(t)||TO(t)||CO(t)||MO(t))}});var _x=C(dn=>{"use strict";var WY=dn&&dn.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),FY=dn&&dn.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Ax=dn&&dn.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&WY(n,e,i[o]);return FY(n,e),n}})();Object.defineProperty(dn,"__esModule",{value:!0});dn.ValueGuard=dn.TypeGuard=dn.KindGuard=void 0;dn.KindGuard=Ax(Le());dn.TypeGuard=Ax(RO());dn.ValueGuard=Ax(Yt())});var PO=C(Ox=>{"use strict";Object.defineProperty(Ox,"__esModule",{value:!0});Ox.Increment=DY;function DY(t){return(parseInt(t)+1).toString()}});var IO=C(fs=>{"use strict";var UY=fs&&fs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),$Y=fs&&fs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&UY(e,t,n)};Object.defineProperty(fs,"__esModule",{value:!0});$Y(PO(),fs)});var EO=C(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.PatternNeverExact=ut.PatternStringExact=ut.PatternNumberExact=ut.PatternBooleanExact=ut.PatternNever=ut.PatternString=ut.PatternNumber=ut.PatternBoolean=void 0;ut.PatternBoolean="(true|false)";ut.PatternNumber="(0|[1-9][0-9]*)";ut.PatternString="(.*)";ut.PatternNever="(?!.*)";ut.PatternBooleanExact=`^${ut.PatternBoolean}$`;ut.PatternNumberExact=`^${ut.PatternNumber}$`;ut.PatternStringExact=`^${ut.PatternString}$`;ut.PatternNeverExact=`^${ut.PatternNever}$`});var rd=C(vs=>{"use strict";var NY=vs&&vs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),BY=vs&&vs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&NY(e,t,n)};Object.defineProperty(vs,"__esModule",{value:!0});BY(EO(),vs)});var AO=C(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.Entries=jY;dr.Clear=qY;dr.Delete=KY;dr.Has=GY;dr.Set=zY;dr.Get=HY;var Kl=new Map;function jY(){return new Map(Kl)}function qY(){return Kl.clear()}function KY(t){return Kl.delete(t)}function GY(t){return Kl.has(t)}function zY(t,e){Kl.set(t,e)}function HY(t){return Kl.get(t)}});var _O=C(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.Entries=VY;pr.Clear=QY;pr.Delete=YY;pr.Has=JY;pr.Set=XY;pr.Get=ZY;var Gl=new Map;function VY(){return new Map(Gl)}function QY(){return Gl.clear()}function YY(t){return Gl.delete(t)}function JY(t){return Gl.has(t)}function XY(t,e){Gl.set(t,e)}function ZY(t){return Gl.get(t)}});var LO=C(Zn=>{"use strict";var eJ=Zn&&Zn.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),tJ=Zn&&Zn.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),OO=Zn&&Zn.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&eJ(n,e,i[o]);return tJ(n,e),n}})();Object.defineProperty(Zn,"__esModule",{value:!0});Zn.TypeRegistry=Zn.FormatRegistry=void 0;Zn.FormatRegistry=OO(AO());Zn.TypeRegistry=OO(_O())});var DO=C(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.SetIncludes=WO;Di.SetIsSubset=nJ;Di.SetDistinct=iJ;Di.SetIntersect=FO;Di.SetUnion=oJ;Di.SetComplement=rJ;Di.SetIntersectMany=aJ;Di.SetUnionMany=lJ;function WO(t,e){return t.includes(e)}function nJ(t,e){return t.every(n=>WO(e,n))}function iJ(t){return[...new Set(t)]}function FO(t,e){return t.filter(n=>e.includes(n))}function oJ(t,e){return[...t,...e]}function rJ(t,e){return t.filter(n=>!e.includes(n))}function sJ(t,e){return t.reduce((n,i)=>FO(n,i),e)}function aJ(t){return t.length===1?t[0]:t.length>1?sJ(t.slice(1),t[0]):[]}function lJ(t){let e=[];for(let n of t)e.push(...n);return e}});var sd=C(bs=>{"use strict";var cJ=bs&&bs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),uJ=bs&&bs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&cJ(e,t,n)};Object.defineProperty(bs,"__esModule",{value:!0});uJ(DO(),bs)});var UO=C(Lx=>{"use strict";Object.defineProperty(Lx,"__esModule",{value:!0});Lx.Any=mJ;var dJ=vo(),pJ=pe();function mJ(t){return(0,dJ.CreateType)({[pJ.Kind]:"Any"},t)}});var zl=C(xs=>{"use strict";var hJ=xs&&xs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),gJ=xs&&xs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&hJ(e,t,n)};Object.defineProperty(xs,"__esModule",{value:!0});gJ(UO(),xs)});var $O=C(Wx=>{"use strict";Object.defineProperty(Wx,"__esModule",{value:!0});Wx.Array=bJ;var fJ=me(),vJ=pe();function bJ(t,e){return(0,fJ.CreateType)({[vJ.Kind]:"Array",type:"array",items:t},e)}});var Hl=C(ys=>{"use strict";var xJ=ys&&ys.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),yJ=ys&&ys.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&xJ(e,t,n)};Object.defineProperty(ys,"__esModule",{value:!0});yJ($O(),ys)});var NO=C(Fx=>{"use strict";Object.defineProperty(Fx,"__esModule",{value:!0});Fx.Argument=SJ;var wJ=me(),kJ=pe();function SJ(t){return(0,wJ.CreateType)({[kJ.Kind]:"Argument",index:t})}});var Bh=C(ws=>{"use strict";var TJ=ws&&ws.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),CJ=ws&&ws.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&TJ(e,t,n)};Object.defineProperty(ws,"__esModule",{value:!0});CJ(NO(),ws)});var BO=C(Dx=>{"use strict";Object.defineProperty(Dx,"__esModule",{value:!0});Dx.AsyncIterator=PJ;var MJ=pe(),RJ=me();function PJ(t,e){return(0,RJ.CreateType)({[MJ.Kind]:"AsyncIterator",type:"AsyncIterator",items:t},e)}});var Vl=C(ks=>{"use strict";var IJ=ks&&ks.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),EJ=ks&&ks.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&IJ(e,t,n)};Object.defineProperty(ks,"__esModule",{value:!0});EJ(BO(),ks)});var jO=C(Ux=>{"use strict";Object.defineProperty(Ux,"__esModule",{value:!0});Ux.Computed=OJ;var AJ=vo(),_J=td();function OJ(t,e,n){return(0,AJ.CreateType)({[_J.Kind]:"Computed",target:t,parameters:e},n)}});var mr=C(Ss=>{"use strict";var LJ=Ss&&Ss.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),WJ=Ss&&Ss.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&LJ(e,t,n)};Object.defineProperty(Ss,"__esModule",{value:!0});WJ(jO(),Ss)});var jh=C($x=>{"use strict";Object.defineProperty($x,"__esModule",{value:!0});$x.Discard=DJ;function FJ(t,e){let{[e]:n,...i}=t;return i}function DJ(t,e){return e.reduce((n,i)=>FJ(n,i),t)}});var xo=C(Ts=>{"use strict";var UJ=Ts&&Ts.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),$J=Ts&&Ts.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&UJ(e,t,n)};Object.defineProperty(Ts,"__esModule",{value:!0});$J(jh(),Ts)});var qO=C(Nx=>{"use strict";Object.defineProperty(Nx,"__esModule",{value:!0});Nx.Never=jJ;var NJ=me(),BJ=pe();function jJ(t){return(0,NJ.CreateType)({[BJ.Kind]:"Never",not:{}},t)}});var Et=C(Cs=>{"use strict";var qJ=Cs&&Cs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),KJ=Cs&&Cs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&qJ(e,t,n)};Object.defineProperty(Cs,"__esModule",{value:!0});KJ(qO(),Cs)});var KO=C(Bx=>{"use strict";Object.defineProperty(Bx,"__esModule",{value:!0});Bx.MappedKey=HJ;var GJ=me(),zJ=pe();function HJ(t){return(0,GJ.CreateType)({[zJ.Kind]:"MappedKey",keys:t})}});var qx=C(jx=>{"use strict";Object.defineProperty(jx,"__esModule",{value:!0});jx.MappedResult=YJ;var VJ=me(),QJ=pe();function YJ(t){return(0,VJ.CreateType)({[QJ.Kind]:"MappedResult",properties:t})}});var GO=C(Kx=>{"use strict";Object.defineProperty(Kx,"__esModule",{value:!0});Kx.Constructor=ZJ;var JJ=me(),XJ=pe();function ZJ(t,e,n){return(0,JJ.CreateType)({[XJ.Kind]:"Constructor",type:"Constructor",parameters:t,returns:e},n)}});var Ql=C(Ms=>{"use strict";var eX=Ms&&Ms.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),tX=Ms&&Ms.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&eX(e,t,n)};Object.defineProperty(Ms,"__esModule",{value:!0});tX(GO(),Ms)});var zO=C(Gx=>{"use strict";Object.defineProperty(Gx,"__esModule",{value:!0});Gx.Function=oX;var nX=me(),iX=pe();function oX(t,e,n){return(0,nX.CreateType)({[iX.Kind]:"Function",type:"Function",parameters:t,returns:e},n)}});var hr=C(Rs=>{"use strict";var rX=Rs&&Rs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),sX=Rs&&Rs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&rX(e,t,n)};Object.defineProperty(Rs,"__esModule",{value:!0});sX(zO(),Rs)});var Hx=C(zx=>{"use strict";Object.defineProperty(zx,"__esModule",{value:!0});zx.UnionCreate=cX;var aX=me(),lX=pe();function cX(t,e){return(0,aX.CreateType)({[lX.Kind]:"Union",anyOf:t},e)}});var YO=C(Vx=>{"use strict";Object.defineProperty(Vx,"__esModule",{value:!0});Vx.UnionEvaluated=bX;var uX=me(),dX=pe(),pX=xo(),mX=Et(),hX=Ui(),HO=Hx(),QO=Le();function gX(t){return t.some(e=>(0,QO.IsOptional)(e))}function VO(t){return t.map(e=>(0,QO.IsOptional)(e)?fX(e):e)}function fX(t){return(0,pX.Discard)(t,[dX.OptionalKind])}function vX(t,e){return gX(t)?(0,hX.Optional)((0,HO.UnionCreate)(VO(t),e)):(0,HO.UnionCreate)(VO(t),e)}function bX(t,e){return t.length===1?(0,uX.CreateType)(t[0],e):t.length===0?(0,mX.Never)(e):vX(t,e)}});var XO=C(JO=>{"use strict";Object.defineProperty(JO,"__esModule",{value:!0});var Wje=pe()});var ZO=C(Qx=>{"use strict";Object.defineProperty(Qx,"__esModule",{value:!0});Qx.Union=kX;var xX=Et(),yX=me(),wX=Hx();function kX(t,e){return t.length===0?(0,xX.Never)(e):t.length===1?(0,yX.CreateType)(t[0],e):(0,wX.UnionCreate)(t,e)}});var mt=C(yo=>{"use strict";var SX=yo&&yo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Yx=yo&&yo.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&SX(e,t,n)};Object.defineProperty(yo,"__esModule",{value:!0});Yx(YO(),yo);Yx(XO(),yo);Yx(ZO(),yo)});var qh=C(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});Yl.TemplateLiteralParserError=void 0;Yl.TemplateLiteralParse=Ps;Yl.TemplateLiteralParseExact=_X;var TX=Wi(),ad=class extends TX.TypeBoxError{};Yl.TemplateLiteralParserError=ad;function CX(t){return t.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Jx(t,e,n){return t[e]===n&&t.charCodeAt(e-1)!==92}function wo(t,e){return Jx(t,e,"(")}function ld(t,e){return Jx(t,e,")")}function e5(t,e){return Jx(t,e,"|")}function MX(t){if(!(wo(t,0)&&ld(t,t.length-1)))return!1;let e=0;for(let n=0;n<t.length;n++)if(wo(t,n)&&(e+=1),ld(t,n)&&(e-=1),e===0&&n!==t.length-1)return!1;return!0}function RX(t){return t.slice(1,t.length-1)}function PX(t){let e=0;for(let n=0;n<t.length;n++)if(wo(t,n)&&(e+=1),ld(t,n)&&(e-=1),e5(t,n)&&e===0)return!0;return!1}function IX(t){for(let e=0;e<t.length;e++)if(wo(t,e))return!0;return!1}function EX(t){let[e,n]=[0,0],i=[];for(let r=0;r<t.length;r++)if(wo(t,r)&&(e+=1),ld(t,r)&&(e-=1),e5(t,r)&&e===0){let s=t.slice(n,r);s.length>0&&i.push(Ps(s)),n=r+1}let o=t.slice(n);return o.length>0&&i.push(Ps(o)),i.length===0?{type:"const",const:""}:i.length===1?i[0]:{type:"or",expr:i}}function AX(t){function e(o,r){if(!wo(o,r))throw new ad("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=r;a<o.length;a++)if(wo(o,a)&&(s+=1),ld(o,a)&&(s-=1),s===0)return[r,a];throw new ad("TemplateLiteralParser: Unclosed group parens in expression")}function n(o,r){for(let s=r;s<o.length;s++)if(wo(o,s))return[r,s];return[r,o.length]}let i=[];for(let o=0;o<t.length;o++)if(wo(t,o)){let[r,s]=e(t,o),a=t.slice(r,s+1);i.push(Ps(a)),o=s}else{let[r,s]=n(t,o),a=t.slice(r,s);a.length>0&&i.push(Ps(a)),o=s-1}return i.length===0?{type:"const",const:""}:i.length===1?i[0]:{type:"and",expr:i}}function Ps(t){return MX(t)?Ps(RX(t)):PX(t)?EX(t):IX(t)?AX(t):{type:"const",const:CX(t)}}function _X(t){return Ps(t.slice(1,t.length-1))}});var Xx=C(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.TemplateLiteralFiniteError=void 0;Jl.IsTemplateLiteralExpressionFinite=Gh;Jl.IsTemplateLiteralFinite=UX;var OX=qh(),LX=Wi(),Kh=class extends LX.TypeBoxError{};Jl.TemplateLiteralFiniteError=Kh;function WX(t){return t.type==="or"&&t.expr.length===2&&t.expr[0].type==="const"&&t.expr[0].const==="0"&&t.expr[1].type==="const"&&t.expr[1].const==="[1-9][0-9]*"}function FX(t){return t.type==="or"&&t.expr.length===2&&t.expr[0].type==="const"&&t.expr[0].const==="true"&&t.expr[1].type==="const"&&t.expr[1].const==="false"}function DX(t){return t.type==="const"&&t.const===".*"}function Gh(t){return WX(t)||DX(t)?!1:FX(t)?!0:t.type==="and"?t.expr.every(e=>Gh(e)):t.type==="or"?t.expr.every(e=>Gh(e)):t.type==="const"?!0:(()=>{throw new Kh("Unknown expression type")})()}function UX(t){let e=(0,OX.TemplateLiteralParseExact)(t.pattern);return Gh(e)}});var Zx=C(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.TemplateLiteralGenerateError=void 0;Xl.TemplateLiteralExpressionGenerate=Hh;Xl.TemplateLiteralGenerate=GX;var $X=Xx(),NX=qh(),BX=Wi(),zh=class extends BX.TypeBoxError{};Xl.TemplateLiteralGenerateError=zh;function*t5(t){if(t.length===1)return yield*t[0];for(let e of t[0])for(let n of t5(t.slice(1)))yield`${e}${n}`}function*jX(t){return yield*t5(t.expr.map(e=>[...Hh(e)]))}function*qX(t){for(let e of t.expr)yield*Hh(e)}function*KX(t){return yield t.const}function*Hh(t){return t.type==="and"?yield*jX(t):t.type==="or"?yield*qX(t):t.type==="const"?yield*KX(t):(()=>{throw new zh("Unknown expression")})()}function GX(t){let e=(0,NX.TemplateLiteralParseExact)(t.pattern);return(0,$X.IsTemplateLiteralExpressionFinite)(e)?[...Hh(e)]:[]}});var n5=C(ey=>{"use strict";Object.defineProperty(ey,"__esModule",{value:!0});ey.Literal=VX;var zX=me(),HX=pe();function VX(t,e){return(0,zX.CreateType)({[HX.Kind]:"Literal",const:t,type:typeof t},e)}});var Jt=C(Is=>{"use strict";var QX=Is&&Is.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),YX=Is&&Is.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&QX(e,t,n)};Object.defineProperty(Is,"__esModule",{value:!0});YX(n5(),Is)});var i5=C(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.Boolean=ZX;var JX=pe(),XX=vo();function ZX(t){return(0,XX.CreateType)({[JX.Kind]:"Boolean",type:"boolean"},t)}});var cd=C(Es=>{"use strict";var eZ=Es&&Es.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),tZ=Es&&Es.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&eZ(e,t,n)};Object.defineProperty(Es,"__esModule",{value:!0});tZ(i5(),Es)});var o5=C(ny=>{"use strict";Object.defineProperty(ny,"__esModule",{value:!0});ny.BigInt=oZ;var nZ=pe(),iZ=vo();function oZ(t){return(0,iZ.CreateType)({[nZ.Kind]:"BigInt",type:"bigint"},t)}});var Zl=C(As=>{"use strict";var rZ=As&&As.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),sZ=As&&As.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&rZ(e,t,n)};Object.defineProperty(As,"__esModule",{value:!0});sZ(o5(),As)});var r5=C(iy=>{"use strict";Object.defineProperty(iy,"__esModule",{value:!0});iy.Number=cZ;var aZ=me(),lZ=pe();function cZ(t){return(0,aZ.CreateType)({[lZ.Kind]:"Number",type:"number"},t)}});var gr=C(_s=>{"use strict";var uZ=_s&&_s.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),dZ=_s&&_s.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&uZ(e,t,n)};Object.defineProperty(_s,"__esModule",{value:!0});dZ(r5(),_s)});var s5=C(oy=>{"use strict";Object.defineProperty(oy,"__esModule",{value:!0});oy.String=hZ;var pZ=me(),mZ=pe();function hZ(t){return(0,pZ.CreateType)({[mZ.Kind]:"String",type:"string"},t)}});var Ls=C(Os=>{"use strict";var gZ=Os&&Os.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),fZ=Os&&Os.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&gZ(e,t,n)};Object.defineProperty(Os,"__esModule",{value:!0});fZ(s5(),Os)});var ay=C(sy=>{"use strict";Object.defineProperty(sy,"__esModule",{value:!0});sy.TemplateLiteralSyntax=CZ;var ud=Jt(),vZ=cd(),bZ=Zl(),xZ=gr(),yZ=Ls(),wZ=mt(),kZ=Et();function*SZ(t){let e=t.trim().replace(/"|'/g,"");return e==="boolean"?yield(0,vZ.Boolean)():e==="number"?yield(0,xZ.Number)():e==="bigint"?yield(0,bZ.BigInt)():e==="string"?yield(0,yZ.String)():yield(()=>{let n=e.split("|").map(i=>(0,ud.Literal)(i.trim()));return n.length===0?(0,kZ.Never)():n.length===1?n[0]:(0,wZ.UnionEvaluated)(n)})()}function*TZ(t){if(t[1]!=="{"){let e=(0,ud.Literal)("$"),n=ry(t.slice(1));return yield*[e,...n]}for(let e=2;e<t.length;e++)if(t[e]==="}"){let n=SZ(t.slice(2,e)),i=ry(t.slice(e+1));return yield*[...n,...i]}yield(0,ud.Literal)(t)}function*ry(t){for(let e=0;e<t.length;e++)if(t[e]==="$"){let n=(0,ud.Literal)(t.slice(0,e)),i=TZ(t.slice(e));return yield*[n,...i]}yield(0,ud.Literal)(t)}function CZ(t){return[...ry(t)]}});var ly=C(pd=>{"use strict";Object.defineProperty(pd,"__esModule",{value:!0});pd.TemplateLiteralPatternError=void 0;pd.TemplateLiteralPattern=IZ;var dd=rd(),MZ=pe(),RZ=Wi(),fr=Le(),Vh=class extends RZ.TypeBoxError{};pd.TemplateLiteralPatternError=Vh;function PZ(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a5(t,e){return(0,fr.IsTemplateLiteral)(t)?t.pattern.slice(1,t.pattern.length-1):(0,fr.IsUnion)(t)?`(${t.anyOf.map(n=>a5(n,e)).join("|")})`:(0,fr.IsNumber)(t)?`${e}${dd.PatternNumber}`:(0,fr.IsInteger)(t)?`${e}${dd.PatternNumber}`:(0,fr.IsBigInt)(t)?`${e}${dd.PatternNumber}`:(0,fr.IsString)(t)?`${e}${dd.PatternString}`:(0,fr.IsLiteral)(t)?`${e}${PZ(t.const.toString())}`:(0,fr.IsBoolean)(t)?`${e}${dd.PatternBoolean}`:(()=>{throw new Vh(`Unexpected Kind '${t[MZ.Kind]}'`)})()}function IZ(t){return`^${t.map(e=>a5(e,"")).join("")}$`}});var l5=C(cy=>{"use strict";Object.defineProperty(cy,"__esModule",{value:!0});cy.TemplateLiteralToUnion=OZ;var EZ=mt(),AZ=Jt(),_Z=Zx();function OZ(t){let n=(0,_Z.TemplateLiteralGenerate)(t).map(i=>(0,AZ.Literal)(i));return(0,EZ.UnionEvaluated)(n)}});var u5=C(uy=>{"use strict";Object.defineProperty(uy,"__esModule",{value:!0});uy.TemplateLiteral=UZ;var LZ=me(),WZ=ay(),c5=ly(),FZ=Yt(),DZ=pe();function UZ(t,e){let n=(0,FZ.IsString)(t)?(0,c5.TemplateLiteralPattern)((0,WZ.TemplateLiteralSyntax)(t)):(0,c5.TemplateLiteralPattern)(t);return(0,LZ.CreateType)({[DZ.Kind]:"TemplateLiteral",type:"string",pattern:n},e)}});var $i=C(_n=>{"use strict";var $Z=_n&&_n.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Ws=_n&&_n.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&$Z(e,t,n)};Object.defineProperty(_n,"__esModule",{value:!0});Ws(Xx(),_n);Ws(Zx(),_n);Ws(ay(),_n);Ws(qh(),_n);Ws(ly(),_n);Ws(l5(),_n);Ws(u5(),_n)});var Qh=C(dy=>{"use strict";Object.defineProperty(dy,"__esModule",{value:!0});dy.IndexPropertyKeys=d5;var NZ=$i(),md=Le();function BZ(t){return(0,NZ.TemplateLiteralGenerate)(t).map(n=>n.toString())}function jZ(t){let e=[];for(let n of t)e.push(...d5(n));return e}function qZ(t){return[t.toString()]}function d5(t){return[...new Set((0,md.IsTemplateLiteral)(t)?BZ(t):(0,md.IsUnion)(t)?jZ(t.anyOf):(0,md.IsLiteral)(t)?qZ(t.const):(0,md.IsNumber)(t)?["[number]"]:(0,md.IsInteger)(t)?["[number]"]:[])]}});var my=C(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});py.IndexFromMappedResult=QZ;var KZ=vt(),GZ=Qh(),zZ=gi();function HZ(t,e,n){let i={};for(let o of Object.getOwnPropertyNames(e))i[o]=(0,zZ.Index)(t,(0,GZ.IndexPropertyKeys)(e[o]),n);return i}function VZ(t,e,n){return HZ(t,e.properties,n)}function QZ(t,e,n){let i=VZ(t,e,n);return(0,KZ.MappedResult)(i)}});var Jh=C(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.IndexFromPropertyKey=gy;ec.IndexFromPropertyKeys=g5;ec.IndexFromComputed=cee;ec.Index=uee;var YZ=me(),JZ=Wi(),m5=mr(),Yh=Et(),XZ=On(),hy=mt(),ZZ=Qh(),eee=fy(),tee=my(),pn=Le();function h5(t,e){return t.map(n=>gy(n,e))}function nee(t){return t.filter(e=>!(0,pn.IsNever)(e))}function iee(t,e){return(0,XZ.IntersectEvaluated)(nee(h5(t,e)))}function oee(t){return t.some(e=>(0,pn.IsNever)(e))?[]:t}function ree(t,e){return(0,hy.UnionEvaluated)(oee(h5(t,e)))}function see(t,e){return e in t?t[e]:e==="[number]"?(0,hy.UnionEvaluated)(t):(0,Yh.Never)()}function aee(t,e){return e==="[number]"?t:(0,Yh.Never)()}function lee(t,e){return e in t?t[e]:(0,Yh.Never)()}function gy(t,e){return(0,pn.IsIntersect)(t)?iee(t.allOf,e):(0,pn.IsUnion)(t)?ree(t.anyOf,e):(0,pn.IsTuple)(t)?see(t.items??[],e):(0,pn.IsArray)(t)?aee(t.items,e):(0,pn.IsObject)(t)?lee(t.properties,e):(0,Yh.Never)()}function g5(t,e){return e.map(n=>gy(t,n))}function p5(t,e){return(0,hy.UnionEvaluated)(g5(t,e))}function cee(t,e){return(0,m5.Computed)("Index",[t,e])}function uee(t,e,n){if((0,pn.IsRef)(t)||(0,pn.IsRef)(e)){let i="Index types using Ref parameters require both Type and Key to be of TSchema";if(!(0,pn.IsSchema)(t)||!(0,pn.IsSchema)(e))throw new JZ.TypeBoxError(i);return(0,m5.Computed)("Index",[t,e])}return(0,pn.IsMappedResult)(e)?(0,tee.IndexFromMappedResult)(t,e,n):(0,pn.IsMappedKey)(e)?(0,eee.IndexFromMappedKey)(t,e,n):(0,YZ.CreateType)((0,pn.IsSchema)(e)?p5(t,(0,ZZ.IndexPropertyKeys)(e)):p5(t,e),n)}});var fy=C(vy=>{"use strict";Object.defineProperty(vy,"__esModule",{value:!0});vy.IndexFromMappedKey=vee;var dee=Jh(),pee=vt(),mee=cn();function hee(t,e,n){return{[e]:(0,dee.Index)(t,[e],(0,mee.Clone)(n))}}function gee(t,e,n){return e.reduce((i,o)=>({...i,...hee(t,o,n)}),{})}function fee(t,e,n){return gee(t,e.keys,n)}function vee(t,e,n){let i=fee(t,e,n);return(0,pee.MappedResult)(i)}});var gi=C(Ni=>{"use strict";var bee=Ni&&Ni.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Xh=Ni&&Ni.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&bee(e,t,n)};Object.defineProperty(Ni,"__esModule",{value:!0});Xh(fy(),Ni);Xh(my(),Ni);Xh(Qh(),Ni);Xh(Jh(),Ni)});var f5=C(by=>{"use strict";Object.defineProperty(by,"__esModule",{value:!0});by.Iterator=wee;var xee=me(),yee=pe();function wee(t,e){return(0,xee.CreateType)({[yee.Kind]:"Iterator",type:"Iterator",items:t},e)}});var tc=C(Fs=>{"use strict";var kee=Fs&&Fs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),See=Fs&&Fs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&kee(e,t,n)};Object.defineProperty(Fs,"__esModule",{value:!0});See(f5(),Fs)});var b5=C(Zh=>{"use strict";Object.defineProperty(Zh,"__esModule",{value:!0});Zh.Object=void 0;var Tee=me(),v5=pe(),Cee=Le();function Mee(t){return globalThis.Object.keys(t).filter(e=>!(0,Cee.IsOptional)(t[e]))}function Ree(t,e){let n=Mee(t),i=n.length>0?{[v5.Kind]:"Object",type:"object",required:n,properties:t}:{[v5.Kind]:"Object",type:"object",properties:t};return(0,Tee.CreateType)(i,e)}Zh.Object=Ree});var mn=C(Ds=>{"use strict";var Pee=Ds&&Ds.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Iee=Ds&&Ds.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Pee(e,t,n)};Object.defineProperty(Ds,"__esModule",{value:!0});Iee(b5(),Ds)});var x5=C(xy=>{"use strict";Object.defineProperty(xy,"__esModule",{value:!0});xy.Promise=_ee;var Eee=me(),Aee=pe();function _ee(t,e){return(0,Eee.CreateType)({[Aee.Kind]:"Promise",type:"Promise",item:t},e)}});var hd=C(Us=>{"use strict";var Oee=Us&&Us.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Lee=Us&&Us.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Oee(e,t,n)};Object.defineProperty(Us,"__esModule",{value:!0});Lee(x5(),Us)});var wy=C(yy=>{"use strict";Object.defineProperty(yy,"__esModule",{value:!0});yy.Readonly=Bee;var y5=me(),w5=pe(),Wee=xo(),Fee=ky(),Dee=Le();function Uee(t){return(0,y5.CreateType)((0,Wee.Discard)(t,[w5.ReadonlyKind]))}function $ee(t){return(0,y5.CreateType)({...t,[w5.ReadonlyKind]:"Readonly"})}function Nee(t,e){return e===!1?Uee(t):$ee(t)}function Bee(t,e){let n=e??!0;return(0,Dee.IsMappedResult)(t)?(0,Fee.ReadonlyFromMappedResult)(t,n):Nee(t,n)}});var ky=C(Sy=>{"use strict";Object.defineProperty(Sy,"__esModule",{value:!0});Sy.ReadonlyFromMappedResult=zee;var jee=vt(),qee=wy();function Kee(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,qee.Readonly)(t[i],e);return n}function Gee(t,e){return Kee(t.properties,e)}function zee(t,e){let n=Gee(t,e);return(0,jee.MappedResult)(n)}});var br=C(vr=>{"use strict";var Hee=vr&&vr.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),k5=vr&&vr.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Hee(e,t,n)};Object.defineProperty(vr,"__esModule",{value:!0});k5(ky(),vr);k5(wy(),vr)});var T5=C(Ty=>{"use strict";Object.defineProperty(Ty,"__esModule",{value:!0});Ty.Tuple=Qee;var Vee=me(),S5=pe();function Qee(t,e){return(0,Vee.CreateType)(t.length>0?{[S5.Kind]:"Tuple",type:"array",items:t,additionalItems:!1,minItems:t.length,maxItems:t.length}:{[S5.Kind]:"Tuple",type:"array",minItems:t.length,maxItems:t.length},e)}});var ko=C($s=>{"use strict";var Yee=$s&&$s.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Jee=$s&&$s.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Yee(e,t,n)};Object.defineProperty($s,"__esModule",{value:!0});Jee(T5(),$s)});var E5=C(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});eg.MappedFunctionReturnType=I5;eg.Mapped=vte;var Cy=pe(),C5=xo(),Xee=Hl(),Zee=Vl(),ete=Ql(),tte=hr(),nte=gi(),ite=On(),ote=tc(),M5=Jt(),R5=mn(),rte=Ui(),ste=hd(),ate=br(),lte=ko(),cte=mt(),ute=sd(),dte=qx(),Xt=Le();function P5(t,e){return t in e?ei(t,e[t]):(0,dte.MappedResult)(e)}function pte(t){return{[t]:(0,M5.Literal)(t)}}function mte(t){let e={};for(let n of t)e[n]=(0,M5.Literal)(n);return e}function hte(t,e){return(0,ute.SetIncludes)(e,t)?pte(t):mte(e)}function gte(t,e){let n=hte(t,e);return P5(t,n)}function gd(t,e){return e.map(n=>ei(t,n))}function fte(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(e))n[i]=ei(t,e[i]);return n}function ei(t,e){let n={...e};return(0,Xt.IsOptional)(e)?(0,rte.Optional)(ei(t,(0,C5.Discard)(e,[Cy.OptionalKind]))):(0,Xt.IsReadonly)(e)?(0,ate.Readonly)(ei(t,(0,C5.Discard)(e,[Cy.ReadonlyKind]))):(0,Xt.IsMappedResult)(e)?P5(t,e.properties):(0,Xt.IsMappedKey)(e)?gte(t,e.keys):(0,Xt.IsConstructor)(e)?(0,ete.Constructor)(gd(t,e.parameters),ei(t,e.returns),n):(0,Xt.IsFunction)(e)?(0,tte.Function)(gd(t,e.parameters),ei(t,e.returns),n):(0,Xt.IsAsyncIterator)(e)?(0,Zee.AsyncIterator)(ei(t,e.items),n):(0,Xt.IsIterator)(e)?(0,ote.Iterator)(ei(t,e.items),n):(0,Xt.IsIntersect)(e)?(0,ite.Intersect)(gd(t,e.allOf),n):(0,Xt.IsUnion)(e)?(0,cte.Union)(gd(t,e.anyOf),n):(0,Xt.IsTuple)(e)?(0,lte.Tuple)(gd(t,e.items??[]),n):(0,Xt.IsObject)(e)?(0,R5.Object)(fte(t,e.properties),n):(0,Xt.IsArray)(e)?(0,Xee.Array)(ei(t,e.items),n):(0,Xt.IsPromise)(e)?(0,ste.Promise)(ei(t,e.item),n):e}function I5(t,e){let n={};for(let i of t)n[i]=ei(i,e);return n}function vte(t,e,n){let i=(0,Xt.IsSchema)(t)?(0,nte.IndexPropertyKeys)(t):t,o=e({[Cy.Kind]:"MappedKey",keys:i}),r=I5(i,o);return(0,R5.Object)(r,n)}});var vt=C(So=>{"use strict";var bte=So&&So.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),My=So&&So.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&bte(e,t,n)};Object.defineProperty(So,"__esModule",{value:!0});My(KO(),So);My(qx(),So);My(E5(),So)});var Py=C(Ry=>{"use strict";Object.defineProperty(Ry,"__esModule",{value:!0});Ry.Optional=Cte;var A5=me(),_5=pe(),xte=xo(),yte=Iy(),wte=Le();function kte(t){return(0,A5.CreateType)((0,xte.Discard)(t,[_5.OptionalKind]))}function Ste(t){return(0,A5.CreateType)({...t,[_5.OptionalKind]:"Optional"})}function Tte(t,e){return e===!1?kte(t):Ste(t)}function Cte(t,e){let n=e??!0;return(0,wte.IsMappedResult)(t)?(0,yte.OptionalFromMappedResult)(t,n):Tte(t,n)}});var Iy=C(Ey=>{"use strict";Object.defineProperty(Ey,"__esModule",{value:!0});Ey.OptionalFromMappedResult=Ete;var Mte=vt(),Rte=Py();function Pte(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,Rte.Optional)(t[i],e);return n}function Ite(t,e){return Pte(t.properties,e)}function Ete(t,e){let n=Ite(t,e);return(0,Mte.MappedResult)(n)}});var Ui=C(xr=>{"use strict";var Ate=xr&&xr.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),O5=xr&&xr.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Ate(e,t,n)};Object.defineProperty(xr,"__esModule",{value:!0});O5(Iy(),xr);O5(Py(),xr)});var Oy=C(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.IntersectCreate=Ote;var _te=me(),L5=pe(),Ay=Le();function Ote(t,e={}){let n=t.every(o=>(0,Ay.IsObject)(o)),i=(0,Ay.IsSchema)(e.unevaluatedProperties)?{unevaluatedProperties:e.unevaluatedProperties}:{};return(0,_te.CreateType)(e.unevaluatedProperties===!1||(0,Ay.IsSchema)(e.unevaluatedProperties)||n?{...i,[L5.Kind]:"Intersect",type:"object",allOf:t}:{...i,[L5.Kind]:"Intersect",allOf:t},e)}});var D5=C(Wy=>{"use strict";Object.defineProperty(Wy,"__esModule",{value:!0});Wy.IntersectEvaluated=jte;var Lte=pe(),Wte=me(),Fte=xo(),Dte=Et(),Ute=Ui(),W5=Oy(),Ly=Le();function $te(t){return t.every(e=>(0,Ly.IsOptional)(e))}function Nte(t){return(0,Fte.Discard)(t,[Lte.OptionalKind])}function F5(t){return t.map(e=>(0,Ly.IsOptional)(e)?Nte(e):e)}function Bte(t,e){return $te(t)?(0,Ute.Optional)((0,W5.IntersectCreate)(F5(t),e)):(0,W5.IntersectCreate)(F5(t),e)}function jte(t,e={}){if(t.length===1)return(0,Wte.CreateType)(t[0],e);if(t.length===0)return(0,Dte.Never)(e);if(t.some(n=>(0,Ly.IsTransform)(n)))throw new Error("Cannot intersect transform types");return Bte(t,e)}});var $5=C(U5=>{"use strict";Object.defineProperty(U5,"__esModule",{value:!0});var M8e=pe()});var N5=C(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.Intersect=Hte;var qte=me(),Kte=Et(),Gte=Oy(),zte=Le();function Hte(t,e){if(t.length===1)return(0,qte.CreateType)(t[0],e);if(t.length===0)return(0,Kte.Never)(e);if(t.some(n=>(0,zte.IsTransform)(n)))throw new Error("Cannot intersect transform types");return(0,Gte.IntersectCreate)(t,e)}});var On=C(To=>{"use strict";var Vte=To&&To.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Dy=To&&To.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Vte(e,t,n)};Object.defineProperty(To,"__esModule",{value:!0});Dy(D5(),To);Dy($5(),To);Dy(N5(),To)});var B5=C(Uy=>{"use strict";Object.defineProperty(Uy,"__esModule",{value:!0});Uy.Ref=Xte;var Qte=Wi(),Yte=me(),Jte=pe();function Xte(...t){let[e,n]=typeof t[0]=="string"?[t[0],t[1]]:[t[0].$id,t[1]];if(typeof e!="string")throw new Qte.TypeBoxError("Ref: $ref must be a string");return(0,Yte.CreateType)({[Jte.Kind]:"Ref",$ref:e},n)}});var yr=C(Ns=>{"use strict";var Zte=Ns&&Ns.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ene=Ns&&Ns.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Zte(e,t,n)};Object.defineProperty(Ns,"__esModule",{value:!0});ene(B5(),Ns)});var q5=C(By=>{"use strict";Object.defineProperty(By,"__esModule",{value:!0});By.Awaited=Ny;var tne=me(),$y=mr(),nne=On(),ine=mt(),one=yr(),fd=Le();function rne(t,e){return(0,$y.Computed)("Awaited",[(0,$y.Computed)(t,e)])}function sne(t){return(0,$y.Computed)("Awaited",[(0,one.Ref)(t)])}function ane(t){return(0,nne.Intersect)(j5(t))}function lne(t){return(0,ine.Union)(j5(t))}function cne(t){return Ny(t)}function j5(t){return t.map(e=>Ny(e))}function Ny(t,e){return(0,tne.CreateType)((0,fd.IsComputed)(t)?rne(t.target,t.parameters):(0,fd.IsIntersect)(t)?ane(t.allOf):(0,fd.IsUnion)(t)?lne(t.anyOf):(0,fd.IsPromise)(t)?cne(t.item):(0,fd.IsRef)(t)?sne(t.$ref):t,e)}});var vd=C(Bs=>{"use strict";var une=Bs&&Bs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),dne=Bs&&Bs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&une(e,t,n)};Object.defineProperty(Bs,"__esModule",{value:!0});dne(q5(),Bs)});var ng=C(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.KeyOfPropertyKeys=qy;tg.KeyOfPattern=bne;var K5=sd(),nc=Le();function G5(t){let e=[];for(let n of t)e.push(qy(n));return e}function pne(t){let e=G5(t);return(0,K5.SetUnionMany)(e)}function mne(t){let e=G5(t);return(0,K5.SetIntersectMany)(e)}function hne(t){return t.map((e,n)=>n.toString())}function gne(t){return["[number]"]}function fne(t){return globalThis.Object.getOwnPropertyNames(t)}function vne(t){return jy?globalThis.Object.getOwnPropertyNames(t).map(n=>n[0]==="^"&&n[n.length-1]==="$"?n.slice(1,n.length-1):n):[]}function qy(t){return(0,nc.IsIntersect)(t)?pne(t.allOf):(0,nc.IsUnion)(t)?mne(t.anyOf):(0,nc.IsTuple)(t)?hne(t.items??[]):(0,nc.IsArray)(t)?gne(t.items):(0,nc.IsObject)(t)?fne(t.properties):(0,nc.IsRecord)(t)?vne(t.patternProperties):[]}var jy=!1;function bne(t){jy=!0;let e=qy(t);return jy=!1,`^(${e.map(i=>`(${i})`).join("|")})$`}});var zy=C(ig=>{"use strict";Object.defineProperty(ig,"__esModule",{value:!0});ig.KeyOfPropertyKeysToRest=z5;ig.KeyOf=Ine;var xne=me(),yne=Jt(),wne=gr(),Gy=mr(),kne=yr(),Sne=ng(),Tne=mt(),Cne=Hy(),Ky=Le();function Mne(t,e){return(0,Gy.Computed)("KeyOf",[(0,Gy.Computed)(t,e)])}function Rne(t){return(0,Gy.Computed)("KeyOf",[(0,kne.Ref)(t)])}function Pne(t,e){let n=(0,Sne.KeyOfPropertyKeys)(t),i=z5(n),o=(0,Tne.UnionEvaluated)(i);return(0,xne.CreateType)(o,e)}function z5(t){return t.map(e=>e==="[number]"?(0,wne.Number)():(0,yne.Literal)(e))}function Ine(t,e){return(0,Ky.IsComputed)(t)?Mne(t.target,t.parameters):(0,Ky.IsRef)(t)?Rne(t.$ref):(0,Ky.IsMappedResult)(t)?(0,Cne.KeyOfFromMappedResult)(t,e):Pne(t,e)}});var Hy=C(Vy=>{"use strict";Object.defineProperty(Vy,"__esModule",{value:!0});Vy.KeyOfFromMappedResult=Wne;var Ene=vt(),Ane=zy(),_ne=cn();function One(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,Ane.KeyOf)(t[i],(0,_ne.Clone)(e));return n}function Lne(t,e){return One(t.properties,e)}function Wne(t,e){let n=Lne(t,e);return(0,Ene.MappedResult)(n)}});var H5=C(Qy=>{"use strict";Object.defineProperty(Qy,"__esModule",{value:!0});Qy.KeyOfPropertyEntries=Une;var Fne=Jh(),Dne=ng();function Une(t){let e=(0,Dne.KeyOfPropertyKeys)(t),n=(0,Fne.IndexFromPropertyKeys)(t,e);return e.map((i,o)=>[e[o],n[o]])}});var ic=C(Bi=>{"use strict";var $ne=Bi&&Bi.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),og=Bi&&Bi.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&$ne(e,t,n)};Object.defineProperty(Bi,"__esModule",{value:!0});og(Hy(),Bi);og(H5(),Bi);og(ng(),Bi);og(zy(),Bi)});var V5=C(Yy=>{"use strict";Object.defineProperty(Yy,"__esModule",{value:!0});Yy.Composite=Yne;var Nne=On(),Bne=gi(),jne=ic(),qne=mn(),Kne=sd(),Gne=Le();function zne(t){let e=[];for(let n of t)e.push(...(0,jne.KeyOfPropertyKeys)(n));return(0,Kne.SetDistinct)(e)}function Hne(t){return t.filter(e=>!(0,Gne.IsNever)(e))}function Vne(t,e){let n=[];for(let i of t)n.push(...(0,Bne.IndexFromPropertyKeys)(i,[e]));return Hne(n)}function Qne(t,e){let n={};for(let i of e)n[i]=(0,Nne.IntersectEvaluated)(Vne(t,i));return n}function Yne(t,e){let n=zne(t),i=Qne(t,n);return(0,qne.Object)(i,e)}});var rg=C(js=>{"use strict";var Jne=js&&js.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Xne=js&&js.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Jne(e,t,n)};Object.defineProperty(js,"__esModule",{value:!0});Xne(V5(),js)});var Q5=C(Jy=>{"use strict";Object.defineProperty(Jy,"__esModule",{value:!0});Jy.Date=tie;var Zne=pe(),eie=me();function tie(t){return(0,eie.CreateType)({[Zne.Kind]:"Date",type:"Date"},t)}});var bd=C(qs=>{"use strict";var nie=qs&&qs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),iie=qs&&qs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&nie(e,t,n)};Object.defineProperty(qs,"__esModule",{value:!0});iie(Q5(),qs)});var Y5=C(Xy=>{"use strict";Object.defineProperty(Xy,"__esModule",{value:!0});Xy.Null=sie;var oie=me(),rie=pe();function sie(t){return(0,oie.CreateType)({[rie.Kind]:"Null",type:"null"},t)}});var xd=C(Ks=>{"use strict";var aie=Ks&&Ks.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),lie=Ks&&Ks.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&aie(e,t,n)};Object.defineProperty(Ks,"__esModule",{value:!0});lie(Y5(),Ks)});var J5=C(Zy=>{"use strict";Object.defineProperty(Zy,"__esModule",{value:!0});Zy.Symbol=die;var cie=me(),uie=pe();function die(t){return(0,cie.CreateType)({[uie.Kind]:"Symbol",type:"symbol"},t)}});var yd=C(Gs=>{"use strict";var pie=Gs&&Gs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),mie=Gs&&Gs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&pie(e,t,n)};Object.defineProperty(Gs,"__esModule",{value:!0});mie(J5(),Gs)});var X5=C(ew=>{"use strict";Object.defineProperty(ew,"__esModule",{value:!0});ew.Undefined=fie;var hie=me(),gie=pe();function fie(t){return(0,hie.CreateType)({[gie.Kind]:"Undefined",type:"undefined"},t)}});var wd=C(zs=>{"use strict";var vie=zs&&zs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),bie=zs&&zs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&vie(e,t,n)};Object.defineProperty(zs,"__esModule",{value:!0});bie(X5(),zs)});var Z5=C(tw=>{"use strict";Object.defineProperty(tw,"__esModule",{value:!0});tw.Uint8Array=wie;var xie=me(),yie=pe();function wie(t){return(0,xie.CreateType)({[yie.Kind]:"Uint8Array",type:"Uint8Array"},t)}});var kd=C(Hs=>{"use strict";var kie=Hs&&Hs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Sie=Hs&&Hs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&kie(e,t,n)};Object.defineProperty(Hs,"__esModule",{value:!0});Sie(Z5(),Hs)});var eL=C(nw=>{"use strict";Object.defineProperty(nw,"__esModule",{value:!0});nw.Unknown=Mie;var Tie=me(),Cie=pe();function Mie(t){return(0,Tie.CreateType)({[Cie.Kind]:"Unknown"},t)}});var Qs=C(Vs=>{"use strict";var Rie=Vs&&Vs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Pie=Vs&&Vs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Rie(e,t,n)};Object.defineProperty(Vs,"__esModule",{value:!0});Pie(eL(),Vs)});var iL=C(sw=>{"use strict";Object.defineProperty(sw,"__esModule",{value:!0});sw.Const=Bie;var tL=zl(),Iie=Zl(),Eie=bd(),Aie=hr(),iw=Jt(),_ie=xd(),nL=mn(),Oie=yd(),Lie=ko(),ow=br(),Wie=wd(),Fie=kd(),Die=Qs(),Uie=vo(),hn=Yt();function $ie(t){return t.map(e=>rw(e,!1))}function Nie(t){let e={};for(let n of globalThis.Object.getOwnPropertyNames(t))e[n]=(0,ow.Readonly)(rw(t[n],!1));return e}function sg(t,e){return e===!0?t:(0,ow.Readonly)(t)}function rw(t,e){return(0,hn.IsAsyncIterator)(t)||(0,hn.IsIterator)(t)?sg((0,tL.Any)(),e):(0,hn.IsArray)(t)?(0,ow.Readonly)((0,Lie.Tuple)($ie(t))):(0,hn.IsUint8Array)(t)?(0,Fie.Uint8Array)():(0,hn.IsDate)(t)?(0,Eie.Date)():(0,hn.IsObject)(t)?sg((0,nL.Object)(Nie(t)),e):(0,hn.IsFunction)(t)?sg((0,Aie.Function)([],(0,Die.Unknown)()),e):(0,hn.IsUndefined)(t)?(0,Wie.Undefined)():(0,hn.IsNull)(t)?(0,_ie.Null)():(0,hn.IsSymbol)(t)?(0,Oie.Symbol)():(0,hn.IsBigInt)(t)?(0,Iie.BigInt)():(0,hn.IsNumber)(t)||(0,hn.IsBoolean)(t)||(0,hn.IsString)(t)?(0,iw.Literal)(t):(0,nL.Object)({})}function Bie(t,e){return(0,Uie.CreateType)(rw(t,!0),e)}});var ag=C(Ys=>{"use strict";var jie=Ys&&Ys.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),qie=Ys&&Ys.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&jie(e,t,n)};Object.defineProperty(Ys,"__esModule",{value:!0});qie(iL(),Ys)});var oL=C(Co=>{"use strict";var Kie=Co&&Co.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Gie=Co&&Co.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),zie=Co&&Co.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Kie(n,e,i[o]);return Gie(n,e),n}})();Object.defineProperty(Co,"__esModule",{value:!0});Co.ConstructorParameters=Yie;var Hie=ko(),Vie=Et(),Qie=zie(Le());function Yie(t,e){return Qie.IsConstructor(t)?(0,Hie.Tuple)(t.parameters,e):(0,Vie.Never)(e)}});var lg=C(Js=>{"use strict";var Jie=Js&&Js.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Xie=Js&&Js.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Jie(e,t,n)};Object.defineProperty(Js,"__esModule",{value:!0});Xie(oL(),Js)});var rL=C(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});aw.Enum=ioe;var Zie=Jt(),eoe=pe(),toe=mt(),noe=Yt();function ioe(t,e){if((0,noe.IsUndefined)(t))throw new Error("Enum undefined or empty");let n=globalThis.Object.getOwnPropertyNames(t).filter(r=>isNaN(r)).map(r=>t[r]),o=[...new Set(n)].map(r=>(0,Zie.Literal)(r));return(0,toe.Union)(o,{...e,[eoe.Hint]:"Enum"})}});var cg=C(Xs=>{"use strict";var ooe=Xs&&Xs.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),roe=Xs&&Xs.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&ooe(e,t,n)};Object.defineProperty(Xs,"__esModule",{value:!0});roe(rL(),Xs)});var gw=C(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.ExtendsResult=Zs.ExtendsResolverError=void 0;Zs.ExtendsCheck=Voe;var sL=zl(),soe=hr(),pw=gr(),cw=Ls(),aoe=Qs(),aL=$i(),oc=rd(),pL=pe(),loe=Wi(),M=_x(),ug=class extends loe.TypeBoxError{};Zs.ExtendsResolverError=ug;var B;(function(t){t[t.Union=0]="Union",t[t.True=1]="True",t[t.False=2]="False"})(B||(Zs.ExtendsResult=B={}));function ti(t){return t===B.False?t:B.True}function rc(t){throw new ug(t)}function bt(t){return M.TypeGuard.IsNever(t)||M.TypeGuard.IsIntersect(t)||M.TypeGuard.IsUnion(t)||M.TypeGuard.IsUnknown(t)||M.TypeGuard.IsAny(t)}function xt(t,e){return M.TypeGuard.IsNever(e)?gL(t,e):M.TypeGuard.IsIntersect(e)?dg(t,e):M.TypeGuard.IsUnion(e)?hw(t,e):M.TypeGuard.IsUnknown(e)?xL(t,e):M.TypeGuard.IsAny(e)?mw(t,e):rc("StructuralRight")}function mw(t,e){return B.True}function coe(t,e){return M.TypeGuard.IsIntersect(e)?dg(t,e):M.TypeGuard.IsUnion(e)&&e.anyOf.some(n=>M.TypeGuard.IsAny(n)||M.TypeGuard.IsUnknown(n))?B.True:M.TypeGuard.IsUnion(e)?B.Union:M.TypeGuard.IsUnknown(e)||M.TypeGuard.IsAny(e)?B.True:B.Union}function uoe(t,e){return M.TypeGuard.IsUnknown(t)?B.False:M.TypeGuard.IsAny(t)?B.Union:M.TypeGuard.IsNever(t)?B.True:B.False}function doe(t,e){return M.TypeGuard.IsObject(e)&&pg(e)?B.True:bt(e)?xt(t,e):M.TypeGuard.IsArray(e)?ti(je(t.items,e.items)):B.False}function poe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsAsyncIterator(e)?ti(je(t.items,e.items)):B.False}function moe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsBigInt(e)?B.True:B.False}function mL(t,e){return M.TypeGuard.IsLiteralBoolean(t)||M.TypeGuard.IsBoolean(t)?B.True:B.False}function hoe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsBoolean(e)?B.True:B.False}function goe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsConstructor(e)?t.parameters.length>e.parameters.length?B.False:t.parameters.every((n,i)=>ti(je(e.parameters[i],n))===B.True)?ti(je(t.returns,e.returns)):B.False:B.False}function foe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsDate(e)?B.True:B.False}function voe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsFunction(e)?t.parameters.length>e.parameters.length?B.False:t.parameters.every((n,i)=>ti(je(e.parameters[i],n))===B.True)?ti(je(t.returns,e.returns)):B.False:B.False}function hL(t,e){return M.TypeGuard.IsLiteral(t)&&M.ValueGuard.IsNumber(t.const)||M.TypeGuard.IsNumber(t)||M.TypeGuard.IsInteger(t)?B.True:B.False}function boe(t,e){return M.TypeGuard.IsInteger(e)||M.TypeGuard.IsNumber(e)?B.True:bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):B.False}function dg(t,e){return e.allOf.every(n=>je(t,n)===B.True)?B.True:B.False}function xoe(t,e){return t.allOf.some(n=>je(n,e)===B.True)?B.True:B.False}function yoe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsIterator(e)?ti(je(t.items,e.items)):B.False}function woe(t,e){return M.TypeGuard.IsLiteral(e)&&e.const===t.const?B.True:bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsString(e)?bL(t,e):M.TypeGuard.IsNumber(e)?fL(t,e):M.TypeGuard.IsInteger(e)?hL(t,e):M.TypeGuard.IsBoolean(e)?mL(t,e):B.False}function gL(t,e){return B.False}function koe(t,e){return B.True}function lL(t){let[e,n]=[t,0];for(;M.TypeGuard.IsNot(e);)e=e.not,n+=1;return n%2===0?e:(0,aoe.Unknown)()}function Soe(t,e){return M.TypeGuard.IsNot(t)?je(lL(t),e):M.TypeGuard.IsNot(e)?je(t,lL(e)):rc("Invalid fallthrough for Not")}function Toe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsNull(e)?B.True:B.False}function fL(t,e){return M.TypeGuard.IsLiteralNumber(t)||M.TypeGuard.IsNumber(t)||M.TypeGuard.IsInteger(t)?B.True:B.False}function Coe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsInteger(e)||M.TypeGuard.IsNumber(e)?B.True:B.False}function gn(t,e){return Object.getOwnPropertyNames(t.properties).length===e}function cL(t){return pg(t)}function uL(t){return gn(t,0)||gn(t,1)&&"description"in t.properties&&M.TypeGuard.IsUnion(t.properties.description)&&t.properties.description.anyOf.length===2&&(M.TypeGuard.IsString(t.properties.description.anyOf[0])&&M.TypeGuard.IsUndefined(t.properties.description.anyOf[1])||M.TypeGuard.IsString(t.properties.description.anyOf[1])&&M.TypeGuard.IsUndefined(t.properties.description.anyOf[0]))}function lw(t){return gn(t,0)}function dL(t){return gn(t,0)}function Moe(t){return gn(t,0)}function Roe(t){return gn(t,0)}function Poe(t){return pg(t)}function Ioe(t){let e=(0,pw.Number)();return gn(t,0)||gn(t,1)&&"length"in t.properties&&ti(je(t.properties.length,e))===B.True}function Eoe(t){return gn(t,0)}function pg(t){let e=(0,pw.Number)();return gn(t,0)||gn(t,1)&&"length"in t.properties&&ti(je(t.properties.length,e))===B.True}function Aoe(t){let e=(0,soe.Function)([(0,sL.Any)()],(0,sL.Any)());return gn(t,0)||gn(t,1)&&"then"in t.properties&&ti(je(t.properties.then,e))===B.True}function vL(t,e){return je(t,e)===B.False||M.TypeGuard.IsOptional(t)&&!M.TypeGuard.IsOptional(e)?B.False:B.True}function Bt(t,e){return M.TypeGuard.IsUnknown(t)?B.False:M.TypeGuard.IsAny(t)?B.Union:M.TypeGuard.IsNever(t)||M.TypeGuard.IsLiteralString(t)&&cL(e)||M.TypeGuard.IsLiteralNumber(t)&&lw(e)||M.TypeGuard.IsLiteralBoolean(t)&&dL(e)||M.TypeGuard.IsSymbol(t)&&uL(e)||M.TypeGuard.IsBigInt(t)&&Moe(e)||M.TypeGuard.IsString(t)&&cL(e)||M.TypeGuard.IsSymbol(t)&&uL(e)||M.TypeGuard.IsNumber(t)&&lw(e)||M.TypeGuard.IsInteger(t)&&lw(e)||M.TypeGuard.IsBoolean(t)&&dL(e)||M.TypeGuard.IsUint8Array(t)&&Poe(e)||M.TypeGuard.IsDate(t)&&Roe(e)||M.TypeGuard.IsConstructor(t)&&Eoe(e)||M.TypeGuard.IsFunction(t)&&Ioe(e)?B.True:M.TypeGuard.IsRecord(t)&&M.TypeGuard.IsString(uw(t))?e[pL.Hint]==="Record"?B.True:B.False:M.TypeGuard.IsRecord(t)&&M.TypeGuard.IsNumber(uw(t))&&gn(e,0)?B.True:B.False}function _oe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsObject(e)?(()=>{for(let n of Object.getOwnPropertyNames(e.properties)){if(!(n in t.properties)&&!M.TypeGuard.IsOptional(e.properties[n]))return B.False;if(M.TypeGuard.IsOptional(e.properties[n]))return B.True;if(vL(t.properties[n],e.properties[n])===B.False)return B.False}return B.True})():B.False}function Ooe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)&&Aoe(e)?B.True:M.TypeGuard.IsPromise(e)?ti(je(t.item,e.item)):B.False}function uw(t){return oc.PatternNumberExact in t.patternProperties?(0,pw.Number)():oc.PatternStringExact in t.patternProperties?(0,cw.String)():rc("Unknown record key pattern")}function dw(t){return oc.PatternNumberExact in t.patternProperties?t.patternProperties[oc.PatternNumberExact]:oc.PatternStringExact in t.patternProperties?t.patternProperties[oc.PatternStringExact]:rc("Unable to get record value schema")}function ni(t,e){let[n,i]=[uw(e),dw(e)];return M.TypeGuard.IsLiteralString(t)&&M.TypeGuard.IsNumber(n)&&ti(je(t,i))===B.True?B.True:M.TypeGuard.IsUint8Array(t)&&M.TypeGuard.IsNumber(n)||M.TypeGuard.IsString(t)&&M.TypeGuard.IsNumber(n)||M.TypeGuard.IsArray(t)&&M.TypeGuard.IsNumber(n)?je(t,i):M.TypeGuard.IsObject(t)?(()=>{for(let o of Object.getOwnPropertyNames(t.properties))if(vL(i,t.properties[o])===B.False)return B.False;return B.True})():B.False}function Loe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?je(dw(t),dw(e)):B.False}function Woe(t,e){let n=M.TypeGuard.IsRegExp(t)?(0,cw.String)():t,i=M.TypeGuard.IsRegExp(e)?(0,cw.String)():e;return je(n,i)}function bL(t,e){return M.TypeGuard.IsLiteral(t)&&M.ValueGuard.IsString(t.const)||M.TypeGuard.IsString(t)?B.True:B.False}function Foe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsString(e)?B.True:B.False}function Doe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsSymbol(e)?B.True:B.False}function Uoe(t,e){return M.TypeGuard.IsTemplateLiteral(t)?je((0,aL.TemplateLiteralToUnion)(t),e):M.TypeGuard.IsTemplateLiteral(e)?je(t,(0,aL.TemplateLiteralToUnion)(e)):rc("Invalid fallthrough for TemplateLiteral")}function $oe(t,e){return M.TypeGuard.IsArray(e)&&t.items!==void 0&&t.items.every(n=>je(n,e.items)===B.True)}function Noe(t,e){return M.TypeGuard.IsNever(t)?B.True:M.TypeGuard.IsUnknown(t)?B.False:M.TypeGuard.IsAny(t)?B.Union:B.False}function Boe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)&&pg(e)||M.TypeGuard.IsArray(e)&&$oe(t,e)?B.True:M.TypeGuard.IsTuple(e)?M.ValueGuard.IsUndefined(t.items)&&!M.ValueGuard.IsUndefined(e.items)||!M.ValueGuard.IsUndefined(t.items)&&M.ValueGuard.IsUndefined(e.items)?B.False:M.ValueGuard.IsUndefined(t.items)&&!M.ValueGuard.IsUndefined(e.items)||t.items.every((n,i)=>je(n,e.items[i])===B.True)?B.True:B.False:B.False}function joe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsUint8Array(e)?B.True:B.False}function qoe(t,e){return bt(e)?xt(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsRecord(e)?ni(t,e):M.TypeGuard.IsVoid(e)?zoe(t,e):M.TypeGuard.IsUndefined(e)?B.True:B.False}function hw(t,e){return e.anyOf.some(n=>je(t,n)===B.True)?B.True:B.False}function Koe(t,e){return t.anyOf.every(n=>je(n,e)===B.True)?B.True:B.False}function xL(t,e){return B.True}function Goe(t,e){return M.TypeGuard.IsNever(e)?gL(t,e):M.TypeGuard.IsIntersect(e)?dg(t,e):M.TypeGuard.IsUnion(e)?hw(t,e):M.TypeGuard.IsAny(e)?mw(t,e):M.TypeGuard.IsString(e)?bL(t,e):M.TypeGuard.IsNumber(e)?fL(t,e):M.TypeGuard.IsInteger(e)?hL(t,e):M.TypeGuard.IsBoolean(e)?mL(t,e):M.TypeGuard.IsArray(e)?uoe(t,e):M.TypeGuard.IsTuple(e)?Noe(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsUnknown(e)?B.True:B.False}function zoe(t,e){return M.TypeGuard.IsUndefined(t)||M.TypeGuard.IsUndefined(t)?B.True:B.False}function Hoe(t,e){return M.TypeGuard.IsIntersect(e)?dg(t,e):M.TypeGuard.IsUnion(e)?hw(t,e):M.TypeGuard.IsUnknown(e)?xL(t,e):M.TypeGuard.IsAny(e)?mw(t,e):M.TypeGuard.IsObject(e)?Bt(t,e):M.TypeGuard.IsVoid(e)?B.True:B.False}function je(t,e){return M.TypeGuard.IsTemplateLiteral(t)||M.TypeGuard.IsTemplateLiteral(e)?Uoe(t,e):M.TypeGuard.IsRegExp(t)||M.TypeGuard.IsRegExp(e)?Woe(t,e):M.TypeGuard.IsNot(t)||M.TypeGuard.IsNot(e)?Soe(t,e):M.TypeGuard.IsAny(t)?coe(t,e):M.TypeGuard.IsArray(t)?doe(t,e):M.TypeGuard.IsBigInt(t)?moe(t,e):M.TypeGuard.IsBoolean(t)?hoe(t,e):M.TypeGuard.IsAsyncIterator(t)?poe(t,e):M.TypeGuard.IsConstructor(t)?goe(t,e):M.TypeGuard.IsDate(t)?foe(t,e):M.TypeGuard.IsFunction(t)?voe(t,e):M.TypeGuard.IsInteger(t)?boe(t,e):M.TypeGuard.IsIntersect(t)?xoe(t,e):M.TypeGuard.IsIterator(t)?yoe(t,e):M.TypeGuard.IsLiteral(t)?woe(t,e):M.TypeGuard.IsNever(t)?koe(t,e):M.TypeGuard.IsNull(t)?Toe(t,e):M.TypeGuard.IsNumber(t)?Coe(t,e):M.TypeGuard.IsObject(t)?_oe(t,e):M.TypeGuard.IsRecord(t)?Loe(t,e):M.TypeGuard.IsString(t)?Foe(t,e):M.TypeGuard.IsSymbol(t)?Doe(t,e):M.TypeGuard.IsTuple(t)?Boe(t,e):M.TypeGuard.IsPromise(t)?Ooe(t,e):M.TypeGuard.IsUint8Array(t)?joe(t,e):M.TypeGuard.IsUndefined(t)?qoe(t,e):M.TypeGuard.IsUnion(t)?Koe(t,e):M.TypeGuard.IsUnknown(t)?Goe(t,e):M.TypeGuard.IsVoid(t)?Hoe(t,e):rc(`Unknown left type operand '${t[pL.Kind]}'`)}function Voe(t,e){return je(t,e)}});var vw=C(fw=>{"use strict";Object.defineProperty(fw,"__esModule",{value:!0});fw.ExtendsFromMappedResult=ere;var Qoe=vt(),Yoe=mg(),Joe=cn();function Xoe(t,e,n,i,o){let r={};for(let s of globalThis.Object.getOwnPropertyNames(t))r[s]=(0,Yoe.Extends)(t[s],e,n,i,(0,Joe.Clone)(o));return r}function Zoe(t,e,n,i,o){return Xoe(t.properties,e,n,i,o)}function ere(t,e,n,i,o){let r=Zoe(t,e,n,i,o);return(0,Qoe.MappedResult)(r)}});var mg=C(xw=>{"use strict";Object.defineProperty(xw,"__esModule",{value:!0});xw.Extends=rre;var yL=me(),tre=mt(),bw=gw(),nre=yw(),ire=vw(),wL=Le();function ore(t,e,n,i){let o=(0,bw.ExtendsCheck)(t,e);return o===bw.ExtendsResult.Union?(0,tre.Union)([n,i]):o===bw.ExtendsResult.True?n:i}function rre(t,e,n,i,o){return(0,wL.IsMappedResult)(t)?(0,ire.ExtendsFromMappedResult)(t,e,n,i,o):(0,wL.IsMappedKey)(t)?(0,yL.CreateType)((0,nre.ExtendsFromMappedKey)(t,e,n,i,o)):(0,yL.CreateType)(ore(t,e,n,i),o)}});var yw=C(ww=>{"use strict";Object.defineProperty(ww,"__esModule",{value:!0});ww.ExtendsFromMappedKey=mre;var sre=vt(),are=Jt(),lre=mg(),cre=cn();function ure(t,e,n,i,o){return{[t]:(0,lre.Extends)((0,are.Literal)(t),e,n,i,(0,cre.Clone)(o))}}function dre(t,e,n,i,o){return t.reduce((r,s)=>({...r,...ure(s,e,n,i,o)}),{})}function pre(t,e,n,i,o){return dre(t.keys,e,n,i,o)}function mre(t,e,n,i,o){let r=pre(t,e,n,i,o);return(0,sre.MappedResult)(r)}});var kL=C(kw=>{"use strict";Object.defineProperty(kw,"__esModule",{value:!0});kw.ExtendsUndefinedCheck=gg;var hg=pe();function hre(t){return t.allOf.every(e=>gg(e))}function gre(t){return t.anyOf.some(e=>gg(e))}function fre(t){return!gg(t.not)}function gg(t){return t[hg.Kind]==="Intersect"?hre(t):t[hg.Kind]==="Union"?gre(t):t[hg.Kind]==="Not"?fre(t):t[hg.Kind]==="Undefined"}});var sc=C(fi=>{"use strict";var vre=fi&&fi.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Sd=fi&&fi.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&vre(e,t,n)};Object.defineProperty(fi,"__esModule",{value:!0});Sd(gw(),fi);Sd(yw(),fi);Sd(vw(),fi);Sd(kL(),fi);Sd(mg(),fi)});var Tw=C(Sw=>{"use strict";Object.defineProperty(Sw,"__esModule",{value:!0});Sw.ExcludeFromTemplateLiteral=yre;var bre=fg(),xre=$i();function yre(t,e){return(0,bre.Exclude)((0,xre.TemplateLiteralToUnion)(t),e)}});var fg=C(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});Rw.Exclude=Mre;var Cw=me(),wre=mt(),kre=Et(),vg=sc(),Sre=Pw(),Tre=Tw(),Mw=Le();function Cre(t,e){let n=t.filter(i=>(0,vg.ExtendsCheck)(i,e)===vg.ExtendsResult.False);return n.length===1?n[0]:(0,wre.Union)(n)}function Mre(t,e,n={}){return(0,Mw.IsTemplateLiteral)(t)?(0,Cw.CreateType)((0,Tre.ExcludeFromTemplateLiteral)(t,e),n):(0,Mw.IsMappedResult)(t)?(0,Cw.CreateType)((0,Sre.ExcludeFromMappedResult)(t,e),n):(0,Cw.CreateType)((0,Mw.IsUnion)(t)?Cre(t.anyOf,e):(0,vg.ExtendsCheck)(t,e)!==vg.ExtendsResult.False?(0,kre.Never)():t,n)}});var Pw=C(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});Iw.ExcludeFromMappedResult=Are;var Rre=vt(),Pre=fg();function Ire(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,Pre.Exclude)(t[i],e);return n}function Ere(t,e){return Ire(t.properties,e)}function Are(t,e){let n=Ere(t,e);return(0,Rre.MappedResult)(n)}});var bg=C(Mo=>{"use strict";var _re=Mo&&Mo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Ew=Mo&&Mo.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&_re(e,t,n)};Object.defineProperty(Mo,"__esModule",{value:!0});Ew(Pw(),Mo);Ew(Tw(),Mo);Ew(fg(),Mo)});var _w=C(Aw=>{"use strict";Object.defineProperty(Aw,"__esModule",{value:!0});Aw.ExtractFromTemplateLiteral=Wre;var Ore=xg(),Lre=$i();function Wre(t,e){return(0,Ore.Extract)((0,Lre.TemplateLiteralToUnion)(t),e)}});var xg=C(Ww=>{"use strict";Object.defineProperty(Ww,"__esModule",{value:!0});Ww.Extract=Bre;var Ow=me(),Fre=mt(),Dre=Et(),yg=sc(),Ure=Fw(),$re=_w(),Lw=Le();function Nre(t,e){let n=t.filter(i=>(0,yg.ExtendsCheck)(i,e)!==yg.ExtendsResult.False);return n.length===1?n[0]:(0,Fre.Union)(n)}function Bre(t,e,n){return(0,Lw.IsTemplateLiteral)(t)?(0,Ow.CreateType)((0,$re.ExtractFromTemplateLiteral)(t,e),n):(0,Lw.IsMappedResult)(t)?(0,Ow.CreateType)((0,Ure.ExtractFromMappedResult)(t,e),n):(0,Ow.CreateType)((0,Lw.IsUnion)(t)?Nre(t.anyOf,e):(0,yg.ExtendsCheck)(t,e)!==yg.ExtendsResult.False?t:(0,Dre.Never)(),n)}});var Fw=C(Dw=>{"use strict";Object.defineProperty(Dw,"__esModule",{value:!0});Dw.ExtractFromMappedResult=zre;var jre=vt(),qre=xg();function Kre(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,qre.Extract)(t[i],e);return n}function Gre(t,e){return Kre(t.properties,e)}function zre(t,e){let n=Gre(t,e);return(0,jre.MappedResult)(n)}});var wg=C(Ro=>{"use strict";var Hre=Ro&&Ro.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Uw=Ro&&Ro.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Hre(e,t,n)};Object.defineProperty(Ro,"__esModule",{value:!0});Uw(Fw(),Ro);Uw(_w(),Ro);Uw(xg(),Ro)});var SL=C(Po=>{"use strict";var Vre=Po&&Po.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Qre=Po&&Po.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Yre=Po&&Po.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Vre(n,e,i[o]);return Qre(n,e),n}})();Object.defineProperty(Po,"__esModule",{value:!0});Po.InstanceType=ese;var Jre=me(),Xre=Et(),Zre=Yre(Le());function ese(t,e){return Zre.IsConstructor(t)?(0,Jre.CreateType)(t.returns,e):(0,Xre.Never)(e)}});var kg=C(ea=>{"use strict";var tse=ea&&ea.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),nse=ea&&ea.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&tse(e,t,n)};Object.defineProperty(ea,"__esModule",{value:!0});nse(SL(),ea)});var TL=C($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});$w.ReadonlyOptional=rse;var ise=br(),ose=Ui();function rse(t){return(0,ise.Readonly)((0,ose.Optional)(t))}});var Td=C(ta=>{"use strict";var sse=ta&&ta.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ase=ta&&ta.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&sse(e,t,n)};Object.defineProperty(ta,"__esModule",{value:!0});ase(TL(),ta)});var IL=C(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.Record=Tse;ac.RecordPattern=Bw;ac.RecordKey=Cse;ac.RecordValue=Mse;var lse=me(),ML=pe(),cse=Et(),use=gr(),RL=mn(),CL=Ls(),dse=mt(),pse=$i(),na=rd(),PL=gi(),mse=Yt(),ji=Le();function ia(t,e,n){return(0,lse.CreateType)({[ML.Kind]:"Record",type:"object",patternProperties:{[t]:e}},n)}function Nw(t,e,n){let i={};for(let o of t)i[o]=e;return(0,RL.Object)(i,{...n,[ML.Hint]:"Record"})}function hse(t,e,n){return(0,pse.IsTemplateLiteralFinite)(t)?Nw((0,PL.IndexPropertyKeys)(t),e,n):ia(t.pattern,e,n)}function gse(t,e,n){return Nw((0,PL.IndexPropertyKeys)((0,dse.Union)(t)),e,n)}function fse(t,e,n){return Nw([t.toString()],e,n)}function vse(t,e,n){return ia(t.source,e,n)}function bse(t,e,n){let i=(0,mse.IsUndefined)(t.pattern)?na.PatternStringExact:t.pattern;return ia(i,e,n)}function xse(t,e,n){return ia(na.PatternStringExact,e,n)}function yse(t,e,n){return ia(na.PatternNeverExact,e,n)}function wse(t,e,n){return(0,RL.Object)({true:e,false:e},n)}function kse(t,e,n){return ia(na.PatternNumberExact,e,n)}function Sse(t,e,n){return ia(na.PatternNumberExact,e,n)}function Tse(t,e,n={}){return(0,ji.IsUnion)(t)?gse(t.anyOf,e,n):(0,ji.IsTemplateLiteral)(t)?hse(t,e,n):(0,ji.IsLiteral)(t)?fse(t.const,e,n):(0,ji.IsBoolean)(t)?wse(t,e,n):(0,ji.IsInteger)(t)?kse(t,e,n):(0,ji.IsNumber)(t)?Sse(t,e,n):(0,ji.IsRegExp)(t)?vse(t,e,n):(0,ji.IsString)(t)?bse(t,e,n):(0,ji.IsAny)(t)?xse(t,e,n):(0,ji.IsNever)(t)?yse(t,e,n):(0,cse.Never)(n)}function Bw(t){return globalThis.Object.getOwnPropertyNames(t.patternProperties)[0]}function Cse(t){let e=Bw(t);return e===na.PatternStringExact?(0,CL.String)():e===na.PatternNumberExact?(0,use.Number)():(0,CL.String)({pattern:e})}function Mse(t){return t.patternProperties[Bw(t)]}});var lc=C(oa=>{"use strict";var Rse=oa&&oa.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Pse=oa&&oa.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Rse(e,t,n)};Object.defineProperty(oa,"__esModule",{value:!0});Pse(IL(),oa)});var AL=C(qi=>{"use strict";var Ise=qi&&qi.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Ese=qi&&qi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),EL=qi&&qi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Ise(n,e,i[o]);return Ese(n,e),n}})();Object.defineProperty(qi,"__esModule",{value:!0});qi.FromTypes=cc;qi.Instantiate=Xse;var Ase=Wh(),_se=Qs(),Ose=Td(),Lse=br(),Wse=Ui(),Fse=mn(),jw=lc(),Dse=EL(Yt()),fn=EL(Le());function Use(t,e){return e.parameters=cc(t,e.parameters),e.returns=vi(t,e.returns),e}function $se(t,e){return e.parameters=cc(t,e.parameters),e.returns=vi(t,e.returns),e}function Nse(t,e){return e.allOf=cc(t,e.allOf),e}function Bse(t,e){return e.anyOf=cc(t,e.anyOf),e}function jse(t,e){return Dse.IsUndefined(e.items)||(e.items=cc(t,e.items)),e}function qse(t,e){return e.items=vi(t,e.items),e}function Kse(t,e){return e.items=vi(t,e.items),e}function Gse(t,e){return e.items=vi(t,e.items),e}function zse(t,e){return e.item=vi(t,e.item),e}function Hse(t,e){let n=Jse(t,e.properties);return{...e,...(0,Fse.Object)(n)}}function Vse(t,e){let n=vi(t,(0,jw.RecordKey)(e)),i=vi(t,(0,jw.RecordValue)(e)),o=(0,jw.Record)(n,i);return{...e,...o}}function Qse(t,e){return e.index in t?t[e.index]:(0,_se.Unknown)()}function Yse(t,e){let n=fn.IsReadonly(e),i=fn.IsOptional(e),o=vi(t,e);return n&&i?(0,Ose.ReadonlyOptional)(o):n&&!i?(0,Lse.Readonly)(o):!n&&i?(0,Wse.Optional)(o):o}function Jse(t,e){return globalThis.Object.getOwnPropertyNames(e).reduce((n,i)=>({...n,[i]:Yse(t,e[i])}),{})}function cc(t,e){return e.map(n=>vi(t,n))}function vi(t,e){return fn.IsConstructor(e)?Use(t,e):fn.IsFunction(e)?$se(t,e):fn.IsIntersect(e)?Nse(t,e):fn.IsUnion(e)?Bse(t,e):fn.IsTuple(e)?jse(t,e):fn.IsArray(e)?qse(t,e):fn.IsAsyncIterator(e)?Kse(t,e):fn.IsIterator(e)?Gse(t,e):fn.IsPromise(e)?zse(t,e):fn.IsObject(e)?Hse(t,e):fn.IsRecord(e)?Vse(t,e):fn.IsArgument(e)?Qse(t,e):e}function Xse(t,e){return vi(e,(0,Ase.CloneType)(t))}});var Sg=C(ra=>{"use strict";var Zse=ra&&ra.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),eae=ra&&ra.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Zse(e,t,n)};Object.defineProperty(ra,"__esModule",{value:!0});eae(AL(),ra)});var _L=C(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});qw.Integer=iae;var tae=me(),nae=pe();function iae(t){return(0,tae.CreateType)({[nae.Kind]:"Integer",type:"integer"},t)}});var Tg=C(sa=>{"use strict";var oae=sa&&sa.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),rae=sa&&sa.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&oae(e,t,n)};Object.defineProperty(sa,"__esModule",{value:!0});rae(_L(),sa)});var Gw=C(Kw=>{"use strict";Object.defineProperty(Kw,"__esModule",{value:!0});Kw.IntrinsicFromMappedKey=mae;var sae=vt(),aae=aa(),lae=Jt(),cae=cn();function uae(t,e,n){return{[t]:(0,aae.Intrinsic)((0,lae.Literal)(t),e,(0,cae.Clone)(n))}}function dae(t,e,n){return t.reduce((o,r)=>({...o,...uae(r,e,n)}),{})}function pae(t,e,n){return dae(t.keys,e,n)}function mae(t,e,n){let i=pae(t,e,n);return(0,sae.MappedResult)(i)}});var aa=C(zw=>{"use strict";Object.defineProperty(zw,"__esModule",{value:!0});zw.Intrinsic=DL;var hae=me(),Cg=$i(),gae=Gw(),OL=Jt(),LL=mt(),Mg=Le();function fae(t){let[e,n]=[t.slice(0,1),t.slice(1)];return[e.toLowerCase(),n].join("")}function vae(t){let[e,n]=[t.slice(0,1),t.slice(1)];return[e.toUpperCase(),n].join("")}function bae(t){return t.toUpperCase()}function xae(t){return t.toLowerCase()}function yae(t,e,n){let i=(0,Cg.TemplateLiteralParseExact)(t.pattern);if(!(0,Cg.IsTemplateLiteralExpressionFinite)(i))return{...t,pattern:WL(t.pattern,e)};let s=[...(0,Cg.TemplateLiteralExpressionGenerate)(i)].map(c=>(0,OL.Literal)(c)),a=FL(s,e),l=(0,LL.Union)(a);return(0,Cg.TemplateLiteral)([l],n)}function WL(t,e){return typeof t=="string"?e==="Uncapitalize"?fae(t):e==="Capitalize"?vae(t):e==="Uppercase"?bae(t):e==="Lowercase"?xae(t):t:t.toString()}function FL(t,e){return t.map(n=>DL(n,e))}function DL(t,e,n={}){return(0,Mg.IsMappedKey)(t)?(0,gae.IntrinsicFromMappedKey)(t,e,n):(0,Mg.IsTemplateLiteral)(t)?yae(t,e,n):(0,Mg.IsUnion)(t)?(0,LL.Union)(FL(t.anyOf,e),n):(0,Mg.IsLiteral)(t)?(0,OL.Literal)(WL(t.const,e),n):(0,hae.CreateType)(t,n)}});var UL=C(Hw=>{"use strict";Object.defineProperty(Hw,"__esModule",{value:!0});Hw.Capitalize=kae;var wae=aa();function kae(t,e={}){return(0,wae.Intrinsic)(t,"Capitalize",e)}});var $L=C(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});Vw.Lowercase=Tae;var Sae=aa();function Tae(t,e={}){return(0,Sae.Intrinsic)(t,"Lowercase",e)}});var NL=C(Qw=>{"use strict";Object.defineProperty(Qw,"__esModule",{value:!0});Qw.Uncapitalize=Mae;var Cae=aa();function Mae(t,e={}){return(0,Cae.Intrinsic)(t,"Uncapitalize",e)}});var BL=C(Yw=>{"use strict";Object.defineProperty(Yw,"__esModule",{value:!0});Yw.Uppercase=Pae;var Rae=aa();function Pae(t,e={}){return(0,Rae.Intrinsic)(t,"Uppercase",e)}});var Rg=C(ii=>{"use strict";var Iae=ii&&ii.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),uc=ii&&ii.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Iae(e,t,n)};Object.defineProperty(ii,"__esModule",{value:!0});uc(UL(),ii);uc(Gw(),ii);uc(aa(),ii);uc($L(),ii);uc(NL(),ii);uc(BL(),ii)});var Xw=C(Jw=>{"use strict";Object.defineProperty(Jw,"__esModule",{value:!0});Jw.OmitFromMappedResult=Wae;var Eae=vt(),Aae=Pg(),_ae=cn();function Oae(t,e,n){let i={};for(let o of globalThis.Object.getOwnPropertyNames(t))i[o]=(0,Aae.Omit)(t[o],e,(0,_ae.Clone)(n));return i}function Lae(t,e,n){return Oae(t.properties,e,n)}function Wae(t,e,n){let i=Lae(t,e,n);return(0,Eae.MappedResult)(i)}});var Pg=C(tk=>{"use strict";Object.defineProperty(tk,"__esModule",{value:!0});tk.Omit=Jae;var Fae=me(),Dae=jh(),Uae=td(),Zw=mr(),$ae=Jt(),Nae=gi(),Bae=On(),jL=mt(),qL=mn(),jae=nk(),qae=Xw(),Io=Le(),Kae=Yt();function Gae(t,e){return t.map(n=>ek(n,e))}function zae(t,e){return t.map(n=>ek(n,e))}function Hae(t,e){let{[e]:n,...i}=t;return i}function Vae(t,e){return e.reduce((n,i)=>Hae(n,i),t)}function Qae(t,e,n){let i=(0,Dae.Discard)(t,[Uae.TransformKind,"$id","required","properties"]),o=Vae(n,e);return(0,qL.Object)(o,i)}function Yae(t){let e=t.reduce((n,i)=>(0,Io.IsLiteralValue)(i)?[...n,(0,$ae.Literal)(i)]:n,[]);return(0,jL.Union)(e)}function ek(t,e){return(0,Io.IsIntersect)(t)?(0,Bae.Intersect)(Gae(t.allOf,e)):(0,Io.IsUnion)(t)?(0,jL.Union)(zae(t.anyOf,e)):(0,Io.IsObject)(t)?Qae(t,e,t.properties):(0,qL.Object)({})}function Jae(t,e,n){let i=(0,Kae.IsArray)(e)?Yae(e):e,o=(0,Io.IsSchema)(e)?(0,Nae.IndexPropertyKeys)(e):e,r=(0,Io.IsRef)(t),s=(0,Io.IsRef)(e);return(0,Io.IsMappedResult)(t)?(0,qae.OmitFromMappedResult)(t,o,n):(0,Io.IsMappedKey)(e)?(0,jae.OmitFromMappedKey)(t,e,n):r&&s?(0,Zw.Computed)("Omit",[t,i],n):!r&&s?(0,Zw.Computed)("Omit",[t,i],n):r&&!s?(0,Zw.Computed)("Omit",[t,i],n):(0,Fae.CreateType)({...ek(t,o),...n})}});var nk=C(ik=>{"use strict";Object.defineProperty(ik,"__esModule",{value:!0});ik.OmitFromMappedKey=ole;var Xae=vt(),Zae=Pg(),ele=cn();function tle(t,e,n){return{[e]:(0,Zae.Omit)(t,[e],(0,ele.Clone)(n))}}function nle(t,e,n){return e.reduce((i,o)=>({...i,...tle(t,o,n)}),{})}function ile(t,e,n){return nle(t,e.keys,n)}function ole(t,e,n){let i=ile(t,e,n);return(0,Xae.MappedResult)(i)}});var Cd=C(Eo=>{"use strict";var rle=Eo&&Eo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ok=Eo&&Eo.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&rle(e,t,n)};Object.defineProperty(Eo,"__esModule",{value:!0});ok(nk(),Eo);ok(Xw(),Eo);ok(Pg(),Eo)});var sk=C(rk=>{"use strict";Object.defineProperty(rk,"__esModule",{value:!0});rk.PickFromMappedResult=dle;var sle=vt(),ale=Ig(),lle=cn();function cle(t,e,n){let i={};for(let o of globalThis.Object.getOwnPropertyNames(t))i[o]=(0,ale.Pick)(t[o],e,(0,lle.Clone)(n));return i}function ule(t,e,n){return cle(t.properties,e,n)}function dle(t,e,n){let i=ule(t,e,n);return(0,sle.MappedResult)(i)}});var Ig=C(ck=>{"use strict";Object.defineProperty(ck,"__esModule",{value:!0});ck.Pick=Mle;var ple=me(),mle=jh(),ak=mr(),hle=On(),gle=Jt(),KL=mn(),GL=mt(),fle=gi(),vle=td(),Ao=Le(),ble=Yt(),xle=uk(),yle=sk();function wle(t,e){return t.map(n=>lk(n,e))}function kle(t,e){return t.map(n=>lk(n,e))}function Sle(t,e){let n={};for(let i of e)i in t&&(n[i]=t[i]);return n}function Tle(t,e,n){let i=(0,mle.Discard)(t,[vle.TransformKind,"$id","required","properties"]),o=Sle(n,e);return(0,KL.Object)(o,i)}function Cle(t){let e=t.reduce((n,i)=>(0,Ao.IsLiteralValue)(i)?[...n,(0,gle.Literal)(i)]:n,[]);return(0,GL.Union)(e)}function lk(t,e){return(0,Ao.IsIntersect)(t)?(0,hle.Intersect)(wle(t.allOf,e)):(0,Ao.IsUnion)(t)?(0,GL.Union)(kle(t.anyOf,e)):(0,Ao.IsObject)(t)?Tle(t,e,t.properties):(0,KL.Object)({})}function Mle(t,e,n){let i=(0,ble.IsArray)(e)?Cle(e):e,o=(0,Ao.IsSchema)(e)?(0,fle.IndexPropertyKeys)(e):e,r=(0,Ao.IsRef)(t),s=(0,Ao.IsRef)(e);return(0,Ao.IsMappedResult)(t)?(0,yle.PickFromMappedResult)(t,o,n):(0,Ao.IsMappedKey)(e)?(0,xle.PickFromMappedKey)(t,e,n):r&&s?(0,ak.Computed)("Pick",[t,i],n):!r&&s?(0,ak.Computed)("Pick",[t,i],n):r&&!s?(0,ak.Computed)("Pick",[t,i],n):(0,ple.CreateType)({...lk(t,o),...n})}});var uk=C(dk=>{"use strict";Object.defineProperty(dk,"__esModule",{value:!0});dk.PickFromMappedKey=Ole;var Rle=vt(),Ple=Ig(),Ile=cn();function Ele(t,e,n){return{[e]:(0,Ple.Pick)(t,[e],(0,Ile.Clone)(n))}}function Ale(t,e,n){return e.reduce((i,o)=>({...i,...Ele(t,o,n)}),{})}function _le(t,e,n){return Ale(t,e.keys,n)}function Ole(t,e,n){let i=_le(t,e,n);return(0,Rle.MappedResult)(i)}});var Md=C(_o=>{"use strict";var Lle=_o&&_o.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),pk=_o&&_o.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Lle(e,t,n)};Object.defineProperty(_o,"__esModule",{value:!0});pk(uk(),_o);pk(sk(),_o);pk(Ig(),_o)});var hk=C(Oo=>{"use strict";var Wle=Oo&&Oo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Fle=Oo&&Oo.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Dle=Oo&&Oo.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Wle(n,e,i[o]);return Fle(n,e),n}})();Object.defineProperty(Oo,"__esModule",{value:!0});Oo.Partial=Yle;var Ule=me(),mk=mr(),$le=Ui(),HL=mn(),Nle=On(),Ble=mt(),jle=yr(),qle=xo(),Kle=pe(),Gle=gk(),Zt=Dle(Le());function zle(t,e){return(0,mk.Computed)("Partial",[(0,mk.Computed)(t,e)])}function Hle(t){return(0,mk.Computed)("Partial",[(0,jle.Ref)(t)])}function Vle(t){let e={};for(let n of globalThis.Object.getOwnPropertyNames(t))e[n]=(0,$le.Optional)(t[n]);return e}function Qle(t,e){let n=(0,qle.Discard)(t,[Kle.TransformKind,"$id","required","properties"]),i=Vle(e);return(0,HL.Object)(i,n)}function zL(t){return t.map(e=>VL(e))}function VL(t){return Zt.IsComputed(t)?zle(t.target,t.parameters):Zt.IsRef(t)?Hle(t.$ref):Zt.IsIntersect(t)?(0,Nle.Intersect)(zL(t.allOf)):Zt.IsUnion(t)?(0,Ble.Union)(zL(t.anyOf)):Zt.IsObject(t)?Qle(t,t.properties):Zt.IsBigInt(t)||Zt.IsBoolean(t)||Zt.IsInteger(t)||Zt.IsLiteral(t)||Zt.IsNull(t)||Zt.IsNumber(t)||Zt.IsString(t)||Zt.IsSymbol(t)||Zt.IsUndefined(t)?t:(0,HL.Object)({})}function Yle(t,e){return Zt.IsMappedResult(t)?(0,Gle.PartialFromMappedResult)(t,e):(0,Ule.CreateType)({...VL(t),...e})}});var gk=C(fk=>{"use strict";Object.defineProperty(fk,"__esModule",{value:!0});fk.PartialFromMappedResult=nce;var Jle=vt(),Xle=hk(),Zle=cn();function ece(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,Xle.Partial)(t[i],(0,Zle.Clone)(e));return n}function tce(t,e){return ece(t.properties,e)}function nce(t,e){let n=tce(t,e);return(0,Jle.MappedResult)(n)}});var Rd=C(wr=>{"use strict";var ice=wr&&wr.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),QL=wr&&wr.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&ice(e,t,n)};Object.defineProperty(wr,"__esModule",{value:!0});QL(gk(),wr);QL(hk(),wr)});var bk=C(Lo=>{"use strict";var oce=Lo&&Lo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),rce=Lo&&Lo.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),sce=Lo&&Lo.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&oce(n,e,i[o]);return rce(n,e),n}})();Object.defineProperty(Lo,"__esModule",{value:!0});Lo.Required=fce;var ace=me(),vk=mr(),JL=mn(),lce=On(),cce=mt(),uce=yr(),XL=pe(),ZL=xo(),dce=xk(),en=sce(Le());function pce(t,e){return(0,vk.Computed)("Required",[(0,vk.Computed)(t,e)])}function mce(t){return(0,vk.Computed)("Required",[(0,uce.Ref)(t)])}function hce(t){let e={};for(let n of globalThis.Object.getOwnPropertyNames(t))e[n]=(0,ZL.Discard)(t[n],[XL.OptionalKind]);return e}function gce(t,e){let n=(0,ZL.Discard)(t,[XL.TransformKind,"$id","required","properties"]),i=hce(e);return(0,JL.Object)(i,n)}function YL(t){return t.map(e=>eW(e))}function eW(t){return en.IsComputed(t)?pce(t.target,t.parameters):en.IsRef(t)?mce(t.$ref):en.IsIntersect(t)?(0,lce.Intersect)(YL(t.allOf)):en.IsUnion(t)?(0,cce.Union)(YL(t.anyOf)):en.IsObject(t)?gce(t,t.properties):en.IsBigInt(t)||en.IsBoolean(t)||en.IsInteger(t)||en.IsLiteral(t)||en.IsNull(t)||en.IsNumber(t)||en.IsString(t)||en.IsSymbol(t)||en.IsUndefined(t)?t:(0,JL.Object)({})}function fce(t,e){return en.IsMappedResult(t)?(0,dce.RequiredFromMappedResult)(t,e):(0,ace.CreateType)({...eW(t),...e})}});var xk=C(yk=>{"use strict";Object.defineProperty(yk,"__esModule",{value:!0});yk.RequiredFromMappedResult=wce;var vce=vt(),bce=bk();function xce(t,e){let n={};for(let i of globalThis.Object.getOwnPropertyNames(t))n[i]=(0,bce.Required)(t[i],e);return n}function yce(t,e){return xce(t.properties,e)}function wce(t,e){let n=yce(t,e);return(0,vce.MappedResult)(n)}});var Pd=C(kr=>{"use strict";var kce=kr&&kr.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),tW=kr&&kr.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&kce(e,t,n)};Object.defineProperty(kr,"__esModule",{value:!0});tW(xk(),kr);tW(bk(),kr)});var rW=C(bi=>{"use strict";var Sce=bi&&bi.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Tce=bi&&bi.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Cce=bi&&bi.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Sce(n,e,i[o]);return Tce(n,e),n}})();Object.defineProperty(bi,"__esModule",{value:!0});bi.FromType=bn;bi.ComputeType=oW;bi.ComputeModuleProperties=cue;var vn=vo(),Mce=Tx(),nW=xo(),Rce=Hl(),Pce=vd(),Ice=Vl(),Ece=Ql(),Ace=gi(),_ce=hr(),Oce=On(),Lce=tc(),Wce=ic(),Fce=mn(),Dce=Cd(),Uce=Md(),wk=Et(),$ce=Rd(),iW=lc(),Nce=Pd(),Bce=ko(),jce=mt(),Eg=pe(),Ut=Cce(Le());function qce(t,e){return e.map(n=>Ut.IsRef(n)?kk(t,n.$ref):bn(t,n))}function kk(t,e){return e in t?Ut.IsRef(t[e])?kk(t,t[e].$ref):bn(t,t[e]):(0,wk.Never)()}function Kce(t){return(0,Pce.Awaited)(t[0])}function Gce(t){return(0,Ace.Index)(t[0],t[1])}function zce(t){return(0,Wce.KeyOf)(t[0])}function Hce(t){return(0,$ce.Partial)(t[0])}function Vce(t){return(0,Dce.Omit)(t[0],t[1])}function Qce(t){return(0,Uce.Pick)(t[0],t[1])}function Yce(t){return(0,Nce.Required)(t[0])}function Jce(t,e,n){let i=qce(t,n);return e==="Awaited"?Kce(i):e==="Index"?Gce(i):e==="KeyOf"?zce(i):e==="Partial"?Hce(i):e==="Omit"?Vce(i):e==="Pick"?Qce(i):e==="Required"?Yce(i):(0,wk.Never)()}function Xce(t,e){return(0,Rce.Array)(bn(t,e))}function Zce(t,e){return(0,Ice.AsyncIterator)(bn(t,e))}function eue(t,e,n){return(0,Ece.Constructor)(Id(t,e),bn(t,n))}function tue(t,e,n){return(0,_ce.Function)(Id(t,e),bn(t,n))}function nue(t,e){return(0,Oce.Intersect)(Id(t,e))}function iue(t,e){return(0,Lce.Iterator)(bn(t,e))}function oue(t,e){return(0,Fce.Object)(globalThis.Object.keys(e).reduce((n,i)=>({...n,[i]:bn(t,e[i])}),{}))}function rue(t,e){let[n,i]=[bn(t,(0,iW.RecordValue)(e)),(0,iW.RecordPattern)(e)],o=(0,Mce.CloneType)(e);return o.patternProperties[i]=n,o}function sue(t,e){return Ut.IsRef(e)?{...kk(t,e.$ref),[Eg.TransformKind]:e[Eg.TransformKind]}:e}function aue(t,e){return(0,Bce.Tuple)(Id(t,e))}function lue(t,e){return(0,jce.Union)(Id(t,e))}function Id(t,e){return e.map(n=>bn(t,n))}function bn(t,e){return Ut.IsOptional(e)?(0,vn.CreateType)(bn(t,(0,nW.Discard)(e,[Eg.OptionalKind])),e):Ut.IsReadonly(e)?(0,vn.CreateType)(bn(t,(0,nW.Discard)(e,[Eg.ReadonlyKind])),e):Ut.IsTransform(e)?(0,vn.CreateType)(sue(t,e),e):Ut.IsArray(e)?(0,vn.CreateType)(Xce(t,e.items),e):Ut.IsAsyncIterator(e)?(0,vn.CreateType)(Zce(t,e.items),e):Ut.IsComputed(e)?(0,vn.CreateType)(Jce(t,e.target,e.parameters)):Ut.IsConstructor(e)?(0,vn.CreateType)(eue(t,e.parameters,e.returns),e):Ut.IsFunction(e)?(0,vn.CreateType)(tue(t,e.parameters,e.returns),e):Ut.IsIntersect(e)?(0,vn.CreateType)(nue(t,e.allOf),e):Ut.IsIterator(e)?(0,vn.CreateType)(iue(t,e.items),e):Ut.IsObject(e)?(0,vn.CreateType)(oue(t,e.properties),e):Ut.IsRecord(e)?(0,vn.CreateType)(rue(t,e)):Ut.IsTuple(e)?(0,vn.CreateType)(aue(t,e.items||[]),e):Ut.IsUnion(e)?(0,vn.CreateType)(lue(t,e.anyOf),e):e}function oW(t,e){return e in t?bn(t,t[e]):(0,wk.Never)()}function cue(t){return globalThis.Object.getOwnPropertyNames(t).reduce((e,n)=>({...e,[n]:oW(t,n)}),{})}});var aW=C(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.TModule=void 0;Ed.Module=pue;var sW=vo(),uue=pe(),due=rW(),Ag=class{constructor(e){let n=(0,due.ComputeModuleProperties)(e),i=this.WithIdentifiers(n);this.$defs=i}Import(e,n){let i={...this.$defs,[e]:(0,sW.CreateType)(this.$defs[e],n)};return(0,sW.CreateType)({[uue.Kind]:"Import",$defs:i,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((n,i)=>({...n,[i]:{...e[i],$id:i}}),{})}};Ed.TModule=Ag;function pue(t){return new Ag(t)}});var _g=C(la=>{"use strict";var mue=la&&la.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),hue=la&&la.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&mue(e,t,n)};Object.defineProperty(la,"__esModule",{value:!0});hue(aW(),la)});var lW=C(Sk=>{"use strict";Object.defineProperty(Sk,"__esModule",{value:!0});Sk.Not=vue;var gue=me(),fue=pe();function vue(t,e){return(0,gue.CreateType)({[fue.Kind]:"Not",not:t},e)}});var Og=C(ca=>{"use strict";var bue=ca&&ca.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),xue=ca&&ca.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&bue(e,t,n)};Object.defineProperty(ca,"__esModule",{value:!0});xue(lW(),ca)});var cW=C(Wo=>{"use strict";var yue=Wo&&Wo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),wue=Wo&&Wo.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),kue=Wo&&Wo.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&yue(n,e,i[o]);return wue(n,e),n}})();Object.defineProperty(Wo,"__esModule",{value:!0});Wo.Parameters=Mue;var Sue=ko(),Tue=Et(),Cue=kue(Le());function Mue(t,e){return Cue.IsFunction(t)?(0,Sue.Tuple)(t.parameters,e):(0,Tue.Never)()}});var Lg=C(ua=>{"use strict";var Rue=ua&&ua.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Pue=ua&&ua.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Rue(e,t,n)};Object.defineProperty(ua,"__esModule",{value:!0});Pue(cW(),ua)});var dW=C(Tk=>{"use strict";Object.defineProperty(Tk,"__esModule",{value:!0});Tk.Recursive=Oue;var Iue=Wh(),Eue=me(),Aue=Yt(),uW=pe(),_ue=0;function Oue(t,e={}){(0,Aue.IsUndefined)(e.$id)&&(e.$id=`T${_ue++}`);let n=(0,Iue.CloneType)(t({[uW.Kind]:"This",$ref:`${e.$id}`}));return n.$id=e.$id,(0,Eue.CreateType)({[uW.Hint]:"Recursive",...n},e)}});var Wg=C(da=>{"use strict";var Lue=da&&da.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Wue=da&&da.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Lue(e,t,n)};Object.defineProperty(da,"__esModule",{value:!0});Wue(dW(),da)});var pW=C(Ck=>{"use strict";Object.defineProperty(Ck,"__esModule",{value:!0});Ck.RegExp=$ue;var Fue=me(),Due=Yt(),Uue=pe();function $ue(t,e){let n=(0,Due.IsString)(t)?new globalThis.RegExp(t):t;return(0,Fue.CreateType)({[Uue.Kind]:"RegExp",type:"RegExp",source:n.source,flags:n.flags},e)}});var Fg=C(pa=>{"use strict";var Nue=pa&&pa.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Bue=pa&&pa.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Nue(e,t,n)};Object.defineProperty(pa,"__esModule",{value:!0});Bue(pW(),pa)});var mW=C(Rk=>{"use strict";Object.defineProperty(Rk,"__esModule",{value:!0});Rk.Rest=que;var Mk=Le();function jue(t){return(0,Mk.IsIntersect)(t)?t.allOf:(0,Mk.IsUnion)(t)?t.anyOf:(0,Mk.IsTuple)(t)?t.items??[]:[]}function que(t){return jue(t)}});var Dg=C(ma=>{"use strict";var Kue=ma&&ma.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Gue=ma&&ma.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Kue(e,t,n)};Object.defineProperty(ma,"__esModule",{value:!0});Gue(mW(),ma)});var hW=C(Fo=>{"use strict";var zue=Fo&&Fo.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Hue=Fo&&Fo.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Vue=Fo&&Fo.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&zue(n,e,i[o]);return Hue(n,e),n}})();Object.defineProperty(Fo,"__esModule",{value:!0});Fo.ReturnType=Xue;var Que=me(),Yue=Et(),Jue=Vue(Le());function Xue(t,e){return Jue.IsFunction(t)?(0,Que.CreateType)(t.returns,e):(0,Yue.Never)(e)}});var Ug=C(ha=>{"use strict";var Zue=ha&&ha.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ede=ha&&ha.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Zue(e,t,n)};Object.defineProperty(ha,"__esModule",{value:!0});ede(hW(),ha)});var fW=C(gW=>{"use strict";Object.defineProperty(gW,"__esModule",{value:!0})});var bW=C(vW=>{"use strict";Object.defineProperty(vW,"__esModule",{value:!0});var p7e=pe()});var yW=C(Sr=>{"use strict";var tde=Sr&&Sr.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),xW=Sr&&Sr.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&tde(e,t,n)};Object.defineProperty(Sr,"__esModule",{value:!0});xW(fW(),Sr);xW(bW(),Sr)});var kW=C(wW=>{"use strict";Object.defineProperty(wW,"__esModule",{value:!0})});var SW=C(ga=>{"use strict";var nde=ga&&ga.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ide=ga&&ga.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&nde(e,t,n)};Object.defineProperty(ga,"__esModule",{value:!0});ide(kW(),ga)});var TW=C(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.TransformEncodeBuilder=fa.TransformDecodeBuilder=void 0;fa.Transform=rde;var $g=pe(),ode=Le(),Ng=class{constructor(e){this.schema=e}Decode(e){return new Bg(this.schema,e)}};fa.TransformDecodeBuilder=Ng;var Bg=class{constructor(e,n){this.schema=e,this.decode=n}EncodeTransform(e,n){let r={Encode:s=>n[$g.TransformKind].Encode(e(s)),Decode:s=>this.decode(n[$g.TransformKind].Decode(s))};return{...n,[$g.TransformKind]:r}}EncodeSchema(e,n){let i={Decode:this.decode,Encode:e};return{...n,[$g.TransformKind]:i}}Encode(e){return(0,ode.IsTransform)(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};fa.TransformEncodeBuilder=Bg;function rde(t){return new Ng(t)}});var jg=C(va=>{"use strict";var sde=va&&va.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),ade=va&&va.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&sde(e,t,n)};Object.defineProperty(va,"__esModule",{value:!0});ade(TW(),va)});var MW=C(Pk=>{"use strict";Object.defineProperty(Pk,"__esModule",{value:!0});Pk.Unsafe=cde;var lde=me(),CW=pe();function cde(t={}){return(0,lde.CreateType)({[CW.Kind]:t[CW.Kind]??"Unsafe"},t)}});var qg=C(ba=>{"use strict";var ude=ba&&ba.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),dde=ba&&ba.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&ude(e,t,n)};Object.defineProperty(ba,"__esModule",{value:!0});dde(MW(),ba)});var RW=C(Ik=>{"use strict";Object.defineProperty(Ik,"__esModule",{value:!0});Ik.Void=hde;var pde=me(),mde=pe();function hde(t){return(0,pde.CreateType)({[mde.Kind]:"Void",type:"void"},t)}});var Kg=C(xa=>{"use strict";var gde=xa&&xa.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),fde=xa&&xa.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&gde(e,t,n)};Object.defineProperty(xa,"__esModule",{value:!0});fde(RW(),xa)});var Ak=C(zg=>{"use strict";Object.defineProperty(zg,"__esModule",{value:!0});zg.JsonTypeBuilder=void 0;var vde=zl(),bde=Hl(),xde=cd(),yde=rg(),wde=ag(),kde=cg(),Sde=bg(),Tde=sc(),Cde=wg(),Mde=gi(),Rde=Tg(),Pde=On(),Gg=Rg(),Ide=ic(),Ede=Jt(),Ade=vt(),_de=Et(),Ode=Og(),Lde=xd(),Wde=_g(),Fde=gr(),Dde=mn(),Ude=Cd(),$de=Ui(),Nde=Rd(),Bde=Md(),jde=br(),qde=Td(),Kde=lc(),Gde=Wg(),zde=yr(),Hde=Pd(),Vde=Dg(),Qde=Ls(),Yde=$i(),Jde=jg(),Xde=ko(),Zde=mt(),epe=Qs(),tpe=qg(),Ek=class{ReadonlyOptional(e){return(0,qde.ReadonlyOptional)(e)}Readonly(e,n){return(0,jde.Readonly)(e,n??!0)}Optional(e,n){return(0,$de.Optional)(e,n??!0)}Any(e){return(0,vde.Any)(e)}Array(e,n){return(0,bde.Array)(e,n)}Boolean(e){return(0,xde.Boolean)(e)}Capitalize(e,n){return(0,Gg.Capitalize)(e,n)}Composite(e,n){return(0,yde.Composite)(e,n)}Const(e,n){return(0,wde.Const)(e,n)}Enum(e,n){return(0,kde.Enum)(e,n)}Exclude(e,n,i){return(0,Sde.Exclude)(e,n,i)}Extends(e,n,i,o,r){return(0,Tde.Extends)(e,n,i,o,r)}Extract(e,n,i){return(0,Cde.Extract)(e,n,i)}Index(e,n,i){return(0,Mde.Index)(e,n,i)}Integer(e){return(0,Rde.Integer)(e)}Intersect(e,n){return(0,Pde.Intersect)(e,n)}KeyOf(e,n){return(0,Ide.KeyOf)(e,n)}Literal(e,n){return(0,Ede.Literal)(e,n)}Lowercase(e,n){return(0,Gg.Lowercase)(e,n)}Mapped(e,n,i){return(0,Ade.Mapped)(e,n,i)}Module(e){return(0,Wde.Module)(e)}Never(e){return(0,_de.Never)(e)}Not(e,n){return(0,Ode.Not)(e,n)}Null(e){return(0,Lde.Null)(e)}Number(e){return(0,Fde.Number)(e)}Object(e,n){return(0,Dde.Object)(e,n)}Omit(e,n,i){return(0,Ude.Omit)(e,n,i)}Partial(e,n){return(0,Nde.Partial)(e,n)}Pick(e,n,i){return(0,Bde.Pick)(e,n,i)}Record(e,n,i){return(0,Kde.Record)(e,n,i)}Recursive(e,n){return(0,Gde.Recursive)(e,n)}Ref(...e){return(0,zde.Ref)(e[0],e[1])}Required(e,n){return(0,Hde.Required)(e,n)}Rest(e){return(0,Vde.Rest)(e)}String(e){return(0,Qde.String)(e)}TemplateLiteral(e,n){return(0,Yde.TemplateLiteral)(e,n)}Transform(e){return(0,Jde.Transform)(e)}Tuple(e,n){return(0,Xde.Tuple)(e,n)}Uncapitalize(e,n){return(0,Gg.Uncapitalize)(e,n)}Union(e,n){return(0,Zde.Union)(e,n)}Unknown(e){return(0,epe.Unknown)(e)}Unsafe(e){return(0,tpe.Unsafe)(e)}Uppercase(e,n){return(0,Gg.Uppercase)(e,n)}};zg.JsonTypeBuilder=Ek});var PW=C(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.Rest=N.Required=N.RegExp=N.Ref=N.Recursive=N.Record=N.ReadonlyOptional=N.Readonly=N.Promise=N.Pick=N.Partial=N.Parameters=N.Optional=N.Omit=N.Object=N.Number=N.Null=N.Not=N.Never=N.Module=N.Mapped=N.Literal=N.KeyOf=N.Iterator=N.Uppercase=N.Lowercase=N.Uncapitalize=N.Capitalize=N.Intersect=N.Integer=N.Instantiate=N.InstanceType=N.Index=N.Function=N.Extract=N.Extends=N.Exclude=N.Enum=N.Date=N.ConstructorParameters=N.Constructor=N.Const=N.Composite=N.Boolean=N.BigInt=N.Awaited=N.AsyncIterator=N.Array=N.Argument=N.Any=void 0;N.Void=N.Unsafe=N.Unknown=N.Union=N.Undefined=N.Uint8Array=N.Tuple=N.Transform=N.TemplateLiteral=N.Symbol=N.String=N.ReturnType=void 0;var npe=zl();Object.defineProperty(N,"Any",{enumerable:!0,get:function(){return npe.Any}});var ipe=Bh();Object.defineProperty(N,"Argument",{enumerable:!0,get:function(){return ipe.Argument}});var ope=Hl();Object.defineProperty(N,"Array",{enumerable:!0,get:function(){return ope.Array}});var rpe=Vl();Object.defineProperty(N,"AsyncIterator",{enumerable:!0,get:function(){return rpe.AsyncIterator}});var spe=vd();Object.defineProperty(N,"Awaited",{enumerable:!0,get:function(){return spe.Awaited}});var ape=Zl();Object.defineProperty(N,"BigInt",{enumerable:!0,get:function(){return ape.BigInt}});var lpe=cd();Object.defineProperty(N,"Boolean",{enumerable:!0,get:function(){return lpe.Boolean}});var cpe=rg();Object.defineProperty(N,"Composite",{enumerable:!0,get:function(){return cpe.Composite}});var upe=ag();Object.defineProperty(N,"Const",{enumerable:!0,get:function(){return upe.Const}});var dpe=Ql();Object.defineProperty(N,"Constructor",{enumerable:!0,get:function(){return dpe.Constructor}});var ppe=lg();Object.defineProperty(N,"ConstructorParameters",{enumerable:!0,get:function(){return ppe.ConstructorParameters}});var mpe=bd();Object.defineProperty(N,"Date",{enumerable:!0,get:function(){return mpe.Date}});var hpe=cg();Object.defineProperty(N,"Enum",{enumerable:!0,get:function(){return hpe.Enum}});var gpe=bg();Object.defineProperty(N,"Exclude",{enumerable:!0,get:function(){return gpe.Exclude}});var fpe=sc();Object.defineProperty(N,"Extends",{enumerable:!0,get:function(){return fpe.Extends}});var vpe=wg();Object.defineProperty(N,"Extract",{enumerable:!0,get:function(){return vpe.Extract}});var bpe=hr();Object.defineProperty(N,"Function",{enumerable:!0,get:function(){return bpe.Function}});var xpe=gi();Object.defineProperty(N,"Index",{enumerable:!0,get:function(){return xpe.Index}});var ype=kg();Object.defineProperty(N,"InstanceType",{enumerable:!0,get:function(){return ype.InstanceType}});var wpe=Sg();Object.defineProperty(N,"Instantiate",{enumerable:!0,get:function(){return wpe.Instantiate}});var kpe=Tg();Object.defineProperty(N,"Integer",{enumerable:!0,get:function(){return kpe.Integer}});var Spe=On();Object.defineProperty(N,"Intersect",{enumerable:!0,get:function(){return Spe.Intersect}});var Hg=Rg();Object.defineProperty(N,"Capitalize",{enumerable:!0,get:function(){return Hg.Capitalize}});Object.defineProperty(N,"Uncapitalize",{enumerable:!0,get:function(){return Hg.Uncapitalize}});Object.defineProperty(N,"Lowercase",{enumerable:!0,get:function(){return Hg.Lowercase}});Object.defineProperty(N,"Uppercase",{enumerable:!0,get:function(){return Hg.Uppercase}});var Tpe=tc();Object.defineProperty(N,"Iterator",{enumerable:!0,get:function(){return Tpe.Iterator}});var Cpe=ic();Object.defineProperty(N,"KeyOf",{enumerable:!0,get:function(){return Cpe.KeyOf}});var Mpe=Jt();Object.defineProperty(N,"Literal",{enumerable:!0,get:function(){return Mpe.Literal}});var Rpe=vt();Object.defineProperty(N,"Mapped",{enumerable:!0,get:function(){return Rpe.Mapped}});var Ppe=_g();Object.defineProperty(N,"Module",{enumerable:!0,get:function(){return Ppe.Module}});var Ipe=Et();Object.defineProperty(N,"Never",{enumerable:!0,get:function(){return Ipe.Never}});var Epe=Og();Object.defineProperty(N,"Not",{enumerable:!0,get:function(){return Epe.Not}});var Ape=xd();Object.defineProperty(N,"Null",{enumerable:!0,get:function(){return Ape.Null}});var _pe=gr();Object.defineProperty(N,"Number",{enumerable:!0,get:function(){return _pe.Number}});var Ope=mn();Object.defineProperty(N,"Object",{enumerable:!0,get:function(){return Ope.Object}});var Lpe=Cd();Object.defineProperty(N,"Omit",{enumerable:!0,get:function(){return Lpe.Omit}});var Wpe=Ui();Object.defineProperty(N,"Optional",{enumerable:!0,get:function(){return Wpe.Optional}});var Fpe=Lg();Object.defineProperty(N,"Parameters",{enumerable:!0,get:function(){return Fpe.Parameters}});var Dpe=Rd();Object.defineProperty(N,"Partial",{enumerable:!0,get:function(){return Dpe.Partial}});var Upe=Md();Object.defineProperty(N,"Pick",{enumerable:!0,get:function(){return Upe.Pick}});var $pe=hd();Object.defineProperty(N,"Promise",{enumerable:!0,get:function(){return $pe.Promise}});var Npe=br();Object.defineProperty(N,"Readonly",{enumerable:!0,get:function(){return Npe.Readonly}});var Bpe=Td();Object.defineProperty(N,"ReadonlyOptional",{enumerable:!0,get:function(){return Bpe.ReadonlyOptional}});var jpe=lc();Object.defineProperty(N,"Record",{enumerable:!0,get:function(){return jpe.Record}});var qpe=Wg();Object.defineProperty(N,"Recursive",{enumerable:!0,get:function(){return qpe.Recursive}});var Kpe=yr();Object.defineProperty(N,"Ref",{enumerable:!0,get:function(){return Kpe.Ref}});var Gpe=Fg();Object.defineProperty(N,"RegExp",{enumerable:!0,get:function(){return Gpe.RegExp}});var zpe=Pd();Object.defineProperty(N,"Required",{enumerable:!0,get:function(){return zpe.Required}});var Hpe=Dg();Object.defineProperty(N,"Rest",{enumerable:!0,get:function(){return Hpe.Rest}});var Vpe=Ug();Object.defineProperty(N,"ReturnType",{enumerable:!0,get:function(){return Vpe.ReturnType}});var Qpe=Ls();Object.defineProperty(N,"String",{enumerable:!0,get:function(){return Qpe.String}});var Ype=yd();Object.defineProperty(N,"Symbol",{enumerable:!0,get:function(){return Ype.Symbol}});var Jpe=$i();Object.defineProperty(N,"TemplateLiteral",{enumerable:!0,get:function(){return Jpe.TemplateLiteral}});var Xpe=jg();Object.defineProperty(N,"Transform",{enumerable:!0,get:function(){return Xpe.Transform}});var Zpe=ko();Object.defineProperty(N,"Tuple",{enumerable:!0,get:function(){return Zpe.Tuple}});var eme=kd();Object.defineProperty(N,"Uint8Array",{enumerable:!0,get:function(){return eme.Uint8Array}});var tme=wd();Object.defineProperty(N,"Undefined",{enumerable:!0,get:function(){return tme.Undefined}});var nme=mt();Object.defineProperty(N,"Union",{enumerable:!0,get:function(){return nme.Union}});var ime=Qs();Object.defineProperty(N,"Unknown",{enumerable:!0,get:function(){return ime.Unknown}});var ome=qg();Object.defineProperty(N,"Unsafe",{enumerable:!0,get:function(){return ome.Unsafe}});var rme=Kg();Object.defineProperty(N,"Void",{enumerable:!0,get:function(){return rme.Void}})});var IW=C(Vg=>{"use strict";Object.defineProperty(Vg,"__esModule",{value:!0});Vg.JavaScriptTypeBuilder=void 0;var sme=Ak(),ame=Bh(),lme=Vl(),cme=vd(),ume=Zl(),dme=Ql(),pme=lg(),mme=bd(),hme=hr(),gme=kg(),fme=Sg(),vme=tc(),bme=Lg(),xme=hd(),yme=Fg(),wme=Ug(),kme=yd(),Sme=kd(),Tme=wd(),Cme=Kg(),_k=class extends sme.JsonTypeBuilder{Argument(e){return(0,ame.Argument)(e)}AsyncIterator(e,n){return(0,lme.AsyncIterator)(e,n)}Awaited(e,n){return(0,cme.Awaited)(e,n)}BigInt(e){return(0,ume.BigInt)(e)}ConstructorParameters(e,n){return(0,pme.ConstructorParameters)(e,n)}Constructor(e,n,i){return(0,dme.Constructor)(e,n,i)}Date(e={}){return(0,mme.Date)(e)}Function(e,n,i){return(0,hme.Function)(e,n,i)}InstanceType(e,n){return(0,gme.InstanceType)(e,n)}Instantiate(e,n){return(0,fme.Instantiate)(e,n)}Iterator(e,n){return(0,vme.Iterator)(e,n)}Parameters(e,n){return(0,bme.Parameters)(e,n)}Promise(e,n){return(0,xme.Promise)(e,n)}RegExp(e,n){return(0,yme.RegExp)(e,n)}ReturnType(e,n){return(0,wme.ReturnType)(e,n)}Symbol(e){return(0,kme.Symbol)(e)}Undefined(e){return(0,Tme.Undefined)(e)}Uint8Array(e){return(0,Sme.Uint8Array)(e)}Void(e){return(0,Cme.Void)(e)}};Vg.JavaScriptTypeBuilder=_k});var EW=C(xn=>{"use strict";var Mme=xn&&xn.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),Rme=xn&&xn.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Pme=xn&&xn.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var i=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[i.length]=o);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i=t(e),o=0;o<i.length;o++)i[o]!=="default"&&Mme(n,e,i[o]);return Rme(n,e),n}})();Object.defineProperty(xn,"__esModule",{value:!0});xn.Type=xn.JavaScriptTypeBuilder=xn.JsonTypeBuilder=void 0;var Ime=Ak();Object.defineProperty(xn,"JsonTypeBuilder",{enumerable:!0,get:function(){return Ime.JsonTypeBuilder}});var Eme=Pme(PW()),Ame=IW();Object.defineProperty(xn,"JavaScriptTypeBuilder",{enumerable:!0,get:function(){return Ame.JavaScriptTypeBuilder}});var _me=Eme;xn.Type=_me});var AW=C(V=>{"use strict";var Ome=V&&V.__createBinding||(Object.create?(function(t,e,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}):(function(t,e,n,i){i===void 0&&(i=n),t[i]=e[n]})),X=V&&V.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Ome(e,t,n)};Object.defineProperty(V,"__esModule",{value:!0});X(Tx(),V);X(vo(),V);X(Wi(),V);X(_x(),V);X(IO(),V);X(rd(),V);X(LO(),V);X(sd(),V);X(pe(),V);X(zl(),V);X(Hl(),V);X(Bh(),V);X(Vl(),V);X(vd(),V);X(Zl(),V);X(cd(),V);X(rg(),V);X(ag(),V);X(Ql(),V);X(lg(),V);X(bd(),V);X(cg(),V);X(bg(),V);X(sc(),V);X(wg(),V);X(hr(),V);X(gi(),V);X(kg(),V);X(Sg(),V);X(Tg(),V);X(On(),V);X(tc(),V);X(Rg(),V);X(ic(),V);X(Jt(),V);X(_g(),V);X(vt(),V);X(Et(),V);X(Og(),V);X(xd(),V);X(gr(),V);X(mn(),V);X(Cd(),V);X(Ui(),V);X(Lg(),V);X(Rd(),V);X(Md(),V);X(hd(),V);X(br(),V);X(Td(),V);X(lc(),V);X(Wg(),V);X(yr(),V);X(Fg(),V);X(Pd(),V);X(Dg(),V);X(Ug(),V);X(yW(),V);X(SW(),V);X(Ls(),V);X(yd(),V);X($i(),V);X(jg(),V);X(ko(),V);X(kd(),V);X(wd(),V);X(mt(),V);X(Qs(),V);X(qg(),V);X(Kg(),V);X(EW(),V)});import zhe from"chalk";import{accessSync as _he,constants as Ohe,existsSync as cf,readFileSync as E3,realpathSync as Lhe}from"fs";import{homedir as A3}from"os";import{basename as Dhe,dirname as Nd,join as Tt,resolve as uf,sep as Uhe,win32 as $he}from"path";import{fileURLToPath as _3}from"url";import{spawn as w3,spawnSync as k3}from"node:child_process";import Yk from"cross-spawn";var S3=100;function Ud(t,e,n){return process.platform==="win32"?Yk(t,e,n):w3(t,e,n)}function Sa(t,e,n){return process.platform==="win32"?Yk.sync(t,e,n):k3(t,e,n)}function lf(t){return new Promise((e,n)=>{let i=!1,o=!1,r=null,s,a=t.stdout===null,l=t.stderr===null,c=()=>{s&&(clearTimeout(s),s=void 0),t.removeListener("error",f),t.removeListener("exit",b),t.removeListener("close",x),t.stdout?.removeListener("end",g),t.stderr?.removeListener("end",h),t.stdout?.removeListener("data",m),t.stderr?.removeListener("data",m)},u=y=>{i||(i=!0,c(),t.stdout?.destroy(),t.stderr?.destroy(),e(y))},d=()=>{!o||i||a&&l&&u(r)},p=()=>{s&&clearTimeout(s),s=setTimeout(()=>u(r),S3)},m=()=>{o&&!i&&p()},g=()=>{a=!0,d()},h=()=>{l=!0,d()},f=y=>{i||(i=!0,c(),n(y))},b=y=>{o=!0,r=y,d(),i||p()},x=y=>{u(y)};t.stdout?.once("end",g),t.stderr?.once("end",h),t.stdout?.on("data",m),t.stderr?.on("data",m),t.once("error",f),t.once("exit",b),t.once("close",x)})}import{realpathSync as T3}from"node:fs";import{homedir as C3}from"node:os";import{isAbsolute as Xk,join as M3,resolve as Jk,relative as R3,sep as Zk}from"node:path";import{fileURLToPath as P3}from"node:url";var I3=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;function ri(t){try{return T3(t)}catch{return t}}function fc(t){let e=t.trim();return!(e.startsWith("npm:")||e.startsWith("git:")||e.startsWith("github:")||e.startsWith("http:")||e.startsWith("https:")||e.startsWith("ssh:"))}function tt(t,e={}){let n=e.trim?t.trim():t;if(e.normalizeUnicodeSpaces&&(n=n.replace(I3," ")),e.stripAtPrefix&&n.startsWith("@")&&(n=n.slice(1)),e.expandTilde??!0){let i=e.homeDir??C3();if(n==="~")return i;if(n.startsWith("~/")||process.platform==="win32"&&n.startsWith("~\\"))return M3(i,n.slice(2))}return/^file:\/\//.test(n)?P3(n):n}function Se(t,e=process.cwd(),n={}){let i=tt(t,n),o=tt(e);return Xk(i)?Jk(i):Jk(o,i)}function $d(t,e){let n=Se(e),i=Se(t,n),o=R3(n,i);return o===""||o!==".."&&!o.startsWith(`..${Zk}`)&&!Xk(o)?o||".":void 0}function eS(t,e){let n=Se(t,e);return($d(n,e)??n).split(Zk).join("/")}function tS(t){let e=process.platform==="darwin"?["com.dropbox.ignored","com.apple.fileprovider.ignore#P"]:process.platform==="linux"?["user.com.dropbox.ignored"]:[];for(let n of e)process.platform==="darwin"?Sa("xattr",["-w",n,"1",t],{encoding:"utf-8",stdio:"ignore"}):Sa("setfattr",["-n",n,"-v","1",t],{encoding:"utf-8",stdio:"ignore"})}var O3=_3(import.meta.url),nS=Nd(O3),Bd=import.meta.url.includes("$bunfs")||import.meta.url.includes("~BUN")||import.meta.url.includes("%7EBUN"),qhe=!!process.versions.bun;function si(){let t=process.env.PI_PACKAGE_DIR;if(t)return tt(t);if(Bd)return Nd(process.execPath);let e=nS;for(;e!==Nd(e);){if(cf(Tt(e,"package.json")))return e;e=Nd(e)}return nS}function df(){if(Bd)return Tt(si(),"theme");let t=si(),e=cf(Tt(t,"src"))?"src":"dist";return Tt(t,e,"modes","interactive","theme")}function L3(){return Tt(si(),"package.json")}function jd(){return uf(Tt(si(),"README.md"))}function vc(){return uf(Tt(si(),"docs"))}function qd(){return uf(Tt(si(),"CHANGELOG.md"))}function W3(){if(Bd)return Tt(si(),"assets");let t=si(),e=cf(Tt(t,"src"))?"src":"dist";return Tt(t,e,"modes","interactive","assets")}function iS(t){return Tt(W3(),t)}var bc={};try{bc=JSON.parse(E3(L3(),"utf-8"))}catch(t){if(t.code!=="ENOENT")throw t}var oS=bc.piConfig?.name,rS=bc.name||"@earendil-works/pi-coding-agent",wt=oS||"pi",pf=oS?wt:"\u03C0",Je=bc.piConfig?.configDir||".pi",wi=bc.version||"0.0.0",mf=`${wt.toUpperCase()}_CODING_AGENT_DIR`,sS=`${wt.toUpperCase()}_CODING_AGENT_SESSION_DIR`;function aS(t){return tt(t)}var F3="https://pi.dev/session/";function lS(t){return`${process.env.PI_SHARE_VIEWER_URL||F3}#${t}`}function _e(){let t=process.env[mf];return t?aS(t):Tt(A3(),Je,"agent")}function Kd(){return Tt(_e(),"themes")}function hf(){return Tt(_e(),"auth.json")}function xc(){return Tt(_e(),"bin")}function cS(){return Tt(_e(),"sessions")}function uS(){return Tt(_e(),`${wt}-debug.log`)}var D3=["off","minimal","low","medium","high","xhigh","max"];function gf(t){return D3.includes(t)}Sn();vf();bf();import{Type as fge}from"typebox";function ne(t,e){return{name:t,login:async n=>({type:"api_key",key:await n.prompt({type:"secret",message:`Enter ${t}`})}),resolve:async({ctx:n,credential:i})=>{if(i?.key)return{auth:{apiKey:i.key},env:i.env,source:"stored credential"};for(let o of e){let r=await n.env(o);if(r)return{auth:{apiKey:r},source:o}}}}}function Dn(t){let e,n=()=>(e??=t.load(),e);return{name:t.name,loginLabel:t.loginLabel,login:async i=>(await n()).login(i),refresh:async i=>(await n()).refresh(i),toAuth:async i=>(await n()).toAuth(i)}}fe();wf();Sf();Vd();Fn();Cr();Cf();Sn();var at=()=>gt(()=>Promise.resolve().then(()=>(DS(),FS)));Sn();var op=()=>gt(()=>Promise.resolve().then(()=>(BS(),NS)));Sn();var JF=t=>import(import.meta.url.endsWith(".js")?t.replace(/\.ts$/,".js"):t),XF;var rp=()=>gt(async()=>XF??await JF("./bedrock-converse-stream.ts"));Sn();var Aa=()=>gt(()=>Promise.resolve().then(()=>(GS(),KS)));Sn();var hp=()=>gt(()=>Promise.resolve().then(()=>(JS(),YS)));Sn();var gp=()=>gt(()=>Promise.resolve().then(()=>(oT(),iT)));Sn();var xp=()=>gt(()=>Promise.resolve().then(()=>(RT(),MT)));Sn();var ge=()=>gt(()=>Promise.resolve().then(()=>(UT(),DT)));Sn();var on=()=>gt(()=>Promise.resolve().then(()=>(GT(),KT)));Sn();var yp=()=>gt(()=>Promise.resolve().then(()=>(JT(),YT)));Zi();var Oa=null,zf=null,Hf=null,Gf=t=>import(t),FU="node:fs",DU="node:os",UU="node:path";typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&(Gf(FU).then(t=>{Oa=t.existsSync}),Gf(DU).then(t=>{zf=t.homedir}),Gf(UU).then(t=>{Hf=t.join}));var Pc=null;function $U(t){let e=t?.GOOGLE_APPLICATION_CREDENTIALS;if(e)return Oa?Oa(e):!1;if(Pc===null){if(!Oa||!zf||!Hf)return typeof process<"u"&&(process.versions?.node||process.versions?.bun)||(Pc=!1),!1;let n=Oe("GOOGLE_APPLICATION_CREDENTIALS",t);n?Pc=Oa(n):Pc=Oa(Hf(zf(),".config","gcloud","application_default_credentials.json"))}return Pc}function NU(t){if(t==="github-copilot")return["COPILOT_GITHUB_TOKEN"];if(t==="anthropic")return["ANTHROPIC_OAUTH_TOKEN","ANTHROPIC_API_KEY"];let n={"ant-ling":"ANT_LING_API_KEY","qwen-token-plan":"QWEN_TOKEN_PLAN_API_KEY","qwen-token-plan-cn":"QWEN_TOKEN_PLAN_CN_API_KEY",openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",radius:"RADIUS_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"}[t];return n?[n]:void 0}function BU(t,e){let n=NU(t);if(!n)return;let i=n.filter(o=>!!Oe(o,e));return i.length>0?i:void 0}function XT(t,e){let n=BU(t,e);if(n?.[0])return Oe(n[0],e);if(t==="google-vertex"){let i=$U(e),o=!!(Oe("GOOGLE_CLOUD_PROJECT",e)||Oe("GCLOUD_PROJECT",e)),r=!!Oe("GOOGLE_CLOUD_LOCATION",e);if(i&&o&&r)return"<authenticated>"}if(t==="amazon-bedrock"&&(Oe("AWS_PROFILE",e)||Oe("AWS_ACCESS_KEY_ID",e)&&Oe("AWS_SECRET_ACCESS_KEY",e)||Oe("AWS_BEARER_TOKEN_BEDROCK",e)||Oe("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",e)||Oe("AWS_CONTAINER_CREDENTIALS_FULL_URI",e)||Oe("AWS_WEB_IDENTITY_TOKEN_FILE",e)))return"<authenticated>"}var ZT={"amazon.nova-2-lite-v1:0":{id:"amazon.nova-2-lite-v1:0",name:"Nova 2 Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:.33,output:2.75,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"amazon.nova-lite-v1:0":{id:"amazon.nova-lite-v1:0",name:"Nova Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:.015,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon.nova-micro-v1:0":{id:"amazon.nova-micro-v1:0",name:"Nova Micro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:.00875,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"amazon.nova-pro-v1:0":{id:"amazon.nova-pro-v1:0",name:"Nova Pro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"anthropic.claude-fable-5":{id:"anthropic.claude-fable-5",name:"Claude Fable 5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"anthropic.claude-haiku-4-5-20251001-v1:0":{id:"anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-1-20250805-v1:0":{id:"anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic.claude-opus-4-5-20251101-v1:0":{id:"anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-6-v1":{id:"anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"anthropic.claude-opus-4-7":{id:"anthropic.claude-opus-4-7",name:"Claude Opus 4.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic.claude-opus-4-8":{id:"anthropic.claude-opus-4-8",name:"Claude Opus 4.8",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-sonnet-4-6":{id:"anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"}},"anthropic.claude-sonnet-5":{id:"anthropic.claude-sonnet-5",name:"Claude Sonnet 5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"au.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"au.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (AU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"au.anthropic.claude-opus-4-6-v1":{id:"au.anthropic.claude-opus-4-6-v1",name:"AU Anthropic Claude Opus 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:16.5,output:82.5,cacheRead:1.65,cacheWrite:20.625},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"au.anthropic.claude-opus-4-8":{id:"au.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (AU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"au.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"au.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (AU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"au.anthropic.claude-sonnet-4-6":{id:"au.anthropic.claude-sonnet-4-6",name:"AU Anthropic Claude Sonnet 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3.3,output:16.5,cacheRead:.33,cacheWrite:4.125},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"au.anthropic.claude-sonnet-5":{id:"au.anthropic.claude-sonnet-5",name:"Claude Sonnet 5 (AU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"deepseek.r1-v1:0":{id:"deepseek.r1-v1:0",name:"DeepSeek-R1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"deepseek.v3-v1:0":{id:"deepseek.v3-v1:0",name:"DeepSeek-V3.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.58,output:1.68,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"deepseek.v3.2":{id:"deepseek.v3.2",name:"DeepSeek-V3.2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.62,output:1.85,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"eu.anthropic.claude-fable-5":{id:"eu.anthropic.claude-fable-5",name:"Claude Fable 5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:11,output:55,cacheRead:1.1,cacheWrite:13.75},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"eu.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"eu.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1.1,output:5.5,cacheRead:.11,cacheWrite:1.375},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-5-20251101-v1:0":{id:"eu.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5.5,output:27.5,cacheRead:.55,cacheWrite:6.875},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-6-v1":{id:"eu.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5.5,output:27.5,cacheRead:.55,cacheWrite:6.875},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"eu.anthropic.claude-opus-4-7":{id:"eu.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5.5,output:27.5,cacheRead:.55,cacheWrite:6.875},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"eu.anthropic.claude-opus-4-8":{id:"eu.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5.5,output:27.5,cacheRead:.55,cacheWrite:6.875},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"eu.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"eu.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3.3,output:16.5,cacheRead:.33,cacheWrite:4.125},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-sonnet-4-6":{id:"eu.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3.3,output:16.5,cacheRead:.33,cacheWrite:4.125},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"}},"eu.anthropic.claude-sonnet-5":{id:"eu.anthropic.claude-sonnet-5",name:"Claude Sonnet 5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.eu-central-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2.2,output:11,cacheRead:.22,cacheWrite:2.75},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"global.anthropic.claude-fable-5":{id:"global.anthropic.claude-fable-5",name:"Claude Fable 5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"global.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"global.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-5-20251101-v1:0":{id:"global.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-6-v1":{id:"global.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"global.anthropic.claude-opus-4-7":{id:"global.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"global.anthropic.claude-opus-4-8":{id:"global.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"global.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"global.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-sonnet-4-6":{id:"global.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"}},"global.anthropic.claude-sonnet-5":{id:"global.anthropic.claude-sonnet-5",name:"Claude Sonnet 5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"google.gemma-3-27b-it":{id:"google.gemma-3-27b-it",name:"Google Gemma 3 27B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.12,output:.2,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:8192},"google.gemma-3-4b-it":{id:"google.gemma-3-4b-it",name:"Gemma 3 4B IT",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.04,output:.08,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"jp.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"jp.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"jp.anthropic.claude-opus-4-7":{id:"jp.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"jp.anthropic.claude-opus-4-8":{id:"jp.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"jp.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"jp.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"jp.anthropic.claude-sonnet-4-6":{id:"jp.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"}},"jp.anthropic.claude-sonnet-5":{id:"jp.anthropic.claude-sonnet-5",name:"Claude Sonnet 5 (JP)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"meta.llama3-1-70b-instruct-v1:0":{id:"meta.llama3-1-70b-instruct-v1:0",name:"Llama 3.1 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-1-8b-instruct-v1:0":{id:"meta.llama3-1-8b-instruct-v1:0",name:"Llama 3.1 8B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.22,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-3-70b-instruct-v1:0":{id:"meta.llama3-3-70b-instruct-v1:0",name:"Llama 3.3 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama4-maverick-17b-instruct-v1:0":{id:"meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.24,output:.97,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"meta.llama4-scout-17b-instruct-v1:0":{id:"meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.17,output:.66,cacheRead:0,cacheWrite:0},contextWindow:35e5,maxTokens:16384},"minimax.minimax-m2":{id:"minimax.minimax-m2",name:"MiniMax M2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204608,maxTokens:128e3},"minimax.minimax-m2.1":{id:"minimax.minimax-m2.1",name:"MiniMax M2.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax.minimax-m2.5":{id:"minimax.minimax-m2.5",name:"MiniMax M2.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:98304},"mistral.devstral-2-123b":{id:"mistral.devstral-2-123b",name:"Devstral 2 123B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8192},"mistral.magistral-small-2509":{id:"mistral.magistral-small-2509",name:"Magistral Small 1.2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e4},"mistral.ministral-3-14b-instruct":{id:"mistral.ministral-3-14b-instruct",name:"Ministral 14B 3.0",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.ministral-3-3b-instruct":{id:"mistral.ministral-3-3b-instruct",name:"Ministral 3 3B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8192},"mistral.ministral-3-8b-instruct":{id:"mistral.ministral-3-8b-instruct",name:"Ministral 3 8B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.mistral-large-3-675b-instruct":{id:"mistral.mistral-large-3-675b-instruct",name:"Mistral Large 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8192},"mistral.pixtral-large-2502-v1:0":{id:"mistral.pixtral-large-2502-v1:0",name:"Pixtral Large (25.02)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"mistral.voxtral-mini-3b-2507":{id:"mistral.voxtral-mini-3b-2507",name:"Voxtral Mini 3B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.voxtral-small-24b-2507":{id:"mistral.voxtral-small-24b-2507",name:"Voxtral Small 24B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.35,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:8192},"moonshot.kimi-k2-thinking":{id:"moonshot.kimi-k2-thinking",name:"Kimi K2 Thinking",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:262143,maxTokens:16e3},"moonshotai.kimi-k2.5":{id:"moonshotai.kimi-k2.5",name:"Kimi K2.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:0,cacheWrite:0},contextWindow:262143,maxTokens:16e3},"nvidia.nemotron-nano-12b-v2":{id:"nvidia.nemotron-nano-12b-v2",name:"NVIDIA Nemotron Nano 12B v2 VL BF16",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"nvidia.nemotron-nano-3-30b":{id:"nvidia.nemotron-nano-3-30b",name:"NVIDIA Nemotron Nano 3 30B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"nvidia.nemotron-nano-9b-v2":{id:"nvidia.nemotron-nano-9b-v2",name:"NVIDIA Nemotron Nano 9B v2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.06,output:.23,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"nvidia.nemotron-super-3-120b":{id:"nvidia.nemotron-super-3-120b",name:"NVIDIA Nemotron 3 Super 120B A12B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.65,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"openai.gpt-5.4":{id:"openai.gpt-5.4",name:"GPT-5.4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2.75,output:16.5,cacheRead:.275,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai.gpt-5.5":{id:"openai.gpt-5.5",name:"GPT-5.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5.5,output:33,cacheRead:.55,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai.gpt-5.6-luna":{id:"openai.gpt-5.6-luna",name:"GPT-5.6 Luna",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai.gpt-5.6-sol":{id:"openai.gpt-5.6-sol",name:"GPT-5.6 Sol",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai.gpt-5.6-terra":{id:"openai.gpt-5.6-terra",name:"GPT-5.6 Terra",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai.gpt-oss-120b":{id:"openai.gpt-oss-120b",name:"gpt-oss-120b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai.gpt-oss-120b-1:0":{id:"openai.gpt-oss-120b-1:0",name:"gpt-oss-120b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai.gpt-oss-20b":{id:"openai.gpt-oss-20b",name:"gpt-oss-20b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai.gpt-oss-20b-1:0":{id:"openai.gpt-oss-20b-1:0",name:"gpt-oss-20b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai.gpt-oss-safeguard-120b":{id:"openai.gpt-oss-safeguard-120b",name:"GPT OSS Safeguard 120B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai.gpt-oss-safeguard-20b":{id:"openai.gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.07,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"qwen.qwen3-235b-a22b-2507-v1:0":{id:"qwen.qwen3-235b-a22b-2507-v1:0",name:"Qwen3 235B A22B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-32b-v1:0":{id:"qwen.qwen3-32b-v1:0",name:"Qwen3 32B (dense)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384},"qwen.qwen3-coder-30b-a3b-v1:0":{id:"qwen.qwen3-coder-30b-a3b-v1:0",name:"Qwen3 Coder 30B A3B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-coder-480b-a35b-v1:0":{id:"qwen.qwen3-coder-480b-a35b-v1:0",name:"Qwen3 Coder 480B A35B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen.qwen3-coder-next":{id:"qwen.qwen3-coder-next",name:"Qwen3 Coder Next",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.22,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen.qwen3-next-80b-a3b":{id:"qwen.qwen3-next-80b-a3b",name:"Qwen/Qwen3-Next-80B-A3B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.14,output:1.4,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"qwen.qwen3-vl-235b-a22b":{id:"qwen.qwen3-vl-235b-a22b",name:"Qwen/Qwen3-VL-235B-A22B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.3,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"us.anthropic.claude-fable-5":{id:"us.anthropic.claude-fable-5",name:"Claude Fable 5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"us.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"us.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-1-20250805-v1:0":{id:"us.anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"us.anthropic.claude-opus-4-5-20251101-v1:0":{id:"us.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-6-v1":{id:"us.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"}},"us.anthropic.claude-opus-4-7":{id:"us.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"us.anthropic.claude-opus-4-8":{id:"us.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"us.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-sonnet-4-6":{id:"us.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"}},"us.anthropic.claude-sonnet-5":{id:"us.anthropic.claude-sonnet-5",name:"Claude Sonnet 5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"us.deepseek.r1-v1:0":{id:"us.deepseek.r1-v1:0",name:"DeepSeek-R1 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"us.meta.llama4-maverick-17b-instruct-v1:0":{id:"us.meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.24,output:.97,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"us.meta.llama4-scout-17b-instruct-v1:0":{id:"us.meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.17,output:.66,cacheRead:0,cacheWrite:0},contextWindow:35e5,maxTokens:16384},"writer.palmyra-x4-v1:0":{id:"writer.palmyra-x4-v1:0",name:"Palmyra X4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:122880,maxTokens:8192},"writer.palmyra-x5-v1:0":{id:"writer.palmyra-x5-v1:0",name:"Palmyra X5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:6,cacheRead:0,cacheWrite:0},contextWindow:104e4,maxTokens:8192},"xai.grok-4.3":{id:"xai.grok-4.3",name:"Grok 4.3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"zai.glm-4.7":{id:"zai.glm-4.7",name:"GLM-4.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"zai.glm-4.7-flash":{id:"zai.glm-4.7-flash",name:"GLM-4.7-Flash",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.07,output:.4,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131072},"zai.glm-5":{id:"zai.glm-5",name:"GLM-5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:101376}};var eC=ZT;var tC={"Ling-2.6-1T":{id:"Ling-2.6-1T",name:"Ling 2.6 1T",api:"openai-completions",baseUrl:"https://api.ant-ling.com/v1",provider:"ant-ling",reasoning:!1,input:["text"],cost:{input:.06,output:.25,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"ant-ling",supportsLongCacheRetention:!1}},"Ling-2.6-flash":{id:"Ling-2.6-flash",name:"Ling 2.6 Flash",api:"openai-completions",baseUrl:"https://api.ant-ling.com/v1",provider:"ant-ling",reasoning:!1,input:["text"],cost:{input:.01,output:.02,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"ant-ling",supportsLongCacheRetention:!1}},"Ring-2.6-1T":{id:"Ring-2.6-1T",name:"Ring 2.6 1T",api:"openai-completions",baseUrl:"https://api.ant-ling.com/v1",provider:"ant-ling",reasoning:!0,input:["text"],cost:{input:.06,output:.25,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"ant-ling",supportsLongCacheRetention:!1},thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:"xhigh"}}};var nC=tC;var iC={"claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-haiku-4-5-20251001":{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-1-20250805":{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-5-20251101":{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-opus-4-7":{id:"claude-opus-4-7",name:"Claude Opus 4.7",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-opus-4-8":{id:"claude-opus-4-8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"claude-sonnet-4-5-20250929":{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}}};var oC=iC;var rC={"gpt-4":{id:"gpt-4",name:"GPT-4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"azure-openai-responses",baseUrl:"",provider:"azure-openai-responses",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null}},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null}},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null}},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.3-chat-latest":{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.5-pro":{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",minimal:null,low:null}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"gpt-realtime-2.1":{id:"gpt-realtime-2.1",name:"GPT-Realtime-2.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:4,output:24,cacheRead:.4,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},o1:{id:"o1",name:"o1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},o3:{id:"o3",name:"o3",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5}};var sC=rC;var aC={"gemma-4-31b":{id:"gemma-4-31b",name:"Gemma 4 31B IT",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.99,output:1.49,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:40960,compat:{supportsStore:!1,supportsDeveloperRole:!1},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-oss-120b":{id:"gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!0,input:["text"],cost:{input:.35,output:.75,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:40960,compat:{supportsStore:!1,supportsDeveloperRole:!1},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"zai-glm-4.7":{id:"zai-glm-4.7",name:"Z.AI GLM-4.7",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!0,input:["text"],cost:{input:2.25,output:2.75,cacheRead:2.25,cacheWrite:0},contextWindow:131072,maxTokens:40960,compat:{supportsStore:!1,supportsDeveloperRole:!1},thinkingLevelMap:{off:"none",minimal:null,low:null,medium:null,high:null,xhigh:null,max:null}}};var lC=aC;var cC={"claude-3-5-haiku":{id:"claude-3-5-haiku",name:"Claude Haiku 3.5 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192,compat:{sendSessionAffinityHeaders:!0}},"claude-3-haiku":{id:"claude-3-haiku",name:"Claude Haiku 3",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096,compat:{sendSessionAffinityHeaders:!0}},"claude-3-opus":{id:"claude-3-opus",name:"Claude Opus 3",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:4096,compat:{sendSessionAffinityHeaders:!0}},"claude-3-sonnet":{id:"claude-3-sonnet",name:"Claude Sonnet 3",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},contextWindow:2e5,maxTokens:4096,compat:{sendSessionAffinityHeaders:!0}},"claude-3.5-haiku":{id:"claude-3.5-haiku",name:"Claude Haiku 3.5 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192,compat:{sendSessionAffinityHeaders:!0}},"claude-3.5-sonnet":{id:"claude-3.5-sonnet",name:"Claude Sonnet 3.5 v2",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192,compat:{sendSessionAffinityHeaders:!0}},"claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,compat:{sendSessionAffinityHeaders:!0}},"claude-opus-4":{id:"claude-opus-4",name:"Claude Opus 4 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,compat:{sendSessionAffinityHeaders:!0}},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,compat:{sendSessionAffinityHeaders:!0}},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3,compat:{sendSessionAffinityHeaders:!0}},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{max:"max"}},"claude-opus-4-7":{id:"claude-opus-4-7",name:"Claude Opus 4.7",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"claude-opus-4-8":{id:"claude-opus-4-8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,compat:{sendSessionAffinityHeaders:!0}},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,compat:{sendSessionAffinityHeaders:!0}},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{max:"max"}},"claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,compat:{sendSessionAffinityHeaders:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"gpt-4":{id:"gpt-4",name:"GPT-4",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.08,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},o1:{id:"o1",name:"o1",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},o3:{id:"o3",name:"o3",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"openai-responses",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"workers-ai/@cf/moonshotai/kimi-k2.5":{id:"workers-ai/@cf/moonshotai/kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"workers-ai/@cf/moonshotai/kimi-k2.6":{id:"workers-ai/@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"workers-ai/@cf/nvidia/nemotron-3-120b-a12b":{id:"workers-ai/@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",api:"openai-completions",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",reasoning:!0,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"workers-ai/@cf/zai-org/glm-4.7-flash":{id:"workers-ai/@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",reasoning:!0,input:["text"],cost:{input:.06,output:.4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"workers-ai/@cf/zai-org/glm-5.2":{id:"workers-ai/@cf/zai-org/glm-5.2",name:"Glm 5.2",api:"openai-completions",provider:"cloudflare-ai-gateway",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}}};var uC=cC;var dC={"@cf/google/gemma-4-26b-a4b-it":{id:"@cf/google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/ibm-granite/granite-4.0-h-micro":{id:"@cf/ibm-granite/granite-4.0-h-micro",name:"Granite 4.0 H Micro",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!1,input:["text"],cost:{input:.017,output:.112,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:131e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/meta/llama-3.3-70b-instruct-fp8-fast":{id:"@cf/meta/llama-3.3-70b-instruct-fp8-fast",name:"Llama 3.3 70B Instruct fp8 Fast",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!1,input:["text"],cost:{input:.293,output:2.253,cacheRead:0,cacheWrite:0},contextWindow:24e3,maxTokens:24e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/meta/llama-4-scout-17b-16e-instruct":{id:"@cf/meta/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E Instruct",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!1,input:["text","image"],cost:{input:.27,output:.85,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/mistralai/mistral-small-3.1-24b-instruct":{id:"@cf/mistralai/mistral-small-3.1-24b-instruct",name:"Mistral Small 3.1 24B Instruct",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!1,input:["text"],cost:{input:.351,output:.555,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/moonshotai/kimi-k2.6":{id:"@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:262144,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/moonshotai/kimi-k2.7-code":{id:"@cf/moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/nvidia/nemotron-3-120b-a12b":{id:"@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/openai/gpt-oss-120b":{id:"@cf/openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:.35,output:.75,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/openai/gpt-oss-20b":{id:"@cf/openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:.2,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/qwen/qwen3-30b-a3b-fp8":{id:"@cf/qwen/qwen3-30b-a3b-fp8",name:"Qwen3 30B A3b fp8",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:.0509,output:.335,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0}},"@cf/zai-org/glm-4.7-flash":{id:"@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:.0605,output:.4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"@cf/zai-org/glm-5.2":{id:"@cf/zai-org/glm-5.2",name:"Glm 5.2",api:"openai-completions",provider:"cloudflare-workers-ai",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsLongCacheRetention:!1,sendSessionAffinityHeaders:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}}};var pC=dC;var mC={"deepseek-v4-flash":{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"openai-completions",baseUrl:"https://api.deepseek.com",provider:"deepseek",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"deepseek-v4-pro":{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"openai-completions",baseUrl:"https://api.deepseek.com",provider:"deepseek",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.003625,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}}};var hC=mC;var gC={"accounts/fireworks/models/deepseek-v4-flash":{id:"accounts/fireworks/models/deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.028,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/deepseek-v4-pro":{id:"accounts/fireworks/models/deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:1.74,output:3.48,cacheRead:.145,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/glm-5p1":{id:"accounts/fireworks/models/glm-5p1",name:"GLM 5.1",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},contextWindow:202800,maxTokens:131072,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/glm-5p2":{id:"accounts/fireworks/models/glm-5p2",name:"GLM 5.2",api:"openai-completions",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.14,cacheWrite:0},contextWindow:1048575,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1},thinkingLevelMap:{off:"none",minimal:null,low:"high",medium:"high",high:"high",xhigh:null,max:"max"}},"accounts/fireworks/models/gpt-oss-120b":{id:"accounts/fireworks/models/gpt-oss-120b",name:"GPT OSS 120B",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/gpt-oss-20b":{id:"accounts/fireworks/models/gpt-oss-20b",name:"GPT OSS 20B",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:.07,output:.3,cacheRead:.035,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/kimi-k2p6":{id:"accounts/fireworks/models/kimi-k2p6",name:"Kimi K2.6",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:262e3,maxTokens:262e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/kimi-k2p7-code":{id:"accounts/fireworks/models/kimi-k2p7-code",name:"Kimi K2.7 Code",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:262e3,maxTokens:262e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/minimax-m2p7":{id:"accounts/fireworks/models/minimax-m2p7",name:"MiniMax-M2.7",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:196608,maxTokens:196608,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/minimax-m3":{id:"accounts/fireworks/models/minimax-m3",name:"MiniMax-M3",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:512e3,maxTokens:512e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/models/qwen3p7-plus":{id:"accounts/fireworks/models/qwen3p7-plus",name:"Qwen 3.7 Plus",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.08,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/routers/glm-5p1-fast":{id:"accounts/fireworks/routers/glm-5p1-fast",name:"GLM 5.1 Fast",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text"],cost:{input:2.8,output:8.8,cacheRead:.52,cacheWrite:0},contextWindow:202800,maxTokens:131072,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/routers/glm-5p2-fast":{id:"accounts/fireworks/routers/glm-5p2-fast",name:"GLM 5.2 Fast",api:"openai-completions",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference/v1",reasoning:!0,input:["text"],cost:{input:2.1,output:6.6,cacheRead:.21,cacheWrite:0},contextWindow:1048575,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1},thinkingLevelMap:{off:"none",minimal:null,low:"high",medium:"high",high:"high",xhigh:null,max:"max"}},"accounts/fireworks/routers/kimi-k2p6-fast":{id:"accounts/fireworks/routers/kimi-k2p6-fast",name:"Kimi K2.6 Fast",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.3,cacheWrite:0},contextWindow:262e3,maxTokens:262e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/routers/kimi-k2p6-turbo":{id:"accounts/fireworks/routers/kimi-k2p6-turbo",name:"Kimi K2.6 Turbo",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.3,cacheWrite:0},contextWindow:262e3,maxTokens:262e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}},"accounts/fireworks/routers/kimi-k2p7-code-fast":{id:"accounts/fireworks/routers/kimi-k2p7-code-fast",name:"Kimi K2.7 Code Fast",api:"anthropic-messages",provider:"fireworks",baseUrl:"https://api.fireworks.ai/inference",reasoning:!0,input:["text","image"],cost:{input:1.9,output:8,cacheRead:.38,cacheWrite:0},contextWindow:262e3,maxTokens:262e3,compat:{sendSessionAffinityHeaders:!0,supportsEagerToolInputStreaming:!1,supportsCacheControlOnTools:!1,supportsLongCacheRetention:!1}}};var fC=gC;var vC={"claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsEagerToolInputStreaming:!1}},"claude-opus-4.5":{id:"claude-opus-4.5",name:"Claude Opus 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"}},"claude-opus-4.6":{id:"claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-opus-4.7":{id:"claude-opus-4.7",name:"Claude Opus 4.7",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-opus-4.8":{id:"claude-opus-4.8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:216e3,maxTokens:16e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsEagerToolInputStreaming:!1}},"claude-sonnet-4.5":{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsEagerToolInputStreaming:!1}},"claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{max:"max",minimal:"low"},compat:{forceAdaptiveThinking:!0}},"claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:128e3,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:18,cacheRead:.4,cacheWrite:0}]},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"gemini-3.5-flash":{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:2e5,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:128e3,maxTokens:16384,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:264e3,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",xhigh:"xhigh"}},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",xhigh:"xhigh"}},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:0}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",xhigh:"xhigh"}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:0}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25,tiers:[{inputTokensAbove:2e5,input:2,output:9,cacheRead:.2,cacheWrite:2.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:12.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:6.25}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:256e3,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"mai-code-1-flash-picker":{id:"mai-code-1-flash-picker",name:"MAI-Code-1-Flash",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:256e3,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}}};var bC=vC;var xC={"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.0-flash-lite":{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash-Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash-Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.1-flash-lite":{id:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.1-flash-lite-preview":{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.1-pro-preview-customtools":{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.5-flash":{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.5-flash-lite":{id:"gemini-3.5-flash-lite",name:"Gemini 3.5 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.6-flash":{id:"gemini-3.6-flash",name:"Gemini 3.6 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-flash-latest":{id:"gemini-flash-latest",name:"Gemini Flash Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-flash-lite-latest":{id:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemma-4-26b-a4b-it":{id:"gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,thinkingLevelMap:{off:null,minimal:"MINIMAL",low:null,medium:null,high:"HIGH"}},"gemma-4-31b-it":{id:"gemma-4-31b-it",name:"Gemma 4 31B IT",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,thinkingLevelMap:{off:null,minimal:"MINIMAL",low:null,medium:null,high:"HIGH"}}};var yC=xC;var wC={"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash-Lite",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.1-flash-lite":{id:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.1-pro-preview-customtools":{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.5-flash":{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-flash-latest":{id:"gemini-flash-latest",name:"Gemini Flash Latest",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-flash-lite-latest":{id:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}}};var kC=wC;var SC={"llama-3.1-8b-instant":{id:"llama-3.1-8b-instant",name:"Llama 3.1 8B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"llama-3.3-70b-versatile":{id:"llama-3.3-70b-versatile",name:"Llama 3.3 70B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"meta-llama/llama-4-scout-17b-16e-instruct":{id:"meta-llama/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text","image"],cost:{input:.11,output:.34,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.0375,cacheWrite:0},contextWindow:131072,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"Safety GPT OSS 20B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen3-32B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.59,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:40960,thinkingLevelMap:{off:"none",minimal:null,low:null,medium:null,high:"default",xhigh:null,max:null}}};var TC=SC;var CC={"MiniMaxAI/MiniMax-M2":{id:"MiniMaxAI/MiniMax-M2",name:"MiniMax-M2",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:128e3},"MiniMaxAI/MiniMax-M2.1":{id:"MiniMaxAI/MiniMax-M2.1",name:"MiniMax-M2.1",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:131072},"MiniMaxAI/MiniMax-M2.5":{id:"MiniMaxAI/MiniMax-M2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:131072},"MiniMaxAI/MiniMax-M2.7":{id:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:131072},"MiniMaxAI/MiniMax-M3":{id:"MiniMaxAI/MiniMax-M3",name:"MiniMax-M3",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:524288,maxTokens:128e3},"Qwen/Qwen3-235B-A22B":{id:"Qwen/Qwen3-235B-A22B",name:"Qwen3 235B-A22B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.2,output:.8,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:40960,maxTokens:16384},"Qwen/Qwen3-235B-A22B-Thinking-2507":{id:"Qwen/Qwen3-235B-A22B-Thinking-2507",name:"Qwen3-235B-A22B-Thinking-2507",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.3,output:3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3-32B":{id:"Qwen/Qwen3-32B",name:"Qwen3 32B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.59,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:16384},"Qwen/Qwen3-Coder-30B-A3B-Instruct":{id:"Qwen/Qwen3-Coder-30B-A3B-Instruct",name:"Qwen3-Coder 30B-A3B Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:.07,output:.26,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3-Coder-480B-A35B-Instruct":{id:"Qwen/Qwen3-Coder-480B-A35B-Instruct",name:"Qwen3-Coder-480B-A35B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:2,output:2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Coder-Next":{id:"Qwen/Qwen3-Coder-Next",name:"Qwen3-Coder-Next",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:.2,output:1.5,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3-Next-80B-A3B-Instruct":{id:"Qwen/Qwen3-Next-80B-A3B-Instruct",name:"Qwen3-Next-80B-A3B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Next-80B-A3B-Thinking":{id:"Qwen/Qwen3-Next-80B-A3B-Thinking",name:"Qwen3-Next-80B-A3B-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:.3,output:2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3.5-122B-A10B":{id:"Qwen/Qwen3.5-122B-A10B",name:"Qwen3.5 122B-A10B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.4,output:3.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.5-27B":{id:"Qwen/Qwen3.5-27B",name:"Qwen3.5 27B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.5-35B-A3B":{id:"Qwen/Qwen3.5-35B-A3B",name:"Qwen3.5 35B-A3B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.5-397B-A17B":{id:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5-397B-A17B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3.6,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:32768,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"Qwen/Qwen3.5-9B":{id:"Qwen/Qwen3.5-9B",name:"Qwen3.5 9B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.17,output:.25,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.6-27B":{id:"Qwen/Qwen3.6-27B",name:"Qwen3.6 27B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.47,output:3.19,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.6-35B-A3B":{id:"Qwen/Qwen3.6-35B-A3B",name:"Qwen3.6 35B-A3B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.15,output:.95,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:65536},"XiaomiMiMo/MiMo-V2-Flash":{id:"XiaomiMiMo/MiMo-V2-Flash",name:"MiMo-V2-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:4096},"XiaomiMiMo/MiMo-V2.5-Pro":{id:"XiaomiMiMo/MiMo-V2.5-Pro",name:"MiMo-V2.5-Pro",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:1048576,maxTokens:131072},"deepseek-ai/DeepSeek-R1":{id:"deepseek-ai/DeepSeek-R1",name:"DeepSeek-R1",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.7,output:2.5,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:64e3,maxTokens:32768},"deepseek-ai/DeepSeek-R1-0528":{id:"deepseek-ai/DeepSeek-R1-0528",name:"DeepSeek-R1-0528",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:3,output:5,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:163840,maxTokens:163840},"deepseek-ai/DeepSeek-V3.2":{id:"deepseek-ai/DeepSeek-V3.2",name:"DeepSeek-V3.2",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.28,output:.4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:163840,maxTokens:65536},"deepseek-ai/DeepSeek-V4-Flash":{id:"deepseek-ai/DeepSeek-V4-Flash",name:"DeepSeek V4 Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:1048576,maxTokens:384e3},"deepseek-ai/DeepSeek-V4-Pro":{id:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.003625,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:1048576,maxTokens:393216,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:null}},"google/gemma-4-26B-A4B-it":{id:"google/gemma-4-26B-A4B-it",name:"Gemma 4 26B A4B IT",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.13,output:.4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:32768},"google/gemma-4-31B-it":{id:"google/gemma-4-31B-it",name:"Gemma 4 31B IT",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.14,output:.4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:32768},"meta-llama/Llama-3.3-70B-Instruct":{id:"meta-llama/Llama-3.3-70B-Instruct",name:"Llama-3.3-70B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:4096},"moonshotai/Kimi-K2-Instruct":{id:"moonshotai/Kimi-K2-Instruct",name:"Kimi-K2-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:16384},"moonshotai/Kimi-K2-Instruct-0905":{id:"moonshotai/Kimi-K2-Instruct-0905",name:"Kimi-K2-Instruct-0905",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:16384},"moonshotai/Kimi-K2-Thinking":{id:"moonshotai/Kimi-K2-Thinking",name:"Kimi-K2-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:262144},"moonshotai/Kimi-K2.5":{id:"moonshotai/Kimi-K2.5",name:"Kimi-K2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:262144},"moonshotai/Kimi-K2.6":{id:"moonshotai/Kimi-K2.6",name:"Kimi-K2.6",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:262144},"moonshotai/Kimi-K2.7-Code":{id:"moonshotai/Kimi-K2.7-Code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:262144},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.69,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:32768,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.1,output:.5,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:32768,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"stepfun-ai/Step-3.5-Flash":{id:"stepfun-ai/Step-3.5-Flash",name:"Step 3.5 Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:256e3},"stepfun-ai/Step-3.7-Flash":{id:"stepfun-ai/Step-3.7-Flash",name:"Step 3.7 Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.15,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:256e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"zai-org/GLM-4.5":{id:"zai-org/GLM-4.5",name:"GLM-4.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:98304},"zai-org/GLM-4.5-Air":{id:"zai-org/GLM-4.5-Air",name:"GLM-4.5-Air",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.13,output:.85,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:131072,maxTokens:98304},"zai-org/GLM-4.5V":{id:"zai-org/GLM-4.5V",name:"GLM-4.5V",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.8,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:65536,maxTokens:16384},"zai-org/GLM-4.6":{id:"zai-org/GLM-4.6",name:"GLM-4.6",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.55,output:2.2,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:131072},"zai-org/GLM-4.7":{id:"zai-org/GLM-4.7",name:"GLM-4.7",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:204800,maxTokens:131072},"zai-org/GLM-4.7-Flash":{id:"zai-org/GLM-4.7-Flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:2e5,maxTokens:128e3},"zai-org/GLM-5":{id:"zai-org/GLM-5",name:"GLM-5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:202752,maxTokens:131072},"zai-org/GLM-5.1":{id:"zai-org/GLM-5.1",name:"GLM-5.1",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:202752,maxTokens:131072},"zai-org/GLM-5.2":{id:"zai-org/GLM-5.2",name:"GLM-5.2",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:0,cacheWrite:0},compat:{supportsDeveloperRole:!1},contextWindow:262144,maxTokens:131072}};var MC=CC;var RC={k3:{id:"k3",name:"Kimi K3",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",headers:{"User-Agent":"KimiCLI/1.5"},compat:{allowEmptySignature:!0,forceAdaptiveThinking:!0},reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:null,high:"high",xhigh:null,max:"max"}},"kimi-for-coding":{id:"kimi-for-coding",name:"Kimi K2.7 Code",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",headers:{"User-Agent":"KimiCLI/1.5"},compat:{allowEmptySignature:!0,forceAdaptiveThinking:!0},reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:262144,maxTokens:32768},"kimi-for-coding-highspeed":{id:"kimi-for-coding-highspeed",name:"Kimi For Coding HighSpeed",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",headers:{"User-Agent":"KimiCLI/1.5"},compat:{forceAdaptiveThinking:!0},reasoning:!0,input:["text","image"],cost:{input:1.9,output:8,cacheRead:.38,cacheWrite:0},contextWindow:262144,maxTokens:32768}};var PC=RC;var IC={"MiniMax-M2.7":{id:"MiniMax-M2.7",name:"MiniMax-M2.7",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.7-highspeed":{id:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M3":{id:"MiniMax-M3",name:"MiniMax-M3",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:1e6,maxTokens:128e3}};var EC=IC;var AC={"MiniMax-M2.7":{id:"MiniMax-M2.7",name:"MiniMax-M2.7",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.7-highspeed":{id:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M3":{id:"MiniMax-M3",name:"MiniMax-M3",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:1e6,maxTokens:128e3}};var _C=AC;var OC={"codestral-latest":{id:"codestral-latest",name:"Codestral (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.3,output:.9,cacheRead:.03,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"devstral-2512":{id:"devstral-2512",name:"Devstral 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-latest":{id:"devstral-latest",name:"Devstral 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-medium-2507":{id:"devstral-medium-2507",name:"Devstral Medium",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-medium-latest":{id:"devstral-medium-latest",name:"Devstral 2 (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-small-2505":{id:"devstral-small-2505",name:"Devstral Small 2505",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:.01,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-small-2507":{id:"devstral-small-2507",name:"Devstral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:.01,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"labs-devstral-small-2512":{id:"labs-devstral-small-2512",name:"Devstral Small 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"magistral-medium-latest":{id:"magistral-medium-latest",name:"Magistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:2,output:5,cacheRead:.2,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"magistral-small":{id:"magistral-small",name:"Magistral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:.5,output:1.5,cacheRead:.05,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-3b-latest":{id:"ministral-3b-latest",name:"Ministral 3B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:.004,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-8b-latest":{id:"ministral-8b-latest",name:"Ministral 8B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:.01,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-large-2411":{id:"mistral-large-2411",name:"Mistral Large 2.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:131072,maxTokens:16384},"mistral-large-2512":{id:"mistral-large-2512",name:"Mistral Large 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:.05,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-large-latest":{id:"mistral-large-latest",name:"Mistral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:.05,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-2505":{id:"mistral-medium-2505",name:"Mistral Medium 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:131072,maxTokens:131072},"mistral-medium-2508":{id:"mistral-medium-2508",name:"Mistral Medium 3.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-2604":{id:"mistral-medium-2604",name:"Mistral Medium 3.5",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-3.5":{id:"mistral-medium-3.5",name:"Mistral Medium 3.5",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-latest":{id:"mistral-medium-latest",name:"Mistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-nemo":{id:"mistral-nemo",name:"Mistral Nemo",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-small-2506":{id:"mistral-small-2506",name:"Mistral Small 3.2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:.01,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"mistral-small-2603":{id:"mistral-small-2603",name:"Mistral Small 4",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral-small-latest":{id:"mistral-small-latest",name:"Mistral Small (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"open-mistral-7b":{id:"open-mistral-7b",name:"Mistral 7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.25,output:.25,cacheRead:.025,cacheWrite:0},contextWindow:8e3,maxTokens:8e3},"open-mistral-nemo":{id:"open-mistral-nemo",name:"Open Mistral Nemo",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"open-mixtral-8x22b":{id:"open-mixtral-8x22b",name:"Mixtral 8x22B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:64e3,maxTokens:64e3},"open-mixtral-8x7b":{id:"open-mixtral-8x7b",name:"Mixtral 8x7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.7,output:.7,cacheRead:.07,cacheWrite:0},contextWindow:32e3,maxTokens:32e3},"pixtral-12b":{id:"pixtral-12b",name:"Pixtral 12B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"pixtral-large-latest":{id:"pixtral-large-latest",name:"Pixtral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:128e3,maxTokens:128e3}};var LC=OC;var WC={"kimi-k2-0711-preview":{id:"kimi-k2-0711-preview",name:"Kimi K2 0711",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-0905-preview":{id:"kimi-k2-0905-preview",name:"Kimi K2 0905",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-thinking":{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-thinking-turbo":{id:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text"],cost:{input:1.15,output:8,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-turbo-preview":{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!1,input:["text"],cost:{input:2.4,output:10,cacheRead:.6,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"},thinkingLevelMap:{off:null}},"kimi-k2.7-code-highspeed":{id:"kimi-k2.7-code-highspeed",name:"Kimi K2.7 Code HighSpeed",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text","image"],cost:{input:1.9,output:8,cacheRead:.38,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"},thinkingLevelMap:{off:null}},"kimi-k3":{id:"kimi-k3",name:"Kimi K3",api:"openai-completions",provider:"moonshotai",baseUrl:"https://api.moonshot.ai/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"openai",requiresReasoningContentOnAssistantMessages:!0,deferredToolsMode:"kimi"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:null,high:"high",xhigh:null,max:"max"}}};var FC=WC;var DC={"kimi-k2-0711-preview":{id:"kimi-k2-0711-preview",name:"Kimi K2 0711",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-0905-preview":{id:"kimi-k2-0905-preview",name:"Kimi K2 0905",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-thinking":{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-thinking-turbo":{id:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text"],cost:{input:1.15,output:8,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2-turbo-preview":{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!1,input:["text"],cost:{input:2.4,output:10,cacheRead:.6,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"}},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"},thinkingLevelMap:{off:null}},"kimi-k2.7-code-highspeed":{id:"kimi-k2.7-code-highspeed",name:"Kimi K2.7 Code HighSpeed",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text","image"],cost:{input:1.9,output:8,cacheRead:.38,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"deepseek"},thinkingLevelMap:{off:null}},"kimi-k3":{id:"kimi-k3",name:"Kimi K3",api:"openai-completions",provider:"moonshotai-cn",baseUrl:"https://api.moonshot.cn/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,maxTokensField:"max_tokens",supportsStrictMode:!1,thinkingFormat:"openai",requiresReasoningContentOnAssistantMessages:!0,deferredToolsMode:"kimi"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:null,high:"high",xhigh:null,max:"max"}}};var UC=DC;var $C={"meta/llama-3.1-70b-instruct":{id:"meta/llama-3.1-70b-instruct",name:"Llama 3.1 70b Instruct",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:4096},"meta/llama-3.1-8b-instruct":{id:"meta/llama-3.1-8b-instruct",name:"Llama 3.1 8B Instruct",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:16e3,maxTokens:4096},"meta/llama-3.2-11b-vision-instruct":{id:"meta/llama-3.2-11b-vision-instruct",name:"Llama 3.2 11b Vision Instruct",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:4096},"meta/llama-3.2-90b-vision-instruct":{id:"meta/llama-3.2-90b-vision-instruct",name:"Llama-3.2-90B-Vision-Instruct",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:8192},"meta/llama-3.3-70b-instruct":{id:"meta/llama-3.3-70b-instruct",name:"Llama 3.3 70b Instruct",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:4096},"minimaxai/minimax-m3":{id:"minimaxai/minimax-m3",name:"MiniMax-M3",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:1e6,maxTokens:16384},"mistralai/mistral-large-3-675b-instruct-2512":{id:"mistralai/mistral-large-3-675b-instruct-2512",name:"Mistral Large 3 675B Instruct 2512",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:262144},"mistralai/mistral-small-4-119b-2603":{id:"mistralai/mistral-small-4-119b-2603",name:"mistral-small-4-119b-2603",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:8192},"moonshotai/kimi-k2.6":{id:"moonshotai/kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:262144},"nvidia/nemotron-3-nano-30b-a3b":{id:"nvidia/nemotron-3-nano-30b-a3b",name:"nemotron-3-nano-30b-a3b",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:131072},"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning":{id:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",name:"Nemotron 3 Nano Omni",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:256e3,maxTokens:65536},"nvidia/nemotron-3-super-120b-a12b":{id:"nvidia/nemotron-3-super-120b-a12b",name:"Nemotron 3 Super",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:.2,output:.8,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:262144},"nvidia/nemotron-3-ultra-550b-a55b":{id:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:.5,output:2.5,cacheRead:.15,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:1e6,maxTokens:65536},"nvidia/nvidia-nemotron-nano-9b-v2":{id:"nvidia/nvidia-nemotron-nano-9b-v2",name:"nvidia-nemotron-nano-9b-v2",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT-OSS-120B",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:128e3,maxTokens:8192},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:32768},"stepfun-ai/step-3.5-flash":{id:"stepfun-ai/step-3.5-flash",name:"Step 3.5 Flash",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:256e3,maxTokens:16384},"stepfun-ai/step-3.7-flash":{id:"stepfun-ai/step-3.7-flash",name:"Step 3.7 Flash",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:256e3,maxTokens:16384},"z-ai/glm-5.2":{id:"z-ai/glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"nvidia",baseUrl:"https://integrate.api.nvidia.com/v1",headers:{"NVCF-POLL-SECONDS":"3600"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:1e6,maxTokens:131072}};var NC=$C;var BC={"gpt-4":{id:"gpt-4",name:"GPT-4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"openai-responses",baseUrl:"https://api.openai.com/v1",provider:"openai",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null}},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:null}},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:null,xhigh:null,max:null}},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:null,xhigh:"xhigh",max:null}},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.3-chat-latest":{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{off:null,xhigh:"xhigh"}},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:0}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsToolSearch:!0}},"gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsToolSearch:!0}},"gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:60,output:270,cacheRead:0,cacheWrite:0}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsToolSearch:!0}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:0}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},compat:{supportsToolSearch:!0}},"gpt-5.5-pro":{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:60,output:270,cacheRead:0,cacheWrite:0}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25,tiers:[{inputTokensAbove:272e3,input:2,output:9,cacheRead:.2,cacheWrite:2.5}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsToolSearch:!0}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:12.5}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsToolSearch:!0}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:6.25}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsToolSearch:!0}},"gpt-realtime-2.1":{id:"gpt-realtime-2.1",name:"GPT-Realtime-2.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:4,output:24,cacheRead:.4,cacheWrite:0},contextWindow:128e3,maxTokens:32e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},o1:{id:"o1",name:"o1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},o3:{id:"o3",name:"o3",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:null,xhigh:null,max:null}},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:null,xhigh:null,max:null}}};var jC=BC;var qC={"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",minimal:"low"}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:0}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",minimal:"low"},compat:{supportsToolSearch:!0}},"gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 mini",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",minimal:"low"},compat:{supportsToolSearch:!0}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:0}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",minimal:"low"},compat:{supportsToolSearch:!0}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25,tiers:[{inputTokensAbove:272e3,input:2,output:9,cacheRead:.2,cacheWrite:2.5}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},compat:{supportsToolSearch:!0}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25,tiers:[{inputTokensAbove:272e3,input:10,output:45,cacheRead:1,cacheWrite:12.5}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},compat:{supportsToolSearch:!0}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125,tiers:[{inputTokensAbove:272e3,input:5,output:22.5,cacheRead:.5,cacheWrite:6.25}]},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},compat:{supportsToolSearch:!0}}};var KC=qC;var GC={"big-pickle":{id:"big-pickle",name:"Big Pickle",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:2e5,maxTokens:32e3},"claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-opus-4-7":{id:"claude-opus-4-7",name:"Claude Opus 4.7",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-opus-4-8":{id:"claude-opus-4-8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"deepseek-v4-flash":{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.028,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1,requiresReasoningContentOnAssistantMessages:!0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:"max"}},"deepseek-v4-flash-free":{id:"deepseek-v4-flash-free",name:"DeepSeek V4 Flash Free",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",requiresReasoningContentOnAssistantMessages:!0},contextWindow:2e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:"max"}},"deepseek-v4-pro":{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1.74,output:3.84,cacheRead:.145,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1,requiresReasoningContentOnAssistantMessages:!0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:"max"}},"gemini-3-flash":{id:"gemini-3-flash",name:"Gemini 3 Flash",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.1-pro":{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null,minimal:null,low:"LOW",medium:null,high:"HIGH"}},"gemini-3.5-flash":{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.5-flash-lite":{id:"gemini-3.5-flash-lite",name:"Gemini 3.5 Flash Lite",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"gemini-3.6-flash":{id:"gemini-3.6-flash",name:"Gemini 3.6 Flash",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,thinkingLevelMap:{off:null}},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:204800,maxTokens:131072},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:204800,maxTokens:131072},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1e6,maxTokens:131072,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:"max"}},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:272e3,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-mini":{id:"gpt-5.4-mini",name:"GPT-5.4 Mini",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 Nano",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:30,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.5":{id:"gpt-5.5",name:"GPT-5.5",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.5-pro":{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:30,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:"medium",high:"high",xhigh:"xhigh",max:null}},"gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}},"grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:5e5,maxTokens:5e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"grok-build-0.1":{id:"grok-build-0.1",name:"Grok Build 0.1",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:2,cacheRead:.2,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens"},contextWindow:256e3,maxTokens:256e3,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null}},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.08,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:65536},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,thinkingFormat:"deepseek",supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:65536},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:262144,maxTokens:262144},"laguna-s-2.1-free":{id:"laguna-s-2.1-free",name:"Laguna S 2.1 Free",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:256e3,maxTokens:32e3,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"mimo-v2.5-free":{id:"mimo-v2.5-free",name:"MiMo V2.5 Free",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:2e5,maxTokens:32e3},"minimax-m2.5":{id:"minimax-m2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:204800,maxTokens:131072},"minimax-m2.7":{id:"minimax-m2.7",name:"MiniMax-M2.7",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1},contextWindow:204800,maxTokens:131072},"minimax-m3":{id:"minimax-m3",name:"MiniMax-M3",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:512e3,maxTokens:128e3},"nemotron-3-ultra-free":{id:"nemotron-3-ultra-free",name:"Nemotron 3 Ultra Free",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1e6,maxTokens:128e3},"north-mini-code-free":{id:"north-mini-code-free",name:"North Mini Code Free",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:256e3,maxTokens:64e3,thinkingLevelMap:{off:"none",minimal:null,low:null,medium:null,high:"high",xhigh:null,max:null}},"qwen3.5-plus":{id:"qwen3.5-plus",name:"Qwen3.5 Plus",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25},contextWindow:262144,maxTokens:65536},"qwen3.6-plus":{id:"qwen3.6-plus",name:"Qwen3.6 Plus",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.625},contextWindow:262144,maxTokens:65536}};var zC=GC;var HC={"deepseek-v4-flash":{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"deepseek-v4-pro":{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.003625,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens",requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:202752,maxTokens:32768},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1e6,maxTokens:131072,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:"high",xhigh:null,max:"max"}},"grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0},compat:{sessionAffinityFormat:"openai-nosession"},contextWindow:5e5,maxTokens:5e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,thinkingFormat:"deepseek",supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:65536,thinkingLevelMap:{minimal:null,low:null,medium:null}},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:262144,maxTokens:262144},"kimi-k3":{id:"kimi-k3",name:"Kimi K3 (2x usage)",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1048576,maxTokens:131072,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null,high:null,xhigh:null,max:"max"}},"mimo-v2.5":{id:"mimo-v2.5",name:"MiMo V2.5",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1e6,maxTokens:128e3},"mimo-v2.5-pro":{id:"mimo-v2.5-pro",name:"MiMo V2.5 Pro",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.003625,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:1048576,maxTokens:128e3},"minimax-m2.7":{id:"minimax-m2.7",name:"MiniMax-M2.7",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,maxTokensField:"max_tokens"},contextWindow:204800,maxTokens:131072},"minimax-m3":{id:"minimax-m3",name:"MiniMax-M3",api:"anthropic-messages",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"qwen3.6-plus":{id:"qwen3.6-plus",name:"Qwen3.6 Plus",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.625},compat:{supportsStore:!1,supportsDeveloperRole:!1,thinkingFormat:"qwen",maxTokensField:"max_tokens"},contextWindow:1e6,maxTokens:65536},"qwen3.7-max":{id:"qwen3.7-max",name:"Qwen3.7 Max",api:"anthropic-messages",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go",reasoning:!0,input:["text"],cost:{input:2.5,output:7.5,cacheRead:.5,cacheWrite:3.125},contextWindow:1e6,maxTokens:65536},"qwen3.7-plus":{id:"qwen3.7-plus",name:"Qwen3.7 Plus",api:"anthropic-messages",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go",reasoning:!0,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.04,cacheWrite:.5},contextWindow:1e6,maxTokens:65536}};var VC=HC;var QC={"ai21/jamba-large-1.7":{id:"ai21/jamba-large-1.7",name:"AI21: Jamba Large 1.7",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2,output:8,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"aion-labs/aion-2.0":{id:"aion-labs/aion-2.0",name:"AionLabs: Aion-2.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.8,output:1.6,cacheRead:.2,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"aion-labs/aion-3.0":{id:"aion-labs/aion-3.0",name:"AionLabs: Aion-3.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:3,output:6,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"aion-labs/aion-3.0-mini":{id:"aion-labs/aion-3.0-mini",name:"AionLabs: Aion-3.0-Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.7,output:1.4,cacheRead:.18,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"amazon/nova-2-lite-v1":{id:"amazon/nova-2-lite-v1",name:"Amazon: Nova 2 Lite",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65535,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"amazon/nova-lite-v1":{id:"amazon/nova-lite-v1",name:"Amazon: Nova Lite 1.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"amazon/nova-micro-v1":{id:"amazon/nova-micro-v1",name:"Amazon: Nova Micro 1.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:5120,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"amazon/nova-premier-v1":{id:"amazon/nova-premier-v1",name:"Amazon: Nova Premier 1.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:2.5,output:12.5,cacheRead:.625,cacheWrite:0},contextWindow:1e6,maxTokens:32e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"amazon/nova-pro-v1":{id:"amazon/nova-pro-v1",name:"Amazon: Nova Pro 1.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.8,output:3.2,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Anthropic: Claude 3 Haiku",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-fable-5":{id:"anthropic/claude-fable-5",name:"Anthropic: Claude Fable 5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"}},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Anthropic: Claude Haiku 4.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Anthropic: Claude Opus 4",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Anthropic: Claude Opus 4.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Anthropic: Claude Opus 4.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Anthropic: Claude Opus 4.6",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{max:"max"}},"anthropic/claude-opus-4.7":{id:"anthropic/claude-opus-4.7",name:"Anthropic: Claude Opus 4.7",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic/claude-opus-4.7-fast":{id:"anthropic/claude-opus-4.7-fast",name:"Anthropic: Claude Opus 4.7 (Fast)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic/claude-opus-4.8":{id:"anthropic/claude-opus-4.8",name:"Anthropic: Claude Opus 4.8",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic/claude-opus-4.8-fast":{id:"anthropic/claude-opus-4.8-fast",name:"Anthropic: Claude Opus 4.8 (Fast)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Anthropic: Claude Sonnet 4",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Anthropic: Claude Sonnet 4.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"}},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Anthropic: Claude Sonnet 4.6",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{max:"max"}},"anthropic/claude-sonnet-5":{id:"anthropic/claude-sonnet-5",name:"Anthropic: Claude Sonnet 5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,compat:{thinkingFormat:"openrouter",cacheControlFormat:"anthropic"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"arcee-ai/trinity-large-thinking":{id:"arcee-ai/trinity-large-thinking",name:"Arcee AI: Trinity Large Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.25,output:.8,cacheRead:.06,cacheWrite:0},contextWindow:262144,maxTokens:8e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"arcee-ai/virtuoso-large":{id:"arcee-ai/virtuoso-large",name:"Arcee AI: Virtuoso Large",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.75,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:64e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},auto:{id:"auto",name:"Auto",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:3e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"bytedance-seed/seed-1.6":{id:"bytedance-seed/seed-1.6",name:"ByteDance Seed: Seed 1.6",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"bytedance-seed/seed-1.6-flash":{id:"bytedance-seed/seed-1.6-flash",name:"ByteDance Seed: Seed 1.6 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"bytedance-seed/seed-2.0-lite":{id:"bytedance-seed/seed-2.0-lite",name:"ByteDance Seed: Seed-2.0-Lite",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"bytedance-seed/seed-2.0-mini":{id:"bytedance-seed/seed-2.0-mini",name:"ByteDance Seed: Seed-2.0-Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"cohere/command-r-08-2024":{id:"cohere/command-r-08-2024",name:"Cohere: Command R (08-2024)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"cohere/command-r-plus-08-2024":{id:"cohere/command-r-plus-08-2024",name:"Cohere: Command R+ (08-2024)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"cohere/north-mini-code:free":{id:"cohere/north-mini-code:free",name:"Cohere: North Mini Code (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:64e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-chat":{id:"deepseek/deepseek-chat",name:"DeepSeek: DeepSeek V3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.2002,output:.8001,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-chat-v3-0324":{id:"deepseek/deepseek-chat-v3-0324",name:"DeepSeek: DeepSeek V3 0324",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.27,output:1.12,cacheRead:.135,cacheWrite:0},contextWindow:163840,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-chat-v3.1":{id:"deepseek/deepseek-chat-v3.1",name:"DeepSeek: DeepSeek V3.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.25,output:.95,cacheRead:.13,cacheWrite:0},contextWindow:163840,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-r1":{id:"deepseek/deepseek-r1",name:"DeepSeek: R1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.7,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-r1-0528":{id:"deepseek/deepseek-r1-0528",name:"DeepSeek: R1 0528",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.5,output:2.15,cacheRead:.35,cacheWrite:0},contextWindow:163840,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek: DeepSeek V3.1 Terminus",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.27,output:1,cacheRead:.135,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek: DeepSeek V3.2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.269,output:.4,cacheRead:.1345,cacheWrite:0},contextWindow:163840,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-v3.2-exp":{id:"deepseek/deepseek-v3.2-exp",name:"DeepSeek: DeepSeek V3.2 Exp",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.27,output:.41,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"deepseek/deepseek-v4-flash":{id:"deepseek/deepseek-v4-flash",name:"DeepSeek: DeepSeek V4 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.098,output:.196,cacheRead:.0196,cacheWrite:0},contextWindow:1048575,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter",requiresReasoningContentOnAssistantMessages:!0},thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:null,xhigh:"xhigh"}},"deepseek/deepseek-v4-pro":{id:"deepseek/deepseek-v4-pro",name:"DeepSeek: DeepSeek V4 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.003625,cacheWrite:0},contextWindow:1048576,maxTokens:384e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter",requiresReasoningContentOnAssistantMessages:!0},thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:null,xhigh:"xhigh"}},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Google: Gemini 2.5 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:.083333},contextWindow:1048576,maxTokens:65535,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Google: Gemini 2.5 Flash Lite",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:.083333},contextWindow:1048576,maxTokens:65535,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Google: Gemini 2.5 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-2.5-pro-preview":{id:"google/gemini-2.5-pro-preview",name:"Google: Gemini 2.5 Pro Preview 06-05",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-2.5-pro-preview-05-06":{id:"google/gemini-2.5-pro-preview-05-06",name:"Google: Gemini 2.5 Pro Preview 05-06",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65535,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3-flash-preview":{id:"google/gemini-3-flash-preview",name:"Google: Gemini 3 Flash Preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.083333},contextWindow:1048576,maxTokens:65535,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3-pro-image":{id:"google/gemini-3-pro-image",name:"Google: Nano Banana Pro (Gemini 3 Pro Image)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:.375},contextWindow:65536,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.1-flash-lite":{id:"google/gemini-3.1-flash-lite",name:"Google: Gemini 3.1 Flash Lite",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Google: Gemini 3.1 Flash Lite Preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Google: Gemini 3.1 Pro Preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:.375},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.1-pro-preview-customtools":{id:"google/gemini-3.1-pro-preview-customtools",name:"Google: Gemini 3.1 Pro Preview Custom Tools",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:.375},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.5-flash":{id:"google/gemini-3.5-flash",name:"Google: Gemini 3.5 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.5-flash-lite":{id:"google/gemini-3.5-flash-lite",name:"Google: Gemini 3.5 Flash Lite",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemini-3.6-flash":{id:"google/gemini-3.6-flash",name:"Google: Gemini 3.6 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-3-12b-it":{id:"google/gemma-3-12b-it",name:"Google: Gemma 3 12B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.05,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-3-27b-it":{id:"google/gemma-3-27b-it",name:"Google: Gemma 3 27B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:11e4,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-4-26b-a4b-it":{id:"google/gemma-4-26b-a4b-it",name:"Google: Gemma 4 26B A4B ",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.07,output:.34,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-4-26b-a4b-it:free":{id:"google/gemma-4-26b-a4b-it:free",name:"Google: Gemma 4 26B A4B (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-4-31b-it":{id:"google/gemma-4-31b-it",name:"Google: Gemma 4 31B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.12,output:.37,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"google/gemma-4-31b-it:free":{id:"google/gemma-4-31b-it:free",name:"Google: Gemma 4 31B (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"ibm-granite/granite-4.1-8b":{id:"ibm-granite/granite-4.1-8b",name:"IBM: Granite 4.1 8B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.05,output:.1,cacheRead:.05,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"inception/mercury-2":{id:"inception/mercury-2",name:"Inception: Mercury 2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.025,cacheWrite:0},contextWindow:128e3,maxTokens:5e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"},thinkingLevelMap:{off:null}},"inclusionai/ling-2.6-1t":{id:"inclusionai/ling-2.6-1t",name:"inclusionAI: Ling-2.6-1T",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.075,output:.625,cacheRead:.015,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"inclusionai/ling-2.6-flash":{id:"inclusionai/ling-2.6-flash",name:"inclusionAI: Ling-2.6-flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.01,output:.03,cacheRead:.002,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"inclusionai/ring-2.6-1t":{id:"inclusionai/ring-2.6-1t",name:"inclusionAI: Ring-2.6-1T",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.075,output:.625,cacheRead:.015,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"kwaipilot/kat-coder-air-v2.5":{id:"kwaipilot/kat-coder-air-v2.5",name:"Kwaipilot: KAT-Coder-Air V2.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:.03,cacheWrite:0},contextWindow:256e3,maxTokens:8e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"kwaipilot/kat-coder-pro-v2":{id:"kwaipilot/kat-coder-pro-v2",name:"Kwaipilot: KAT-Coder-Pro V2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:256e3,maxTokens:8e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"kwaipilot/kat-coder-pro-v2.5":{id:"kwaipilot/kat-coder-pro-v2.5",name:"Kwaipilot: KAT-Coder-Pro V2.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.74,output:2.96,cacheRead:.15,cacheWrite:0},contextWindow:256e3,maxTokens:8e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meituan/longcat-2.0":{id:"meituan/longcat-2.0",name:"Meituan: LongCat 2.0",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.006,cacheWrite:0},contextWindow:1048756,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta-llama/llama-3.1-70b-instruct":{id:"meta-llama/llama-3.1-70b-instruct",name:"Meta: Llama 3.1 70B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.4,output:.4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta-llama/llama-3.1-8b-instruct":{id:"meta-llama/llama-3.1-8b-instruct",name:"Meta: Llama 3.1 8B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:.025,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta-llama/llama-3.3-70b-instruct":{id:"meta-llama/llama-3.3-70b-instruct",name:"Meta: Llama 3.3 70B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.13,output:.4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta-llama/llama-4-maverick":{id:"meta-llama/llama-4-maverick",name:"Meta: Llama 4 Maverick",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.2,output:.8,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta-llama/llama-4-scout":{id:"meta-llama/llama-4-scout",name:"Meta: Llama 4 Scout",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:327680,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"meta/muse-spark-1.1":{id:"meta/muse-spark-1.1",name:"Meta: Muse Spark 1.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:4.25,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m1":{id:"minimax/minimax-m1",name:"MiniMax: MiniMax M1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.55,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:4e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax: MiniMax M2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax: MiniMax M2.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax: MiniMax M2.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.15,output:.9,cacheRead:.05,cacheWrite:0},contextWindow:196608,maxTokens:196608,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m2.7":{id:"minimax/minimax-m2.7",name:"MiniMax: MiniMax M2.7",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.25,output:1,cacheRead:.05,cacheWrite:0},contextWindow:196608,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"minimax/minimax-m3":{id:"minimax/minimax-m3",name:"MiniMax: MiniMax M3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:524288,maxTokens:512e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/codestral-2508":{id:"mistralai/codestral-2508",name:"Mistral: Codestral 2508",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.3,output:.9,cacheRead:.03,cacheWrite:0},contextWindow:256e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/devstral-2512":{id:"mistralai/devstral-2512",name:"Mistral: Devstral 2 2512",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/ministral-14b-2512":{id:"mistralai/ministral-14b-2512",name:"Mistral: Ministral 3 14B 2512",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.2,output:.2,cacheRead:.02,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/ministral-3b-2512":{id:"mistralai/ministral-3b-2512",name:"Mistral: Ministral 3 3B 2512",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.1,cacheRead:.01,cacheWrite:0},contextWindow:131072,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/ministral-8b-2512":{id:"mistralai/ministral-8b-2512",name:"Mistral: Ministral 3 8B 2512",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:.015,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-large":{id:"mistralai/mistral-large",name:"Mistral Large",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-large-2407":{id:"mistralai/mistral-large-2407",name:"Mistral Large 2407",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:131072,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-large-2512":{id:"mistralai/mistral-large-2512",name:"Mistral: Mistral Large 3 2512",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:.05,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-medium-3":{id:"mistralai/mistral-medium-3",name:"Mistral: Mistral Medium 3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:131072,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-medium-3-5":{id:"mistralai/mistral-medium-3-5",name:"Mistral: Mistral Medium 3.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-medium-3.1":{id:"mistralai/mistral-medium-3.1",name:"Mistral: Mistral Medium 3.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:.04,cacheWrite:0},contextWindow:131072,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-nemo":{id:"mistralai/mistral-nemo",name:"Mistral: Mistral Nemo",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.019,output:.03,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-saba":{id:"mistralai/mistral-saba",name:"Mistral: Saba",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.2,output:.6,cacheRead:.02,cacheWrite:0},contextWindow:32768,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-small-2603":{id:"mistralai/mistral-small-2603",name:"Mistral: Mistral Small 4",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mistral-small-3.2-24b-instruct":{id:"mistralai/mistral-small-3.2-24b-instruct",name:"Mistral: Mistral Small 3.2 24B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:.01,cacheWrite:0},contextWindow:131072,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/mixtral-8x22b-instruct":{id:"mistralai/mixtral-8x22b-instruct",name:"Mistral: Mixtral 8x22B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:.2,cacheWrite:0},contextWindow:65536,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"mistralai/voxtral-small-24b-2507":{id:"mistralai/voxtral-small-24b-2507",name:"Mistral: Voxtral Small 24B 2507",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:.01,cacheWrite:0},contextWindow:32e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"MoonshotAI: Kimi K2 0711",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.57,output:2.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:100352,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k2-0905":{id:"moonshotai/kimi-k2-0905",name:"MoonshotAI: Kimi K2 0905",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:100352,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"MoonshotAI: Kimi K2 Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:100352,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"MoonshotAI: Kimi K2.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.41,output:2.06,cacheRead:.07,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k2.6":{id:"moonshotai/kimi-k2.6",name:"MoonshotAI: Kimi K2.6",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.684,output:3.42,cacheRead:.144,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter",requiresReasoningContentOnAssistantMessages:!0}},"moonshotai/kimi-k2.7-code":{id:"moonshotai/kimi-k2.7-code",name:"MoonshotAI: Kimi K2.7 Code",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.82,output:3.75,cacheRead:.16,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"moonshotai/kimi-k3":{id:"moonshotai/kimi-k3",name:"MoonshotAI: Kimi K3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nex-agi/nex-n2-mini":{id:"nex-agi/nex-n2-mini",name:"Nex AGI: Nex-N2-Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.025,output:.1,cacheRead:.0025,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nex-agi/nex-n2-pro":{id:"nex-agi/nex-n2-pro",name:"Nex AGI: Nex-N2-Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:1,cacheRead:.025,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-nano-30b-a3b":{id:"nvidia/nemotron-3-nano-30b-a3b",name:"NVIDIA: Nemotron 3 Nano 30B A3B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.05,output:.2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:228e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-nano-30b-a3b:free":{id:"nvidia/nemotron-3-nano-30b-a3b:free",name:"NVIDIA: Nemotron 3 Nano 30B A3B (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free":{id:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",name:"NVIDIA: Nemotron 3 Nano Omni (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-super-120b-a12b":{id:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA: Nemotron 3 Super",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.08,output:.45,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-super-120b-a12b:free":{id:"nvidia/nemotron-3-super-120b-a12b:free",name:"NVIDIA: Nemotron 3 Super (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-ultra-550b-a55b":{id:"nvidia/nemotron-3-ultra-550b-a55b",name:"NVIDIA: Nemotron 3 Ultra",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.6,output:3.6,cacheRead:.2,cacheWrite:0},contextWindow:512288,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-3-ultra-550b-a55b:free":{id:"nvidia/nemotron-3-ultra-550b-a55b:free",name:"NVIDIA: Nemotron 3 Ultra (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-nano-12b-v2-vl:free":{id:"nvidia/nemotron-nano-12b-v2-vl:free",name:"NVIDIA: Nemotron Nano 12B 2 VL (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"nvidia/nemotron-nano-9b-v2:free":{id:"nvidia/nemotron-nano-9b-v2:free",name:"NVIDIA: Nemotron Nano 9B V2 (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"openai/gpt-3.5-turbo":{id:"openai/gpt-3.5-turbo",name:"OpenAI: GPT-3.5 Turbo",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-3.5-turbo-0613":{id:"openai/gpt-3.5-turbo-0613",name:"OpenAI: GPT-3.5 Turbo (older v0613)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:1,output:2,cacheRead:0,cacheWrite:0},contextWindow:4095,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-3.5-turbo-16k":{id:"openai/gpt-3.5-turbo-16k",name:"OpenAI: GPT-3.5 Turbo 16k",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:3,output:4,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4":{id:"openai/gpt-4",name:"OpenAI: GPT-4",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8191,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"OpenAI: GPT-4 Turbo",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4-turbo-preview":{id:"openai/gpt-4-turbo-preview",name:"OpenAI: GPT-4 Turbo Preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"OpenAI: GPT-4.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"OpenAI: GPT-4.1 Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"OpenAI: GPT-4.1 Nano",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1047576,maxTokens:32768,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o":{id:"openai/gpt-4o",name:"OpenAI: GPT-4o",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o-2024-05-13":{id:"openai/gpt-4o-2024-05-13",name:"OpenAI: GPT-4o (2024-05-13)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o-2024-08-06":{id:"openai/gpt-4o-2024-08-06",name:"OpenAI: GPT-4o (2024-08-06)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o-2024-11-20":{id:"openai/gpt-4o-2024-11-20",name:"OpenAI: GPT-4o (2024-11-20)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"OpenAI: GPT-4o-mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-4o-mini-2024-07-18":{id:"openai/gpt-4o-mini-2024-07-18",name:"OpenAI: GPT-4o-mini (2024-07-18)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5":{id:"openai/gpt-5",name:"OpenAI: GPT-5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"OpenAI: GPT-5 Codex",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"OpenAI: GPT-5 Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"OpenAI: GPT-5 Nano",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"OpenAI: GPT-5 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.1":{id:"openai/gpt-5.1",name:"OpenAI: GPT-5.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.1-chat":{id:"openai/gpt-5.1-chat",name:"OpenAI: GPT-5.1 Chat",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"OpenAI: GPT-5.1-Codex",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"OpenAI: GPT-5.1-Codex-Max",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"OpenAI: GPT-5.1-Codex-Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"OpenAI: GPT-5.2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"OpenAI: GPT-5.2 Chat",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"OpenAI: GPT-5.2-Codex",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"OpenAI: GPT-5.2 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"OpenAI: GPT-5.3 Chat",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"OpenAI: GPT-5.3-Codex",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"OpenAI: GPT-5.4",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-mini":{id:"openai/gpt-5.4-mini",name:"OpenAI: GPT-5.4 Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-nano":{id:"openai/gpt-5.4-nano",name:"OpenAI: GPT-5.4 Nano",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"OpenAI: GPT-5.4 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.5":{id:"openai/gpt-5.5",name:"OpenAI: GPT-5.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.5-pro":{id:"openai/gpt-5.5-pro",name:"OpenAI: GPT-5.5 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",off:null,minimal:null,low:null}},"openai/gpt-5.6-luna":{id:"openai/gpt-5.6-luna",name:"OpenAI: GPT-5.6 Luna",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-5.6-luna-pro":{id:"openai/gpt-5.6-luna-pro",name:"OpenAI: GPT-5.6 Luna Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-5.6-sol":{id:"openai/gpt-5.6-sol",name:"OpenAI: GPT-5.6 Sol",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-5.6-sol-pro":{id:"openai/gpt-5.6-sol-pro",name:"OpenAI: GPT-5.6 Sol Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-5.6-terra":{id:"openai/gpt-5.6-terra",name:"OpenAI: GPT-5.6 Terra",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-5.6-terra-pro":{id:"openai/gpt-5.6-terra-pro",name:"OpenAI: GPT-5.6 Terra Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},contextWindow:105e4,maxTokens:128e3,compat:{thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh",max:"max"}},"openai/gpt-audio":{id:"openai/gpt-audio",name:"OpenAI: GPT Audio",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-audio-mini":{id:"openai/gpt-audio-mini",name:"OpenAI: GPT Audio Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.6,output:2.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384,compat:{thinkingFormat:"openrouter"}},"openai/gpt-chat-latest":{id:"openai/gpt-chat-latest",name:"OpenAI: GPT Chat Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{thinkingFormat:"openrouter"}},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"OpenAI: gpt-oss-120b",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.037,output:.17,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{thinkingFormat:"openrouter"}},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"OpenAI: gpt-oss-20b",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.03,output:.13,cacheRead:.03,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{thinkingFormat:"openrouter"}},"openai/gpt-oss-20b:free":{id:"openai/gpt-oss-20b:free",name:"OpenAI: gpt-oss-20b (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{thinkingFormat:"openrouter"}},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"OpenAI: gpt-oss-safeguard-20b",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.0375,cacheWrite:0},contextWindow:131072,maxTokens:65536,compat:{thinkingFormat:"openrouter"}},"openai/o1":{id:"openai/o1",name:"OpenAI: o1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o3":{id:"openai/o3",name:"OpenAI: o3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"OpenAI: o3 Deep Research",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o3-mini":{id:"openai/o3-mini",name:"OpenAI: o3 Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o3-mini-high":{id:"openai/o3-mini-high",name:"OpenAI: o3 Mini High",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o3-pro":{id:"openai/o3-pro",name:"OpenAI: o3 Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o4-mini":{id:"openai/o4-mini",name:"OpenAI: o4 Mini",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o4-mini-deep-research":{id:"openai/o4-mini-deep-research",name:"OpenAI: o4 Mini Deep Research",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openai/o4-mini-high":{id:"openai/o4-mini-high",name:"OpenAI: o4 Mini High",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,compat:{thinkingFormat:"openrouter"}},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"openrouter/auto-beta":{id:"openrouter/auto-beta",name:"Auto Router (Beta)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"openrouter/free":{id:"openrouter/free",name:"Free Models Router",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"openrouter/fusion":{id:"openrouter/fusion",name:"OpenRouter: Fusion",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:3e4,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-m.1":{id:"poolside/laguna-m.1",name:"Poolside: Laguna M.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.2,output:.4,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-m.1:free":{id:"poolside/laguna-m.1:free",name:"Poolside: Laguna M.1 (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-s-2.1":{id:"poolside/laguna-s-2.1",name:"Poolside: Laguna S 2.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.1,output:.2,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-s-2.1:free":{id:"poolside/laguna-s-2.1:free",name:"Poolside: Laguna S 2.1 (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-xs-2.1":{id:"poolside/laguna-xs-2.1",name:"Poolside: Laguna XS 2.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.06,output:.12,cacheRead:.03,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"poolside/laguna-xs-2.1:free":{id:"poolside/laguna-xs-2.1:free",name:"Poolside: Laguna XS 2.1 (free)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen-2.5-72b-instruct":{id:"qwen/qwen-2.5-72b-instruct",name:"Qwen2.5 72B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.36,output:.4,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen-2.5-7b-instruct":{id:"qwen/qwen-2.5-7b-instruct",name:"Qwen: Qwen2.5 7B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.04,output:.1,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen-plus":{id:"qwen/qwen-plus",name:"Qwen: Qwen-Plus",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.26,output:.78,cacheRead:.052,cacheWrite:.325},contextWindow:1e6,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen-plus-2025-07-28":{id:"qwen/qwen-plus-2025-07-28",name:"Qwen: Qwen Plus 0728",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen-plus-2025-07-28:thinking":{id:"qwen/qwen-plus-2025-07-28:thinking",name:"Qwen: Qwen Plus 0728 (thinking)",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:.325},contextWindow:1e6,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-14b":{id:"qwen/qwen3-14b",name:"Qwen: Qwen3 14B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.12,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-235b-a22b":{id:"qwen/qwen3-235b-a22b",name:"Qwen: Qwen3 235B A22B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.455,output:1.82,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-235b-a22b-2507":{id:"qwen/qwen3-235b-a22b-2507",name:"Qwen: Qwen3 235B A22B Instruct 2507",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.09,output:.55,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-235b-a22b-thinking-2507":{id:"qwen/qwen3-235b-a22b-thinking-2507",name:"Qwen: Qwen3 235B A22B Thinking 2507",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.3,output:3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-30b-a3b":{id:"qwen/qwen3-30b-a3b",name:"Qwen: Qwen3 30B A3B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.13,output:.52,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-30b-a3b-instruct-2507":{id:"qwen/qwen3-30b-a3b-instruct-2507",name:"Qwen: Qwen3 30B A3B Instruct 2507",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-30b-a3b-thinking-2507":{id:"qwen/qwen3-30b-a3b-thinking-2507",name:"Qwen: Qwen3 30B A3B Thinking 2507",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.13,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:81920,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen: Qwen3 32B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.08,output:.28,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-8b":{id:"qwen/qwen3-8b",name:"Qwen: Qwen3 8B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.117,output:.455,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-coder":{id:"qwen/qwen3-coder",name:"Qwen: Qwen3 Coder 480B A35B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.3,output:1,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-coder-30b-a3b-instruct":{id:"qwen/qwen3-coder-30b-a3b-instruct",name:"Qwen: Qwen3 Coder 30B A3B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.07,output:.27,cacheRead:0,cacheWrite:0},contextWindow:16e4,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-coder-flash":{id:"qwen/qwen3-coder-flash",name:"Qwen: Qwen3 Coder Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.195,output:.975,cacheRead:.039,cacheWrite:.24375},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-coder-next":{id:"qwen/qwen3-coder-next",name:"Qwen: Qwen3 Coder Next",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.11,output:.8,cacheRead:.07,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-coder-plus":{id:"qwen/qwen3-coder-plus",name:"Qwen: Qwen3 Coder Plus",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.65,output:3.25,cacheRead:.13,cacheWrite:.8125},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-max":{id:"qwen/qwen3-max",name:"Qwen: Qwen3 Max",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.78,output:3.9,cacheRead:.156,cacheWrite:.975},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-max-thinking":{id:"qwen/qwen3-max-thinking",name:"Qwen: Qwen3 Max Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.78,output:3.9,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-next-80b-a3b-instruct":{id:"qwen/qwen3-next-80b-a3b-instruct",name:"Qwen: Qwen3 Next 80B A3B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.1,output:1.1,cacheRead:.07,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-next-80b-a3b-thinking":{id:"qwen/qwen3-next-80b-a3b-thinking",name:"Qwen: Qwen3 Next 80B A3B Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.0975,output:.78,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-235b-a22b-instruct":{id:"qwen/qwen3-vl-235b-a22b-instruct",name:"Qwen: Qwen3 VL 235B A22B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.21,output:1.9,cacheRead:.1,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-235b-a22b-thinking":{id:"qwen/qwen3-vl-235b-a22b-thinking",name:"Qwen: Qwen3 VL 235B A22B Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.26,output:2.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-30b-a3b-instruct":{id:"qwen/qwen3-vl-30b-a3b-instruct",name:"Qwen: Qwen3 VL 30B A3B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.13,output:.52,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-30b-a3b-thinking":{id:"qwen/qwen3-vl-30b-a3b-thinking",name:"Qwen: Qwen3 VL 30B A3B Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.13,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-32b-instruct":{id:"qwen/qwen3-vl-32b-instruct",name:"Qwen: Qwen3 VL 32B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.104,output:.416,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-8b-instruct":{id:"qwen/qwen3-vl-8b-instruct",name:"Qwen: Qwen3 VL 8B Instruct",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.117,output:.455,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3-vl-8b-thinking":{id:"qwen/qwen3-vl-8b-thinking",name:"Qwen: Qwen3 VL 8B Thinking",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.117,output:1.365,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-122b-a10b":{id:"qwen/qwen3.5-122b-a10b",name:"Qwen: Qwen3.5-122B-A10B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.26,output:2.08,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-27b":{id:"qwen/qwen3.5-27b",name:"Qwen: Qwen3.5-27B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.26,output:2.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:81920,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-35b-a3b":{id:"qwen/qwen3.5-35b-a3b",name:"Qwen: Qwen3.5-35B-A3B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.14,output:1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-397b-a17b":{id:"qwen/qwen3.5-397b-a17b",name:"Qwen: Qwen3.5 397B A17B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.39,output:2.34,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-9b":{id:"qwen/qwen3.5-9b",name:"Qwen: Qwen3.5-9B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.1,output:.15,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-flash-02-23":{id:"qwen/qwen3.5-flash-02-23",name:"Qwen: Qwen3.5-Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.065,output:.26,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-plus-02-15":{id:"qwen/qwen3.5-plus-02-15",name:"Qwen: Qwen3.5 Plus 2026-02-15",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.26,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.5-plus-20260420":{id:"qwen/qwen3.5-plus-20260420",name:"Qwen: Qwen3.5 Plus 2026-04-20",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.8,cacheRead:0,cacheWrite:.375},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.6-27b":{id:"qwen/qwen3.6-27b",name:"Qwen: Qwen3.6 27B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.45,output:2.7,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.6-35b-a3b":{id:"qwen/qwen3.6-35b-a3b",name:"Qwen: Qwen3.6 35B A3B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.14,output:1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.6-flash":{id:"qwen/qwen3.6-flash",name:"Qwen: Qwen3.6 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.1875,output:1.125,cacheRead:0,cacheWrite:.234375},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.6-max-preview":{id:"qwen/qwen3.6-max-preview",name:"Qwen: Qwen3.6 Max Preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:1.04,output:6.24,cacheRead:0,cacheWrite:1.3},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.6-plus":{id:"qwen/qwen3.6-plus",name:"Qwen: Qwen3.6 Plus",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.325,output:1.95,cacheRead:0,cacheWrite:.40625},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.7-max":{id:"qwen/qwen3.7-max",name:"Qwen: Qwen3.7 Max",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:1.475,output:4.425,cacheRead:.295,cacheWrite:1.84375},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"qwen/qwen3.7-plus":{id:"qwen/qwen3.7-plus",name:"Qwen: Qwen3.7 Plus",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.32,output:1.28,cacheRead:.064,cacheWrite:.4},contextWindow:1e6,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"rekaai/reka-edge":{id:"rekaai/reka-edge",name:"Reka Edge",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text","image"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"relace/relace-search":{id:"relace/relace-search",name:"Relace: Relace Search",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"sakana/fugu-ultra":{id:"sakana/fugu-ultra",name:"Sakana: Fugu Ultra",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"sao10k/l3.1-euryale-70b":{id:"sao10k/l3.1-euryale-70b",name:"Sao10K: Llama 3.1 Euryale 70B v2.2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.85,output:.85,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"stepfun/step-3.5-flash":{id:"stepfun/step-3.5-flash",name:"StepFun: Step 3.5 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"stepfun/step-3.7-flash":{id:"stepfun/step-3.7-flash",name:"StepFun: Step 3.7 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.15,cacheRead:.04,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"tencent/hy3":{id:"tencent/hy3",name:"Tencent: Hy3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.14,output:.58,cacheRead:.035,cacheWrite:0},contextWindow:262144,maxTokens:262144,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"tencent/hy3-preview":{id:"tencent/hy3-preview",name:"Tencent: Hy3 preview",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.063,output:.21,cacheRead:.021,cacheWrite:0},contextWindow:262144,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"thedrummer/unslopnemo-12b":{id:"thedrummer/unslopnemo-12b",name:"TheDrummer: UnslopNemo 12B",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!1,input:["text"],cost:{input:.4,output:.4,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"thinkingmachines/inkling":{id:"thinkingmachines/inkling",name:"Thinking Machines: Inkling",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:4.05,cacheRead:.17,cacheWrite:0},contextWindow:524288,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"upstage/solar-pro-3":{id:"upstage/solar-pro-3",name:"Upstage: Solar Pro 3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"x-ai/grok-4.20":{id:"x-ai/grok-4.20",name:"xAI: Grok 4.20",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"x-ai/grok-4.3":{id:"x-ai/grok-4.3",name:"xAI: Grok 4.3",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"x-ai/grok-4.5":{id:"x-ai/grok-4.5",name:"xAI: Grok 4.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.3,cacheWrite:0},contextWindow:5e5,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"x-ai/grok-build-0.1":{id:"x-ai/grok-build-0.1",name:"xAI: Grok Build 0.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:2,cacheRead:.2,cacheWrite:0},contextWindow:256e3,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"xiaomi/mimo-v2.5":{id:"xiaomi/mimo-v2.5",name:"Xiaomi: MiMo-V2.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"xiaomi/mimo-v2.5-pro":{id:"xiaomi/mimo-v2.5-pro",name:"Xiaomi: MiMo-V2.5-Pro",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.0036,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.5":{id:"z-ai/glm-4.5",name:"Z.ai: GLM 4.5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:131072,maxTokens:98304,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.5-air":{id:"z-ai/glm-4.5-air",name:"Z.ai: GLM 4.5 Air",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.13,output:.85,cacheRead:.025,cacheWrite:0},contextWindow:131072,maxTokens:98304,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.5v":{id:"z-ai/glm-4.5v",name:"Z.ai: GLM 4.5V",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.8,cacheRead:.11,cacheWrite:0},contextWindow:65536,maxTokens:16384,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.6":{id:"z-ai/glm-4.6",name:"Z.ai: GLM 4.6",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.5,output:2,cacheRead:.1,cacheWrite:0},contextWindow:202752,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.6v":{id:"z-ai/glm-4.6v",name:"Z.ai: GLM 4.6V",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.3,output:.9,cacheRead:.055,cacheWrite:0},contextWindow:131072,maxTokens:32768,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.7":{id:"z-ai/glm-4.7",name:"Z.ai: GLM 4.7",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.4,output:1.75,cacheRead:.08,cacheWrite:0},contextWindow:202752,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-4.7-flash":{id:"z-ai/glm-4.7-flash",name:"Z.ai: GLM 4.7 Flash",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.0605,output:.4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-5":{id:"z-ai/glm-5",name:"Z.ai: GLM 5",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.6,output:1.9,cacheRead:.119,cacheWrite:0},contextWindow:204800,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-5-turbo":{id:"z-ai/glm-5-turbo",name:"Z.ai: GLM 5 Turbo",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},contextWindow:202752,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-5.1":{id:"z-ai/glm-5.1",name:"Z.ai: GLM 5.1",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.966,output:3.036,cacheRead:.1794,cacheWrite:0},contextWindow:2e5,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"z-ai/glm-5.2":{id:"z-ai/glm-5.2",name:"Z.ai: GLM 5.2",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text"],cost:{input:.8106,output:2.5476,cacheRead:.15054,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"},thinkingLevelMap:{xhigh:"xhigh"}},"z-ai/glm-5v-turbo":{id:"z-ai/glm-5v-turbo",name:"Z.ai: GLM 5V Turbo",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},contextWindow:202752,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~anthropic/claude-fable-latest":{id:"~anthropic/claude-fable-latest",name:"Anthropic: Claude Fable Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~anthropic/claude-haiku-latest":{id:"~anthropic/claude-haiku-latest",name:"Anthropic Claude Haiku Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~anthropic/claude-opus-latest":{id:"~anthropic/claude-opus-latest",name:"Anthropic: Claude Opus Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~anthropic/claude-sonnet-latest":{id:"~anthropic/claude-sonnet-latest",name:"Anthropic Claude Sonnet Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~google/gemini-flash-latest":{id:"~google/gemini-flash-latest",name:"Google Gemini Flash Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:.083333},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~google/gemini-pro-latest":{id:"~google/gemini-pro-latest",name:"Google Gemini Pro Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:.375},contextWindow:1048576,maxTokens:65536,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~moonshotai/kimi-latest":{id:"~moonshotai/kimi-latest",name:"MoonshotAI Kimi Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:131072,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~openai/gpt-latest":{id:"~openai/gpt-latest",name:"OpenAI GPT Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:105e4,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~openai/gpt-mini-latest":{id:"~openai/gpt-mini-latest",name:"OpenAI GPT Mini Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}},"~x-ai/grok-latest":{id:"~x-ai/grok-latest",name:"xAI: Grok Latest",api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",provider:"openrouter",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.3,cacheWrite:0},contextWindow:5e5,maxTokens:4096,compat:{supportsDeveloperRole:!1,thinkingFormat:"openrouter"}}};var YC=QC;var JC={"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:24576},"deepseek-v3.2":{id:"deepseek-v3.2",name:"DeepSeek V3.2",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"deepseek-v4-flash":{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"deepseek",supportsDeveloperRole:!1,supportsStore:!1,requiresReasoningContentOnAssistantMessages:!0},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"deepseek-v4-pro":{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"deepseek",supportsDeveloperRole:!1,supportsStore:!1,requiresReasoningContentOnAssistantMessages:!0},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:16384},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:128e3},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen3.6-flash":{id:"qwen3.6-flash",name:"Qwen3.6 Flash",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.6-plus":{id:"qwen3.6-plus",name:"Qwen3.6 Plus",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.7-max":{id:"qwen3.7-max",name:"Qwen3.7 Max",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.7-plus":{id:"qwen3.7-plus",name:"Qwen3.7 Plus",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"qwen3.8-max-preview":{id:"qwen3.8-max-preview",name:"Qwen3.8 Max Preview",api:"openai-completions",provider:"qwen-token-plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:131072}};var XC=JC;var ZC={"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:24576},"deepseek-v3.2":{id:"deepseek-v3.2",name:"DeepSeek V3.2",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"deepseek-v4-flash":{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"deepseek",supportsDeveloperRole:!1,supportsStore:!1,requiresReasoningContentOnAssistantMessages:!0},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"deepseek-v4-pro":{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"deepseek",supportsDeveloperRole:!1,supportsStore:!1,requiresReasoningContentOnAssistantMessages:!0},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:384e3,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",max:"max"}},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:16384},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:128e3},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"kimi-k2.6":{id:"kimi-k2.6",name:"Kimi K2.6",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"kimi-k2.7-code":{id:"kimi-k2.7-code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen3.6-flash":{id:"qwen3.6-flash",name:"Qwen3.6 Flash",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.6-plus":{id:"qwen3.6-plus",name:"Qwen3.6 Plus",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.7-max":{id:"qwen3.7-max",name:"Qwen3.7 Max",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen3.7-plus":{id:"qwen3.7-plus",name:"Qwen3.7 Plus",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"qwen3.8-max-preview":{id:"qwen3.8-max-preview",name:"Qwen3.8 Max Preview",api:"openai-completions",provider:"qwen-token-plan-cn",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",compat:{thinkingFormat:"qwen",supportsDeveloperRole:!1,supportsStore:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:131072}};var e1=ZC;var t1={"MiniMaxAI/MiniMax-M2.7":{id:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{off:null,minimal:null,low:null,medium:null},input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:202752,maxTokens:131072},"MiniMaxAI/MiniMax-M3":{id:"MiniMaxAI/MiniMax-M3",name:"MiniMax-M3",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:524288,maxTokens:25e4},"Qwen/Qwen2.5-7B-Instruct-Turbo":{id:"Qwen/Qwen2.5-7B-Instruct-Turbo",name:"Qwen 2.5 7B Instruct Turbo",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!1,input:["text"],cost:{input:.3,output:.3,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:32768,maxTokens:32768},"Qwen/Qwen3.5-9B":{id:"Qwen/Qwen3.5-9B",name:"Qwen3.5 9B",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text","image"],cost:{input:.17,output:.25,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3.6-Plus":{id:"Qwen/Qwen3.6-Plus",name:"Qwen3.6 Plus",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text"],cost:{input:.5,output:3,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:1e6,maxTokens:5e5},"Qwen/Qwen3.7-Max":{id:"Qwen/Qwen3.7-Max",name:"Qwen3.7 Max",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!1,input:["text"],cost:{input:1.25,output:3.75,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:1e6,maxTokens:5e5},"deepseek-ai/DeepSeek-V4-Pro":{id:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null,high:"high",xhigh:null},input:["text"],cost:{input:1.74,output:3.48,cacheRead:.2,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:512e3,maxTokens:384e3},"google/gemma-4-31B-it":{id:"google/gemma-4-31B-it",name:"Gemma 4 31B Instruct",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text","image"],cost:{input:.39,output:.97,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:131072},"meta-llama/Llama-3.3-70B-Instruct-Turbo":{id:"meta-llama/Llama-3.3-70B-Instruct-Turbo",name:"Llama 3.3 70B",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!1,input:["text"],cost:{input:1.04,output:1.04,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:131072},"moonshotai/Kimi-K2.6":{id:"moonshotai/Kimi-K2.6",name:"Kimi K2.6",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text","image"],cost:{input:1.2,output:4.5,cacheRead:.2,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:131e3},"moonshotai/Kimi-K2.7-Code":{id:"moonshotai/Kimi-K2.7-Code",name:"Kimi K2.7 Code",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:131072},"nvidia/nemotron-3-ultra-550b-a55b":{id:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text"],cost:{input:.6,output:3.6,cacheRead:.2,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:512300,maxTokens:512300},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,maxTokensField:"max_tokens",thinkingFormat:"openai",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},input:["text"],cost:{input:.05,output:.2,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,maxTokensField:"max_tokens",thinkingFormat:"openai",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:131072,maxTokens:131072},"thinkingmachines/Inkling":{id:"thinkingmachines/Inkling",name:"Inkling",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text","image"],cost:{input:1,output:4.05,cacheRead:.17,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:524288,maxTokens:131072},"zai-org/GLM-5.2":{id:"zai-org/GLM-5.2",name:"GLM-5.2",api:"openai-completions",provider:"together",baseUrl:"https://api.together.ai/v1",reasoning:!0,thinkingLevelMap:{minimal:null,low:null,medium:null},input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,maxTokensField:"max_tokens",thinkingFormat:"together",supportsStrictMode:!1,supportsLongCacheRetention:!1},contextWindow:262144,maxTokens:164e3}};var n1=t1;var i1={"alibaba/qwen-3-14b":{id:"alibaba/qwen-3-14b",name:"Qwen3-14B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.12,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-235b":{id:"alibaba/qwen-3-235b",name:"Qwen3 235B A22B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"alibaba/qwen-3-30b":{id:"alibaba/qwen-3-30b",name:"Qwen3-30B-A3B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.12,output:.5,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-32b":{id:"alibaba/qwen-3-32b",name:"Qwen 3 32B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.16,output:.64,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"alibaba/qwen-3.6-max-preview":{id:"alibaba/qwen-3.6-max-preview",name:"Qwen 3.6 Max Preview",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.3,output:7.8,cacheRead:.26,cacheWrite:1.625},contextWindow:24e4,maxTokens:64e3},"alibaba/qwen3-235b-a22b-thinking":{id:"alibaba/qwen3-235b-a22b-thinking",name:"Qwen3 VL 235B A22B Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.4,output:4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"alibaba/qwen3-coder":{id:"alibaba/qwen3-coder",name:"Qwen3 Coder 480B A35B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:1.5,output:7.5,cacheRead:.3,cacheWrite:0},contextWindow:262144,maxTokens:65536},"alibaba/qwen3-coder-30b-a3b":{id:"alibaba/qwen3-coder-30b-a3b",name:"Qwen 3 Coder 30B A3B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:8192},"alibaba/qwen3-coder-next":{id:"alibaba/qwen3-coder-next",name:"Qwen3 Coder Next",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.5,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3-coder-plus":{id:"alibaba/qwen3-coder-plus",name:"Qwen3 Coder Plus",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:1,output:5,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"alibaba/qwen3-max":{id:"alibaba/qwen3-max",name:"Qwen3 Max",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"alibaba/qwen3-max-preview":{id:"alibaba/qwen3-max-preview",name:"Qwen3 Max Preview",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"alibaba/qwen3-max-thinking":{id:"alibaba/qwen3-max-thinking",name:"Qwen 3 Max Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:256e3,maxTokens:65536},"alibaba/qwen3-next-80b-a3b-instruct":{id:"alibaba/qwen3-next-80b-a3b-instruct",name:"Qwen3 Next 80B A3B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.15,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"alibaba/qwen3-next-80b-a3b-thinking":{id:"alibaba/qwen3-next-80b-a3b-thinking",name:"Qwen3 Next 80B A3B Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.15,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"alibaba/qwen3-vl-235b-a22b-instruct":{id:"alibaba/qwen3-vl-235b-a22b-instruct",name:"Qwen3 VL 235B A22B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:129024},"alibaba/qwen3-vl-instruct":{id:"alibaba/qwen3-vl-instruct",name:"Qwen3 VL 235B A22B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:129024},"alibaba/qwen3-vl-thinking":{id:"alibaba/qwen3-vl-thinking",name:"Qwen3 VL 235B A22B Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.4,output:4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"alibaba/qwen3.5-flash":{id:"alibaba/qwen3.5-flash",name:"Qwen 3.5 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.001,cacheWrite:.125},contextWindow:1e6,maxTokens:64e3},"alibaba/qwen3.5-plus":{id:"alibaba/qwen3.5-plus",name:"Qwen 3.5 Plus",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.4,output:2.4,cacheRead:.04,cacheWrite:.5},contextWindow:1e6,maxTokens:64e3},"alibaba/qwen3.6-27b":{id:"alibaba/qwen3.6-27b",name:"Qwen 3.6 27B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.6,output:3.6,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3.6-plus":{id:"alibaba/qwen3.6-plus",name:"Qwen 3.6 Plus",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.1,cacheWrite:.625},contextWindow:1e6,maxTokens:64e3},"alibaba/qwen3.7-max":{id:"alibaba/qwen3.7-max",name:"Qwen 3.7 Max",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.25,output:3.75,cacheRead:.25,cacheWrite:1.5625},contextWindow:991e3,maxTokens:64e3},"alibaba/qwen3.7-plus":{id:"alibaba/qwen3.7-plus",name:"Qwen 3.7 Plus",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.08,cacheWrite:.5},contextWindow:1e6,maxTokens:64e3},"amazon/nova-2-lite":{id:"amazon/nova-2-lite",name:"Nova 2 Lite",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"amazon/nova-lite":{id:"amazon/nova-lite",name:"Nova Lite",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon/nova-micro":{id:"amazon/nova-micro",name:"Nova Micro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"amazon/nova-pro":{id:"amazon/nova-pro",name:"Nova Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.8,output:3.2,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Claude 3 Haiku",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"anthropic/claude-fable-5":{id:"anthropic/claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Claude Opus 4",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:8192},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Claude Opus 4.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Claude Opus 4.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"anthropic/claude-opus-4.7":{id:"anthropic/claude-opus-4.7",name:"Claude Opus 4.7",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"anthropic/claude-opus-4.7-fast":{id:"anthropic/claude-opus-4.7-fast",name:"Claude Opus 4.7 (Fast)",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"anthropic/claude-opus-4.8":{id:"anthropic/claude-opus-4.8",name:"Claude Opus 4.8",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"anthropic/claude-opus-4.8-fast":{id:"anthropic/claude-opus-4.8-fast",name:"Claude Opus 4.8 (Fast)",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:8192},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{max:"max"},compat:{forceAdaptiveThinking:!0}},"anthropic/claude-sonnet-5":{id:"anthropic/claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",max:"max"},compat:{forceAdaptiveThinking:!0}},"arcee-ai/trinity-large-thinking":{id:"arcee-ai/trinity-large-thinking",name:"Trinity Large Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.25,output:.9,cacheRead:0,cacheWrite:0},contextWindow:262100,maxTokens:8e4},"arcee-ai/trinity-mini":{id:"arcee-ai/trinity-mini",name:"Trinity Mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.045,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"bytedance/seed-1.6":{id:"bytedance/seed-1.6",name:"Seed 1.6",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.05,cacheWrite:0},contextWindow:256e3,maxTokens:32e3},"bytedance/seed-1.8":{id:"bytedance/seed-1.8",name:"Bytedance Seed 1.8",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.05,cacheWrite:0},contextWindow:256e3,maxTokens:64e3},"cohere/command-a":{id:"cohere/command-a",name:"Command A",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8e3},"deepseek/deepseek-r1":{id:"deepseek/deepseek-r1",name:"DeepSeek-R1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"deepseek/deepseek-v3":{id:"deepseek/deepseek-v3",name:"DeepSeek V3 0324",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.27,output:1.12,cacheRead:.135,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek/deepseek-v3.1":{id:"deepseek/deepseek-v3.1",name:"DeepSeek V3.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.25,output:.95,cacheRead:.13,cacheWrite:0},contextWindow:163840,maxTokens:128e3},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek V3.1 Terminus",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.27,output:1,cacheRead:.135,cacheWrite:0},contextWindow:131072,maxTokens:65536},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek V3.2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.28,output:.42,cacheRead:.028,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"deepseek/deepseek-v3.2-thinking":{id:"deepseek/deepseek-v3.2-thinking",name:"DeepSeek V3.2 Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.62,output:1.85,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"deepseek/deepseek-v4-flash":{id:"deepseek/deepseek-v4-flash",name:"DeepSeek V4 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.028,cacheWrite:0},contextWindow:1e6,maxTokens:384e3},"deepseek/deepseek-v4-pro":{id:"deepseek/deepseek-v4-pro",name:"DeepSeek V4 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.0036,cacheWrite:0},contextWindow:1e6,maxTokens:384e3},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-3-flash":{id:"google/gemini-3-flash",name:"Gemini 3 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3-pro-preview":{id:"google/gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3.1-flash-lite":{id:"google/gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3.5-flash":{id:"google/gemini-3.5-flash",name:"Gemini 3.5 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.5,output:9,cacheRead:.15,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3.5-flash-lite":{id:"google/gemini-3.5-flash-lite",name:"Gemini 3.5 Flash Lite",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3.6-flash":{id:"google/gemini-3.6-flash",name:"Gemini 3.6 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.15,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemma-4-26b-a4b-it":{id:"google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:262144,maxTokens:131072},"google/gemma-4-31b-it":{id:"google/gemma-4-31b-it",name:"Gemma 4 31B IT",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.14,output:.4,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"inception/mercury-2":{id:"inception/mercury-2",name:"Mercury 2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.025,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"inception/mercury-coder-small":{id:"inception/mercury-coder-small",name:"Mercury Coder Small Beta",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:16384},"interfaze/interfaze-beta":{id:"interfaze/interfaze-beta",name:"Interfaze Beta",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.5,output:3.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32e3},"kwaipilot/kat-coder-air-v2.5":{id:"kwaipilot/kat-coder-air-v2.5",name:"Kat Coder Air V2.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.03,cacheWrite:0},contextWindow:256e3,maxTokens:8e4},"kwaipilot/kat-coder-pro-v1":{id:"kwaipilot/kat-coder-pro-v1",name:"KAT-Coder-Pro V1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:256e3,maxTokens:32e3},"kwaipilot/kat-coder-pro-v2":{id:"kwaipilot/kat-coder-pro-v2",name:"Kat Coder Pro V2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"kwaipilot/kat-coder-pro-v2.5":{id:"kwaipilot/kat-coder-pro-v2.5",name:"Kat Coder Pro V2.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.74,output:2.96,cacheRead:.15,cacheWrite:0},contextWindow:256e3,maxTokens:8e4},"meta/llama-3.1-70b":{id:"meta/llama-3.1-70b",name:"Llama 3.1 70B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.1-8b":{id:"meta/llama-3.1-8b",name:"Llama 3.1 8B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.22,output:.22,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.3-70b":{id:"meta/llama-3.3-70b",name:"Llama 3.3 70B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-4-maverick":{id:"meta/llama-4-maverick",name:"Llama 4 Maverick 17B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.24,output:.97,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-4-scout":{id:"meta/llama-4-scout",name:"Llama 4 Scout 17B Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.17,output:.66,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/muse-spark-1.1":{id:"meta/muse-spark-1.1",name:"Muse Spark 1.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:4.25,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:1048576},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax M2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:205e3,maxTokens:205e3},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax M2.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.1-lightning":{id:"minimax/minimax-m2.1-lightning",name:"MiniMax M2.1 Lightning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax M2.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131e3},"minimax/minimax-m2.5-highspeed":{id:"minimax/minimax-m2.5-highspeed",name:"MiniMax M2.5 High Speed",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131e3},"minimax/minimax-m2.7":{id:"minimax/minimax-m2.7",name:"MiniMax M2.7",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131e3},"minimax/minimax-m2.7-highspeed":{id:"minimax/minimax-m2.7-highspeed",name:"MiniMax M2.7 High Speed",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131100},"minimax/minimax-m3":{id:"minimax/minimax-m3",name:"MiniMax M3",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"mistral/codestral":{id:"mistral/codestral",name:"Mistral Codestral",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.3,output:.9,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/devstral-2":{id:"mistral/devstral-2",name:"Devstral 2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/devstral-small-2":{id:"mistral/devstral-small-2",name:"Devstral Small 2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/magistral-medium":{id:"mistral/magistral-medium",name:"Magistral Medium 2509",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/magistral-small":{id:"mistral/magistral-small",name:"Magistral Small 2509",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/ministral-14b":{id:"mistral/ministral-14b",name:"Ministral 14B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/ministral-3b":{id:"mistral/ministral-3b",name:"Ministral 3B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/ministral-8b":{id:"mistral/ministral-8b",name:"Ministral 8B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/mistral-large-3":{id:"mistral/mistral-large-3",name:"Mistral Large 3",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/mistral-medium":{id:"mistral/mistral-medium",name:"Mistral Medium 3.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/mistral-medium-3.5":{id:"mistral/mistral-medium-3.5",name:"Mistral Medium Latest",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/mistral-nemo":{id:"mistral/mistral-nemo",name:"Mistral Nemo 12B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral/mistral-small":{id:"mistral/mistral-small",name:"Mistral Small",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:4e3},"mistral/pixtral-12b":{id:"mistral/pixtral-12b",name:"Pixtral 12B 2409",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"Kimi K2 Instruct",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.57,output:2.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"Kimi K2 Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.47,output:2,cacheRead:.141,cacheWrite:0},contextWindow:216144,maxTokens:216144},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"Kimi K2.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262114,maxTokens:262114},"moonshotai/kimi-k2.6":{id:"moonshotai/kimi-k2.6",name:"Kimi K2.6",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.16,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"moonshotai/kimi-k2.7-code":{id:"moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.95,output:4,cacheRead:.19,cacheWrite:0},contextWindow:256e3,maxTokens:32768},"moonshotai/kimi-k2.7-code-highspeed":{id:"moonshotai/kimi-k2.7-code-highspeed",name:"Kimi K2.7 Code High Speed",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.9,output:8,cacheRead:.38,cacheWrite:0},contextWindow:262144,maxTokens:32768},"moonshotai/kimi-k3":{id:"moonshotai/kimi-k3",name:"Kimi K3",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"nvidia/nemotron-3-nano-30b-a3b":{id:"nvidia/nemotron-3-nano-30b-a3b",name:"Nemotron 3 Nano 30B A3B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.05,output:.24,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"nvidia/nemotron-3-super-120b-a12b":{id:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA Nemotron 3 Super 120B A12B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.15,output:.65,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:32e3},"nvidia/nemotron-3-ultra-550b-a55b":{id:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.12,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"nvidia/nemotron-nano-12b-v2-vl":{id:"nvidia/nemotron-nano-12b-v2-vl",name:"Nvidia Nemotron Nano 12B V2 VL",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"nvidia/nemotron-nano-9b-v2":{id:"nvidia/nemotron-nano-9b-v2",name:"Nvidia Nemotron Nano 9B V2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.06,output:.23,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-3.5-turbo":{id:"openai/gpt-3.5-turbo",name:"GPT-3.5 Turbo",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"GPT-4 Turbo",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"GPT-4.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"GPT-4.1 mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"GPT-4.1 nano",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4o":{id:"openai/gpt-4o",name:"GPT-4o",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"GPT-4o mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5":{id:"openai/gpt-5",name:"GPT-5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-chat":{id:"openai/gpt-5-chat",name:"GPT 5 Chat",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"GPT-5-Codex",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"GPT-5 mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"GPT-5 nano",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"GPT-5 pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"GPT-5.1-Codex",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"GPT 5.1 Codex Max",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"GPT 5.1 Codex Mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-instant":{id:"openai/gpt-5.1-instant",name:"GPT-5.1 Instant",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.1-thinking":{id:"openai/gpt-5.1-thinking",name:"GPT 5.1 Thinking",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"GPT 5.2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"GPT 5.2 Chat",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"GPT 5.2 Codex",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"GPT 5.2 ",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"GPT-5.3 Chat",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"GPT 5.3 Codex",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"GPT 5.4",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-mini":{id:"openai/gpt-5.4-mini",name:"GPT 5.4 Mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-nano":{id:"openai/gpt-5.4-nano",name:"GPT 5.4 Nano",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"GPT 5.4 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.5":{id:"openai/gpt-5.5",name:"GPT 5.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.5-pro":{id:"openai/gpt-5.5-pro",name:"GPT 5.5 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh",off:null,minimal:null,low:null}},"openai/gpt-5.6-luna":{id:"openai/gpt-5.6-luna",name:"GPT 5.6 Luna",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1,output:6,cacheRead:.1,cacheWrite:1.25},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.6-sol":{id:"openai/gpt-5.6-sol",name:"GPT 5.6 Sol",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:6.25},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-5.6-terra":{id:"openai/gpt-5.6-terra",name:"GPT 5.6 Terra",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:3.125},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:{xhigh:"xhigh"}},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.1,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.05,output:.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.037,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/o1":{id:"openai/o1",name:"o1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3":{id:"openai/o3",name:"o3",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"o3-deep-research",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini":{id:"openai/o3-mini",name:"o3-mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-pro":{id:"openai/o3-pro",name:"o3 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini":{id:"openai/o4-mini",name:"o4-mini",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"poolside/laguna-s-2.1":{id:"poolside/laguna-s-2.1",name:"Laguna S 2.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.1,output:.2,cacheRead:.01,cacheWrite:0},contextWindow:1e6,maxTokens:131072},"poolside/laguna-s-2.1-free":{id:"poolside/laguna-s-2.1-free",name:"Laguna S 2.1 Free",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:32768},"sakana/fugu-ultra":{id:"sakana/fugu-ultra",name:"Fugu Ultra",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"stepfun/step-3.5-flash":{id:"stepfun/step-3.5-flash",name:"StepFun 3.5 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.09,output:.3,cacheRead:.02,cacheWrite:0},contextWindow:262114,maxTokens:262114},"stepfun/step-3.7-flash":{id:"stepfun/step-3.7-flash",name:"Step 3.7 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.15,cacheRead:.04,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"thinkingmachines/inkling":{id:"thinkingmachines/inkling",name:"Inkling",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1,output:4.05,cacheRead:.17,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xai/grok-4.1-fast-non-reasoning":{id:"xai/grok-4.1-fast-non-reasoning",name:"Grok 4.1 Fast Non-Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"xai/grok-4.1-fast-reasoning":{id:"xai/grok-4.1-fast-reasoning",name:"Grok 4.1 Fast Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"xai/grok-4.20-multi-agent":{id:"xai/grok-4.20-multi-agent",name:"Grok 4.20 Multi-Agent",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.20-multi-agent-beta":{id:"xai/grok-4.20-multi-agent-beta",name:"Grok 4.20 Multi Agent Beta",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.20-non-reasoning":{id:"xai/grok-4.20-non-reasoning",name:"Grok 4.20 Non-Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.20-non-reasoning-beta":{id:"xai/grok-4.20-non-reasoning-beta",name:"Grok 4.20 Beta Non-Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!1,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.20-reasoning":{id:"xai/grok-4.20-reasoning",name:"Grok 4.20 Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.20-reasoning-beta":{id:"xai/grok-4.20-reasoning-beta",name:"Grok 4.20 Beta Reasoning",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:2e6,maxTokens:2e6},"xai/grok-4.3":{id:"xai/grok-4.3",name:"Grok 4.3",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:1e6},"xai/grok-4.5":{id:"xai/grok-4.5",name:"Grok 4.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.3,cacheWrite:0},contextWindow:5e5,maxTokens:5e5},"xai/grok-build-0.1":{id:"xai/grok-build-0.1",name:"Grok Build 0.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1,output:2,cacheRead:.2,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xiaomi/mimo-v2.5":{id:"xiaomi/mimo-v2.5",name:"MiMo M2.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:105e4,maxTokens:131100},"xiaomi/mimo-v2.5-pro":{id:"xiaomi/mimo-v2.5-pro",name:"MiMo V2.5 Pro",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.0036,cacheWrite:0},contextWindow:105e4,maxTokens:131e3},"zai/glm-4.5":{id:"zai/glm-4.5",name:"GLM 4.5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:128e3,maxTokens:96e3},"zai/glm-4.5-air":{id:"zai/glm-4.5-air",name:"GLM 4.5 Air",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},contextWindow:128e3,maxTokens:96e3},"zai/glm-4.5v":{id:"zai/glm-4.5v",name:"GLM 4.5V",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.8,cacheRead:.11,cacheWrite:0},contextWindow:66e3,maxTokens:16e3},"zai/glm-4.6":{id:"zai/glm-4.6",name:"GLM 4.6",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:2e5,maxTokens:96e3},"zai/glm-4.6v":{id:"zai/glm-4.6v",name:"GLM-4.6V",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:.3,output:.9,cacheRead:.05,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.6v-flash":{id:"zai/glm-4.6v-flash",name:"GLM-4.6V-Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.7":{id:"zai/glm-4.7",name:"GLM 4.7",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.12,cacheWrite:0},contextWindow:2e5,maxTokens:12e4},"zai/glm-4.7-flash":{id:"zai/glm-4.7-flash",name:"GLM 4.7 Flash",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.07,output:.4,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131e3},"zai/glm-4.7-flashx":{id:"zai/glm-4.7-flashx",name:"GLM 4.7 FlashX",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.06,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"zai/glm-5":{id:"zai/glm-5",name:"GLM 5",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:.95,output:3.15,cacheRead:.2,cacheWrite:0},contextWindow:202800,maxTokens:131100},"zai/glm-5-turbo":{id:"zai/glm-5-turbo",name:"GLM 5 Turbo",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},contextWindow:202800,maxTokens:131100},"zai/glm-5.1":{id:"zai/glm-5.1",name:"GLM 5.1",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.3,output:4.3,cacheRead:.26,cacheWrite:0},contextWindow:202e3,maxTokens:202e3},"zai/glm-5.2":{id:"zai/glm-5.2",name:"GLM 5.2",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},contextWindow:104e4,maxTokens:128e3},"zai/glm-5.2-fast":{id:"zai/glm-5.2-fast",name:"GLM 5.2 Fast",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text"],cost:{input:2.1,output:6.6,cacheRead:.21,cacheWrite:0},contextWindow:1e6,maxTokens:128e3},"zai/glm-5v-turbo":{id:"zai/glm-5v-turbo",name:"GLM 5V Turbo",api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",provider:"vercel-ai-gateway",reasoning:!0,input:["text","image"],cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},contextWindow:2e5,maxTokens:128e3}};var o1=i1;var r1={"grok-4.3":{id:"grok-4.3",name:"Grok 4.3",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:2.5,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:3e4,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}},"grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"xai",baseUrl:"https://api.x.ai/v1",compat:{supportsLongCacheRetention:!1},reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.3,cacheWrite:0},contextWindow:5e5,maxTokens:5e5,thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null}},"grok-build-0.1":{id:"grok-build-0.1",name:"Grok Build 0.1",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:2,cacheRead:.2,cacheWrite:0},contextWindow:256e3,maxTokens:256e3,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1}}};var s1=r1;var a1={"mimo-v2-flash":{id:"mimo-v2-flash",name:"MiMo-V2-Flash",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:262144,maxTokens:65536},"mimo-v2-omni":{id:"mimo-v2-omni",name:"MiMo-V2-Omni",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text","image"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:262144,maxTokens:131072},"mimo-v2-pro":{id:"mimo-v2-pro",name:"MiMo-V2-Pro",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.0036,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5":{id:"mimo-v2.5",name:"MiMo-V2.5",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text","image"],cost:{input:.14,output:.28,cacheRead:.0028,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5-pro":{id:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:.435,output:.87,cacheRead:.0036,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5-pro-ultraspeed":{id:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",api:"openai-completions",provider:"xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:1.305,output:2.61,cacheRead:.0108,cacheWrite:0},contextWindow:1048576,maxTokens:131072}};var l1=a1;var c1={"mimo-v2-pro":{id:"mimo-v2-pro",name:"MiMo-V2-Pro",api:"openai-completions",provider:"xiaomi-token-plan-ams",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5":{id:"mimo-v2.5",name:"MiMo-V2.5",api:"openai-completions",provider:"xiaomi-token-plan-ams",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5-pro":{id:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",api:"openai-completions",provider:"xiaomi-token-plan-ams",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072}};var u1=c1;var d1={"mimo-v2-pro":{id:"mimo-v2-pro",name:"MiMo-V2-Pro",api:"openai-completions",provider:"xiaomi-token-plan-cn",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5":{id:"mimo-v2.5",name:"MiMo-V2.5",api:"openai-completions",provider:"xiaomi-token-plan-cn",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5-pro":{id:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",api:"openai-completions",provider:"xiaomi-token-plan-cn",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072}};var p1=d1;var m1={"mimo-v2-pro":{id:"mimo-v2-pro",name:"MiMo-V2-Pro",api:"openai-completions",provider:"xiaomi-token-plan-sgp",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5":{id:"mimo-v2.5",name:"MiMo-V2.5",api:"openai-completions",provider:"xiaomi-token-plan-sgp",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072},"mimo-v2.5-pro":{id:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",api:"openai-completions",provider:"xiaomi-token-plan-sgp",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",compat:{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:"deepseek"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:131072}};var h1=m1;var g1={"glm-4.5-air":{id:"glm-4.5-air",name:"GLM-4.5-Air",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai"},contextWindow:131072,maxTokens:98304},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:204800,maxTokens:131072},"glm-5-turbo":{id:"glm-5-turbo",name:"GLM-5-Turbo",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,thinkingLevelMap:{minimal:null,low:"high",medium:"high",high:"high",max:"max"},input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:1e6,maxTokens:131072},"glm-5v-turbo":{id:"glm-5v-turbo",name:"GLM-5V-Turbo",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072}};var f1=g1;var v1={"glm-4.5-air":{id:"glm-4.5-air",name:"GLM-4.5-Air",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai"},contextWindow:131072,maxTokens:98304},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:204800,maxTokens:131072},"glm-5-turbo":{id:"glm-5-turbo",name:"GLM-5-Turbo",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072},"glm-5.1":{id:"glm-5.1",name:"GLM-5.1",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072},"glm-5.2":{id:"glm-5.2",name:"GLM-5.2",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,thinkingLevelMap:{minimal:null,low:"high",medium:"high",high:"high",max:"max"},input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!0,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:1e6,maxTokens:131072},"glm-5v-turbo":{id:"glm-5v-turbo",name:"GLM-5V-Turbo",api:"openai-completions",provider:"zai-coding-cn",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1,thinkingFormat:"zai",zaiToolStream:!0},contextWindow:2e5,maxTokens:131072}};var b1=v1;fe();fe();var C$={name:"AWS credentials or bearer token",login:async t=>{let e=await t.prompt({type:"select",message:"Select Amazon Bedrock authentication method:",options:[{id:"bearer-token",label:"Bearer token"},{id:"aws-profile",label:"AWS profile"},{id:"credential-chain",label:"Existing AWS credential chain"}]});if(e==="bearer-token")return{type:"api_key",key:await t.prompt({type:"secret",message:"Enter Amazon Bedrock bearer token"})};if(t.notify({type:"info",message:"Amazon Bedrock supports AWS profiles, IAM credentials, and role-based credentials.",links:[{label:"AWS credential provider chain",url:"https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html"}]}),e==="aws-profile")return{type:"api_key",env:{AWS_PROFILE:await t.prompt({type:"text",message:"Enter AWS profile name"})}};if(e!=="credential-chain")throw new Error(`Unknown Amazon Bedrock auth method: ${e}`);return await t.prompt({type:"text",message:"Configure AWS credentials, then press Enter to continue"}),{type:"api_key"}},resolve:async({ctx:t,credential:e})=>{if(e?.key)return{auth:{apiKey:e.key},env:e.env,source:"stored credential"};if(await t.env("AWS_BEARER_TOKEN_BEDROCK"))return{auth:{},source:"AWS_BEARER_TOKEN_BEDROCK"};if(e?.env?.AWS_PROFILE??await t.env("AWS_PROFILE"))return{auth:{},env:e?.env,source:e?.env?.AWS_PROFILE?"stored credential":"AWS_PROFILE"};if(await t.env("AWS_ACCESS_KEY_ID")&&await t.env("AWS_SECRET_ACCESS_KEY"))return{auth:{},source:"AWS access keys"};if(await t.env("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"))return{auth:{},source:"ECS task role"};if(await t.env("AWS_CONTAINER_CREDENTIALS_FULL_URI"))return{auth:{},source:"ECS task role"};if(await t.env("AWS_WEB_IDENTITY_TOKEN_FILE"))return{auth:{},source:"web identity token"}}};function x1(){return Q({id:"amazon-bedrock",name:"Amazon Bedrock",auth:{apiKey:C$},models:Object.values(eC),api:rp()})}fe();function y1(){return Q({id:"ant-ling",name:"Ant Ling",baseUrl:"https://api.ant-ling.com/v1",auth:{apiKey:ne("Ant Ling API key",["ANT_LING_API_KEY"])},models:Object.values(nC),api:ge()})}var La=t=>import(import.meta.url.endsWith(".js")?t.replace(/\.ts$/,".js"):t),Bn;var w1=async()=>Bn?Bn.anthropic():(await La("./anthropic.ts")).anthropicOAuth,k1=async()=>Bn?Bn.openaiCodex():(await La("./openai-codex.ts")).openaiCodexOAuth,S1=async()=>Bn?Bn.githubCopilot():(await La("./github-copilot.ts")).githubCopilotOAuth,T1=async()=>Bn?Bn.kimiCoding():(await La("./kimi-coding.ts")).kimiCodingOAuth,C1=async()=>Bn?Bn.xai():(await La("./xai.ts")).xaiOAuth,M1=async t=>Bn?Bn.radius(t):(await La("./radius.ts")).createRadiusOAuth(t);fe();function R1(){return Q({id:"anthropic",name:"Anthropic",baseUrl:"https://api.anthropic.com",auth:{apiKey:ne("Anthropic API key",["ANTHROPIC_OAUTH_TOKEN","ANTHROPIC_API_KEY"]),oauth:Dn({name:"Anthropic (Claude Pro/Max)",load:w1})},models:Object.values(oC),api:at()})}fe();function P1(){return Q({id:"azure-openai-responses",name:"Azure OpenAI",auth:{apiKey:ne("Azure OpenAI API key",["AZURE_OPENAI_API_KEY"])},models:Object.values(sC),api:op()})}fe();function I1(){return Q({id:"cerebras",name:"Cerebras",baseUrl:"https://api.cerebras.ai/v1",auth:{apiKey:ne("Cerebras API key",["CEREBRAS_API_KEY"])},models:Object.values(lC),api:ge()})}fe();var Qf="CLOUDFLARE_API_KEY",M$="CLOUDFLARE_ACCOUNT_ID",R$="CLOUDFLARE_GATEWAY_ID";async function Vf(t,e,n){return(n?t===Qf?n.key:n.env?.[t]:void 0)??await e.env(t)}async function E1(t,e,n){let i=await Vf(Qf,e,n),o=await Vf(M$,e,n),r=t==="ai-gateway"?await Vf(R$,e,n):void 0;if(!(!i||!o||t==="ai-gateway"&&!r))return{apiKey:i,env:{CLOUDFLARE_ACCOUNT_ID:o,...r?{CLOUDFLARE_GATEWAY_ID:r}:{}},source:n?"stored credential":Qf}}function A1(){return{name:"Cloudflare API key",login:async t=>{let e=await t.prompt({type:"secret",message:"Enter Cloudflare API key"}),n=await t.prompt({type:"text",message:"Enter Cloudflare account ID"});return{type:"api_key",key:e,env:{CLOUDFLARE_ACCOUNT_ID:n}}},resolve:async({ctx:t,credential:e})=>{let n=await E1("workers-ai",t,e);if(n)return{auth:{apiKey:n.apiKey},env:n.env,source:n.source}}}}function _1(){return{name:"Cloudflare API key",login:async t=>{let e=await t.prompt({type:"secret",message:"Enter Cloudflare API key"}),n=await t.prompt({type:"text",message:"Enter Cloudflare account ID"}),i=await t.prompt({type:"text",message:"Enter Cloudflare AI Gateway ID"});return{type:"api_key",key:e,env:{CLOUDFLARE_ACCOUNT_ID:n,CLOUDFLARE_GATEWAY_ID:i}}},resolve:async({ctx:t,credential:e})=>{let n=await E1("ai-gateway",t,e);if(n)return{auth:{headers:{"cf-aig-authorization":`Bearer ${n.apiKey}`,Authorization:null,"x-api-key":null}},env:n.env,source:n.source}}}}var Yf="CLOUDFLARE_ACCOUNT_ID",Jf="CLOUDFLARE_GATEWAY_ID";function O1(t,e){if(!e)return t;let n=t.baseUrl.replaceAll(`{${Yf}}`,e[Yf]??`{${Yf}}`).replaceAll(`{${Jf}}`,e[Jf]??`{${Jf}}`);return n===t.baseUrl?t:{...t,baseUrl:n}}function Wa(t){return{stream:(e,n,i)=>t.stream(O1(e,i?.env),n,i),streamSimple:(e,n,i)=>t.streamSimple(O1(e,i?.env),n,i)}}function L1(){return Q({id:"cloudflare-ai-gateway",name:"Cloudflare AI Gateway",auth:{apiKey:_1()},models:Object.values(uC),api:{"anthropic-messages":Wa(at()),"openai-completions":Wa(ge()),"openai-responses":Wa(on())}})}fe();function W1(){return Q({id:"cloudflare-workers-ai",name:"Cloudflare Workers AI",auth:{apiKey:A1()},models:Object.values(pC),api:Wa(ge())})}fe();function F1(){return Q({id:"deepseek",name:"DeepSeek",baseUrl:"https://api.deepseek.com",auth:{apiKey:ne("DeepSeek API key",["DEEPSEEK_API_KEY"])},models:Object.values(hC),api:ge()})}fe();function D1(){return Q({id:"fireworks",name:"Fireworks",baseUrl:"https://api.fireworks.ai/inference",auth:{apiKey:ne("Fireworks API key",["FIREWORKS_API_KEY"])},models:Object.values(fC),api:{"anthropic-messages":at(),"openai-completions":ge()}})}fe();function U1(){return Q({id:"github-copilot",name:"GitHub Copilot",baseUrl:"https://api.individual.githubcopilot.com",auth:{apiKey:ne("GitHub Copilot token",["COPILOT_GITHUB_TOKEN"]),oauth:Dn({name:"GitHub Copilot",load:S1})},models:Object.values(bC),filterModels:(t,e)=>{if(e?.type!=="oauth")return t;let n=e.availableModelIds;if(!Array.isArray(n)||!n.every(o=>typeof o=="string"))return t;let i=new Set(n);return t.filter(o=>i.has(o.id))},api:{"anthropic-messages":at(),"openai-completions":ge(),"openai-responses":on()}})}fe();function $1(){return Q({id:"google",name:"Google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",auth:{apiKey:ne("Gemini API key",["GEMINI_API_KEY"])},models:Object.values(yC),api:Aa()})}fe();var P$="~/.config/gcloud/application_default_credentials.json",I$={name:"Google Cloud credentials",login:async t=>{let e=await t.prompt({type:"select",message:"Select Google Vertex AI authentication method:",options:[{id:"api-key",label:"Google Cloud API key"},{id:"adc",label:"Application Default Credentials"},{id:"service-account",label:"Service account credentials file"}]});if(e==="api-key")return{type:"api_key",key:await t.prompt({type:"secret",message:"Enter Google Cloud API key"})};if(e!=="adc"&&e!=="service-account")throw new Error(`Unknown Google Vertex AI auth method: ${e}`);t.notify({type:"info",message:e==="adc"?"Run `gcloud auth application-default login`, then provide the project and location.":"Provide a service account credentials file, project, and location.",links:[{label:"Application Default Credentials",url:"https://cloud.google.com/docs/authentication/provide-credentials-adc"}]});let n=await t.prompt({type:"text",message:"Enter Google Cloud project ID"}),i=await t.prompt({type:"text",message:"Enter Google Cloud location"}),o=e==="service-account"?await t.prompt({type:"text",message:"Enter service account credentials file path"}):void 0;return{type:"api_key",env:{GOOGLE_CLOUD_PROJECT:n,GOOGLE_CLOUD_LOCATION:i,...o?{GOOGLE_APPLICATION_CREDENTIALS:o}:{}}}},resolve:async({ctx:t,credential:e})=>{let n=e?.key??await t.env("GOOGLE_CLOUD_API_KEY");if(n)return{auth:{apiKey:n},source:e?.key?"stored credential":"GOOGLE_CLOUD_API_KEY"};let i=e?.env?.GOOGLE_APPLICATION_CREDENTIALS??await t.env("GOOGLE_APPLICATION_CREDENTIALS"),o=await t.fileExists(i??P$),r=e?.env?.GOOGLE_CLOUD_PROJECT??await t.env("GOOGLE_CLOUD_PROJECT")??await t.env("GCLOUD_PROJECT"),s=e?.env?.GOOGLE_CLOUD_LOCATION??await t.env("GOOGLE_CLOUD_LOCATION");if(o&&r&&s)return{auth:{},env:e?.env,source:e?"stored credential":"gcloud application default credentials"}}};function N1(){return Q({id:"google-vertex",name:"Google Vertex AI",auth:{apiKey:I$},models:Object.values(kC),api:hp()})}fe();function B1(){return Q({id:"groq",name:"Groq",baseUrl:"https://api.groq.com/openai/v1",auth:{apiKey:ne("Groq API key",["GROQ_API_KEY"])},models:Object.values(TC),api:ge()})}fe();function j1(){return Q({id:"huggingface",name:"Hugging Face",baseUrl:"https://router.huggingface.co/v1",auth:{apiKey:ne("Hugging Face token",["HF_TOKEN"])},models:Object.values(MC),api:ge()})}fe();function q1(){return Q({id:"kimi-coding",name:"Kimi For Coding",baseUrl:"https://api.kimi.com/coding",auth:{apiKey:ne("Kimi API key",["KIMI_API_KEY"]),oauth:Dn({name:"Kimi Code (subscription)",loginLabel:"Sign in with Kimi Code",load:T1})},models:Object.values(PC),api:at()})}fe();function K1(){return Q({id:"minimax",name:"MiniMax",baseUrl:"https://api.minimax.io/anthropic",auth:{apiKey:ne("MiniMax API key",["MINIMAX_API_KEY"])},models:Object.values(EC),api:at()})}fe();function G1(){return Q({id:"minimax-cn",name:"MiniMax CN",baseUrl:"https://api.minimaxi.com/anthropic",auth:{apiKey:ne("MiniMax CN API key",["MINIMAX_CN_API_KEY"])},models:Object.values(_C),api:at()})}fe();function z1(){return Q({id:"mistral",name:"Mistral",baseUrl:"https://api.mistral.ai",auth:{apiKey:ne("Mistral API key",["MISTRAL_API_KEY"])},models:Object.values(LC),api:gp()})}fe();function H1(){return Q({id:"moonshotai",name:"Moonshot AI",baseUrl:"https://api.moonshot.ai/v1",auth:{apiKey:ne("Moonshot AI API key",["MOONSHOT_API_KEY"])},models:Object.values(FC),api:ge()})}fe();function V1(){return Q({id:"moonshotai-cn",name:"Moonshot AI CN",baseUrl:"https://api.moonshot.cn/v1",auth:{apiKey:ne("Moonshot AI API key",["MOONSHOT_API_KEY"])},models:Object.values(UC),api:ge()})}fe();function Q1(){return Q({id:"nvidia",name:"NVIDIA",baseUrl:"https://integrate.api.nvidia.com/v1",auth:{apiKey:ne("NVIDIA API key",["NVIDIA_API_KEY"])},models:Object.values(NC),api:ge()})}fe();function Y1(){return Q({id:"openai",name:"OpenAI",baseUrl:"https://api.openai.com/v1",auth:{apiKey:ne("OpenAI API key",["OPENAI_API_KEY"])},models:Object.values(jC),api:on()})}fe();function J1(){return Q({id:"openai-codex",name:"OpenAI Codex",baseUrl:"https://chatgpt.com/backend-api",auth:{oauth:Dn({name:"OpenAI (ChatGPT Plus/Pro)",load:k1})},models:Object.values(KC),api:xp()})}fe();function X1(){return Q({id:"opencode",name:"OpenCode Zen",auth:{apiKey:ne("OpenCode API key",["OPENCODE_API_KEY"])},models:Object.values(zC),api:{"anthropic-messages":at(),"google-generative-ai":Aa(),"openai-completions":ge(),"openai-responses":on()}})}fe();function Z1(){return Q({id:"opencode-go",name:"OpenCode Zen Go",auth:{apiKey:ne("OpenCode API key",["OPENCODE_API_KEY"])},models:Object.values(VC),api:{"anthropic-messages":at(),"openai-completions":ge(),"openai-responses":on()}})}fe();function eM(){return Q({id:"openrouter",name:"OpenRouter",baseUrl:"https://openrouter.ai/api/v1",auth:{apiKey:ne("OpenRouter API key",["OPENROUTER_API_KEY"])},models:Object.values(YC),api:ge()})}fe();function tM(){return Q({id:"qwen-token-plan",name:"Qwen Token Plan",baseUrl:"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",auth:{apiKey:ne("Qwen Token Plan API key",["QWEN_TOKEN_PLAN_API_KEY"])},models:Object.values(XC),api:ge()})}fe();function nM(){return Q({id:"qwen-token-plan-cn",name:"Qwen Token Plan CN",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",auth:{apiKey:ne("Qwen Token Plan CN API key",["QWEN_TOKEN_PLAN_CN_API_KEY"])},models:Object.values(e1),api:ge()})}var iM="https://radius.pi.dev";function E$(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=t;return typeof e.id=="string"&&typeof e.name=="string"&&typeof e.reasoning=="boolean"&&Array.isArray(e.input)&&typeof e.cost=="object"&&e.cost!==null&&!Array.isArray(e.cost)&&typeof e.contextWindow=="number"&&typeof e.maxTokens=="number"}function oM(t){if(typeof t!="object"||t===null||Array.isArray(t))return;let{baseUrl:e,models:n}=t;if(!(typeof e!="string"||!Array.isArray(n)))return{baseUrl:e,models:n.filter(E$).map(i=>({...i}))}}function rM(t){return(/^https?:\/\//iu.test(t)?t:`https://${t}`).replace(/\/+$/u,"")}function A$(t){return oM(t?.gatewayConfig)}function Xf(t,e){return e.models.map(n=>({...n,api:"pi-messages",provider:t,baseUrl:e.baseUrl}))}function Zf(t,e){let n=A$(e);return n?Xf(t,n):[]}function _$(t){let e=t.trim();return e.length>512?`${e.slice(0,512)}\u2026`:e}async function sM(t,e,n){let i={accept:"application/json"};e&&(i.authorization=`Bearer ${e}`);let o=await fetch(new URL("/v1/config",t),{headers:i,signal:n});if(!o.ok)throw new Error(`Could not load Radius config from ${t}: ${o.status}: ${_$(await o.text())}`);let r=oM(await o.json());if(!r)throw new Error(`Invalid Radius config from ${t}`);return r}function aM(t={}){let e=t.id??"radius",n=t.name??"Radius",i=rM(t.gateway??iM),o=Zf(e,void 0),r,s=yp();return{id:e,name:n,auth:{apiKey:ne("Radius API key",["RADIUS_API_KEY"]),oauth:Dn({name:n,load:()=>M1({name:n,gateway:i})})},getModels:()=>o,refreshModels:a=>(r??=(async()=>{try{let l=await a.store.read();if(l&&(o=l.models.filter(d=>d.provider===e)),!l&&a.credential?.type==="oauth"){let d=Zf(e,a.credential);d.length>0&&(o=d,await a.store.write({models:d,checkedAt:Date.now()}))}if(!a.allowNetwork||a.signal?.aborted)return;let c=a.credential?.type==="oauth"?a.credential.access:a.credential?.key,u=await sM(i,c,a.signal);if(a.signal?.aborted)return;o=Xf(e,u),await a.store.write({models:o,checkedAt:Date.now()})}finally{r=void 0}})(),r),stream:(a,l,c)=>s.stream(a,l,c),streamSimple:(a,l,c)=>s.streamSimple(a,l,c)}}fe();function lM(){return Q({id:"together",name:"Together",baseUrl:"https://api.together.ai/v1",auth:{apiKey:ne("Together API key",["TOGETHER_API_KEY"])},models:Object.values(n1),api:ge()})}fe();function cM(){return Q({id:"vercel-ai-gateway",name:"Vercel AI Gateway",baseUrl:"https://ai-gateway.vercel.sh",auth:{apiKey:ne("Vercel AI Gateway API key",["AI_GATEWAY_API_KEY"])},models:Object.values(o1),api:at()})}fe();function uM(){return Q({id:"xai",name:"xAI",baseUrl:"https://api.x.ai/v1",auth:{apiKey:ne("xAI API key",["XAI_API_KEY"]),oauth:Dn({name:"xAI (Grok/X subscription)",loginLabel:"Sign in with SuperGrok or X Premium",load:C1})},models:Object.values(s1),api:{"openai-completions":ge(),"openai-responses":on()}})}fe();function dM(){return Q({id:"xiaomi",name:"Xiaomi",baseUrl:"https://api.xiaomimimo.com/v1",auth:{apiKey:ne("Xiaomi API key",["XIAOMI_API_KEY"])},models:Object.values(l1),api:ge()})}fe();function pM(){return Q({id:"xiaomi-token-plan-ams",name:"Xiaomi Token Plan AMS",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",auth:{apiKey:ne("Xiaomi Token Plan AMS API key",["XIAOMI_TOKEN_PLAN_AMS_API_KEY"])},models:Object.values(u1),api:ge()})}fe();function mM(){return Q({id:"xiaomi-token-plan-cn",name:"Xiaomi Token Plan CN",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",auth:{apiKey:ne("Xiaomi Token Plan CN API key",["XIAOMI_TOKEN_PLAN_CN_API_KEY"])},models:Object.values(p1),api:ge()})}fe();function hM(){return Q({id:"xiaomi-token-plan-sgp",name:"Xiaomi Token Plan SGP",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",auth:{apiKey:ne("Xiaomi Token Plan SGP API key",["XIAOMI_TOKEN_PLAN_SGP_API_KEY"])},models:Object.values(h1),api:ge()})}fe();function gM(){return Q({id:"zai",name:"Z.AI",baseUrl:"https://api.z.ai/api/coding/paas/v4",auth:{apiKey:ne("Z.AI API key",["ZAI_API_KEY"])},models:Object.values(f1),api:ge()})}fe();function fM(){return Q({id:"zai-coding-cn",name:"Z.AI Coding CN",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",auth:{apiKey:ne("Z.AI Coding CN API key",["ZAI_CODING_CN_API_KEY"])},models:Object.values(b1),api:ge()})}function O$(){return[x1(),y1(),R1(),P1(),I1(),L1(),W1(),F1(),D1(),U1(),$1(),N1(),B1(),j1(),q1(),K1(),G1(),z1(),H1(),V1(),Q1(),Y1(),J1(),X1(),Z1(),eM(),tM(),nM(),aM(),lM(),cM(),uM(),dM(),pM(),mM(),hM(),gM(),fM()]}function vM(t){let e=gS(t);for(let n of O$())e.setProvider(n);return e}var bM=new Map;function L$(t,e){return(n,i,o)=>{if(n.api!==t)throw new Error(`Mismatched api: ${n.api} expected ${t}`);return e(n,i,o)}}function W$(t,e){return(n,i,o)=>{if(n.api!==t)throw new Error(`Mismatched api: ${n.api} expected ${t}`);return e(n,i,o)}}function F$(t,e){bM.set(t.api,{provider:{api:t.api,stream:L$(t.api,t.stream),streamSimple:W$(t.api,t.streamSimple)},sourceId:e})}function wp(t){return bM.get(t)?.provider}var D$=[["anthropic-messages",at()],["openai-completions",ge()],["openai-responses",on()],["openai-codex-responses",xp()],["azure-openai-responses",op()],["google-generative-ai",Aa()],["google-vertex",hp()],["mistral-conversations",gp()],["bedrock-converse-stream",rp()],["pi-messages",yp()]],xM=new Map;function U$(){for(let[t,e]of D$)wp(t)||F$({api:t,stream:e.stream,streamSimple:e.streamSimple}),xM.set(t,wp(t))}U$();var ev=vM(),$$="<authenticated>";function yM(t){return typeof t=="string"&&t.trim().length>0}function kp(t,e){if(yM(e?.apiKey))return e;let n=XT(t.provider,e?.env);return!n||n===$$?e:{...e,apiKey:n}}function wM(t){return yM(t?.apiKey)||typeof t?.headers?.["cf-aig-authorization"]=="string"}function kM(t){if(wp(t.api)!==xM.get(t.api))return;let e=ev.getProvider(t.provider);return e?.getModels().some(n=>n.api===t.api)?e:void 0}function SM(t){let e=wp(t);if(!e)throw new Error(`No API provider registered for api: ${t}`);return e}function N$(t,e,n){let i=kM(t);return i?t.provider.startsWith("cloudflare-")&&!wM(n)?ev.stream(t,e,n):i.stream(t,e,kp(t,n)):SM(t.api).stream(t,e,kp(t,n))}async function TM(t,e,n){return N$(t,e,n).result()}function CM(t,e,n){let i=kM(t);return i?t.provider.startsWith("cloudflare-")&&!wM(n)?ev.streamSimple(t,e,n):i.streamSimple(t,e,kp(t,n)):SM(t.api).streamSimple(t,e,kp(t,n))}import*as Pn from"node:fs";import*as qr from"node:path";import{spawn as B$}from"child_process";import{readdirSync as j$,statSync as MM}from"fs";import{homedir as RM}from"os";import{basename as tv,dirname as Tp,join as No}from"path";function Sp(t,e){let n=t.toLowerCase(),i=e.toLowerCase(),o=u=>{if(u.length===0)return{matches:!0,score:0};if(u.length>i.length)return{matches:!1,score:0};let d=0,p=0,m=-1,g=0;for(let h=0;h<i.length&&d<u.length;h++)if(i[h]===u[d]){let f=h===0||/[\s\-_./:]/.test(i[h-1]);m===h-1?(g++,p-=g*5):(g=0,m>=0&&(p+=(h-m-1)*2)),f&&(p-=10),p+=h*.1,m=h,d++}return d<u.length?{matches:!1,score:0}:(u===i&&(p-=100),{matches:!0,score:p})},r=o(n);if(r.matches)return r;let s=n.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/),a=n.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/),l=s?`${s.groups?.digits??""}${s.groups?.letters??""}`:a?`${a.groups?.letters??""}${a.groups?.digits??""}`:"";if(!l)return r;let c=o(l);return c.matches?{matches:!0,score:c.score+5}:r}function Gt(t,e,n){if(!e.trim())return t;let i=e.trim().split(/[\s/]+/).filter(r=>r.length>0);if(i.length===0)return t;let o=[];for(let r of t){let s=n(r),a=0,l=!0;for(let c of i){let u=Sp(c,s);if(u.matches)a+=u.score;else{l=!1;break}}l&&o.push({item:r,totalScore:a})}return o.sort((r,s)=>r.totalScore-s.totalScore),o.map(r=>r.item)}var OM=new Set([" "," ",'"',"'","="]);function Ar(t){return t.replace(/\\/g,"/")}function q$(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K$(t){let e=Ar(t);if(!e.includes("/"))return e;let n=e.endsWith("/"),i=e.replace(/^\/+|\/+$/g,"");if(!i)return e;let o="[\\\\/]",r=i.split("/").filter(Boolean).map(a=>q$(a));if(r.length===0)return e;let s=r.join(o);return n&&(s+=o),s}function PM(t){for(let e=t.length-1;e>=0;e-=1)if(OM.has(t[e]??""))return e;return-1}function G$(t){let e=!1,n=-1;for(let i=0;i<t.length;i+=1)t[i]==='"'&&(e=!e,e&&(n=i));return e?n:null}function IM(t,e){return e===0||OM.has(t[e-1]??"")}function EM(t){let e=G$(t);return e===null?null:e>0&&t[e-1]==="@"?IM(t,e-1)?t.slice(e-1):null:IM(t,e)?t.slice(e):null}function AM(t){return t.startsWith('@"')?{rawPrefix:t.slice(2),isAtPrefix:!0,isQuotedPrefix:!0}:t.startsWith('"')?{rawPrefix:t.slice(1),isAtPrefix:!1,isQuotedPrefix:!0}:t.startsWith("@")?{rawPrefix:t.slice(1),isAtPrefix:!0,isQuotedPrefix:!1}:{rawPrefix:t,isAtPrefix:!1,isQuotedPrefix:!1}}function _M(t,e){let n=e.isQuotedPrefix||t.includes(" "),i=e.isAtPrefix?"@":"";return n?`${`${i}"`}${t}"`:`${i}${t}`}async function z$(t,e,n,i,o){let r=["--base-directory",t,"--max-results",String(i),"--type","f","--type","d","--follow","--hidden","--exclude",".git","--exclude",".git/*","--exclude",".git/**"];return Ar(n).includes("/")&&r.push("--full-path"),n&&r.push(K$(n)),await new Promise(s=>{if(o.aborted){s([]);return}let a=B$(e,r,{stdio:["ignore","pipe","pipe"]}),l="",c=!1,u=p=>{c||(c=!0,o.removeEventListener("abort",d),s(p))},d=()=>{a.exitCode===null&&a.kill("SIGKILL")};o.addEventListener("abort",d,{once:!0}),a.stdout.setEncoding("utf-8"),a.stdout.on("data",p=>{l+=p}),a.on("error",()=>{u([])}),a.on("close",p=>{if(o.aborted||p!==0||!l){u([]);return}let m=l.trim().split(`
36
36
  `).filter(Boolean),g=[];for(let h of m){let f=Ar(h),b=f.endsWith("/"),x=b?f.slice(0,-1):f;x===".git"||x.startsWith(".git/")||x.includes("/.git/")||g.push({path:f,isDirectory:b})}u(g)})})}var Ic=class{constructor(e=[],n,i=null){this.commands=e,this.basePath=n,this.fdPath=i}async getSuggestions(e,n,i,o){let s=(e[n]||"").slice(0,i),a=this.extractAtPrefix(s);if(a){let{rawPrefix:u,isQuotedPrefix:d}=AM(a),p=await this.getFuzzyFileSuggestions(u,{isQuotedPrefix:d,signal:o.signal});return p.length===0?null:{items:p,prefix:a}}if(!o.force&&s.startsWith("/")){let u=s.indexOf(" ");if(u===-1){let h=s.slice(1),f=this.commands.map(x=>{let y="name"in x?x.name:x.value,T="argumentHint"in x&&x.argumentHint?x.argumentHint:void 0,P=x.description??"",I=T?P?`${T} \u2014 ${P}`:T:P;return{name:y,label:y,description:I||void 0}}),b=Gt(f,h,x=>x.name).map(x=>({value:x.name,label:x.label,...x.description&&{description:x.description}}));return b.length===0?null:{items:b,prefix:s}}let d=s.slice(1,u),p=s.slice(u+1),m=this.commands.find(h=>("name"in h?h.name:h.value)===d);if(!m||!("getArgumentCompletions"in m)||!m.getArgumentCompletions)return null;let g=await m.getArgumentCompletions(p);return!Array.isArray(g)||g.length===0?null:{items:g,prefix:p}}let l=this.extractPathPrefix(s,o.force??!1);if(l===null)return null;let c=this.getFileSuggestions(l);return c.length===0?null:{items:c,prefix:l}}applyCompletion(e,n,i,o,r){let s=e[n]||"",a=s.slice(0,i-r.length),l=s.slice(i),c=r.startsWith('"')||r.startsWith('@"'),u=l.startsWith('"'),d=o.value.endsWith('"'),p=c&&d&&u?l.slice(1):l;if(r.startsWith("/")&&a.trim()===""&&!r.slice(1).includes("/")){let T=`${a}/${o.value} ${p}`,P=[...e];return P[n]=T,{lines:P,cursorLine:n,cursorCol:a.length+o.value.length+2}}if(r.startsWith("@")){let T=o.label.endsWith("/"),P=T?"":" ",I=`${a+o.value}${P}${p}`,W=[...e];W[n]=I;let D=o.value.endsWith('"'),_=T&&D?o.value.length-1:o.value.length;return{lines:W,cursorLine:n,cursorCol:a.length+_+P.length}}let g=s.slice(0,i);if(g.includes("/")&&g.includes(" ")){let T=a+o.value+p,P=[...e];P[n]=T;let I=o.label.endsWith("/"),W=o.value.endsWith('"'),D=I&&W?o.value.length-1:o.value.length;return{lines:P,cursorLine:n,cursorCol:a.length+D}}let h=a+o.value+p,f=[...e];f[n]=h;let b=o.label.endsWith("/"),x=o.value.endsWith('"'),y=b&&x?o.value.length-1:o.value.length;return{lines:f,cursorLine:n,cursorCol:a.length+y}}extractAtPrefix(e){let n=EM(e);if(n?.startsWith('@"'))return n;let i=PM(e),o=i===-1?0:i+1;return e[o]==="@"?e.slice(o):null}extractPathPrefix(e,n=!1){let i=EM(e);if(i)return i;let o=PM(e),r=o===-1?e:e.slice(o+1);return n||r.includes("/")||r.startsWith(".")||r.startsWith("~/")||r===""&&e.endsWith(" ")?r:null}expandHomePath(e){if(e.startsWith("~/")){let n=No(RM(),e.slice(2));return e.endsWith("/")&&!n.endsWith("/")?`${n}/`:n}else if(e==="~")return RM();return e}resolveScopedFuzzyQuery(e){let n=Ar(e),i=n.lastIndexOf("/");if(i===-1)return null;let o=n.slice(0,i+1),r=n.slice(i+1),s;o.startsWith("~/")?s=this.expandHomePath(o):o.startsWith("/")?s=o:s=No(this.basePath,o);try{if(!MM(s).isDirectory())return null}catch{return null}return{baseDir:s,query:r,displayBase:o}}scopedPathForDisplay(e,n){let i=Ar(n);return e==="/"?`/${i}`:`${Ar(e)}${i}`}getFileSuggestions(e){try{let n,i,{rawPrefix:o,isAtPrefix:r,isQuotedPrefix:s}=AM(e),a=o;if(a.startsWith("~")&&(a=this.expandHomePath(a)),o===""||o==="./"||o==="../"||o==="~"||o==="~/"||o==="/"||r&&o==="")o.startsWith("~")||a.startsWith("/")?n=a:n=No(this.basePath,a),i="";else if(o.endsWith("/"))o.startsWith("~")||a.startsWith("/")?n=a:n=No(this.basePath,a),i="";else{let d=Tp(a),p=tv(a);o.startsWith("~")||a.startsWith("/")?n=d:n=No(this.basePath,d),i=p}let c=j$(n,{withFileTypes:!0}),u=[];for(let d of c){if(!d.name.toLowerCase().startsWith(i.toLowerCase()))continue;let p=d.isDirectory();if(!p&&d.isSymbolicLink())try{let x=No(n,d.name);p=MM(x).isDirectory()}catch{}let m,g=d.name,h=o;if(h.endsWith("/"))m=h+g;else if(h.includes("/")||h.includes("\\"))if(h.startsWith("~/")){let x=h.slice(2),y=Tp(x);m=`~/${y==="."?g:No(y,g)}`}else if(h.startsWith("/")){let x=Tp(h);x==="/"?m=`/${g}`:m=`${x}/${g}`}else m=No(Tp(h),g),h.startsWith("./")&&!m.startsWith("./")&&(m=`./${m}`);else h.startsWith("~")?m=`~/${g}`:m=g;m=Ar(m);let f=p?`${m}/`:m,b=_M(f,{isDirectory:p,isAtPrefix:r,isQuotedPrefix:s});u.push({value:b,label:g+(p?"/":"")})}return u.sort((d,p)=>{let m=d.value.endsWith("/"),g=p.value.endsWith("/");return m&&!g?-1:!m&&g?1:d.label.localeCompare(p.label)}),u}catch{return[]}}scoreEntry(e,n,i){let r=tv(e).toLowerCase(),s=n.toLowerCase(),a=0;return r===s?a=100:r.startsWith(s)?a=80:r.includes(s)?a=50:e.toLowerCase().includes(s)&&(a=30),i&&a>0&&(a+=10),a}async getFuzzyFileSuggestions(e,n){if(!this.fdPath||n.signal.aborted)return[];try{let i=this.resolveScopedFuzzyQuery(e),o=i?.baseDir??this.basePath,r=i?.query??e,s=await z$(o,this.fdPath,r,100,n.signal);if(n.signal.aborted)return[];let a=s.map(u=>({...u,score:r?this.scoreEntry(u.path,r,u.isDirectory):1})).filter(u=>u.score>0);a.sort((u,d)=>d.score-u.score);let l=a.slice(0,20),c=[];for(let{path:u,isDirectory:d}of l){let p=d?u.slice(0,-1):u,m=i?this.scopedPathForDisplay(i.displayBase,p):p,g=tv(p),h=d?`${m}/`:m,f=_M(h,{isDirectory:d,isAtPrefix:!0,isQuotedPrefix:n.isQuotedPrefix});c.push({value:f,label:g+(d?"/":""),description:m})}return c}catch{return[]}}shouldTriggerFileCompletion(e,n,i){let r=(e[n]||"").slice(0,i);return!(r.trim().startsWith("/")&&!r.trim().includes(" "))}};import{eastAsianWidth as LM}from"get-east-asian-width";var Ti=new Intl.Segmenter(void 0,{granularity:"grapheme"}),H$=new Intl.Segmenter(void 0,{granularity:"word"});function Cp(){return Ti}function Mp(){return H$}function V$(t){let e=t.codePointAt(0);return e>=126976&&e<=130047||e>=8960&&e<=9215||e>=9728&&e<=10175||e>=11088&&e<=11093||t.includes("\uFE0F")||t.length>2}var Q$=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$","v"),Y$=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),J$=new RegExp("^\\p{RGI_Emoji}$","v"),X$=512,Ec=new Map,Rp=/[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}\p{Script_Extensions=Hangul}\p{Script_Extensions=Bopomofo}]/u;function ov(t){for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);if(n<32||n>126)return!1}return!0}function Z$(t,e){if(e<=0||t.length===0)return{text:"",width:0};if(ov(t)){let l=t.slice(0,e);return{text:l,width:l.length}}let n=t.includes("\x1B"),i=t.includes(" ");if(!n&&!i){let l="",c=0;for(let{segment:u}of Ti.segment(t)){let d=_r(u);if(c+d>e)break;l+=u,c+=d}return{text:l,width:c}}let o="",r=0,s=0,a="";for(;s<t.length;){let l=zt(t,s);if(l){a+=l.code,s+=l.length;continue}if(t[s]===" "){if(r+3>e)break;a&&(o+=a,a=""),o+=" ",r+=3,s++;continue}let c=s;for(;c<t.length&&t[c]!==" "&&!zt(t,c);)c++;for(let{segment:u}of Ti.segment(t.slice(s,c))){let d=_r(u);if(r+d>e)return{text:o,width:r};a&&(o+=a,a=""),o+=u,r+=d}s=c}return{text:o,width:r}}function nv(t,e,n,i,o,r){let s="\x1B[0m",a=e+i,l;return n.length>0?l=`${t}${s}${n}${s}`:l=`${t}${s}`,r?l+" ".repeat(Math.max(0,o-a)):l}function _r(t){if(t===" ")return 3;if(Q$.test(t))return 0;if(V$(t)&&J$.test(t))return 2;let n=t.replace(Y$,"").codePointAt(0);if(n===void 0)return 0;if(n>=127462&&n<=127487)return 2;let i=LM(n);if(t.length>1)for(let o of t.slice(1)){let r=o.codePointAt(0);r>=65280&&r<=65519?i+=LM(r):(r===3635||r===3763)&&(i+=1)}return i}function j(t){if(t.length===0)return 0;if(ov(t))return t.length;let e=Ec.get(t);if(e!==void 0)return e;let n=t;if(t.includes(" ")&&(n=n.replace(/\t/g," ")),n.includes("\x1B")){let o="",r=0;for(;r<n.length;){let s=zt(n,r);if(s){r+=s.length;continue}o+=n[r],r++}n=o}let i=0;for(let{segment:o}of Ti.segment(n))i+=_r(o);if(Ec.size>=X$){let o=Ec.keys().next().value;o!==void 0&&Ec.delete(o)}return Ec.set(t,i),i}var eN=/[\u0e33\u0eb3]/,tN=/[\u0e33\u0eb3]/g;function WM(t){let e=t;if(eN.test(e)&&(e=e.replace(tN,o=>o==="\u0E33"?"\u0E4D\u0E32":"\u0ECD\u0EB2")),!e.includes(" "))return e;let n="",i=0;for(;i<e.length;){let o=zt(e,i);if(o){n+=o.code,i+=o.length;continue}n+=e[i]===" "?" ":e[i],i++}return n}function zt(t,e){if(e>=t.length||t[e]!=="\x1B")return null;let n=t[e+1];if(n==="["){let i=e+2;for(;i<t.length&&!/[mGKHJ]/.test(t[i]);)i++;return i<t.length?{code:t.substring(e,i+1),length:i+1-e}:null}if(n==="]"){let i=e+2;for(;i<t.length;){if(t[i]==="\x07")return{code:t.substring(e,i+1),length:i+1-e};if(t[i]==="\x1B"&&t[i+1]==="\\")return{code:t.substring(e,i+2),length:i+2-e};i++}return null}if(n==="_"){let i=e+2;for(;i<t.length;){if(t[i]==="\x07")return{code:t.substring(e,i+1),length:i+1-e};if(t[i]==="\x1B"&&t[i+1]==="\\")return{code:t.substring(e,i+2),length:i+2-e};i++}return null}return null}function nN(t){if(!t.startsWith("\x1B]8;"))return;let e=t.endsWith("\x07")?"\x07":"\x1B\\",n=t.slice(4,e==="\x07"?-1:-2),i=n.indexOf(";");if(i===-1)return;let o=n.slice(0,i),r=n.slice(i+1);return r?{params:o,url:r,terminator:e}:null}function iN(t){return`\x1B]8;${t.params};${t.url}${t.terminator}`}function oN(t){return`\x1B]8;;${t}`}var Ac=class{constructor(){this.bold=!1;this.dim=!1;this.italic=!1;this.underline=!1;this.blink=!1;this.inverse=!1;this.hidden=!1;this.strikethrough=!1;this.fgColor=null;this.bgColor=null;this.activeHyperlink=null}process(e){let n=nN(e);if(n!==void 0){this.activeHyperlink=n;return}if(!e.endsWith("m"))return;let i=e.match(/\x1b\[([\d;]*)m/);if(!i)return;let o=i[1];if(o===""||o==="0"){this.reset();return}let r=o.split(";"),s=0;for(;s<r.length;){let a=Number.parseInt(r[s],10);if(a===38||a===48){if(r[s+1]==="5"&&r[s+2]!==void 0){let l=`${r[s]};${r[s+1]};${r[s+2]}`;a===38?this.fgColor=l:this.bgColor=l,s+=3;continue}else if(r[s+1]==="2"&&r[s+4]!==void 0){let l=`${r[s]};${r[s+1]};${r[s+2]};${r[s+3]};${r[s+4]}`;a===38?this.fgColor=l:this.bgColor=l,s+=5;continue}}switch(a){case 0:this.reset();break;case 1:this.bold=!0;break;case 2:this.dim=!0;break;case 3:this.italic=!0;break;case 4:this.underline=!0;break;case 5:this.blink=!0;break;case 7:this.inverse=!0;break;case 8:this.hidden=!0;break;case 9:this.strikethrough=!0;break;case 21:this.bold=!1;break;case 22:this.bold=!1,this.dim=!1;break;case 23:this.italic=!1;break;case 24:this.underline=!1;break;case 25:this.blink=!1;break;case 27:this.inverse=!1;break;case 28:this.hidden=!1;break;case 29:this.strikethrough=!1;break;case 39:this.fgColor=null;break;case 49:this.bgColor=null;break;default:a>=30&&a<=37||a>=90&&a<=97?this.fgColor=String(a):(a>=40&&a<=47||a>=100&&a<=107)&&(this.bgColor=String(a));break}s++}}reset(){this.bold=!1,this.dim=!1,this.italic=!1,this.underline=!1,this.blink=!1,this.inverse=!1,this.hidden=!1,this.strikethrough=!1,this.fgColor=null,this.bgColor=null}clear(){this.reset(),this.activeHyperlink=null}getActiveCodes(){let e=[];this.bold&&e.push("1"),this.dim&&e.push("2"),this.italic&&e.push("3"),this.underline&&e.push("4"),this.blink&&e.push("5"),this.inverse&&e.push("7"),this.hidden&&e.push("8"),this.strikethrough&&e.push("9"),this.fgColor&&e.push(this.fgColor),this.bgColor&&e.push(this.bgColor);let n=e.length>0?`\x1B[${e.join(";")}m`:"";return this.activeHyperlink&&(n+=iN(this.activeHyperlink)),n}hasActiveCodes(){return this.bold||this.dim||this.italic||this.underline||this.blink||this.inverse||this.hidden||this.strikethrough||this.fgColor!==null||this.bgColor!==null||this.activeHyperlink!==null}getLineEndReset(){let e="";return this.underline&&(e+="\x1B[24m"),this.activeHyperlink&&(e+=oN(this.activeHyperlink.terminator)),e}};function FM(t,e){let n=0;for(;n<t.length;){let i=zt(t,n);i?(e.process(i.code),n+=i.length):n++}}function rN(t){let e=[],n="",i="",o=null,r=0,s=()=>{n&&(e.push(n),n="",o=null)};for(;r<t.length;){let a=zt(t,r);if(a){i+=a.code,r+=a.length;continue}let l=r;for(;l<t.length&&!zt(t,l);)l++;for(let{segment:c}of Ti.segment(t.slice(r,l))){let u=c===" ";if(!u&&Rp.test(c)){s();let p=i+c;i="",e.push(p);continue}let d=u?"space":"word";n&&o!==d&&s(),i&&(n+=i,i=""),o=d,n+=c}r=l}return i&&(n?n+=i:e.length>0?e[e.length-1]+=i:n=i),n&&e.push(n),e}function rn(t,e){if(!t)return[""];let n=t.split(/\r\n|\r|\n/),i=[],o=new Ac;for(let r of n){let s=i.length>0?o.getActiveCodes():"",a=sN(s+r,e);for(let l of a)i.push(l);FM(r,o)}return i.length>0?i:[""]}function sN(t,e){if(!t)return[""];if(j(t)<=e)return[t];let i=[],o=new Ac,r=rN(t),s="",a=0;for(let l of r){let c=j(l),u=l.trim()==="";if(c>e&&!u){if(s){let m=o.getLineEndReset();m&&(s+=m),i.push(s),s="",a=0}let p=aN(l,e,o);for(let m=0;m<p.length-1;m++)i.push(p[m]);s=p[p.length-1],a=j(s);continue}if(a+c>e&&a>0){let p=s.trimEnd(),m=o.getLineEndReset();m&&(p+=m),i.push(p),u?(s=o.getActiveCodes(),a=0):(s=o.getActiveCodes()+l,a=c)}else s+=l,a+=c;FM(l,o)}return s&&i.push(s),i.length>0?i.map(l=>l.trimEnd()):[""]}var rv=/[(){}[\]<>.,;:'"!?+\-=*/\\|&%^$#@~`]/;function Mn(t){return/\s/.test(t)}function aN(t,e,n){let i=[],o=n.getActiveCodes(),r=0,s=0,a=[];for(;s<t.length;){let l=zt(t,s);if(l)a.push({type:"ansi",value:l.code}),s+=l.length;else{let c=s;for(;c<t.length&&!zt(t,c);)c++;let u=t.slice(s,c);for(let d of Ti.segment(u))a.push({type:"grapheme",value:d.segment});s=c}}for(let l of a){if(l.type==="ansi"){o+=l.value,n.process(l.value);continue}let c=l.value;if(!c)continue;let u=j(c);if(r+u>e){let d=n.getLineEndReset();d&&(o+=d),i.push(o),o=n.getActiveCodes(),r=0}o+=c,r+=u}return o&&i.push(o),i.length>0?i:[""]}function Bo(t,e,n){let i=j(t),o=Math.max(0,e-i),r=" ".repeat(o),s=t+r;return n(s)}function te(t,e,n="...",i=!1){if(e<=0)return"";if(t.length===0)return i?" ".repeat(e):"";let o=j(n);if(o>=e){let h=j(t);if(h<=e)return i?t+" ".repeat(e-h):t;let f=Z$(n,e);return f.width===0?i?" ".repeat(e):"":nv("",0,f.text,f.width,e,i)}if(ov(t)){if(t.length<=e)return i?t+" ".repeat(e-t.length):t;let h=e-o;return nv(t.slice(0,h),h,n,o,e,i)}let r=e-o,s="",a="",l=0,c=0,u=!0,d=!1,p=!1,m=t.includes("\x1B"),g=t.includes(" ");if(!m&&!g){for(let{segment:h}of Ti.segment(t)){let f=_r(h);if(u&&c+f<=r?(s+=h,c+=f):u=!1,l+=f,l>e){d=!0;break}}p=!d}else{let h=0;for(;h<t.length;){let f=zt(t,h);if(f){a+=f.code,h+=f.length;continue}if(t[h]===" "){if(u&&c+3<=r?(a&&(s+=a,a=""),s+=" ",c+=3):(u=!1,a=""),l+=3,l>e){d=!0;break}h++;continue}let b=h;for(;b<t.length&&t[b]!==" "&&!zt(t,b);)b++;for(let{segment:x}of Ti.segment(t.slice(h,b))){let y=_r(x);if(u&&c+y<=r?(a&&(s+=a,a=""),s+=x,c+=y):(u=!1,a=""),l+=y,l>e){d=!0;break}}if(d)break;h=b}p=h>=t.length}return!d&&p?i?t+" ".repeat(Math.max(0,e-l)):t:nv(s,c,n,o,e,i)}function no(t,e,n,i=!1){return sv(t,e,n,i).text}function sv(t,e,n,i=!1){if(n<=0)return{text:"",width:0};let o=e+n,r="",s=0,a=0,l=0,c="";for(;l<t.length;){let u=zt(t,l);if(u){a>=e&&a<o?r+=u.code:a<e&&(c+=u.code),l+=u.length;continue}let d=l;for(;d<t.length&&!zt(t,d);)d++;for(let{segment:p}of Ti.segment(t.slice(l,d))){let m=_r(p),g=a>=e&&a<o,h=!i||a+m<=o;if(g&&h&&(c&&(r+=c,c=""),r+=p,s+=m),a+=m,a>=o)break}if(l=d,a>=o)break}return{text:r,width:s}}var iv=new Ac;function DM(t,e,n,i,o=!1){let r="",s=0,a="",l=0,c=0,u=0,d="",p=!1,m=n+i;for(iv.clear();u<t.length;){let g=zt(t,u);if(g){iv.process(g.code),c<e?d+=g.code:c>=n&&c<m&&p&&(a+=g.code),u+=g.length;continue}let h=u;for(;h<t.length&&!zt(t,h);)h++;for(let{segment:f}of Ti.segment(t.slice(u,h))){let b=_r(f);if(c<e&&c+b<=e?(d&&(r+=d,d=""),r+=f,s+=b):c>=n&&c<m&&(!o||c+b<=m)&&(p||(a+=iv.getActiveCodes(),p=!0),a+=f,l+=b),c+=b,i<=0?c>=e:c>=m)break}if(u=h,i<=0?c>=e:c>=m)break}return{before:r,beforeWidth:s,after:a,afterWidth:l}}var pt=class{constructor(e=1,n=1,i){this.children=[];this.paddingX=e,this.paddingY=n,this.bgFn=i}addChild(e){this.children.push(e),this.invalidateCache()}removeChild(e){let n=this.children.indexOf(e);n!==-1&&(this.children.splice(n,1),this.invalidateCache())}clear(){this.children=[],this.invalidateCache()}setBgFn(e){this.bgFn=e}invalidateCache(){this.cache=void 0}matchCache(e,n,i){let o=this.cache;return!!o&&o.width===e&&o.bgSample===i&&o.childLines.length===n.length&&o.childLines.every((r,s)=>r===n[s])}invalidate(){this.invalidateCache();for(let e of this.children)e.invalidate?.()}render(e){if(this.children.length===0)return[];let n=Math.max(1,e-this.paddingX*2),i=" ".repeat(this.paddingX),o=[];for(let a of this.children){let l=a.render(n);for(let c of l)o.push(i+c)}if(o.length===0)return[];let r=this.bgFn?this.bgFn("test"):void 0;if(this.matchCache(e,o,r))return this.cache.lines;let s=[];for(let a=0;a<this.paddingY;a++)s.push(this.applyBg("",e));for(let a of o)s.push(this.applyBg(a,e));for(let a=0;a<this.paddingY;a++)s.push(this.applyBg("",e));return this.cache={childLines:o,width:e,bgSample:r,lines:s},s}applyBg(e,n){let i=j(e),o=Math.max(0,n-i),r=e+" ".repeat(o);return this.bgFn?Bo(r,n,this.bgFn):r}};var io=!1;function Oc(t){io=t}var Or={escape:"escape",esc:"esc",enter:"enter",return:"return",tab:"tab",space:"space",backspace:"backspace",delete:"delete",insert:"insert",clear:"clear",home:"home",end:"end",pageUp:"pageUp",pageDown:"pageDown",up:"up",down:"down",left:"left",right:"right",f1:"f1",f2:"f2",f3:"f3",f4:"f4",f5:"f5",f6:"f6",f7:"f7",f8:"f8",f9:"f9",f10:"f10",f11:"f11",f12:"f12",backtick:"`",hyphen:"-",equals:"=",leftbracket:"[",rightbracket:"]",backslash:"\\",semicolon:";",quote:"'",comma:",",period:".",slash:"/",exclamation:"!",at:"@",hash:"#",dollar:"$",percent:"%",caret:"^",ampersand:"&",asterisk:"*",leftparen:"(",rightparen:")",underscore:"_",plus:"+",pipe:"|",tilde:"~",leftbrace:"{",rightbrace:"}",colon:":",lessthan:"<",greaterthan:">",question:"?",ctrl:t=>`ctrl+${t}`,shift:t=>`shift+${t}`,alt:t=>`alt+${t}`,super:t=>`super+${t}`,ctrlShift:t=>`ctrl+shift+${t}`,shiftCtrl:t=>`shift+ctrl+${t}`,ctrlAlt:t=>`ctrl+alt+${t}`,altCtrl:t=>`alt+ctrl+${t}`,shiftAlt:t=>`shift+alt+${t}`,altShift:t=>`alt+shift+${t}`,ctrlSuper:t=>`ctrl+super+${t}`,superCtrl:t=>`super+ctrl+${t}`,shiftSuper:t=>`shift+super+${t}`,superShift:t=>`super+shift+${t}`,altSuper:t=>`alt+super+${t}`,superAlt:t=>`super+alt+${t}`,ctrlShiftAlt:t=>`ctrl+shift+alt+${t}`,ctrlShiftSuper:t=>`ctrl+shift+super+${t}`},av=new Set(["`","-","=","[","]","\\",";","'",",",".","/","!","@","#","$","%","^","&","*","(",")","_","+","|","~","{","}",":","<",">","?"]),ie={shift:1,alt:2,ctrl:4,super:8},_c=192,Ue={escape:27,tab:9,enter:13,space:32,backspace:127,kpEnter:57414},Ct={up:-1,down:-2,right:-3,left:-4},He={delete:-10,insert:-11,pageUp:-12,pageDown:-13,home:-14,end:-15},lN=new Map([[57399,48],[57400,49],[57401,50],[57402,51],[57403,52],[57404,53],[57405,54],[57406,55],[57407,56],[57408,57],[57409,46],[57410,47],[57411,42],[57412,45],[57413,43],[57415,61],[57416,44],[57417,Ct.left],[57418,Ct.right],[57419,Ct.up],[57420,Ct.down],[57421,He.pageUp],[57422,He.pageDown],[57423,He.home],[57424,He.end],[57425,He.insert],[57426,He.delete]]);function lv(t){return lN.get(t)??t}function Ap(t,e){return(e&~_c&ie.shift)!==0&&t>=65&&t<=90?t+32:t}var jn={up:["\x1B[A","\x1BOA"],down:["\x1B[B","\x1BOB"],right:["\x1B[C","\x1BOC"],left:["\x1B[D","\x1BOD"],home:["\x1B[H","\x1BOH","\x1B[1~","\x1B[7~"],end:["\x1B[F","\x1BOF","\x1B[4~","\x1B[8~"],insert:["\x1B[2~"],delete:["\x1B[3~"],pageUp:["\x1B[5~","\x1B[[5~"],pageDown:["\x1B[6~","\x1B[[6~"],clear:["\x1B[E","\x1BOE"],f1:["\x1BOP","\x1B[11~","\x1B[[A"],f2:["\x1BOQ","\x1B[12~","\x1B[[B"],f3:["\x1BOR","\x1B[13~","\x1B[[C"],f4:["\x1BOS","\x1B[14~","\x1B[[D"],f5:["\x1B[15~","\x1B[[E"],f6:["\x1B[17~"],f7:["\x1B[18~"],f8:["\x1B[19~"],f9:["\x1B[20~"],f10:["\x1B[21~"],f11:["\x1B[23~"],f12:["\x1B[24~"]},cN={up:["\x1B[a"],down:["\x1B[b"],right:["\x1B[c"],left:["\x1B[d"],clear:["\x1B[e"],insert:["\x1B[2$"],delete:["\x1B[3$"],pageUp:["\x1B[5$"],pageDown:["\x1B[6$"],home:["\x1B[7$"],end:["\x1B[8$"]},uN={up:["\x1BOa"],down:["\x1BOb"],right:["\x1BOc"],left:["\x1BOd"],clear:["\x1BOe"],insert:["\x1B[2^"],delete:["\x1B[3^"],pageUp:["\x1B[5^"],pageDown:["\x1B[6^"],home:["\x1B[7^"],end:["\x1B[8^"]};var sn=(t,e)=>e.includes(t),Rn=(t,e,n)=>n===ie.shift?sn(t,cN[e]):n===ie.ctrl?sn(t,uN[e]):!1,Pp="press";function ai(t){return t.includes("\x1B[200~")?!1:!!(t.includes(":3u")||t.includes(":3~")||t.includes(":3A")||t.includes(":3B")||t.includes(":3C")||t.includes(":3D")||t.includes(":3H")||t.includes(":3F"))}function Ip(t){if(!t)return"press";let e=parseInt(t,10);return e===2?"repeat":e===3?"release":"press"}function dN(t){let e=t.match(/^\x1b\[(\d+)(?::(\d*))?(?::(\d+))?(?:;(\d+))?(?::(\d+))?u$/);if(e){let r=parseInt(e[1],10),s=e[2]&&e[2].length>0?parseInt(e[2],10):void 0,a=e[3]?parseInt(e[3],10):void 0,l=e[4]?parseInt(e[4],10):1,c=Ip(e[5]);return Pp=c,{codepoint:r,shiftedKey:s,baseLayoutKey:a,modifier:l-1,eventType:c}}let n=t.match(/^\x1b\[1;(\d+)(?::(\d+))?([ABCD])$/);if(n){let r=parseInt(n[1],10),s=Ip(n[2]),a={A:-1,B:-2,C:-3,D:-4};return Pp=s,{codepoint:a[n[3]],modifier:r-1,eventType:s}}let i=t.match(/^\x1b\[(\d+)(?:;(\d+))?(?::(\d+))?~$/);if(i){let r=parseInt(i[1],10),s=i[2]?parseInt(i[2],10):1,a=Ip(i[3]),c={2:He.insert,3:He.delete,5:He.pageUp,6:He.pageDown,7:He.home,8:He.end}[r];if(c!==void 0)return Pp=a,{codepoint:c,modifier:s-1,eventType:a}}let o=t.match(/^\x1b\[1;(\d+)(?::(\d+))?([HF])$/);if(o){let r=parseInt(o[1],10),s=Ip(o[2]),a=o[3]==="H"?He.home:He.end;return Pp=s,{codepoint:a,modifier:r-1,eventType:s}}return null}function ve(t,e,n){let i=dN(t);if(!i)return!1;let o=i.modifier&~_c,r=n&~_c;if(o!==r)return!1;let s=Ap(lv(i.codepoint),i.modifier),a=Ap(lv(e),n);if(s===a)return!0;if(i.baseLayoutKey!==void 0&&i.baseLayoutKey===e){let l=s,c=l>=97&&l<=122,u=av.has(String.fromCharCode(l));if(!c&&!u)return!0}return!1}function cv(t){let e=t.match(/^\x1b\[27;(\d+);(\d+)~$/);if(!e)return null;let n=parseInt(e[1],10);return{codepoint:parseInt(e[2],10),modifier:n-1}}function qn(t,e,n){let i=cv(t);return i?i.codepoint===e&&i.modifier===n:!1}function pN(){return!!process.env.WT_SESSION&&!process.env.SSH_CONNECTION&&!process.env.SSH_CLIENT&&!process.env.SSH_TTY}function UM(t,e){return t==="\x7F"?e===0:t!=="\b"?!1:pN()?e===ie.ctrl:e===0}function mN(t){let e=t.toLowerCase(),n=e.charCodeAt(0);return n>=97&&n<=122||e==="["||e==="\\"||e==="]"||e==="_"?String.fromCharCode(n&31):e==="-"?"":null}function $M(t){return t>="0"&&t<="9"}function Ep(t,e,n){if(n===0)return!1;let i=cv(t);return!i||i.modifier!==n?!1:Ap(i.codepoint,i.modifier)===Ap(e,n)}function hN(t){let e=t.toLowerCase().split("+"),n=e[e.length-1];return n?{key:n,ctrl:e.includes("ctrl"),shift:e.includes("shift"),alt:e.includes("alt"),super:e.includes("super")}:null}function Fe(t,e){let n=hN(e);if(!n)return!1;let{key:i,ctrl:o,shift:r,alt:s,super:a}=n,l=0;switch(r&&(l|=ie.shift),s&&(l|=ie.alt),o&&(l|=ie.ctrl),a&&(l|=ie.super),i){case"escape":case"esc":return l!==0?!1:t==="\x1B"||ve(t,Ue.escape,0)||qn(t,Ue.escape,0);case"space":return!io&&(l===ie.ctrl&&t==="\0"||l===ie.alt&&t==="\x1B ")?!0:l===0?t===" "||ve(t,Ue.space,0)||qn(t,Ue.space,0):ve(t,Ue.space,l)||qn(t,Ue.space,l);case"tab":return l===ie.shift?t==="\x1B[Z"||ve(t,Ue.tab,ie.shift)||qn(t,Ue.tab,ie.shift):l===0?t===" "||ve(t,Ue.tab,0):ve(t,Ue.tab,l)||qn(t,Ue.tab,l);case"enter":case"return":return l===ie.shift?ve(t,Ue.enter,ie.shift)||ve(t,Ue.kpEnter,ie.shift)||qn(t,Ue.enter,ie.shift)?!0:io?t==="\x1B\r"||t===`
37
37
  `:!1:l===ie.alt?ve(t,Ue.enter,ie.alt)||ve(t,Ue.kpEnter,ie.alt)||qn(t,Ue.enter,ie.alt)?!0:io?!1:t==="\x1B\r":l===0?t==="\r"||!io&&t===`
38
- `||t==="\x1BOM"||ve(t,Ue.enter,0)||ve(t,Ue.kpEnter,0):ve(t,Ue.enter,l)||ve(t,Ue.kpEnter,l)||qn(t,Ue.enter,l);case"backspace":return l===ie.alt?t==="\x1B\x7F"||t==="\x1B\b"?!0:ve(t,Ue.backspace,ie.alt)||qn(t,Ue.backspace,ie.alt):l===ie.ctrl?UM(t,ie.ctrl)?!0:ve(t,Ue.backspace,ie.ctrl)||qn(t,Ue.backspace,ie.ctrl):l===0?UM(t,0)||ve(t,Ue.backspace,0)||qn(t,Ue.backspace,0):ve(t,Ue.backspace,l)||qn(t,Ue.backspace,l);case"insert":return l===0?sn(t,jn.insert)||ve(t,He.insert,0):Rn(t,"insert",l)?!0:ve(t,He.insert,l);case"delete":return l===0?sn(t,jn.delete)||ve(t,He.delete,0):Rn(t,"delete",l)?!0:ve(t,He.delete,l);case"clear":return l===0?sn(t,jn.clear):Rn(t,"clear",l);case"home":return l===0?sn(t,jn.home)||ve(t,He.home,0):Rn(t,"home",l)?!0:ve(t,He.home,l);case"end":return l===0?sn(t,jn.end)||ve(t,He.end,0):Rn(t,"end",l)?!0:ve(t,He.end,l);case"pageup":return l===0?sn(t,jn.pageUp)||ve(t,He.pageUp,0):Rn(t,"pageUp",l)?!0:ve(t,He.pageUp,l);case"pagedown":return l===0?sn(t,jn.pageDown)||ve(t,He.pageDown,0):Rn(t,"pageDown",l)?!0:ve(t,He.pageDown,l);case"up":return l===ie.alt?t==="\x1Bp"||ve(t,Ct.up,ie.alt):l===0?sn(t,jn.up)||ve(t,Ct.up,0):Rn(t,"up",l)?!0:ve(t,Ct.up,l);case"down":return l===ie.alt?t==="\x1Bn"||ve(t,Ct.down,ie.alt):l===0?sn(t,jn.down)||ve(t,Ct.down,0):Rn(t,"down",l)?!0:ve(t,Ct.down,l);case"left":return l===ie.alt?t==="\x1B[1;3D"||!io&&t==="\x1BB"||t==="\x1Bb"||ve(t,Ct.left,ie.alt):l===ie.ctrl?t==="\x1B[1;5D"||Rn(t,"left",ie.ctrl)||ve(t,Ct.left,ie.ctrl):l===0?sn(t,jn.left)||ve(t,Ct.left,0):Rn(t,"left",l)?!0:ve(t,Ct.left,l);case"right":return l===ie.alt?t==="\x1B[1;3C"||!io&&t==="\x1BF"||t==="\x1Bf"||ve(t,Ct.right,ie.alt):l===ie.ctrl?t==="\x1B[1;5C"||Rn(t,"right",ie.ctrl)||ve(t,Ct.right,ie.ctrl):l===0?sn(t,jn.right)||ve(t,Ct.right,0):Rn(t,"right",l)?!0:ve(t,Ct.right,l);case"f1":case"f2":case"f3":case"f4":case"f5":case"f6":case"f7":case"f8":case"f9":case"f10":case"f11":case"f12":return l!==0?!1:sn(t,jn[i])}if(i.length===1&&(i>="a"&&i<="z"||$M(i)||av.has(i))){let c=i.charCodeAt(0),u=mN(i),d=i>="a"&&i<="z",p=$M(i);return l===ie.ctrl+ie.alt&&!io&&u&&t===`\x1B${u}`||l===ie.alt&&!io&&(d||p||av.has(i))&&t===`\x1B${i}`?!0:l===ie.ctrl?u&&t===u?!0:ve(t,c,ie.ctrl)||Ep(t,c,ie.ctrl):l===ie.shift+ie.ctrl?ve(t,c,ie.shift+ie.ctrl)||Ep(t,c,ie.shift+ie.ctrl):l===ie.shift?d&&t===i.toUpperCase()?!0:ve(t,c,ie.shift)||Ep(t,c,ie.shift):l!==0?ve(t,c,l)||Ep(t,c,l):t===i||ve(t,c,0)}return!1}var gN=/^\x1b\[(\d+)(?::(\d*))?(?::(\d+))?(?:;(\d+))?(?::(\d+))?u$/,fN=ie.shift|_c;function _p(t){let e=t.match(gN);if(!e)return;let n=Number.parseInt(e[1]??"",10);if(!Number.isFinite(n))return;let i=e[2]&&e[2].length>0?Number.parseInt(e[2],10):void 0,o=e[4]?Number.parseInt(e[4],10):1,r=Number.isFinite(o)?o-1:0;if((r&~fN)!==0||r&(ie.alt|ie.ctrl))return;let s=n;if(r&ie.shift&&typeof i=="number"&&(s=i),s=lv(s),!(!Number.isFinite(s)||s<32))try{return String.fromCodePoint(s)}catch{return}}function vN(t){let e=cv(t);if(!(!e||(e.modifier&~_c&~ie.shift)!==0)&&!(!Number.isFinite(e.codepoint)||e.codepoint<32))try{return String.fromCodePoint(e.codepoint)}catch{return}}function uv(t){return _p(t)??vN(t)}var Da={"tui.editor.cursorUp":{defaultKeys:"up",description:"Move cursor up"},"tui.editor.cursorDown":{defaultKeys:"down",description:"Move cursor down"},"tui.editor.cursorLeft":{defaultKeys:["left","ctrl+b"],description:"Move cursor left"},"tui.editor.cursorRight":{defaultKeys:["right","ctrl+f"],description:"Move cursor right"},"tui.editor.cursorWordLeft":{defaultKeys:["alt+left","ctrl+left","alt+b"],description:"Move cursor word left"},"tui.editor.cursorWordRight":{defaultKeys:["alt+right","ctrl+right","alt+f"],description:"Move cursor word right"},"tui.editor.cursorLineStart":{defaultKeys:["home","ctrl+a"],description:"Move to line start"},"tui.editor.cursorLineEnd":{defaultKeys:["end","ctrl+e"],description:"Move to line end"},"tui.editor.jumpForward":{defaultKeys:"ctrl+]",description:"Jump forward to character"},"tui.editor.jumpBackward":{defaultKeys:"ctrl+alt+]",description:"Jump backward to character"},"tui.editor.pageUp":{defaultKeys:"pageUp",description:"Page up"},"tui.editor.pageDown":{defaultKeys:"pageDown",description:"Page down"},"tui.editor.deleteCharBackward":{defaultKeys:"backspace",description:"Delete character backward"},"tui.editor.deleteCharForward":{defaultKeys:["delete","ctrl+d"],description:"Delete character forward"},"tui.editor.deleteWordBackward":{defaultKeys:["ctrl+w","alt+backspace"],description:"Delete word backward"},"tui.editor.deleteWordForward":{defaultKeys:["alt+d","alt+delete"],description:"Delete word forward"},"tui.editor.deleteToLineStart":{defaultKeys:"ctrl+u",description:"Delete to line start"},"tui.editor.deleteToLineEnd":{defaultKeys:"ctrl+k",description:"Delete to line end"},"tui.editor.yank":{defaultKeys:"ctrl+y",description:"Yank"},"tui.editor.yankPop":{defaultKeys:"alt+y",description:"Yank pop"},"tui.editor.undo":{defaultKeys:"ctrl+-",description:"Undo"},"tui.input.newLine":{defaultKeys:["shift+enter","ctrl+j"],description:"Insert newline"},"tui.input.submit":{defaultKeys:"enter",description:"Submit input"},"tui.input.tab":{defaultKeys:"tab",description:"Tab / autocomplete"},"tui.input.copy":{defaultKeys:"ctrl+c",description:"Copy selection"},"tui.select.up":{defaultKeys:"up",description:"Move selection up"},"tui.select.down":{defaultKeys:"down",description:"Move selection down"},"tui.select.pageUp":{defaultKeys:"pageUp",description:"Selection page up"},"tui.select.pageDown":{defaultKeys:"pageDown",description:"Selection page down"},"tui.select.confirm":{defaultKeys:"enter",description:"Confirm selection"},"tui.select.cancel":{defaultKeys:["escape","ctrl+c"],description:"Cancel selection"}};function dv(t){if(t===void 0)return[];let e=Array.isArray(t)?t:[t],n=new Set,i=[];for(let o of e)n.has(o)||(n.add(o),i.push(o));return i}var Fa=class{constructor(e,n={}){this.keysById=new Map;this.conflicts=[];this.definitions=e,this.userBindings=n,this.rebuild()}rebuild(){this.keysById.clear(),this.conflicts=[];let e=new Map;for(let[n,i]of Object.entries(this.userBindings))if(n in this.definitions)for(let o of dv(i)){let r=e.get(o)??new Set;r.add(n),e.set(o,r)}for(let[n,i]of e)i.size>1&&this.conflicts.push({key:n,keybindings:[...i]});for(let[n,i]of Object.entries(this.definitions)){let o=this.userBindings[n],r=dv(o===void 0?i.defaultKeys:o);this.keysById.set(n,r)}}matches(e,n){let i=this.keysById.get(n)??[];for(let o of i)if(Fe(e,o))return!0;return!1}getKeys(e){return[...this.keysById.get(e)??[]]}getDefinition(e){return this.definitions[e]}getConflicts(){return this.conflicts.map(e=>({...e,keybindings:[...e.keybindings]}))}setUserBindings(e){this.userBindings=e,this.rebuild()}getUserBindings(){return{...this.userBindings}}getResolvedBindings(){let e={};for(let n of Object.keys(this.definitions)){let i=this.keysById.get(n)??[];e[n]=i.length===1?i[0]:[...i]}return e}},Op=null;function Lc(t){Op=t}function ke(){return Op||(Op=new Fa(Da)),Op}var A=class{constructor(e="",n=1,i=1,o){this.text=e,this.paddingX=n,this.paddingY=i,this.customBgFn=o}setText(e){this.text=e,this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}setCustomBgFn(e){this.customBgFn=e,this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}invalidate(){this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}render(e){if(this.cachedLines&&this.cachedText===this.text&&this.cachedWidth===e)return this.cachedLines;if(!this.text||this.text.trim()===""){let d=[];return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=d,d}let n=this.text.replace(/\t/g," "),i=Math.max(1,e-this.paddingX*2),o=rn(n,i),r=" ".repeat(this.paddingX),s=" ".repeat(this.paddingX),a=[];for(let d of o){let p=r+d+s;if(this.customBgFn)a.push(Bo(p,e,this.customBgFn));else{let m=j(p),g=Math.max(0,e-m);a.push(p+" ".repeat(g))}}let l=" ".repeat(e),c=[];for(let d=0;d<this.paddingY;d++){let p=this.customBgFn?Bo(l,e,this.customBgFn):l;c.push(p)}let u=[...c,...a,...c];return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=u,u.length>0?u:[""]}};var NM=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],BM=80,li=class extends A{constructor(n,i,o,r="Loading...",s){super("",1,0);this.frames=[...NM];this.intervalMs=BM;this.currentFrame=0;this.intervalId=null;this.ui=null;this.renderIndicatorVerbatim=!1;this.message="Loading...";this.ui=n,this.spinnerColorFn=i,this.messageColorFn=o,this.message=r,this.setIndicator(s)}render(n){return["",...super.render(n)]}start(){this.updateDisplay(),this.restartAnimation()}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}setMessage(n){this.message=n,this.updateDisplay()}setIndicator(n){this.renderIndicatorVerbatim=n!==void 0,this.frames=n?.frames!==void 0?[...n.frames]:[...NM],this.intervalMs=n?.intervalMs&&n.intervalMs>0?n.intervalMs:BM,this.currentFrame=0,this.start()}restartAnimation(){this.stop(),!(this.frames.length<=1)&&(this.intervalId=setInterval(()=>{this.currentFrame=(this.currentFrame+1)%this.frames.length,this.updateDisplay()},this.intervalMs))}updateDisplay(){let n=this.frames[this.currentFrame]??"",i=this.renderIndicatorVerbatim?n:this.spinnerColorFn(n),o=n.length>0?`${i} `:"";this.setText(`${o}${this.messageColorFn(this.message)}`),this.ui&&this.ui.requestRender()}};var Wc=class extends li{constructor(){super(...arguments);this.abortController=new AbortController}get signal(){return this.abortController.signal}get aborted(){return this.abortController.signal.aborted}handleInput(n){ke().matches(n,"tui.select.cancel")&&(this.abortController.abort(),this.onAbort?.())}dispose(){this.stop()}};var Ua=class{constructor(){this.ring=[]}push(e,n){if(e)if(n.accumulate&&this.ring.length>0){let i=this.ring.pop();this.ring.push(n.prepend?e+i:i+e)}else this.ring.push(e)}peek(){return this.ring.length>0?this.ring[this.ring.length-1]:void 0}rotate(){if(this.ring.length>1){let e=this.ring.pop();this.ring.unshift(e)}}get length(){return this.ring.length}};import*as jo from"node:fs";import*as wv from"node:os";import*as Ba from"node:path";import{performance as xv}from"node:perf_hooks";function bN(t){let e=t.startsWith("#")?t.slice(1):t,n=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return{r:n,g:i,b:o}}function $a(t){if(!/^[0-9a-f]+$/i.test(t))return;let e=16**t.length-1;if(!(e<=0))return Math.round(parseInt(t,16)/e*255)}var jM=/^\x1b\]11;([^\x07\x1b]*)(?:\x07|\x1b\\)$/i,xN=/^\x1b\[\?997;(1|2)n$/;function qM(t){return jM.test(t)}function pv(t){let e=t.match(jM);if(!e)return;let n=e[1].trim();if(n.startsWith("#")){let u=n.slice(1);if(/^[0-9a-f]{6}$/i.test(u))return bN(n);if(/^[0-9a-f]{12}$/i.test(u)){let d=$a(u.slice(0,4)),p=$a(u.slice(4,8)),m=$a(u.slice(8,12));return d!==void 0&&p!==void 0&&m!==void 0?{r:d,g:p,b:m}:void 0}return}let i=n.replace(/^rgba?:/i,""),[o,r,s]=i.split("/");if(o===void 0||r===void 0||s===void 0)return;let a=$a(o),l=$a(r),c=$a(s);return a!==void 0&&l!==void 0&&c!==void 0?{r:a,g:l,b:c}:void 0}function mv(t){let e=t.match(xN);if(e)return e[1]==="2"?"light":"dark"}import{execSync as yN}from"node:child_process";var hv=null,zM={widthPx:9,heightPx:18};function Lp(){return zM}function gv(t){zM=t}function wN(){try{return yN("tmux display-message -p '#{client_termfeatures}'",{encoding:"utf8",timeout:250,stdio:["ignore","pipe","ignore"]}).split(",").map(e=>e.trim()).includes("hyperlinks")}catch{return!1}}function HM(t=wN){let e=process.env.TERM_PROGRAM?.toLowerCase()||"",n=process.env.TERMINAL_EMULATOR?.toLowerCase()||"",i=process.env.TERM?.toLowerCase()||"",o=process.env.COLORTERM?.toLowerCase()||"",r=o==="truecolor"||o==="24bit";return process.env.TMUX||i.startsWith("tmux")?{images:null,trueColor:r,hyperlinks:t()}:i.startsWith("screen")?{images:null,trueColor:r,hyperlinks:!1}:process.env.KITTY_WINDOW_ID||e==="kitty"?{images:"kitty",trueColor:!0,hyperlinks:!0}:e==="ghostty"||i.includes("ghostty")||process.env.GHOSTTY_RESOURCES_DIR?{images:"kitty",trueColor:!0,hyperlinks:!0}:process.env.WEZTERM_PANE||e==="wezterm"?{images:"kitty",trueColor:!0,hyperlinks:!0}:e==="warpterminal"||process.env.WARP_SESSION_ID||process.env.WARP_TERMINAL_SESSION_UUID?{images:"kitty",trueColor:!0,hyperlinks:!0}:process.env.ITERM_SESSION_ID||e==="iterm.app"?{images:"iterm2",trueColor:!0,hyperlinks:!0}:process.env.WT_SESSION?{images:null,trueColor:!0,hyperlinks:!0}:e==="vscode"?{images:null,trueColor:!0,hyperlinks:!0}:e==="alacritty"?{images:null,trueColor:!0,hyperlinks:!0}:n==="jetbrains-jediterm"?{images:null,trueColor:!0,hyperlinks:!1}:{images:null,trueColor:r,hyperlinks:!1}}function ft(){return hv||(hv=HM()),hv}var KM="\x1B_G",GM="\x1B]1337;File=";function oo(t){return t.startsWith(KM)||t.startsWith(GM)?!0:t.includes(KM)||t.includes(GM)}function fv(){return Math.floor(Math.random()*4294967294)+1}function VM(t,e={}){let i=["a=T","f=100","q=2"];if(e.moveCursor===!1&&i.push("C=1"),e.columns&&i.push(`c=${e.columns}`),e.rows&&i.push(`r=${e.rows}`),e.imageId&&i.push(`i=${e.imageId}`),t.length<=4096)return`\x1B_G${i.join(",")};${t}\x1B\\`;let o=[],r=0,s=!0;for(;r<t.length;){let a=t.slice(r,r+4096),l=r+4096>=t.length;s?(o.push(`\x1B_G${i.join(",")},m=1;${a}\x1B\\`),s=!1):l?o.push(`\x1B_Gm=0;${a}\x1B\\`):o.push(`\x1B_Gm=1;${a}\x1B\\`),r+=4096}return o.join("")}function vv(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}function QM(t,e={}){let n=[`inline=${e.inline!==!1?1:0}`];if(e.width!==void 0&&n.push(`width=${e.width}`),e.height!==void 0&&n.push(`height=${e.height}`),e.name){let i=Buffer.from(e.name).toString("base64");n.push(`name=${i}`)}return e.preserveAspectRatio===!1&&n.push("preserveAspectRatio=0"),`\x1B]1337;File=${n.join(";")}:${t}\x07`}function kN(t,e,n,i={widthPx:9,heightPx:18}){let o=Math.max(1,Math.floor(e)),r=n===void 0?void 0:Math.max(1,Math.floor(n)),s=Math.max(1,t.widthPx),a=Math.max(1,t.heightPx),l=o*i.widthPx/s,c=r===void 0?l:r*i.heightPx/a,u=Math.min(l,c),d=s*u,p=a*u,m=Math.ceil(d/i.widthPx),g=Math.ceil(p/i.heightPx);return{columns:Math.max(1,Math.min(o,m)),rows:Math.max(1,r===void 0?g:Math.min(r,g))}}function YM(t){try{let e=Buffer.from(t,"base64");if(e.length<24||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)return null;let n=e.readUInt32BE(16),i=e.readUInt32BE(20);return{widthPx:n,heightPx:i}}catch{return null}}function JM(t){try{let e=Buffer.from(t,"base64");if(e.length<2||e[0]!==255||e[1]!==216)return null;let n=2;for(;n<e.length-9;){if(e[n]!==255){n++;continue}let i=e[n+1];if(i>=192&&i<=194){let r=e.readUInt16BE(n+5);return{widthPx:e.readUInt16BE(n+7),heightPx:r}}if(n+3>=e.length)return null;let o=e.readUInt16BE(n+2);if(o<2)return null;n+=2+o}return null}catch{return null}}function XM(t){try{let e=Buffer.from(t,"base64");if(e.length<10)return null;let n=e.slice(0,6).toString("ascii");if(n!=="GIF87a"&&n!=="GIF89a")return null;let i=e.readUInt16LE(6),o=e.readUInt16LE(8);return{widthPx:i,heightPx:o}}catch{return null}}function ZM(t){try{let e=Buffer.from(t,"base64");if(e.length<30)return null;let n=e.slice(0,4).toString("ascii"),i=e.slice(8,12).toString("ascii");if(n!=="RIFF"||i!=="WEBP")return null;let o=e.slice(12,16).toString("ascii");if(o==="VP8 "){if(e.length<30)return null;let r=e.readUInt16LE(26)&16383,s=e.readUInt16LE(28)&16383;return{widthPx:r,heightPx:s}}else if(o==="VP8L"){if(e.length<25)return null;let r=e.readUInt32LE(21),s=(r&16383)+1,a=(r>>14&16383)+1;return{widthPx:s,heightPx:a}}else if(o==="VP8X"){if(e.length<30)return null;let r=(e[24]|e[25]<<8|e[26]<<16)+1,s=(e[27]|e[28]<<8|e[29]<<16)+1;return{widthPx:r,heightPx:s}}return null}catch{return null}}function Fc(t,e){return e==="image/png"?YM(t):e==="image/jpeg"?JM(t):e==="image/gif"?XM(t):e==="image/webp"?ZM(t):null}function bv(t,e,n={}){let i=ft();if(!i.images)return null;let o=n.maxWidthCells??80,r=kN(e,o,n.maxHeightCells,Lp());return i.images==="kitty"?{sequence:VM(t,{columns:r.columns,rows:r.rows,imageId:n.imageId,moveCursor:n.moveCursor}),rows:r.rows,imageId:n.imageId}:i.images==="iterm2"?{sequence:QM(t,{width:r.columns,height:"auto",preserveAspectRatio:n.preserveAspectRatio??!0}),rows:r.rows}:null}function Lr(t,e){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}function Na(t,e,n){let i=[];return n&&i.push(n),i.push(`[${t}]`),e&&i.push(`${e.widthPx}x${e.heightPx}`),`[Image: ${i.join(" ")}]`}var eR="\x1B_G";function nR(t){let e=t.indexOf(eR);if(e===-1)return;let n=e+eR.length,i=t.indexOf(";",n);if(i===-1)return;let o=[],r=1,s=t.slice(n,i);for(let a of s.split(",")){let[l,c]=a.split("=",2);if(c===void 0)continue;let u=Number(c);!Number.isInteger(u)||u<=0||u>4294967295||(l==="i"?o.push(u):l==="r"&&(r=u))}return{ids:o,rows:r}}function yv(t){return nR(t)?.ids??[]}function SN(t){return nR(t)?.rows??1}function kv(t){return t!==null&&"focused"in t}var Wr="\x1B_pi:c\x07";function tR(t,e){if(t===void 0)return;if(typeof t=="number")return t;let n=t.match(/^(\d+(?:\.\d+)?)%$/);if(n)return Math.floor(e*parseFloat(n[1])/100)}function TN(){return!!process.env.TERMUX_VERSION}var z=class{constructor(){this.children=[]}addChild(e){this.children.push(e)}removeChild(e){let n=this.children.indexOf(e);n!==-1&&this.children.splice(n,1)}clear(){this.children=[]}invalidate(){for(let e of this.children)e.invalidate?.()}render(e){let n=[];for(let i of this.children){let o=i.render(e);for(let r of o)n.push(r)}return n}},Fr=class t extends z{constructor(n,i){super();this.previousLines=[];this.previousKittyImageIds=new Set;this.previousWidth=0;this.previousHeight=0;this.focusedComponent=null;this.inputListeners=new Set;this.renderRequested=!1;this.lastRenderAt=0;this.cursorRow=0;this.hardwareCursorRow=0;this.showHardwareCursor=process.env.PI_HARDWARE_CURSOR==="1";this.clearOnShrink=process.env.PI_CLEAR_ON_SHRINK==="1";this.maxLinesRendered=0;this.previousViewportTop=0;this.fullRedrawCount=0;this.stopped=!1;this.pendingOsc11BackgroundReplies=0;this.pendingOsc11BackgroundQueries=[];this.terminalColorSchemeListeners=new Set;this.terminalColorSchemeNotificationsEnabled=!1;this.focusOrderCounter=0;this.overlayStack=[];this.overlayFocusRestore={status:"inactive"};this.terminal=n,i!==void 0&&(this.showHardwareCursor=i)}static{this.MIN_RENDER_INTERVAL_MS=16}get fullRedraws(){return this.fullRedrawCount}getShowHardwareCursor(){return this.showHardwareCursor}setShowHardwareCursor(n){this.showHardwareCursor!==n&&(this.showHardwareCursor=n,n||this.terminal.hideCursor(),this.requestRender())}getClearOnShrink(){return this.clearOnShrink}setClearOnShrink(n){this.clearOnShrink=n}setFocus(n){this.setFocusInternal({component:n,overlayFocusRestore:"clear"})}setFocusInternal({component:n,overlayFocusRestore:i}){let o=this.focusedComponent,r=n,s=o?this.overlayStack.find(u=>u.component===o&&this.isOverlayVisible(u)):void 0,a=r?this.overlayStack.some(u=>u.component===r):!1,l=this.getVisibleOverlayFocusRestore();r&&!a?l.status==="blocked"&&l.blockedBy===o?l.resume.status==="focus-target"||!this.isComponentMounted(l.blockedBy)?r=this.resolveBlockedOverlayFocusResume(l):this.overlayFocusRestore={status:"blocked",overlay:l.overlay,blockedBy:r,resume:l.resume}:s&&l.status!=="inactive"&&l.overlay===s&&!this.isOverlayFocusAncestor(s,r)&&(this.overlayFocusRestore={status:"blocked",overlay:s,blockedBy:r,resume:{status:"restore-overlay"}}):r===null&&(l.status==="blocked"&&l.blockedBy===o?r=this.resolveBlockedOverlayFocusResume(l):i==="clear"&&this.clearOverlayFocusRestore()),kv(this.focusedComponent)&&(this.focusedComponent.focused=!1),this.focusedComponent=r,kv(r)&&(r.focused=!0);let c=r?this.overlayStack.find(u=>u.component===r&&this.isOverlayVisible(u)):void 0;c&&(this.overlayFocusRestore={status:"eligible",overlay:c})}clearOverlayFocusRestore(){this.overlayFocusRestore={status:"inactive"}}clearOverlayFocusRestoreFor(n){this.overlayFocusRestore.status!=="inactive"&&this.overlayFocusRestore.overlay===n&&this.clearOverlayFocusRestore()}resolveBlockedOverlayFocusResume(n){return n.resume.status==="restore-overlay"?n.overlay.component:(this.clearOverlayFocusRestore(),n.resume.target)}getVisibleOverlayFocusRestore(){let n=this.overlayFocusRestore;return n.status==="inactive"?n:!this.overlayStack.includes(n.overlay)||!this.isOverlayVisible(n.overlay)?{status:"inactive"}:n}isOverlayFocusAncestor(n,i){let o=new Set,r=n.preFocus;for(;r&&!o.has(r);){if(o.add(r),r===i)return!0;r=this.overlayStack.find(s=>s.component===r)?.preFocus??null}return!1}retargetOverlayPreFocus(n){for(let i of this.overlayStack)i!==n&&i.preFocus===n.component&&(i.preFocus=n.preFocus)}isComponentMounted(n){return this.children.some(i=>this.containsComponent(i,n))}containsComponent(n,i){return n===i?!0:n instanceof z?n.children.some(o=>this.containsComponent(o,i)):!1}showOverlay(n,i){let o={component:n,...i===void 0?{}:{options:i},preFocus:this.focusedComponent,hidden:!1,focusOrder:++this.focusOrderCounter};return this.overlayStack.push(o),!i?.nonCapturing&&this.isOverlayVisible(o)&&this.setFocus(n),this.terminal.hideCursor(),this.requestRender(),{hide:()=>{let r=this.overlayStack.indexOf(o);if(r!==-1){if(this.clearOverlayFocusRestoreFor(o),this.retargetOverlayPreFocus(o),this.overlayStack.splice(r,1),this.focusedComponent===n){let s=this.getTopmostVisibleOverlay();this.setFocus(s?.component??o.preFocus)}this.overlayStack.length===0&&this.terminal.hideCursor(),this.requestRender()}},setHidden:r=>{if(o.hidden!==r){if(o.hidden=r,r){if(this.clearOverlayFocusRestoreFor(o),this.focusedComponent===n){let s=this.getTopmostVisibleOverlay();this.setFocus(s?.component??o.preFocus)}}else!i?.nonCapturing&&this.isOverlayVisible(o)&&(o.focusOrder=++this.focusOrderCounter,this.setFocus(n));this.requestRender()}},isHidden:()=>o.hidden,focus:()=>{!this.overlayStack.includes(o)||!this.isOverlayVisible(o)||(o.focusOrder=++this.focusOrderCounter,this.setFocus(n),this.requestRender())},unfocus:r=>{let s=this.focusedComponent===n,a=this.overlayFocusRestore,l=a.status!=="inactive"&&a.overlay===o;if(!(!s&&!l)){if(a.status==="blocked"&&a.overlay===o&&this.focusedComponent===a.blockedBy){r?this.overlayFocusRestore={status:"blocked",overlay:o,blockedBy:a.blockedBy,resume:{status:"focus-target",target:r.target}}:this.clearOverlayFocusRestore(),this.requestRender();return}if(this.clearOverlayFocusRestoreFor(o),s||r){let c=this.getTopmostVisibleOverlay(),u=c&&c!==o?c.component:o.preFocus;this.setFocus(r?r.target:u)}this.requestRender()}},isFocused:()=>this.focusedComponent===n}}hideOverlay(){let n=this.overlayStack[this.overlayStack.length-1];if(n){if(this.clearOverlayFocusRestoreFor(n),this.retargetOverlayPreFocus(n),this.overlayStack.pop(),this.focusedComponent===n.component){let i=this.getTopmostVisibleOverlay();this.setFocus(i?.component??n.preFocus)}this.overlayStack.length===0&&this.terminal.hideCursor(),this.requestRender()}}hasOverlay(){return this.overlayStack.some(n=>this.isOverlayVisible(n))}isOverlayVisible(n){return n.hidden?!1:n.options?.visible?n.options.visible(this.terminal.columns,this.terminal.rows):!0}getTopmostVisibleOverlay(){let n;for(let i of this.overlayStack)i.options?.nonCapturing||!this.isOverlayVisible(i)||(!n||i.focusOrder>n.focusOrder)&&(n=i);return n}invalidate(){super.invalidate();for(let n of this.overlayStack)n.component.invalidate?.()}start(){this.stopped=!1,this.terminal.start(n=>this.handleInput(n),()=>this.requestRender()),this.terminal.hideCursor(),this.terminalColorSchemeNotificationsEnabled&&this.terminal.write("\x1B[?2031h"),this.queryCellSize(),this.requestRender()}addInputListener(n){return this.inputListeners.add(n),()=>{this.inputListeners.delete(n)}}removeInputListener(n){this.inputListeners.delete(n)}onTerminalColorSchemeChange(n){return this.terminalColorSchemeListeners.add(n),()=>{this.terminalColorSchemeListeners.delete(n)}}setTerminalColorSchemeNotifications(n){this.terminalColorSchemeNotificationsEnabled!==n&&(this.terminalColorSchemeNotificationsEnabled=n,this.stopped||this.terminal.write(n?"\x1B[?2031h":"\x1B[?2031l"))}queryCellSize(){ft().images&&this.terminal.write("\x1B[16t")}stop(){if(this.stopped=!0,this.renderTimer&&(clearTimeout(this.renderTimer),this.renderTimer=void 0),this.terminalColorSchemeNotificationsEnabled&&this.terminal.write("\x1B[?2031l"),this.previousLines.length>0){this.terminal.write(" ");let i=this.previousLines.length-this.hardwareCursorRow;i>0?this.terminal.write(`\x1B[${i}B`):i<0&&this.terminal.write(`\x1B[${-i}A`),this.terminal.write(`\r
38
+ `||t==="\x1BOM"||ve(t,Ue.enter,0)||ve(t,Ue.kpEnter,0):ve(t,Ue.enter,l)||ve(t,Ue.kpEnter,l)||qn(t,Ue.enter,l);case"backspace":return l===ie.alt?t==="\x1B\x7F"||t==="\x1B\b"?!0:ve(t,Ue.backspace,ie.alt)||qn(t,Ue.backspace,ie.alt):l===ie.ctrl?UM(t,ie.ctrl)?!0:ve(t,Ue.backspace,ie.ctrl)||qn(t,Ue.backspace,ie.ctrl):l===0?UM(t,0)||ve(t,Ue.backspace,0)||qn(t,Ue.backspace,0):ve(t,Ue.backspace,l)||qn(t,Ue.backspace,l);case"insert":return l===0?sn(t,jn.insert)||ve(t,He.insert,0):Rn(t,"insert",l)?!0:ve(t,He.insert,l);case"delete":return l===0?sn(t,jn.delete)||ve(t,He.delete,0):Rn(t,"delete",l)?!0:ve(t,He.delete,l);case"clear":return l===0?sn(t,jn.clear):Rn(t,"clear",l);case"home":return l===0?sn(t,jn.home)||ve(t,He.home,0):Rn(t,"home",l)?!0:ve(t,He.home,l);case"end":return l===0?sn(t,jn.end)||ve(t,He.end,0):Rn(t,"end",l)?!0:ve(t,He.end,l);case"pageup":return l===0?sn(t,jn.pageUp)||ve(t,He.pageUp,0):Rn(t,"pageUp",l)?!0:ve(t,He.pageUp,l);case"pagedown":return l===0?sn(t,jn.pageDown)||ve(t,He.pageDown,0):Rn(t,"pageDown",l)?!0:ve(t,He.pageDown,l);case"up":return l===ie.alt?t==="\x1Bp"||ve(t,Ct.up,ie.alt):l===0?sn(t,jn.up)||ve(t,Ct.up,0):Rn(t,"up",l)?!0:ve(t,Ct.up,l);case"down":return l===ie.alt?t==="\x1Bn"||ve(t,Ct.down,ie.alt):l===0?sn(t,jn.down)||ve(t,Ct.down,0):Rn(t,"down",l)?!0:ve(t,Ct.down,l);case"left":return l===ie.alt?t==="\x1B[1;3D"||!io&&t==="\x1BB"||t==="\x1Bb"||ve(t,Ct.left,ie.alt):l===ie.ctrl?t==="\x1B[1;5D"||Rn(t,"left",ie.ctrl)||ve(t,Ct.left,ie.ctrl):l===0?sn(t,jn.left)||ve(t,Ct.left,0):Rn(t,"left",l)?!0:ve(t,Ct.left,l);case"right":return l===ie.alt?t==="\x1B[1;3C"||!io&&t==="\x1BF"||t==="\x1Bf"||ve(t,Ct.right,ie.alt):l===ie.ctrl?t==="\x1B[1;5C"||Rn(t,"right",ie.ctrl)||ve(t,Ct.right,ie.ctrl):l===0?sn(t,jn.right)||ve(t,Ct.right,0):Rn(t,"right",l)?!0:ve(t,Ct.right,l);case"f1":case"f2":case"f3":case"f4":case"f5":case"f6":case"f7":case"f8":case"f9":case"f10":case"f11":case"f12":return l!==0?!1:sn(t,jn[i])}if(i.length===1&&(i>="a"&&i<="z"||$M(i)||av.has(i))){let c=i.charCodeAt(0),u=mN(i),d=i>="a"&&i<="z",p=$M(i);return l===ie.ctrl+ie.alt&&!io&&u&&t===`\x1B${u}`||l===ie.alt&&!io&&(d||p||av.has(i))&&t===`\x1B${i}`?!0:l===ie.ctrl?u&&t===u?!0:ve(t,c,ie.ctrl)||Ep(t,c,ie.ctrl):l===ie.shift+ie.ctrl?ve(t,c,ie.shift+ie.ctrl)||Ep(t,c,ie.shift+ie.ctrl):l===ie.shift?d&&t===i.toUpperCase()?!0:ve(t,c,ie.shift)||Ep(t,c,ie.shift):l!==0?ve(t,c,l)||Ep(t,c,l):t===i||ve(t,c,0)}return!1}var gN=/^\x1b\[(\d+)(?::(\d*))?(?::(\d+))?(?:;(\d+))?(?::(\d+))?u$/,fN=ie.shift|_c;function _p(t){let e=t.match(gN);if(!e)return;let n=Number.parseInt(e[1]??"",10);if(!Number.isFinite(n))return;let i=e[2]&&e[2].length>0?Number.parseInt(e[2],10):void 0,o=e[4]?Number.parseInt(e[4],10):1,r=Number.isFinite(o)?o-1:0;if((r&~fN)!==0||r&(ie.alt|ie.ctrl))return;let s=n;if(r&ie.shift&&typeof i=="number"&&(s=i),s=lv(s),!(!Number.isFinite(s)||s<32))try{return String.fromCodePoint(s)}catch{return}}function vN(t){let e=cv(t);if(!(!e||(e.modifier&~_c&~ie.shift)!==0)&&!(!Number.isFinite(e.codepoint)||e.codepoint<32))try{return String.fromCodePoint(e.codepoint)}catch{return}}function uv(t){return _p(t)??vN(t)}var Da={"tui.editor.cursorUp":{defaultKeys:"up",description:"Move cursor up"},"tui.editor.cursorDown":{defaultKeys:"down",description:"Move cursor down"},"tui.editor.cursorLeft":{defaultKeys:["left","ctrl+b"],description:"Move cursor left"},"tui.editor.cursorRight":{defaultKeys:["right","ctrl+f"],description:"Move cursor right"},"tui.editor.cursorWordLeft":{defaultKeys:["alt+left","ctrl+left","alt+b"],description:"Move cursor word left"},"tui.editor.cursorWordRight":{defaultKeys:["alt+right","ctrl+right","alt+f"],description:"Move cursor word right"},"tui.editor.cursorLineStart":{defaultKeys:["home","ctrl+a"],description:"Move to line start"},"tui.editor.cursorLineEnd":{defaultKeys:["end","ctrl+e"],description:"Move to line end"},"tui.editor.jumpForward":{defaultKeys:"ctrl+]",description:"Jump forward to character"},"tui.editor.jumpBackward":{defaultKeys:"ctrl+alt+]",description:"Jump backward to character"},"tui.editor.pageUp":{defaultKeys:"pageUp",description:"Page up"},"tui.editor.pageDown":{defaultKeys:"pageDown",description:"Page down"},"tui.editor.deleteCharBackward":{defaultKeys:"backspace",description:"Delete character backward"},"tui.editor.deleteCharForward":{defaultKeys:["delete","ctrl+d"],description:"Delete character forward"},"tui.editor.deleteWordBackward":{defaultKeys:["ctrl+w","alt+backspace"],description:"Delete word backward"},"tui.editor.deleteWordForward":{defaultKeys:["alt+d","alt+delete"],description:"Delete word forward"},"tui.editor.deleteToLineStart":{defaultKeys:"ctrl+u",description:"Delete to line start"},"tui.editor.deleteToLineEnd":{defaultKeys:"ctrl+k",description:"Delete to line end"},"tui.editor.yank":{defaultKeys:"ctrl+y",description:"Yank"},"tui.editor.yankPop":{defaultKeys:"alt+y",description:"Yank pop"},"tui.editor.undo":{defaultKeys:"ctrl+-",description:"Undo"},"tui.input.newLine":{defaultKeys:["shift+enter","ctrl+j"],description:"Insert newline"},"tui.input.submit":{defaultKeys:"enter",description:"Submit input"},"tui.input.tab":{defaultKeys:"tab",description:"Tab / autocomplete"},"tui.input.copy":{defaultKeys:"ctrl+c",description:"Copy selection"},"tui.select.up":{defaultKeys:"up",description:"Move selection up"},"tui.select.down":{defaultKeys:"down",description:"Move selection down"},"tui.select.pageUp":{defaultKeys:"pageUp",description:"Selection page up"},"tui.select.pageDown":{defaultKeys:"pageDown",description:"Selection page down"},"tui.select.confirm":{defaultKeys:"enter",description:"Confirm selection"},"tui.select.cancel":{defaultKeys:["escape","ctrl+c"],description:"Cancel selection"}};function dv(t){if(t===void 0)return[];let e=Array.isArray(t)?t:[t],n=new Set,i=[];for(let o of e)n.has(o)||(n.add(o),i.push(o));return i}var Fa=class{constructor(e,n={}){this.keysById=new Map;this.conflicts=[];this.definitions=e,this.userBindings=n,this.rebuild()}rebuild(){this.keysById.clear(),this.conflicts=[];let e=new Map;for(let[n,i]of Object.entries(this.userBindings))if(n in this.definitions)for(let o of dv(i)){let r=e.get(o)??new Set;r.add(n),e.set(o,r)}for(let[n,i]of e)i.size>1&&this.conflicts.push({key:n,keybindings:[...i]});for(let[n,i]of Object.entries(this.definitions)){let o=this.userBindings[n],r=dv(o===void 0?i.defaultKeys:o);this.keysById.set(n,r)}}matches(e,n){let i=this.keysById.get(n)??[];for(let o of i)if(Fe(e,o))return!0;return!1}getKeys(e){return[...this.keysById.get(e)??[]]}getDefinition(e){return this.definitions[e]}getConflicts(){return this.conflicts.map(e=>({...e,keybindings:[...e.keybindings]}))}setUserBindings(e){this.userBindings=e,this.rebuild()}getUserBindings(){return{...this.userBindings}}getResolvedBindings(){let e={};for(let n of Object.keys(this.definitions)){let i=this.keysById.get(n)??[];e[n]=i.length===1?i[0]:[...i]}return e}},Op=null;function Lc(t){Op=t}function we(){return Op||(Op=new Fa(Da)),Op}var A=class{constructor(e="",n=1,i=1,o){this.text=e,this.paddingX=n,this.paddingY=i,this.customBgFn=o}setText(e){this.text=e,this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}setCustomBgFn(e){this.customBgFn=e,this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}invalidate(){this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}render(e){if(this.cachedLines&&this.cachedText===this.text&&this.cachedWidth===e)return this.cachedLines;if(!this.text||this.text.trim()===""){let d=[];return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=d,d}let n=this.text.replace(/\t/g," "),i=Math.max(1,e-this.paddingX*2),o=rn(n,i),r=" ".repeat(this.paddingX),s=" ".repeat(this.paddingX),a=[];for(let d of o){let p=r+d+s;if(this.customBgFn)a.push(Bo(p,e,this.customBgFn));else{let m=j(p),g=Math.max(0,e-m);a.push(p+" ".repeat(g))}}let l=" ".repeat(e),c=[];for(let d=0;d<this.paddingY;d++){let p=this.customBgFn?Bo(l,e,this.customBgFn):l;c.push(p)}let u=[...c,...a,...c];return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=u,u.length>0?u:[""]}};var NM=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],BM=80,li=class extends A{constructor(n,i,o,r="Loading...",s){super("",1,0);this.frames=[...NM];this.intervalMs=BM;this.currentFrame=0;this.intervalId=null;this.ui=null;this.renderIndicatorVerbatim=!1;this.message="Loading...";this.ui=n,this.spinnerColorFn=i,this.messageColorFn=o,this.message=r,this.setIndicator(s)}render(n){return["",...super.render(n)]}start(){this.updateDisplay(),this.restartAnimation()}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}setMessage(n){this.message=n,this.updateDisplay()}setIndicator(n){this.renderIndicatorVerbatim=n!==void 0,this.frames=n?.frames!==void 0?[...n.frames]:[...NM],this.intervalMs=n?.intervalMs&&n.intervalMs>0?n.intervalMs:BM,this.currentFrame=0,this.start()}restartAnimation(){this.stop(),!(this.frames.length<=1)&&(this.intervalId=setInterval(()=>{this.currentFrame=(this.currentFrame+1)%this.frames.length,this.updateDisplay()},this.intervalMs))}updateDisplay(){let n=this.frames[this.currentFrame]??"",i=this.renderIndicatorVerbatim?n:this.spinnerColorFn(n),o=n.length>0?`${i} `:"";this.setText(`${o}${this.messageColorFn(this.message)}`),this.ui&&this.ui.requestRender()}};var Wc=class extends li{constructor(){super(...arguments);this.abortController=new AbortController}get signal(){return this.abortController.signal}get aborted(){return this.abortController.signal.aborted}handleInput(n){we().matches(n,"tui.select.cancel")&&(this.abortController.abort(),this.onAbort?.())}dispose(){this.stop()}};var Ua=class{constructor(){this.ring=[]}push(e,n){if(e)if(n.accumulate&&this.ring.length>0){let i=this.ring.pop();this.ring.push(n.prepend?e+i:i+e)}else this.ring.push(e)}peek(){return this.ring.length>0?this.ring[this.ring.length-1]:void 0}rotate(){if(this.ring.length>1){let e=this.ring.pop();this.ring.unshift(e)}}get length(){return this.ring.length}};import*as jo from"node:fs";import*as wv from"node:os";import*as Ba from"node:path";import{performance as xv}from"node:perf_hooks";function bN(t){let e=t.startsWith("#")?t.slice(1):t,n=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return{r:n,g:i,b:o}}function $a(t){if(!/^[0-9a-f]+$/i.test(t))return;let e=16**t.length-1;if(!(e<=0))return Math.round(parseInt(t,16)/e*255)}var jM=/^\x1b\]11;([^\x07\x1b]*)(?:\x07|\x1b\\)$/i,xN=/^\x1b\[\?997;(1|2)n$/;function qM(t){return jM.test(t)}function pv(t){let e=t.match(jM);if(!e)return;let n=e[1].trim();if(n.startsWith("#")){let u=n.slice(1);if(/^[0-9a-f]{6}$/i.test(u))return bN(n);if(/^[0-9a-f]{12}$/i.test(u)){let d=$a(u.slice(0,4)),p=$a(u.slice(4,8)),m=$a(u.slice(8,12));return d!==void 0&&p!==void 0&&m!==void 0?{r:d,g:p,b:m}:void 0}return}let i=n.replace(/^rgba?:/i,""),[o,r,s]=i.split("/");if(o===void 0||r===void 0||s===void 0)return;let a=$a(o),l=$a(r),c=$a(s);return a!==void 0&&l!==void 0&&c!==void 0?{r:a,g:l,b:c}:void 0}function mv(t){let e=t.match(xN);if(e)return e[1]==="2"?"light":"dark"}import{execSync as yN}from"node:child_process";var hv=null,zM={widthPx:9,heightPx:18};function Lp(){return zM}function gv(t){zM=t}function wN(){try{return yN("tmux display-message -p '#{client_termfeatures}'",{encoding:"utf8",timeout:250,stdio:["ignore","pipe","ignore"]}).split(",").map(e=>e.trim()).includes("hyperlinks")}catch{return!1}}function HM(t=wN){let e=process.env.TERM_PROGRAM?.toLowerCase()||"",n=process.env.TERMINAL_EMULATOR?.toLowerCase()||"",i=process.env.TERM?.toLowerCase()||"",o=process.env.COLORTERM?.toLowerCase()||"",r=o==="truecolor"||o==="24bit";return process.env.TMUX||i.startsWith("tmux")?{images:null,trueColor:r,hyperlinks:t()}:i.startsWith("screen")?{images:null,trueColor:r,hyperlinks:!1}:process.env.KITTY_WINDOW_ID||e==="kitty"?{images:"kitty",trueColor:!0,hyperlinks:!0}:e==="ghostty"||i.includes("ghostty")||process.env.GHOSTTY_RESOURCES_DIR?{images:"kitty",trueColor:!0,hyperlinks:!0}:process.env.WEZTERM_PANE||e==="wezterm"?{images:"kitty",trueColor:!0,hyperlinks:!0}:e==="warpterminal"||process.env.WARP_SESSION_ID||process.env.WARP_TERMINAL_SESSION_UUID?{images:"kitty",trueColor:!0,hyperlinks:!0}:process.env.ITERM_SESSION_ID||e==="iterm.app"?{images:"iterm2",trueColor:!0,hyperlinks:!0}:process.env.WT_SESSION?{images:null,trueColor:!0,hyperlinks:!0}:e==="vscode"?{images:null,trueColor:!0,hyperlinks:!0}:e==="alacritty"?{images:null,trueColor:!0,hyperlinks:!0}:n==="jetbrains-jediterm"?{images:null,trueColor:!0,hyperlinks:!1}:{images:null,trueColor:r,hyperlinks:!1}}function ft(){return hv||(hv=HM()),hv}var KM="\x1B_G",GM="\x1B]1337;File=";function oo(t){return t.startsWith(KM)||t.startsWith(GM)?!0:t.includes(KM)||t.includes(GM)}function fv(){return Math.floor(Math.random()*4294967294)+1}function VM(t,e={}){let i=["a=T","f=100","q=2"];if(e.moveCursor===!1&&i.push("C=1"),e.columns&&i.push(`c=${e.columns}`),e.rows&&i.push(`r=${e.rows}`),e.imageId&&i.push(`i=${e.imageId}`),t.length<=4096)return`\x1B_G${i.join(",")};${t}\x1B\\`;let o=[],r=0,s=!0;for(;r<t.length;){let a=t.slice(r,r+4096),l=r+4096>=t.length;s?(o.push(`\x1B_G${i.join(",")},m=1;${a}\x1B\\`),s=!1):l?o.push(`\x1B_Gm=0;${a}\x1B\\`):o.push(`\x1B_Gm=1;${a}\x1B\\`),r+=4096}return o.join("")}function vv(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}function QM(t,e={}){let n=[`inline=${e.inline!==!1?1:0}`];if(e.width!==void 0&&n.push(`width=${e.width}`),e.height!==void 0&&n.push(`height=${e.height}`),e.name){let i=Buffer.from(e.name).toString("base64");n.push(`name=${i}`)}return e.preserveAspectRatio===!1&&n.push("preserveAspectRatio=0"),`\x1B]1337;File=${n.join(";")}:${t}\x07`}function kN(t,e,n,i={widthPx:9,heightPx:18}){let o=Math.max(1,Math.floor(e)),r=n===void 0?void 0:Math.max(1,Math.floor(n)),s=Math.max(1,t.widthPx),a=Math.max(1,t.heightPx),l=o*i.widthPx/s,c=r===void 0?l:r*i.heightPx/a,u=Math.min(l,c),d=s*u,p=a*u,m=Math.ceil(d/i.widthPx),g=Math.ceil(p/i.heightPx);return{columns:Math.max(1,Math.min(o,m)),rows:Math.max(1,r===void 0?g:Math.min(r,g))}}function YM(t){try{let e=Buffer.from(t,"base64");if(e.length<24||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)return null;let n=e.readUInt32BE(16),i=e.readUInt32BE(20);return{widthPx:n,heightPx:i}}catch{return null}}function JM(t){try{let e=Buffer.from(t,"base64");if(e.length<2||e[0]!==255||e[1]!==216)return null;let n=2;for(;n<e.length-9;){if(e[n]!==255){n++;continue}let i=e[n+1];if(i>=192&&i<=194){let r=e.readUInt16BE(n+5);return{widthPx:e.readUInt16BE(n+7),heightPx:r}}if(n+3>=e.length)return null;let o=e.readUInt16BE(n+2);if(o<2)return null;n+=2+o}return null}catch{return null}}function XM(t){try{let e=Buffer.from(t,"base64");if(e.length<10)return null;let n=e.slice(0,6).toString("ascii");if(n!=="GIF87a"&&n!=="GIF89a")return null;let i=e.readUInt16LE(6),o=e.readUInt16LE(8);return{widthPx:i,heightPx:o}}catch{return null}}function ZM(t){try{let e=Buffer.from(t,"base64");if(e.length<30)return null;let n=e.slice(0,4).toString("ascii"),i=e.slice(8,12).toString("ascii");if(n!=="RIFF"||i!=="WEBP")return null;let o=e.slice(12,16).toString("ascii");if(o==="VP8 "){if(e.length<30)return null;let r=e.readUInt16LE(26)&16383,s=e.readUInt16LE(28)&16383;return{widthPx:r,heightPx:s}}else if(o==="VP8L"){if(e.length<25)return null;let r=e.readUInt32LE(21),s=(r&16383)+1,a=(r>>14&16383)+1;return{widthPx:s,heightPx:a}}else if(o==="VP8X"){if(e.length<30)return null;let r=(e[24]|e[25]<<8|e[26]<<16)+1,s=(e[27]|e[28]<<8|e[29]<<16)+1;return{widthPx:r,heightPx:s}}return null}catch{return null}}function Fc(t,e){return e==="image/png"?YM(t):e==="image/jpeg"?JM(t):e==="image/gif"?XM(t):e==="image/webp"?ZM(t):null}function bv(t,e,n={}){let i=ft();if(!i.images)return null;let o=n.maxWidthCells??80,r=kN(e,o,n.maxHeightCells,Lp());return i.images==="kitty"?{sequence:VM(t,{columns:r.columns,rows:r.rows,imageId:n.imageId,moveCursor:n.moveCursor}),rows:r.rows,imageId:n.imageId}:i.images==="iterm2"?{sequence:QM(t,{width:r.columns,height:"auto",preserveAspectRatio:n.preserveAspectRatio??!0}),rows:r.rows}:null}function Lr(t,e){return`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`}function Na(t,e,n){let i=[];return n&&i.push(n),i.push(`[${t}]`),e&&i.push(`${e.widthPx}x${e.heightPx}`),`[Image: ${i.join(" ")}]`}var eR="\x1B_G";function nR(t){let e=t.indexOf(eR);if(e===-1)return;let n=e+eR.length,i=t.indexOf(";",n);if(i===-1)return;let o=[],r=1,s=t.slice(n,i);for(let a of s.split(",")){let[l,c]=a.split("=",2);if(c===void 0)continue;let u=Number(c);!Number.isInteger(u)||u<=0||u>4294967295||(l==="i"?o.push(u):l==="r"&&(r=u))}return{ids:o,rows:r}}function yv(t){return nR(t)?.ids??[]}function SN(t){return nR(t)?.rows??1}function kv(t){return t!==null&&"focused"in t}var Wr="\x1B_pi:c\x07";function tR(t,e){if(t===void 0)return;if(typeof t=="number")return t;let n=t.match(/^(\d+(?:\.\d+)?)%$/);if(n)return Math.floor(e*parseFloat(n[1])/100)}function TN(){return!!process.env.TERMUX_VERSION}var z=class{constructor(){this.children=[]}addChild(e){this.children.push(e)}removeChild(e){let n=this.children.indexOf(e);n!==-1&&this.children.splice(n,1)}clear(){this.children=[]}invalidate(){for(let e of this.children)e.invalidate?.()}render(e){let n=[];for(let i of this.children){let o=i.render(e);for(let r of o)n.push(r)}return n}},Fr=class t extends z{constructor(n,i){super();this.previousLines=[];this.previousKittyImageIds=new Set;this.previousWidth=0;this.previousHeight=0;this.focusedComponent=null;this.inputListeners=new Set;this.renderRequested=!1;this.lastRenderAt=0;this.cursorRow=0;this.hardwareCursorRow=0;this.showHardwareCursor=process.env.PI_HARDWARE_CURSOR==="1";this.clearOnShrink=process.env.PI_CLEAR_ON_SHRINK==="1";this.maxLinesRendered=0;this.previousViewportTop=0;this.fullRedrawCount=0;this.stopped=!1;this.pendingOsc11BackgroundReplies=0;this.pendingOsc11BackgroundQueries=[];this.terminalColorSchemeListeners=new Set;this.terminalColorSchemeNotificationsEnabled=!1;this.focusOrderCounter=0;this.overlayStack=[];this.overlayFocusRestore={status:"inactive"};this.terminal=n,i!==void 0&&(this.showHardwareCursor=i)}static{this.MIN_RENDER_INTERVAL_MS=16}get fullRedraws(){return this.fullRedrawCount}getShowHardwareCursor(){return this.showHardwareCursor}setShowHardwareCursor(n){this.showHardwareCursor!==n&&(this.showHardwareCursor=n,n||this.terminal.hideCursor(),this.requestRender())}getClearOnShrink(){return this.clearOnShrink}setClearOnShrink(n){this.clearOnShrink=n}setFocus(n){this.setFocusInternal({component:n,overlayFocusRestore:"clear"})}setFocusInternal({component:n,overlayFocusRestore:i}){let o=this.focusedComponent,r=n,s=o?this.overlayStack.find(u=>u.component===o&&this.isOverlayVisible(u)):void 0,a=r?this.overlayStack.some(u=>u.component===r):!1,l=this.getVisibleOverlayFocusRestore();r&&!a?l.status==="blocked"&&l.blockedBy===o?l.resume.status==="focus-target"||!this.isComponentMounted(l.blockedBy)?r=this.resolveBlockedOverlayFocusResume(l):this.overlayFocusRestore={status:"blocked",overlay:l.overlay,blockedBy:r,resume:l.resume}:s&&l.status!=="inactive"&&l.overlay===s&&!this.isOverlayFocusAncestor(s,r)&&(this.overlayFocusRestore={status:"blocked",overlay:s,blockedBy:r,resume:{status:"restore-overlay"}}):r===null&&(l.status==="blocked"&&l.blockedBy===o?r=this.resolveBlockedOverlayFocusResume(l):i==="clear"&&this.clearOverlayFocusRestore()),kv(this.focusedComponent)&&(this.focusedComponent.focused=!1),this.focusedComponent=r,kv(r)&&(r.focused=!0);let c=r?this.overlayStack.find(u=>u.component===r&&this.isOverlayVisible(u)):void 0;c&&(this.overlayFocusRestore={status:"eligible",overlay:c})}clearOverlayFocusRestore(){this.overlayFocusRestore={status:"inactive"}}clearOverlayFocusRestoreFor(n){this.overlayFocusRestore.status!=="inactive"&&this.overlayFocusRestore.overlay===n&&this.clearOverlayFocusRestore()}resolveBlockedOverlayFocusResume(n){return n.resume.status==="restore-overlay"?n.overlay.component:(this.clearOverlayFocusRestore(),n.resume.target)}getVisibleOverlayFocusRestore(){let n=this.overlayFocusRestore;return n.status==="inactive"?n:!this.overlayStack.includes(n.overlay)||!this.isOverlayVisible(n.overlay)?{status:"inactive"}:n}isOverlayFocusAncestor(n,i){let o=new Set,r=n.preFocus;for(;r&&!o.has(r);){if(o.add(r),r===i)return!0;r=this.overlayStack.find(s=>s.component===r)?.preFocus??null}return!1}retargetOverlayPreFocus(n){for(let i of this.overlayStack)i!==n&&i.preFocus===n.component&&(i.preFocus=n.preFocus)}isComponentMounted(n){return this.children.some(i=>this.containsComponent(i,n))}containsComponent(n,i){return n===i?!0:n instanceof z?n.children.some(o=>this.containsComponent(o,i)):!1}showOverlay(n,i){let o={component:n,...i===void 0?{}:{options:i},preFocus:this.focusedComponent,hidden:!1,focusOrder:++this.focusOrderCounter};return this.overlayStack.push(o),!i?.nonCapturing&&this.isOverlayVisible(o)&&this.setFocus(n),this.terminal.hideCursor(),this.requestRender(),{hide:()=>{let r=this.overlayStack.indexOf(o);if(r!==-1){if(this.clearOverlayFocusRestoreFor(o),this.retargetOverlayPreFocus(o),this.overlayStack.splice(r,1),this.focusedComponent===n){let s=this.getTopmostVisibleOverlay();this.setFocus(s?.component??o.preFocus)}this.overlayStack.length===0&&this.terminal.hideCursor(),this.requestRender()}},setHidden:r=>{if(o.hidden!==r){if(o.hidden=r,r){if(this.clearOverlayFocusRestoreFor(o),this.focusedComponent===n){let s=this.getTopmostVisibleOverlay();this.setFocus(s?.component??o.preFocus)}}else!i?.nonCapturing&&this.isOverlayVisible(o)&&(o.focusOrder=++this.focusOrderCounter,this.setFocus(n));this.requestRender()}},isHidden:()=>o.hidden,focus:()=>{!this.overlayStack.includes(o)||!this.isOverlayVisible(o)||(o.focusOrder=++this.focusOrderCounter,this.setFocus(n),this.requestRender())},unfocus:r=>{let s=this.focusedComponent===n,a=this.overlayFocusRestore,l=a.status!=="inactive"&&a.overlay===o;if(!(!s&&!l)){if(a.status==="blocked"&&a.overlay===o&&this.focusedComponent===a.blockedBy){r?this.overlayFocusRestore={status:"blocked",overlay:o,blockedBy:a.blockedBy,resume:{status:"focus-target",target:r.target}}:this.clearOverlayFocusRestore(),this.requestRender();return}if(this.clearOverlayFocusRestoreFor(o),s||r){let c=this.getTopmostVisibleOverlay(),u=c&&c!==o?c.component:o.preFocus;this.setFocus(r?r.target:u)}this.requestRender()}},isFocused:()=>this.focusedComponent===n}}hideOverlay(){let n=this.overlayStack[this.overlayStack.length-1];if(n){if(this.clearOverlayFocusRestoreFor(n),this.retargetOverlayPreFocus(n),this.overlayStack.pop(),this.focusedComponent===n.component){let i=this.getTopmostVisibleOverlay();this.setFocus(i?.component??n.preFocus)}this.overlayStack.length===0&&this.terminal.hideCursor(),this.requestRender()}}hasOverlay(){return this.overlayStack.some(n=>this.isOverlayVisible(n))}isOverlayVisible(n){return n.hidden?!1:n.options?.visible?n.options.visible(this.terminal.columns,this.terminal.rows):!0}getTopmostVisibleOverlay(){let n;for(let i of this.overlayStack)i.options?.nonCapturing||!this.isOverlayVisible(i)||(!n||i.focusOrder>n.focusOrder)&&(n=i);return n}invalidate(){super.invalidate();for(let n of this.overlayStack)n.component.invalidate?.()}start(){this.stopped=!1,this.terminal.start(n=>this.handleInput(n),()=>this.requestRender()),this.terminal.hideCursor(),this.terminalColorSchemeNotificationsEnabled&&this.terminal.write("\x1B[?2031h"),this.queryCellSize(),this.requestRender()}addInputListener(n){return this.inputListeners.add(n),()=>{this.inputListeners.delete(n)}}removeInputListener(n){this.inputListeners.delete(n)}onTerminalColorSchemeChange(n){return this.terminalColorSchemeListeners.add(n),()=>{this.terminalColorSchemeListeners.delete(n)}}setTerminalColorSchemeNotifications(n){this.terminalColorSchemeNotificationsEnabled!==n&&(this.terminalColorSchemeNotificationsEnabled=n,this.stopped||this.terminal.write(n?"\x1B[?2031h":"\x1B[?2031l"))}queryCellSize(){ft().images&&this.terminal.write("\x1B[16t")}stop(){if(this.stopped=!0,this.renderTimer&&(clearTimeout(this.renderTimer),this.renderTimer=void 0),this.terminalColorSchemeNotificationsEnabled&&this.terminal.write("\x1B[?2031l"),this.previousLines.length>0){this.terminal.write(" ");let i=this.previousLines.length-this.hardwareCursorRow;i>0?this.terminal.write(`\x1B[${i}B`):i<0&&this.terminal.write(`\x1B[${-i}A`),this.terminal.write(`\r
39
39
  `)}this.terminal.showCursor(),this.terminal.stop()}requestRender(n=!1){if(n){this.previousLines=[],this.previousWidth=-1,this.previousHeight=-1,this.cursorRow=0,this.hardwareCursorRow=0,this.maxLinesRendered=0,this.previousViewportTop=0,this.renderTimer&&(clearTimeout(this.renderTimer),this.renderTimer=void 0),this.renderRequested=!0,process.nextTick(()=>{this.stopped||!this.renderRequested||(this.renderRequested=!1,this.lastRenderAt=xv.now(),this.doRender())});return}this.renderRequested||(this.renderRequested=!0,process.nextTick(()=>this.scheduleRender()))}scheduleRender(){if(this.stopped||this.renderTimer||!this.renderRequested)return;let n=xv.now()-this.lastRenderAt,i=Math.max(0,t.MIN_RENDER_INTERVAL_MS-n);this.renderTimer=setTimeout(()=>{this.renderTimer=void 0,!(this.stopped||!this.renderRequested)&&(this.renderRequested=!1,this.lastRenderAt=xv.now(),this.doRender(),this.renderRequested&&this.scheduleRender())},i)}handleInput(n){if(this.consumeOsc11BackgroundResponse(n)||this.consumeTerminalColorSchemeReport(n))return;if(this.inputListeners.size>0){let r=n;for(let s of this.inputListeners){let a=s(r);if(a?.consume)return;a?.data!==void 0&&(r=a.data)}if(r.length===0)return;n=r}if(this.consumeCellSizeResponse(n))return;if(Fe(n,"shift+ctrl+d")&&this.onDebug){this.onDebug();return}let i=this.overlayStack.find(r=>r.component===this.focusedComponent);if(i&&!this.isOverlayVisible(i)){let r=this.getTopmostVisibleOverlay();r?this.setFocus(r.component):this.setFocusInternal({component:i.preFocus,overlayFocusRestore:"preserve"})}if(!this.overlayStack.some(r=>r.component===this.focusedComponent)){let r=this.getVisibleOverlayFocusRestore();r.status==="eligible"?this.setFocus(r.overlay.component):r.status==="blocked"&&r.blockedBy!==this.focusedComponent&&(r.resume.status==="restore-overlay"?this.setFocus(r.overlay.component):(this.clearOverlayFocusRestore(),this.setFocus(r.resume.target)))}if(this.focusedComponent?.handleInput){if(ai(n)&&!this.focusedComponent.wantsKeyRelease)return;this.focusedComponent.handleInput(n),this.requestRender()}}consumeOsc11BackgroundResponse(n){if(this.pendingOsc11BackgroundReplies<=0||!qM(n))return!1;let i=pv(n);this.pendingOsc11BackgroundReplies-=1;let o=this.pendingOsc11BackgroundQueries.shift();return o&&!o.settled&&(o.settled=!0,o.timer&&(clearTimeout(o.timer),o.timer=void 0),o.resolve?.(i),o.resolve=void 0),!0}consumeTerminalColorSchemeReport(n){let i=mv(n);if(!i)return!1;for(let o of this.terminalColorSchemeListeners)o(i);return!0}consumeCellSizeResponse(n){let i=n.match(/^\x1b\[6;(\d+);(\d+)t$/);if(!i)return!1;let o=parseInt(i[1],10),r=parseInt(i[2],10);return o<=0||r<=0||(gv({widthPx:r,heightPx:o}),this.invalidate(),this.requestRender()),!0}resolveOverlayLayout(n,i,o,r){let s=n??{},a=typeof s.margin=="number"?{top:s.margin,right:s.margin,bottom:s.margin,left:s.margin}:s.margin??{},l=Math.max(0,a.top??0),c=Math.max(0,a.right??0),u=Math.max(0,a.bottom??0),d=Math.max(0,a.left??0),p=Math.max(1,o-d-c),m=Math.max(1,r-l-u),g=tR(s.width,o)??Math.min(80,p);s.minWidth!==void 0&&(g=Math.max(g,s.minWidth)),g=Math.max(1,Math.min(g,p));let h=tR(s.maxHeight,r);h!==void 0&&(h=Math.max(1,Math.min(h,m)));let f=h!==void 0?Math.min(i,h):i,b,x;if(s.row!==void 0)if(typeof s.row=="string"){let y=s.row.match(/^(\d+(?:\.\d+)?)%$/);if(y){let T=Math.max(0,m-f),P=parseFloat(y[1])/100;b=l+Math.floor(T*P)}else b=this.resolveAnchorRow("center",f,m,l)}else b=s.row;else{let y=s.anchor??"center";b=this.resolveAnchorRow(y,f,m,l)}if(s.col!==void 0)if(typeof s.col=="string"){let y=s.col.match(/^(\d+(?:\.\d+)?)%$/);if(y){let T=Math.max(0,p-g),P=parseFloat(y[1])/100;x=d+Math.floor(T*P)}else x=this.resolveAnchorCol("center",g,p,d)}else x=s.col;else{let y=s.anchor??"center";x=this.resolveAnchorCol(y,g,p,d)}return s.offsetY!==void 0&&(b+=s.offsetY),s.offsetX!==void 0&&(x+=s.offsetX),b=Math.max(l,Math.min(b,r-u-f)),x=Math.max(d,Math.min(x,o-c-g)),{width:g,row:b,col:x,maxHeight:h}}resolveAnchorRow(n,i,o,r){switch(n){case"top-left":case"top-center":case"top-right":return r;case"bottom-left":case"bottom-center":case"bottom-right":return r+o-i;case"left-center":case"center":case"right-center":return r+Math.floor((o-i)/2)}}resolveAnchorCol(n,i,o,r){switch(n){case"top-left":case"left-center":case"bottom-left":return r;case"top-right":case"right-center":case"bottom-right":return r+o-i;case"top-center":case"center":case"bottom-center":return r+Math.floor((o-i)/2)}}compositeOverlays(n,i,o){if(this.overlayStack.length===0)return n;let r=[...n],s=[],a=r.length,l=this.overlayStack.filter(d=>this.isOverlayVisible(d));l.sort((d,p)=>d.focusOrder-p.focusOrder);for(let d of l){let{component:p,options:m}=d,{width:g,maxHeight:h}=this.resolveOverlayLayout(m,0,i,o),f=p.render(g);h!==void 0&&f.length>h&&(f=f.slice(0,h));let{row:b,col:x}=this.resolveOverlayLayout(m,f.length,i,o);s.push({overlayLines:f,row:b,col:x,w:g}),a=Math.max(a,b+f.length)}let c=Math.max(r.length,o,a);for(;r.length<c;)r.push("");let u=Math.max(0,c-o);for(let{overlayLines:d,row:p,col:m,w:g}of s)for(let h=0;h<d.length;h++){let f=u+p+h;if(f>=0&&f<r.length){let b=j(d[h])>g?no(d[h],0,g,!0):d[h];r[f]=this.compositeLineAt(r[f],b,m,g,i)}}return r}static{this.SEGMENT_RESET="\x1B[0m\x1B]8;;\x07"}applyLineResets(n){let i=t.SEGMENT_RESET;for(let o=0;o<n.length;o++){let r=n[o];oo(r)||(n[o]=WM(r)+i)}return n}collectKittyImageIds(n){let i=new Set;for(let o of n)for(let r of yv(o))i.add(r);return i}deleteKittyImages(n){let i="";for(let o of n)i+=vv(o);return i}getKittyImageReservedRows(n,i,o=n.length-1){let r=SN(n[i]??"");if(r<=1)return 1;let s=Math.min(r,o-i+1,n.length-i),a=1;for(;a<s;){let l=n[i+a]??"";if(oo(l)||j(l)>0)break;a++}return a}expandChangedRangeForKittyImages(n,i,o){let r=n,s=i,a=l=>{for(let c=0;c<l.length;c++){if(yv(l[c]).length===0)continue;let u=c+this.getKittyImageReservedRows(l,c)-1;(c>=n||c<=i&&u>=n)&&(r=Math.min(r,c),s=Math.max(s,u))}};return a(this.previousLines),a(o),{firstChanged:r,lastChanged:s}}deleteChangedKittyImages(n,i){if(n<0||i<n)return"";let o=new Set,r=Math.min(i,this.previousLines.length-1);for(let s=n;s<=r;s++)for(let a of yv(this.previousLines[s]??""))o.add(a);return this.deleteKittyImages(o)}compositeLineAt(n,i,o,r,s){if(oo(n))return n;let a=o+r,l=DM(n,o,a,s-a,!0),c=sv(i,0,r,!0),u=Math.max(0,o-l.beforeWidth),d=Math.max(0,r-c.width),p=Math.max(o,l.beforeWidth),m=Math.max(r,c.width),g=Math.max(0,s-p-m),h=Math.max(0,g-l.afterWidth),f=t.SEGMENT_RESET,b=l.before+" ".repeat(u)+f+c.text+" ".repeat(d)+f+l.after+" ".repeat(h);return j(b)<=s?b:no(b,0,s,!0)}extractCursorPosition(n,i){let o=Math.max(0,n.length-i);for(let r=n.length-1;r>=o;r--){let s=n[r],a=s.indexOf(Wr);if(a!==-1){let l=s.slice(0,a),c=j(l);return n[r]=s.slice(0,a)+s.slice(a+Wr.length),{row:r,col:c}}}return null}doRender(){if(this.stopped)return;let n=this.terminal.columns,i=this.terminal.rows,o=this.previousWidth!==0&&this.previousWidth!==n,r=this.previousHeight!==0&&this.previousHeight!==i,s=this.previousHeight>0?this.previousViewportTop+this.previousHeight:i,a=r?Math.max(0,s-i):this.previousViewportTop,l=a,c=this.hardwareCursorRow,u=O=>{let R=c-a;return O-l-R},d=this.render(n);this.overlayStack.length>0&&(d=this.compositeOverlays(d,n,i));let p=this.extractCursorPosition(d,i);d=this.applyLineResets(d);let m=O=>{this.fullRedrawCount+=1;let R="\x1B[?2026h";O&&(R+=this.deleteKittyImages(this.previousKittyImageIds),R+="\x1B[2J\x1B[H\x1B[3J");for(let U=0;U<d.length;U++){U>0&&(R+=`\r
40
40
  `);let G=d[U],Z=oo(G)?this.getKittyImageReservedRows(d,U):1;if(Z>1&&Z<=i){for(let Y=1;Y<Z;Y++)R+=`\r
41
41
  `;R+=`\x1B[${Z-1}A`,R+=G,R+=`\x1B[${Z-1}B`,U+=Z-1;continue}R+=G}R+="\x1B[?2026l",this.terminal.write(R),this.cursorRow=Math.max(0,d.length-1),this.hardwareCursorRow=this.cursorRow,O?this.maxLinesRendered=d.length:this.maxLinesRendered=Math.max(this.maxLinesRendered,d.length);let E=Math.max(i,d.length);this.previousViewportTop=Math.max(0,E-i),this.positionHardwareCursor(p,d.length),this.previousLines=d,this.previousKittyImageIds=this.collectKittyImageIds(d),this.previousWidth=n,this.previousHeight=i},g=process.env.PI_DEBUG_REDRAW==="1",h=O=>{if(!g)return;let R=Ba.join(wv.homedir(),".pi","agent","pi-debug.log"),E=`[${new Date().toISOString()}] fullRender: ${O} (prev=${this.previousLines.length}, new=${d.length}, height=${i})
@@ -47,8 +47,8 @@ ${s}`),i.push({type:"error",reason:o.stopReason,error:o}),i.end()}})(),i},nU=(t,
47
47
  `);jo.mkdirSync(Ba.dirname(G),{recursive:!0}),jo.writeFileSync(G,q),this.stop();let Z=[`Rendered line ${O} exceeds terminal width (${j(R)} > ${n}).`,"","This is likely caused by a custom TUI component not truncating its output.","Use visibleWidth() to measure and truncateToWidth() to truncate lines.","",`Debug log written to: ${G}`].join(`
48
48
  `);throw new Error(Z)}P+=R}let F=_;if(this.previousLines.length>d.length){if(_<d.length-1){let R=d.length-1-_;P+=`\x1B[${R}B`,F=d.length-1}let O=this.previousLines.length-d.length;for(let R=d.length;R<this.previousLines.length;R++)P+=`\r
49
49
  \x1B[2K`;P+=`\x1B[${O}A`}if(P+="\x1B[?2026l",process.env.PI_TUI_DEBUG==="1"){let O="/tmp/tui";jo.mkdirSync(O,{recursive:!0});let R=Ba.join(O,`render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`),E=[`firstChanged: ${f}`,`viewportTop: ${l}`,`cursorRow: ${this.cursorRow}`,`height: ${i}`,`lineDiff: ${D}`,`hardwareCursorRow: ${c}`,`renderEnd: ${_}`,`finalCursorRow: ${F}`,`cursorPos: ${JSON.stringify(p)}`,`newLines.length: ${d.length}`,`previousLines.length: ${this.previousLines.length}`,"","=== newLines ===",JSON.stringify(d,null,2),"","=== previousLines ===",JSON.stringify(this.previousLines,null,2),"","=== buffer ===",JSON.stringify(P)].join(`
50
- `);jo.writeFileSync(R,E)}this.terminal.write(P),this.cursorRow=Math.max(0,d.length-1),this.hardwareCursorRow=F,this.maxLinesRendered=Math.max(this.maxLinesRendered,d.length),this.previousViewportTop=Math.max(a,F-i+1),this.positionHardwareCursor(p,d.length),this.previousLines=d,this.previousKittyImageIds=this.collectKittyImageIds(d),this.previousWidth=n,this.previousHeight=i}positionHardwareCursor(n,i){if(!n||i<=0){this.terminal.hideCursor();return}let o=Math.max(0,Math.min(n.row,i-1)),r=Math.max(0,n.col),s=o-this.hardwareCursorRow,a="";s>0?a+=`\x1B[${s}B`:s<0&&(a+=`\x1B[${-s}A`),a+=`\x1B[${r+1}G`,a&&this.terminal.write(a),this.hardwareCursorRow=o,this.showHardwareCursor?this.terminal.showCursor():this.terminal.hideCursor()}queryTerminalBackgroundColor({timeoutMs:n}){return new Promise(i=>{let o={settled:!1,resolve:i,timer:void 0};o.timer=setTimeout(()=>{o.settled||(o.settled=!0,o.timer=void 0,o.resolve?.(void 0),o.resolve=void 0)},n),this.pendingOsc11BackgroundQueries.push(o),this.pendingOsc11BackgroundReplies+=1,this.terminal.write("\x1B]11;?\x07")})}queryTerminalColorScheme({timeoutMs:n}){return new Promise(i=>{let o=!1,r,s=()=>{},a=l=>{o||(o=!0,r&&(clearTimeout(r),r=void 0),s(),i(l))};s=this.onTerminalColorSchemeChange(a),r=setTimeout(()=>a(void 0),n),this.terminal.write("\x1B[?996n")})}};var ja=class{constructor(){this.stack=[]}push(e){this.stack.push(structuredClone(e))}pop(){return this.stack.pop()}clear(){this.stack.length=0}get length(){return this.stack.length}};var iR=Mp();function Wp(t,e,n){if(e<=0)return 0;let i=t.slice(0,e),o=n?.segment,r=n?.isAtomicSegment,s=o?[...o(i)]:[...iR.segment(i)],a=e;for(;s.length>0&&!r?.(s[s.length-1]?.segment||"")&&Mn(s[s.length-1]?.segment||"");)a-=s.pop()?.segment.length||0;if(s.length===0)return a;let l=s[s.length-1];if(r?.(l.segment))a-=l.segment.length;else if(l.isWordLike){let c=l.segment,u=[...c.matchAll(new RegExp(rv,"g"))];if(u.length<=0)a-=c.length;else{let d=u[u.length-1];a-=c.length-(d.index+d[0].length)}}else for(;s.length>0&&!r?.(s[s.length-1]?.segment||"")&&!s[s.length-1]?.isWordLike&&!Mn(s[s.length-1]?.segment||"");)a-=s.pop()?.segment.length||0;return a}function Fp(t,e,n){if(e>=t.length)return t.length;let i=t.slice(e),o=n?.segment,r=n?.isAtomicSegment,a=(o?o(i):iR.segment(i))[Symbol.iterator](),l=a.next(),c=e;for(;!l.done&&!r?.(l.value.segment)&&Mn(l.value.segment);)c+=l.value.segment.length,l=a.next();if(l.done)return c;if(r?.(l.value.segment))c+=l.value.segment.length;else if(l.value.isWordLike)c+=rv.exec(l.value.segment)?.index??l.value.segment.length;else for(;!l.done&&!r?.(l.value.segment)&&!l.value.isWordLike&&!Mn(l.value.segment);)c+=l.value.segment.length,l=a.next();return c}var oR=32,rR=2,CN=10,MN=t=>t.replace(/[\r\n]+/g," ").trim(),RN=(t,e,n)=>Math.max(e,Math.min(t,n)),Ht=class{constructor(e,n,i,o={}){this.items=[];this.filteredItems=[];this.selectedIndex=0;this.maxVisible=5;this.items=e,this.filteredItems=e,this.maxVisible=n,this.theme=i,this.layout=o}setFilter(e){this.filteredItems=this.items.filter(n=>n.value.toLowerCase().startsWith(e.toLowerCase())),this.selectedIndex=0}setSelectedIndex(e){this.selectedIndex=Math.max(0,Math.min(e,this.filteredItems.length-1))}invalidate(){}render(e){let n=[];if(this.filteredItems.length===0)return n.push(this.theme.noMatch(" No matching commands")),n;let i=this.getPrimaryColumnWidth(),o=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredItems.length-this.maxVisible)),r=Math.min(o+this.maxVisible,this.filteredItems.length);for(let s=o;s<r;s++){let a=this.filteredItems[s];if(!a)continue;let l=s===this.selectedIndex,c=a.description?MN(a.description):void 0;n.push(this.renderItem(a,l,e,c,i))}if(o>0||r<this.filteredItems.length){let s=` (${this.selectedIndex+1}/${this.filteredItems.length})`;n.push(this.theme.scrollInfo(te(s,e-2,"")))}return n}handleInput(e){let n=ke();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.filteredItems.length-1:this.selectedIndex-1,this.notifySelectionChange();else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.filteredItems.length-1?0:this.selectedIndex+1,this.notifySelectionChange();else if(n.matches(e,"tui.select.confirm")){let i=this.filteredItems[this.selectedIndex];i&&this.onSelect&&this.onSelect(i)}else n.matches(e,"tui.select.cancel")&&this.onCancel&&this.onCancel()}renderItem(e,n,i,o,r){let s=n?"\u2192 ":" ",a=j(s);if(o&&i>40){let u=Math.max(1,Math.min(r,i-a-4)),d=Math.max(1,u-rR),p=this.truncatePrimary(e,n,d,u),m=j(p),g=" ".repeat(Math.max(1,u-m)),h=a+m+g.length,f=i-h-2;if(f>CN){let b=te(o,f,"");if(n)return this.theme.selectedText(`${s}${p}${g}${b}`);let x=this.theme.description(g+b);return s+p+x}}let l=i-a-2,c=this.truncatePrimary(e,n,l,l);return n?this.theme.selectedText(`${s}${c}`):s+c}getPrimaryColumnWidth(){let{min:e,max:n}=this.getPrimaryColumnBounds(),i=this.filteredItems.reduce((o,r)=>Math.max(o,j(this.getDisplayValue(r))+rR),0);return RN(i,e,n)}getPrimaryColumnBounds(){let e=this.layout.minPrimaryColumnWidth??this.layout.maxPrimaryColumnWidth??oR,n=this.layout.maxPrimaryColumnWidth??this.layout.minPrimaryColumnWidth??oR;return{min:Math.max(1,Math.min(e,n)),max:Math.max(1,Math.max(e,n))}}truncatePrimary(e,n,i,o){let r=this.getDisplayValue(e),s=this.layout.truncatePrimary?this.layout.truncatePrimary({text:r,maxWidth:i,columnWidth:o,item:e,isSelected:n}):te(r,i,"");return te(s,i,"")}getDisplayValue(e){return e.label||e.value}notifySelectionChange(){let e=this.filteredItems[this.selectedIndex];e&&this.onSelectionChange&&this.onSelectionChange(e)}getSelectedItem(){return this.filteredItems[this.selectedIndex]||null}};var cR=Cp(),PN=Mp(),uR=/\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]/g,dR=/^\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]$/;function qa(t){return t.length>=10&&dR.test(t)}function IN(t,e,n){if(n.size===0||!t.includes("[paste #"))return e.segment(t);let i=[];for(let a of t.matchAll(uR)){let l=Number.parseInt(a[1],10);n.has(l)&&i.push({start:a.index,end:a.index+a[0].length})}if(i.length===0)return e.segment(t);let o=e.segment(t),r=[],s=0;for(let a of o){for(;s<i.length&&i[s].end<=a.index;)s++;let l=s<i.length?i[s]:null;if(l&&a.index>=l.start&&a.index<l.end){if(a.index===l.start){let c=t.slice(l.start,l.end);r.push({segment:c,index:l.start,input:t})}}else r.push(a)}return r}function Sv(t,e,n){if(!t||e<=0)return[{text:"",startIndex:0,endIndex:0}];if(j(t)<=e)return[{text:t,startIndex:0,endIndex:t.length}];let o=[],r=n??[...cR.segment(t)],s=0,a=0,l=-1,c=0;for(let u=0;u<r.length;u++){let d=r[u],p=d.segment,m=j(p),g=d.index,h=!qa(p)&&Mn(p);if(s+m>e&&(l>=0&&s-c+m<=e?(o.push({text:t.slice(a,l),startIndex:a,endIndex:l}),a=l,s-=c):a<g&&(o.push({text:t.slice(a,g),startIndex:a,endIndex:g}),a=g,s=0),l=-1),m>e){let b=Sv(p,e);for(let y=0;y<b.length-1;y++){let T=b[y];o.push({text:T.text,startIndex:g+T.startIndex,endIndex:g+T.endIndex})}let x=b[b.length-1];a=g+x.startIndex,s=j(x.text),l=-1;continue}s+=m;let f=r[u+1];if(h&&f&&(qa(f.segment)||!Mn(f.segment)))l=f.index,c=s;else if(!h&&f&&!Mn(f.segment)){let b=!qa(p)&&Rp.test(p),x=!qa(f.segment)&&Rp.test(f.segment);(b||x)&&(l=f.index,c=s)}}return o.push({text:t.slice(a),startIndex:a,endIndex:t.length}),o}var EN={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},AN=20,sR=["@","#"];function pR(t){return t.replace(/[\\^$.*+?()[\]{}|-]/g,"\\$&")}function aR(t){return new RegExp(`(?:^|[\\s])[${t.map(pR).join("")}][^\\s]*$`)}function lR(t){let e=t.filter(n=>n!=="@").map(pR);return new RegExp(`(?:^|[ \\t])(?:@(?:"[^"]*|[^\\s]*)|[${e.join("")}][^\\s]*)$`)}var Dr=class{constructor(e,n,i={}){this.state={lines:[""],cursorLine:0,cursorCol:0};this.focused=!1;this.paddingX=0;this.lastWidth=80;this.scrollOffset=0;this.autocompleteTriggerCharacters=[...sR];this.autocompleteTriggerPattern=aR(this.autocompleteTriggerCharacters);this.autocompleteDebouncePattern=lR(this.autocompleteTriggerCharacters);this.autocompleteState=null;this.autocompletePrefix="";this.autocompleteMaxVisible=5;this.autocompleteRequestTask=Promise.resolve();this.autocompleteStartToken=0;this.autocompleteRequestId=0;this.pastes=new Map;this.pasteCounter=0;this.pasteBuffer="";this.isInPaste=!1;this.history=[];this.historyIndex=-1;this.historyDraft=null;this.killRing=new Ua;this.lastAction=null;this.jumpMode=null;this.preferredVisualCol=null;this.snappedFromCursorCol=null;this.undoStack=new ja;this.disableSubmit=!1;this.tui=e,this.theme=n,this.borderColor=n.borderColor;let o=i.paddingX??0;this.paddingX=Number.isFinite(o)?Math.max(0,Math.floor(o)):0;let r=i.autocompleteMaxVisible??5;this.autocompleteMaxVisible=Number.isFinite(r)?Math.max(3,Math.min(20,Math.floor(r))):5}validPasteIds(){return new Set(this.pastes.keys())}segment(e,n){return IN(e,n==="word"?PN:cR,this.validPasteIds())}getPaddingX(){return this.paddingX}setPaddingX(e){let n=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;this.paddingX!==n&&(this.paddingX=n,this.tui.requestRender())}getAutocompleteMaxVisible(){return this.autocompleteMaxVisible}setAutocompleteMaxVisible(e){let n=Number.isFinite(e)?Math.max(3,Math.min(20,Math.floor(e))):5;this.autocompleteMaxVisible!==n&&(this.autocompleteMaxVisible=n,this.tui.requestRender())}setAutocompleteProvider(e){this.cancelAutocomplete(),this.autocompleteProvider=e,this.setAutocompleteTriggerCharacters(e.triggerCharacters??[])}addToHistory(e){let n=e.trim();n&&(this.history.length>0&&this.history[0]===n||(this.history.unshift(n),this.history.length>100&&this.history.pop()))}isEditorEmpty(){return this.state.lines.length===1&&this.state.lines[0]===""}isOnFirstVisualLine(){let e=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(e)===0}isOnLastVisualLine(){let e=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(e)===e.length-1}navigateHistory(e){if(this.lastAction=null,this.history.length===0)return;let n=this.historyIndex-e;if(!(n<-1||n>=this.history.length))if(this.historyIndex===-1&&n>=0&&(this.pushUndoSnapshot(),this.historyDraft=structuredClone(this.state)),this.historyIndex=n,this.historyIndex===-1){let i=this.historyDraft;this.historyDraft=null,i?(this.state=i,this.preferredVisualCol=null,this.snappedFromCursorCol=null,this.scrollOffset=0,this.onChange&&this.onChange(this.getText())):this.setTextInternal("")}else this.setTextInternal(this.history[this.historyIndex]||"",e===-1?"start":"end")}exitHistoryBrowsing(){this.historyIndex=-1,this.historyDraft=null}setTextInternal(e,n="end"){let i=e.split(`
51
- `);this.state.lines=i.length===0?[""]:i,this.state.cursorLine=n==="start"?0:this.state.lines.length-1,this.setCursorCol(n==="start"?0:this.state.lines[this.state.cursorLine]?.length||0),this.scrollOffset=0,this.onChange&&this.onChange(this.getText())}invalidate(){}render(e){let n=Math.max(0,Math.floor((e-1)/2)),i=Math.min(this.paddingX,n),o=Math.max(1,e-i*2),r=Math.max(1,o-(i?0:1));this.lastWidth=r;let s=this.borderColor("\u2500"),a=this.layoutText(r),l=this.tui.terminal.rows,c=Math.max(5,Math.floor(l*.3)),u=a.findIndex(x=>x.hasCursor);u===-1&&(u=0),u<this.scrollOffset?this.scrollOffset=u:u>=this.scrollOffset+c&&(this.scrollOffset=u-c+1);let d=Math.max(0,a.length-c);this.scrollOffset=Math.max(0,Math.min(this.scrollOffset,d));let p=a.slice(this.scrollOffset,this.scrollOffset+c),m=[],g=" ".repeat(i),h=g;if(this.scrollOffset>0){let x=`\u2500\u2500\u2500 \u2191 ${this.scrollOffset} more `,y=e-j(x);y>=0?m.push(this.borderColor(x+"\u2500".repeat(y))):m.push(this.borderColor(te(x,e)))}else m.push(s.repeat(e));let f=this.focused;for(let x of p){let y=x.text,T=j(x.text),P=!1;if(x.hasCursor&&x.cursorPos!==void 0){let D=y.slice(0,x.cursorPos),_=y.slice(x.cursorPos),F=f?Wr:"";if(_.length>0){let R=[...this.segment(_,"grapheme")][0]?.segment||"",E=_.slice(R.length),U=`\x1B[7m${R}\x1B[0m`;y=D+F+U+E}else y=D+F+"\x1B[7m \x1B[0m",T=T+1,T>o&&i>0&&(P=!0)}let I=" ".repeat(Math.max(0,o-T)),W=P?h.slice(1):h;m.push(`${g}${y}${I}${W}`)}let b=a.length-(this.scrollOffset+p.length);if(b>0){let x=`\u2500\u2500\u2500 \u2193 ${b} more `,y=e-j(x);m.push(this.borderColor(x+"\u2500".repeat(Math.max(0,y))))}else m.push(s.repeat(e));if(this.autocompleteState&&this.autocompleteList){let x=this.autocompleteList.render(o);for(let y of x){let T=j(y),P=" ".repeat(Math.max(0,o-T));m.push(`${g}${y}${P}${h}`)}}return m}handleInput(e){let n=ke();if(this.jumpMode!==null){if(n.matches(e,"tui.editor.jumpForward")||n.matches(e,"tui.editor.jumpBackward")){this.jumpMode=null;return}let o=uv(e)??(e.charCodeAt(0)>=32?e:void 0);if(o!==void 0){let r=this.jumpMode;this.jumpMode=null,this.jumpToChar(o,r);return}this.jumpMode=null}if(e.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",e=e.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=e;let o=this.pasteBuffer.indexOf("\x1B[201~");if(o!==-1){let r=this.pasteBuffer.substring(0,o);r.length>0&&this.handlePaste(r),this.isInPaste=!1;let s=this.pasteBuffer.substring(o+6);this.pasteBuffer="",s.length>0&&this.handleInput(s);return}return}if(n.matches(e,"tui.input.copy"))return;if(n.matches(e,"tui.editor.undo")){this.undo();return}if(this.autocompleteState&&this.autocompleteList){if(n.matches(e,"tui.select.cancel")){this.cancelAutocomplete();return}if(n.matches(e,"tui.select.up")||n.matches(e,"tui.select.down")){this.autocompleteList.handleInput(e);return}if(n.matches(e,"tui.input.tab")){let o=this.autocompleteList.getSelectedItem();if(o&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;let r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,o,this.autocompletePrefix);this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText())}return}if(n.matches(e,"tui.select.confirm")){let o=this.autocompleteList.getSelectedItem();if(o&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;let r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,o,this.autocompletePrefix);if(this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.autocompletePrefix.startsWith("/"))this.cancelAutocomplete();else{this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText());return}}}}if(n.matches(e,"tui.input.tab")&&!this.autocompleteState){this.handleTabCompletion();return}if(n.matches(e,"tui.editor.deleteToLineEnd")){this.deleteToEndOfLine();return}if(n.matches(e,"tui.editor.deleteToLineStart")){this.deleteToStartOfLine();return}if(n.matches(e,"tui.editor.deleteWordBackward")){this.deleteWordBackwards();return}if(n.matches(e,"tui.editor.deleteWordForward")){this.deleteWordForward();return}if(n.matches(e,"tui.editor.deleteCharBackward")||Fe(e,"shift+backspace")){this.handleBackspace();return}if(n.matches(e,"tui.editor.deleteCharForward")||Fe(e,"shift+delete")){this.handleForwardDelete();return}if(n.matches(e,"tui.editor.yank")){this.yank();return}if(n.matches(e,"tui.editor.yankPop")){this.yankPop();return}if(n.matches(e,"tui.editor.cursorLineStart")){this.moveToLineStart();return}if(n.matches(e,"tui.editor.cursorLineEnd")){this.moveToLineEnd();return}if(n.matches(e,"tui.editor.cursorWordLeft")){this.moveWordBackwards();return}if(n.matches(e,"tui.editor.cursorWordRight")){this.moveWordForwards();return}if(n.matches(e,"tui.input.newLine")||e.charCodeAt(0)===10&&e.length>1||e==="\x1B\r"||e==="\x1B[13;2~"||e.length>1&&e.includes("\x1B")&&e.includes("\r")||e===`
50
+ `);jo.writeFileSync(R,E)}this.terminal.write(P),this.cursorRow=Math.max(0,d.length-1),this.hardwareCursorRow=F,this.maxLinesRendered=Math.max(this.maxLinesRendered,d.length),this.previousViewportTop=Math.max(a,F-i+1),this.positionHardwareCursor(p,d.length),this.previousLines=d,this.previousKittyImageIds=this.collectKittyImageIds(d),this.previousWidth=n,this.previousHeight=i}positionHardwareCursor(n,i){if(!n||i<=0){this.terminal.hideCursor();return}let o=Math.max(0,Math.min(n.row,i-1)),r=Math.max(0,n.col),s=o-this.hardwareCursorRow,a="";s>0?a+=`\x1B[${s}B`:s<0&&(a+=`\x1B[${-s}A`),a+=`\x1B[${r+1}G`,a&&this.terminal.write(a),this.hardwareCursorRow=o,this.showHardwareCursor?this.terminal.showCursor():this.terminal.hideCursor()}queryTerminalBackgroundColor({timeoutMs:n}){return new Promise(i=>{let o={settled:!1,resolve:i,timer:void 0};o.timer=setTimeout(()=>{o.settled||(o.settled=!0,o.timer=void 0,o.resolve?.(void 0),o.resolve=void 0)},n),this.pendingOsc11BackgroundQueries.push(o),this.pendingOsc11BackgroundReplies+=1,this.terminal.write("\x1B]11;?\x07")})}queryTerminalColorScheme({timeoutMs:n}){return new Promise(i=>{let o=!1,r,s=()=>{},a=l=>{o||(o=!0,r&&(clearTimeout(r),r=void 0),s(),i(l))};s=this.onTerminalColorSchemeChange(a),r=setTimeout(()=>a(void 0),n),this.terminal.write("\x1B[?996n")})}};var ja=class{constructor(){this.stack=[]}push(e){this.stack.push(structuredClone(e))}pop(){return this.stack.pop()}clear(){this.stack.length=0}get length(){return this.stack.length}};var iR=Mp();function Wp(t,e,n){if(e<=0)return 0;let i=t.slice(0,e),o=n?.segment,r=n?.isAtomicSegment,s=o?[...o(i)]:[...iR.segment(i)],a=e;for(;s.length>0&&!r?.(s[s.length-1]?.segment||"")&&Mn(s[s.length-1]?.segment||"");)a-=s.pop()?.segment.length||0;if(s.length===0)return a;let l=s[s.length-1];if(r?.(l.segment))a-=l.segment.length;else if(l.isWordLike){let c=l.segment,u=[...c.matchAll(new RegExp(rv,"g"))];if(u.length<=0)a-=c.length;else{let d=u[u.length-1];a-=c.length-(d.index+d[0].length)}}else for(;s.length>0&&!r?.(s[s.length-1]?.segment||"")&&!s[s.length-1]?.isWordLike&&!Mn(s[s.length-1]?.segment||"");)a-=s.pop()?.segment.length||0;return a}function Fp(t,e,n){if(e>=t.length)return t.length;let i=t.slice(e),o=n?.segment,r=n?.isAtomicSegment,a=(o?o(i):iR.segment(i))[Symbol.iterator](),l=a.next(),c=e;for(;!l.done&&!r?.(l.value.segment)&&Mn(l.value.segment);)c+=l.value.segment.length,l=a.next();if(l.done)return c;if(r?.(l.value.segment))c+=l.value.segment.length;else if(l.value.isWordLike)c+=rv.exec(l.value.segment)?.index??l.value.segment.length;else for(;!l.done&&!r?.(l.value.segment)&&!l.value.isWordLike&&!Mn(l.value.segment);)c+=l.value.segment.length,l=a.next();return c}var oR=32,rR=2,CN=10,MN=t=>t.replace(/[\r\n]+/g," ").trim(),RN=(t,e,n)=>Math.max(e,Math.min(t,n)),Ht=class{constructor(e,n,i,o={}){this.items=[];this.filteredItems=[];this.selectedIndex=0;this.maxVisible=5;this.items=e,this.filteredItems=e,this.maxVisible=n,this.theme=i,this.layout=o}setFilter(e){this.filteredItems=this.items.filter(n=>n.value.toLowerCase().startsWith(e.toLowerCase())),this.selectedIndex=0}setSelectedIndex(e){this.selectedIndex=Math.max(0,Math.min(e,this.filteredItems.length-1))}invalidate(){}render(e){let n=[];if(this.filteredItems.length===0)return n.push(this.theme.noMatch(" No matching commands")),n;let i=this.getPrimaryColumnWidth(),o=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredItems.length-this.maxVisible)),r=Math.min(o+this.maxVisible,this.filteredItems.length);for(let s=o;s<r;s++){let a=this.filteredItems[s];if(!a)continue;let l=s===this.selectedIndex,c=a.description?MN(a.description):void 0;n.push(this.renderItem(a,l,e,c,i))}if(o>0||r<this.filteredItems.length){let s=` (${this.selectedIndex+1}/${this.filteredItems.length})`;n.push(this.theme.scrollInfo(te(s,e-2,"")))}return n}handleInput(e){let n=we();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.filteredItems.length-1:this.selectedIndex-1,this.notifySelectionChange();else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.filteredItems.length-1?0:this.selectedIndex+1,this.notifySelectionChange();else if(n.matches(e,"tui.select.confirm")){let i=this.filteredItems[this.selectedIndex];i&&this.onSelect&&this.onSelect(i)}else n.matches(e,"tui.select.cancel")&&this.onCancel&&this.onCancel()}renderItem(e,n,i,o,r){let s=n?"\u2192 ":" ",a=j(s);if(o&&i>40){let u=Math.max(1,Math.min(r,i-a-4)),d=Math.max(1,u-rR),p=this.truncatePrimary(e,n,d,u),m=j(p),g=" ".repeat(Math.max(1,u-m)),h=a+m+g.length,f=i-h-2;if(f>CN){let b=te(o,f,"");if(n)return this.theme.selectedText(`${s}${p}${g}${b}`);let x=this.theme.description(g+b);return s+p+x}}let l=i-a-2,c=this.truncatePrimary(e,n,l,l);return n?this.theme.selectedText(`${s}${c}`):s+c}getPrimaryColumnWidth(){let{min:e,max:n}=this.getPrimaryColumnBounds(),i=this.filteredItems.reduce((o,r)=>Math.max(o,j(this.getDisplayValue(r))+rR),0);return RN(i,e,n)}getPrimaryColumnBounds(){let e=this.layout.minPrimaryColumnWidth??this.layout.maxPrimaryColumnWidth??oR,n=this.layout.maxPrimaryColumnWidth??this.layout.minPrimaryColumnWidth??oR;return{min:Math.max(1,Math.min(e,n)),max:Math.max(1,Math.max(e,n))}}truncatePrimary(e,n,i,o){let r=this.getDisplayValue(e),s=this.layout.truncatePrimary?this.layout.truncatePrimary({text:r,maxWidth:i,columnWidth:o,item:e,isSelected:n}):te(r,i,"");return te(s,i,"")}getDisplayValue(e){return e.label||e.value}notifySelectionChange(){let e=this.filteredItems[this.selectedIndex];e&&this.onSelectionChange&&this.onSelectionChange(e)}getSelectedItem(){return this.filteredItems[this.selectedIndex]||null}};var cR=Cp(),PN=Mp(),uR=/\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]/g,dR=/^\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]$/;function qa(t){return t.length>=10&&dR.test(t)}function IN(t,e,n){if(n.size===0||!t.includes("[paste #"))return e.segment(t);let i=[];for(let a of t.matchAll(uR)){let l=Number.parseInt(a[1],10);n.has(l)&&i.push({start:a.index,end:a.index+a[0].length})}if(i.length===0)return e.segment(t);let o=e.segment(t),r=[],s=0;for(let a of o){for(;s<i.length&&i[s].end<=a.index;)s++;let l=s<i.length?i[s]:null;if(l&&a.index>=l.start&&a.index<l.end){if(a.index===l.start){let c=t.slice(l.start,l.end);r.push({segment:c,index:l.start,input:t})}}else r.push(a)}return r}function Sv(t,e,n){if(!t||e<=0)return[{text:"",startIndex:0,endIndex:0}];if(j(t)<=e)return[{text:t,startIndex:0,endIndex:t.length}];let o=[],r=n??[...cR.segment(t)],s=0,a=0,l=-1,c=0;for(let u=0;u<r.length;u++){let d=r[u],p=d.segment,m=j(p),g=d.index,h=!qa(p)&&Mn(p);if(s+m>e&&(l>=0&&s-c+m<=e?(o.push({text:t.slice(a,l),startIndex:a,endIndex:l}),a=l,s-=c):a<g&&(o.push({text:t.slice(a,g),startIndex:a,endIndex:g}),a=g,s=0),l=-1),m>e){let b=Sv(p,e);for(let y=0;y<b.length-1;y++){let T=b[y];o.push({text:T.text,startIndex:g+T.startIndex,endIndex:g+T.endIndex})}let x=b[b.length-1];a=g+x.startIndex,s=j(x.text),l=-1;continue}s+=m;let f=r[u+1];if(h&&f&&(qa(f.segment)||!Mn(f.segment)))l=f.index,c=s;else if(!h&&f&&!Mn(f.segment)){let b=!qa(p)&&Rp.test(p),x=!qa(f.segment)&&Rp.test(f.segment);(b||x)&&(l=f.index,c=s)}}return o.push({text:t.slice(a),startIndex:a,endIndex:t.length}),o}var EN={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},AN=20,sR=["@","#"];function pR(t){return t.replace(/[\\^$.*+?()[\]{}|-]/g,"\\$&")}function aR(t){return new RegExp(`(?:^|[\\s])[${t.map(pR).join("")}][^\\s]*$`)}function lR(t){let e=t.filter(n=>n!=="@").map(pR);return new RegExp(`(?:^|[ \\t])(?:@(?:"[^"]*|[^\\s]*)|[${e.join("")}][^\\s]*)$`)}var Dr=class{constructor(e,n,i={}){this.state={lines:[""],cursorLine:0,cursorCol:0};this.focused=!1;this.paddingX=0;this.lastWidth=80;this.scrollOffset=0;this.autocompleteTriggerCharacters=[...sR];this.autocompleteTriggerPattern=aR(this.autocompleteTriggerCharacters);this.autocompleteDebouncePattern=lR(this.autocompleteTriggerCharacters);this.autocompleteState=null;this.autocompletePrefix="";this.autocompleteMaxVisible=5;this.autocompleteRequestTask=Promise.resolve();this.autocompleteStartToken=0;this.autocompleteRequestId=0;this.pastes=new Map;this.pasteCounter=0;this.pasteBuffer="";this.isInPaste=!1;this.history=[];this.historyIndex=-1;this.historyDraft=null;this.killRing=new Ua;this.lastAction=null;this.jumpMode=null;this.preferredVisualCol=null;this.snappedFromCursorCol=null;this.undoStack=new ja;this.disableSubmit=!1;this.tui=e,this.theme=n,this.borderColor=n.borderColor;let o=i.paddingX??0;this.paddingX=Number.isFinite(o)?Math.max(0,Math.floor(o)):0;let r=i.autocompleteMaxVisible??5;this.autocompleteMaxVisible=Number.isFinite(r)?Math.max(3,Math.min(20,Math.floor(r))):5}validPasteIds(){return new Set(this.pastes.keys())}segment(e,n){return IN(e,n==="word"?PN:cR,this.validPasteIds())}getPaddingX(){return this.paddingX}setPaddingX(e){let n=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;this.paddingX!==n&&(this.paddingX=n,this.tui.requestRender())}getAutocompleteMaxVisible(){return this.autocompleteMaxVisible}setAutocompleteMaxVisible(e){let n=Number.isFinite(e)?Math.max(3,Math.min(20,Math.floor(e))):5;this.autocompleteMaxVisible!==n&&(this.autocompleteMaxVisible=n,this.tui.requestRender())}setAutocompleteProvider(e){this.cancelAutocomplete(),this.autocompleteProvider=e,this.setAutocompleteTriggerCharacters(e.triggerCharacters??[])}addToHistory(e){let n=e.trim();n&&(this.history.length>0&&this.history[0]===n||(this.history.unshift(n),this.history.length>100&&this.history.pop()))}isEditorEmpty(){return this.state.lines.length===1&&this.state.lines[0]===""}isOnFirstVisualLine(){let e=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(e)===0}isOnLastVisualLine(){let e=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(e)===e.length-1}navigateHistory(e){if(this.lastAction=null,this.history.length===0)return;let n=this.historyIndex-e;if(!(n<-1||n>=this.history.length))if(this.historyIndex===-1&&n>=0&&(this.pushUndoSnapshot(),this.historyDraft=structuredClone(this.state)),this.historyIndex=n,this.historyIndex===-1){let i=this.historyDraft;this.historyDraft=null,i?(this.state=i,this.preferredVisualCol=null,this.snappedFromCursorCol=null,this.scrollOffset=0,this.onChange&&this.onChange(this.getText())):this.setTextInternal("")}else this.setTextInternal(this.history[this.historyIndex]||"",e===-1?"start":"end")}exitHistoryBrowsing(){this.historyIndex=-1,this.historyDraft=null}setTextInternal(e,n="end"){let i=e.split(`
51
+ `);this.state.lines=i.length===0?[""]:i,this.state.cursorLine=n==="start"?0:this.state.lines.length-1,this.setCursorCol(n==="start"?0:this.state.lines[this.state.cursorLine]?.length||0),this.scrollOffset=0,this.onChange&&this.onChange(this.getText())}invalidate(){}render(e){let n=Math.max(0,Math.floor((e-1)/2)),i=Math.min(this.paddingX,n),o=Math.max(1,e-i*2),r=Math.max(1,o-(i?0:1));this.lastWidth=r;let s=this.borderColor("\u2500"),a=this.layoutText(r),l=this.tui.terminal.rows,c=Math.max(5,Math.floor(l*.3)),u=a.findIndex(x=>x.hasCursor);u===-1&&(u=0),u<this.scrollOffset?this.scrollOffset=u:u>=this.scrollOffset+c&&(this.scrollOffset=u-c+1);let d=Math.max(0,a.length-c);this.scrollOffset=Math.max(0,Math.min(this.scrollOffset,d));let p=a.slice(this.scrollOffset,this.scrollOffset+c),m=[],g=" ".repeat(i),h=g;if(this.scrollOffset>0){let x=`\u2500\u2500\u2500 \u2191 ${this.scrollOffset} more `,y=e-j(x);y>=0?m.push(this.borderColor(x+"\u2500".repeat(y))):m.push(this.borderColor(te(x,e)))}else m.push(s.repeat(e));let f=this.focused;for(let x of p){let y=x.text,T=j(x.text),P=!1;if(x.hasCursor&&x.cursorPos!==void 0){let D=y.slice(0,x.cursorPos),_=y.slice(x.cursorPos),F=f?Wr:"";if(_.length>0){let R=[...this.segment(_,"grapheme")][0]?.segment||"",E=_.slice(R.length),U=`\x1B[7m${R}\x1B[0m`;y=D+F+U+E}else y=D+F+"\x1B[7m \x1B[0m",T=T+1,T>o&&i>0&&(P=!0)}let I=" ".repeat(Math.max(0,o-T)),W=P?h.slice(1):h;m.push(`${g}${y}${I}${W}`)}let b=a.length-(this.scrollOffset+p.length);if(b>0){let x=`\u2500\u2500\u2500 \u2193 ${b} more `,y=e-j(x);m.push(this.borderColor(x+"\u2500".repeat(Math.max(0,y))))}else m.push(s.repeat(e));if(this.autocompleteState&&this.autocompleteList){let x=this.autocompleteList.render(o);for(let y of x){let T=j(y),P=" ".repeat(Math.max(0,o-T));m.push(`${g}${y}${P}${h}`)}}return m}handleInput(e){let n=we();if(this.jumpMode!==null){if(n.matches(e,"tui.editor.jumpForward")||n.matches(e,"tui.editor.jumpBackward")){this.jumpMode=null;return}let o=uv(e)??(e.charCodeAt(0)>=32?e:void 0);if(o!==void 0){let r=this.jumpMode;this.jumpMode=null,this.jumpToChar(o,r);return}this.jumpMode=null}if(e.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",e=e.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=e;let o=this.pasteBuffer.indexOf("\x1B[201~");if(o!==-1){let r=this.pasteBuffer.substring(0,o);r.length>0&&this.handlePaste(r),this.isInPaste=!1;let s=this.pasteBuffer.substring(o+6);this.pasteBuffer="",s.length>0&&this.handleInput(s);return}return}if(n.matches(e,"tui.input.copy"))return;if(n.matches(e,"tui.editor.undo")){this.undo();return}if(this.autocompleteState&&this.autocompleteList){if(n.matches(e,"tui.select.cancel")){this.cancelAutocomplete();return}if(n.matches(e,"tui.select.up")||n.matches(e,"tui.select.down")){this.autocompleteList.handleInput(e);return}if(n.matches(e,"tui.input.tab")){let o=this.autocompleteList.getSelectedItem();if(o&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;let r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,o,this.autocompletePrefix);this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText())}return}if(n.matches(e,"tui.select.confirm")){let o=this.autocompleteList.getSelectedItem();if(o&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;let r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,o,this.autocompletePrefix);if(this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.autocompletePrefix.startsWith("/"))this.cancelAutocomplete();else{this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText());return}}}}if(n.matches(e,"tui.input.tab")&&!this.autocompleteState){this.handleTabCompletion();return}if(n.matches(e,"tui.editor.deleteToLineEnd")){this.deleteToEndOfLine();return}if(n.matches(e,"tui.editor.deleteToLineStart")){this.deleteToStartOfLine();return}if(n.matches(e,"tui.editor.deleteWordBackward")){this.deleteWordBackwards();return}if(n.matches(e,"tui.editor.deleteWordForward")){this.deleteWordForward();return}if(n.matches(e,"tui.editor.deleteCharBackward")||Fe(e,"shift+backspace")){this.handleBackspace();return}if(n.matches(e,"tui.editor.deleteCharForward")||Fe(e,"shift+delete")){this.handleForwardDelete();return}if(n.matches(e,"tui.editor.yank")){this.yank();return}if(n.matches(e,"tui.editor.yankPop")){this.yankPop();return}if(n.matches(e,"tui.editor.cursorLineStart")){this.moveToLineStart();return}if(n.matches(e,"tui.editor.cursorLineEnd")){this.moveToLineEnd();return}if(n.matches(e,"tui.editor.cursorWordLeft")){this.moveWordBackwards();return}if(n.matches(e,"tui.editor.cursorWordRight")){this.moveWordForwards();return}if(n.matches(e,"tui.input.newLine")||e.charCodeAt(0)===10&&e.length>1||e==="\x1B\r"||e==="\x1B[13;2~"||e.length>1&&e.includes("\x1B")&&e.includes("\r")||e===`
52
52
  `&&e.length===1){if(this.shouldSubmitOnBackslashEnter(e,n)){this.handleBackspace(),this.submitValue();return}this.addNewLine();return}if(n.matches(e,"tui.input.submit")){if(this.disableSubmit)return;let o=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>0&&o[this.state.cursorCol-1]==="\\"){this.handleBackspace(),this.addNewLine();return}this.submitValue();return}if(n.matches(e,"tui.editor.cursorUp")){this.isOnFirstVisualLine()&&(this.isEditorEmpty()||this.historyIndex>-1||this.state.cursorCol===0)?this.navigateHistory(-1):this.isOnFirstVisualLine()?this.moveToLineStart():this.moveCursor(-1,0);return}if(n.matches(e,"tui.editor.cursorDown")){this.historyIndex>-1&&this.isOnLastVisualLine()?this.navigateHistory(1):this.isOnLastVisualLine()?this.moveToLineEnd():this.moveCursor(1,0);return}if(n.matches(e,"tui.editor.cursorRight")){this.moveCursor(0,1);return}if(n.matches(e,"tui.editor.cursorLeft")){this.moveCursor(0,-1);return}if(n.matches(e,"tui.editor.pageUp")){this.pageScroll(-1);return}if(n.matches(e,"tui.editor.pageDown")){this.pageScroll(1);return}if(n.matches(e,"tui.editor.jumpForward")){this.jumpMode="forward";return}if(n.matches(e,"tui.editor.jumpBackward")){this.jumpMode="backward";return}if(Fe(e,"shift+space")){this.insertCharacter(" ");return}let i=uv(e);if(i!==void 0){this.insertCharacter(i);return}e.charCodeAt(0)>=32&&this.insertCharacter(e)}layoutText(e){let n=[];if(this.state.lines.length===0||this.state.lines.length===1&&this.state.lines[0]==="")return n.push({text:"",hasCursor:!0,cursorPos:0}),n;for(let i=0;i<this.state.lines.length;i++){let o=this.state.lines[i]||"",r=i===this.state.cursorLine;if(j(o)<=e)r?n.push({text:o,hasCursor:!0,cursorPos:this.state.cursorCol}):n.push({text:o,hasCursor:!1});else{let a=Sv(o,e,[...this.segment(o,"grapheme")]);for(let l=0;l<a.length;l++){let c=a[l];if(!c)continue;let u=this.state.cursorCol,d=l===a.length-1,p=!1,m=0;r&&(d?(p=u>=c.startIndex,m=u-c.startIndex):(p=u>=c.startIndex&&u<c.endIndex,p&&(m=u-c.startIndex,m>c.text.length&&(m=c.text.length)))),p?n.push({text:c.text,hasCursor:!0,cursorPos:m}):n.push({text:c.text,hasCursor:!1})}}}return n}getText(){return this.state.lines.join(`
53
53
  `)}expandPasteMarkers(e){let n=e;for(let[i,o]of this.pastes){let r=new RegExp(`\\[paste #${i}( (\\+\\d+ lines|\\d+ chars))?\\]`,"g");n=n.replace(r,()=>o)}return n}getExpandedText(){return this.expandPasteMarkers(this.state.lines.join(`
54
54
  `))}getLines(){return[...this.state.lines]}getCursor(){return{line:this.state.cursorLine,col:this.state.cursorCol}}setText(e){this.cancelAutocomplete(),this.lastAction=null,this.exitHistoryBrowsing();let n=this.normalizeText(e);this.getText()!==n&&this.pushUndoSnapshot(),this.pastes.clear(),this.pasteCounter=0,this.setTextInternal(n)}insertTextAtCursor(e){e&&(this.cancelAutocomplete(),this.pushUndoSnapshot(),this.lastAction=null,this.exitHistoryBrowsing(),this.insertTextAtCursorInternal(e))}normalizeText(e){return e.replace(/\r\n/g,`
@@ -63,13 +63,13 @@ ${s}`),i.push({type:"error",reason:o.stopReason,error:o}),i.end()}})(),i},nU=(t,
63
63
  `,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill";let n=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=n+e,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(n.length)}}else{this.pushUndoSnapshot();let n=this.lastAction==="kill",i=this.state.cursorCol;this.moveWordBackwards();let o=this.state.cursorCol;this.setCursorCol(i);let r=e.slice(o,this.state.cursorCol);this.killRing.push(r,{prepend:!0,accumulate:n}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=e.slice(0,o)+e.slice(this.state.cursorCol),this.setCursorCol(o)}this.onChange&&this.onChange(this.getText())}deleteWordForward(){this.exitHistoryBrowsing();let e=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>=e.length){if(this.state.cursorLine<this.state.lines.length-1){this.pushUndoSnapshot(),this.killRing.push(`
64
64
  `,{prepend:!1,accumulate:this.lastAction==="kill"}),this.lastAction="kill";let n=this.state.lines[this.state.cursorLine+1]||"";this.state.lines[this.state.cursorLine]=e+n,this.state.lines.splice(this.state.cursorLine+1,1)}}else{this.pushUndoSnapshot();let n=this.lastAction==="kill",i=this.state.cursorCol;this.moveWordForwards();let o=this.state.cursorCol;this.setCursorCol(i);let r=e.slice(this.state.cursorCol,o);this.killRing.push(r,{prepend:!1,accumulate:n}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=e.slice(0,this.state.cursorCol)+e.slice(o)}this.onChange&&this.onChange(this.getText())}handleForwardDelete(){this.exitHistoryBrowsing(),this.lastAction=null;let e=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol<e.length){this.pushUndoSnapshot();let n=e.slice(this.state.cursorCol),o=[...this.segment(n,"grapheme")][0],r=o?o.segment.length:1,s=e.slice(0,this.state.cursorCol),a=e.slice(this.state.cursorCol+r);this.state.lines[this.state.cursorLine]=s+a}else if(this.state.cursorLine<this.state.lines.length-1){this.pushUndoSnapshot();let n=this.state.lines[this.state.cursorLine+1]||"";this.state.lines[this.state.cursorLine]=e+n,this.state.lines.splice(this.state.cursorLine+1,1)}if(this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else{let i=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(i)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(i)&&this.tryTriggerAutocomplete()}}buildVisualLineMap(e){let n=[];for(let i=0;i<this.state.lines.length;i++){let o=this.state.lines[i]||"",r=j(o);if(o.length===0)n.push({logicalLine:i,startCol:0,length:0});else if(r<=e)n.push({logicalLine:i,startCol:0,length:o.length});else{let s=Sv(o,e,[...this.segment(o,"grapheme")]);for(let a of s)n.push({logicalLine:i,startCol:a.startIndex,length:a.endIndex-a.startIndex})}}return n}findVisualLineAt(e,n,i){for(let o=0;o<e.length;o++){let r=e[o];if(!r||r.logicalLine!==n)continue;let s=i-r.startCol,a=o===e.length-1||e[o+1]?.logicalLine!==r.logicalLine;if(s>=0&&(s<r.length||a&&s===r.length))return o}return e.length-1}findCurrentVisualLine(e){return this.findVisualLineAt(e,this.state.cursorLine,this.state.cursorCol)}moveCursor(e,n){this.lastAction=null;let i=this.buildVisualLineMap(this.lastWidth),o=this.findCurrentVisualLine(i);if(e!==0){let r=o+e;r>=0&&r<i.length&&this.moveToVisualLine(i,o,r)}if(n!==0){let r=this.state.lines[this.state.cursorLine]||"";if(n>0)if(this.state.cursorCol<r.length){let s=r.slice(this.state.cursorCol),l=[...this.segment(s,"grapheme")][0];this.setCursorCol(this.state.cursorCol+(l?l.segment.length:1))}else if(this.state.cursorLine<this.state.lines.length-1)this.state.cursorLine++,this.setCursorCol(0);else{let s=i[o];s&&(this.preferredVisualCol=this.state.cursorCol-s.startCol)}else if(this.state.cursorCol>0){let s=r.slice(0,this.state.cursorCol),a=[...this.segment(s,"grapheme")],l=a[a.length-1];this.setCursorCol(this.state.cursorCol-(l?l.segment.length:1))}else if(this.state.cursorLine>0){this.state.cursorLine--;let s=this.state.lines[this.state.cursorLine]||"";this.setCursorCol(s.length)}}this.autocompleteState&&this.updateAutocomplete()}pageScroll(e){this.lastAction=null;let n=this.tui.terminal.rows,i=Math.max(5,Math.floor(n*.3)),o=this.buildVisualLineMap(this.lastWidth),r=this.findCurrentVisualLine(o),s=Math.max(0,Math.min(o.length-1,r+e*i));this.moveToVisualLine(o,r,s)}moveWordBackwards(){this.lastAction=null;let e=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol===0){if(this.state.cursorLine>0){this.state.cursorLine--;let n=this.state.lines[this.state.cursorLine]||"";this.setCursorCol(n.length)}return}this.setCursorCol(Wp(e,this.state.cursorCol,{segment:n=>this.segment(n,"word"),isAtomicSegment:qa}))}yank(){if(this.killRing.length===0)return;this.pushUndoSnapshot();let e=this.killRing.peek();this.insertYankedText(e),this.lastAction="yank"}yankPop(){if(this.lastAction!=="yank"||this.killRing.length<=1)return;this.pushUndoSnapshot(),this.deleteYankedText(),this.killRing.rotate();let e=this.killRing.peek();this.insertYankedText(e),this.lastAction="yank"}insertYankedText(e){this.exitHistoryBrowsing();let n=e.split(`
65
65
  `);if(n.length===1){let i=this.state.lines[this.state.cursorLine]||"",o=i.slice(0,this.state.cursorCol),r=i.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=o+e+r,this.setCursorCol(this.state.cursorCol+e.length)}else{let i=this.state.lines[this.state.cursorLine]||"",o=i.slice(0,this.state.cursorCol),r=i.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=o+(n[0]||"");for(let a=1;a<n.length-1;a++)this.state.lines.splice(this.state.cursorLine+a,0,n[a]||"");let s=this.state.cursorLine+n.length-1;this.state.lines.splice(s,0,(n[n.length-1]||"")+r),this.state.cursorLine=s,this.setCursorCol((n[n.length-1]||"").length)}this.onChange&&this.onChange(this.getText())}deleteYankedText(){let e=this.killRing.peek();if(!e)return;let n=e.split(`
66
- `);if(n.length===1){let i=this.state.lines[this.state.cursorLine]||"",o=e.length,r=i.slice(0,this.state.cursorCol-o),s=i.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=r+s,this.setCursorCol(this.state.cursorCol-o)}else{let i=this.state.cursorLine-(n.length-1),o=(this.state.lines[i]||"").length-(n[0]||"").length,r=(this.state.lines[this.state.cursorLine]||"").slice(this.state.cursorCol),s=(this.state.lines[i]||"").slice(0,o);this.state.lines.splice(i,n.length,s+r),this.state.cursorLine=i,this.setCursorCol(o)}this.onChange&&this.onChange(this.getText())}pushUndoSnapshot(){this.undoStack.push({state:this.state,pastes:this.pastes,pasteCounter:this.pasteCounter})}undo(){this.exitHistoryBrowsing();let e=this.undoStack.pop();e&&(Object.assign(this.state,e.state),this.pastes=e.pastes,this.pasteCounter=e.pasteCounter,this.lastAction=null,this.preferredVisualCol=null,this.onChange&&this.onChange(this.getText()))}jumpToChar(e,n){this.lastAction=null;let i=n==="forward",o=this.state.lines,r=i?o.length:-1,s=i?1:-1;for(let a=this.state.cursorLine;a!==r;a+=s){let l=o[a]||"",u=a===this.state.cursorLine?i?this.state.cursorCol+1:this.state.cursorCol-1:void 0,d=i?l.indexOf(e,u):l.lastIndexOf(e,u);if(d!==-1){this.state.cursorLine=a,this.setCursorCol(d);return}}}moveWordForwards(){this.lastAction=null;let e=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>=e.length){this.state.cursorLine<this.state.lines.length-1&&(this.state.cursorLine++,this.setCursorCol(0));return}this.setCursorCol(Fp(e,this.state.cursorCol,{segment:n=>this.segment(n,"word"),isAtomicSegment:qa}))}isSlashMenuAllowed(){return this.state.cursorLine===0}isAtStartOfMessage(){if(!this.isSlashMenuAllowed())return!1;let n=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);return n.trim()===""||n.trim()==="/"}isInSlashCommandContext(e){return this.isSlashMenuAllowed()&&e.trimStart().startsWith("/")}getBestAutocompleteMatchIndex(e,n){if(!n)return-1;let i=-1;for(let o=0;o<e.length;o++){let r=e[o].value;if(r===n)return o;i===-1&&r.startsWith(n)&&(i=o)}return i}createAutocompleteList(e,n){let i=e.startsWith("/")?EN:void 0;return new Ht(n,this.autocompleteMaxVisible,this.theme.selectList,i)}tryTriggerAutocomplete(e=!1){this.requestAutocomplete({force:!1,explicitTab:e})}handleTabCompletion(){if(!this.autocompleteProvider)return;let n=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(n)&&!n.trimStart().includes(" ")?this.handleSlashCommandCompletion():this.forceFileAutocomplete(!0)}handleSlashCommandCompletion(){this.requestAutocomplete({force:!1,explicitTab:!0})}forceFileAutocomplete(e=!1){this.requestAutocomplete({force:!0,explicitTab:e})}requestAutocomplete(e){if(!this.autocompleteProvider||e.force&&!(!this.autocompleteProvider.shouldTriggerFileCompletion||this.autocompleteProvider.shouldTriggerFileCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol)))return;this.cancelAutocompleteRequest();let n=++this.autocompleteStartToken,i=this.getAutocompleteDebounceMs(e);if(i>0){this.autocompleteDebounceTimer=setTimeout(()=>{this.autocompleteDebounceTimer=void 0,this.startAutocompleteRequest(n,e)},i);return}this.startAutocompleteRequest(n,e)}async startAutocompleteRequest(e,n){let i=this.autocompleteRequestTask;this.autocompleteRequestTask=(async()=>{if(await i,e!==this.autocompleteStartToken||!this.autocompleteProvider)return;let o=new AbortController;this.autocompleteAbort=o;let r=++this.autocompleteRequestId,s=this.getText(),a=this.state.cursorLine,l=this.state.cursorCol;await this.runAutocompleteRequest(r,o,s,a,l,n)})(),await this.autocompleteRequestTask}setAutocompleteTriggerCharacters(e){let n=[...sR];for(let i of e)i.length!==1||i==="/"||Mn(i)||n.includes(i)||n.push(i);this.autocompleteTriggerCharacters=n,this.autocompleteTriggerPattern=aR(n),this.autocompleteDebouncePattern=lR(n)}getAutocompleteDebounceMs(e){if(e.explicitTab||e.force)return 0;let i=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);return this.autocompleteDebouncePattern.test(i)?AN:0}async runAutocompleteRequest(e,n,i,o,r,s){if(!this.autocompleteProvider)return;let a=await this.autocompleteProvider.getSuggestions(this.state.lines,this.state.cursorLine,this.state.cursorCol,{signal:n.signal,force:s.force});if(this.isAutocompleteRequestCurrent(e,n,i,o,r)){if(this.autocompleteAbort=void 0,!a||!Array.isArray(a.items)||a.items.length===0){this.cancelAutocomplete(),this.tui.requestRender();return}if(s.force&&s.explicitTab&&a.items.length===1){let l=a.items[0];this.pushUndoSnapshot(),this.lastAction=null;let c=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,l,a.prefix);this.state.lines=c.lines,this.state.cursorLine=c.cursorLine,this.setCursorCol(c.cursorCol),this.onChange&&this.onChange(this.getText()),this.tui.requestRender();return}this.applyAutocompleteSuggestions(a,s.force?"force":"regular"),this.tui.requestRender()}}isAutocompleteRequestCurrent(e,n,i,o,r){return!n.signal.aborted&&e===this.autocompleteRequestId&&this.getText()===i&&this.state.cursorLine===o&&this.state.cursorCol===r}applyAutocompleteSuggestions(e,n){this.autocompletePrefix=e.prefix,this.autocompleteList=this.createAutocompleteList(e.prefix,e.items);let i=this.getBestAutocompleteMatchIndex(e.items,e.prefix);i>=0&&this.autocompleteList.setSelectedIndex(i),this.autocompleteState=n}cancelAutocompleteRequest(){this.autocompleteStartToken+=1,this.autocompleteDebounceTimer&&(clearTimeout(this.autocompleteDebounceTimer),this.autocompleteDebounceTimer=void 0),this.autocompleteAbort?.abort(),this.autocompleteAbort=void 0}clearAutocompleteUi(){this.autocompleteState=null,this.autocompleteList=void 0,this.autocompletePrefix=""}cancelAutocomplete(){this.cancelAutocompleteRequest(),this.clearAutocompleteUi()}isShowingAutocomplete(){return this.autocompleteState!==null}updateAutocomplete(){!this.autocompleteState||!this.autocompleteProvider||this.requestAutocomplete({force:this.autocompleteState==="force",explicitTab:!1})}};var Ur=class{constructor(e,n,i,o={},r){this.base64Data=e,this.mimeType=n,this.theme=i,this.options=o,this.dimensions=r||Fc(e,n)||{widthPx:800,heightPx:600},this.imageId=o.imageId}getImageId(){return this.imageId}invalidate(){this.cachedLines=void 0,this.cachedWidth=void 0}render(e){if(this.cachedLines&&this.cachedWidth===e)return this.cachedLines;let n=Math.max(1,Math.min(e-2,this.options.maxWidthCells??60)),i=Lp(),o=Math.max(1,Math.ceil(n*i.widthPx/i.heightPx)),r=this.options.maxHeightCells??o,s=ft(),a;if(s.images){s.images==="kitty"&&this.imageId===void 0&&(this.imageId=fv());let l=bv(this.base64Data,this.dimensions,{maxWidthCells:n,maxHeightCells:r,imageId:this.imageId,moveCursor:!1});if(l)if(l.imageId&&(this.imageId=l.imageId),s.images==="kitty"){a=[l.sequence];for(let c=0;c<l.rows-1;c++)a.push("")}else{a=[];for(let d=0;d<l.rows-1;d++)a.push("");let c=l.rows-1,u=c>0?`\x1B[${c}A`:"";a.push(u+l.sequence)}else{let c=Na(this.mimeType,this.dimensions,this.options.filename);a=[this.theme.fallbackColor(c)]}}else{let l=Na(this.mimeType,this.dimensions,this.options.filename);a=[this.theme.fallbackColor(l)]}return this.cachedLines=a,this.cachedWidth=e,a}};var Dc=Cp(),Xe=class{constructor(){this.value="";this.cursor=0;this.focused=!1;this.pasteBuffer="";this.isInPaste=!1;this.killRing=new Ua;this.lastAction=null;this.undoStack=new ja}getValue(){return this.value}setValue(e){this.value=e,this.cursor=Math.min(this.cursor,e.length)}handleInput(e){if(e.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",e=e.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=e;let r=this.pasteBuffer.indexOf("\x1B[201~");if(r!==-1){let s=this.pasteBuffer.substring(0,r);this.handlePaste(s),this.isInPaste=!1;let a=this.pasteBuffer.substring(r+6);this.pasteBuffer="",a&&this.handleInput(a)}return}let n=ke();if(n.matches(e,"tui.select.cancel")){this.onEscape&&this.onEscape();return}if(n.matches(e,"tui.editor.undo")){this.undo();return}if(n.matches(e,"tui.input.submit")||e===`
66
+ `);if(n.length===1){let i=this.state.lines[this.state.cursorLine]||"",o=e.length,r=i.slice(0,this.state.cursorCol-o),s=i.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=r+s,this.setCursorCol(this.state.cursorCol-o)}else{let i=this.state.cursorLine-(n.length-1),o=(this.state.lines[i]||"").length-(n[0]||"").length,r=(this.state.lines[this.state.cursorLine]||"").slice(this.state.cursorCol),s=(this.state.lines[i]||"").slice(0,o);this.state.lines.splice(i,n.length,s+r),this.state.cursorLine=i,this.setCursorCol(o)}this.onChange&&this.onChange(this.getText())}pushUndoSnapshot(){this.undoStack.push({state:this.state,pastes:this.pastes,pasteCounter:this.pasteCounter})}undo(){this.exitHistoryBrowsing();let e=this.undoStack.pop();e&&(Object.assign(this.state,e.state),this.pastes=e.pastes,this.pasteCounter=e.pasteCounter,this.lastAction=null,this.preferredVisualCol=null,this.onChange&&this.onChange(this.getText()))}jumpToChar(e,n){this.lastAction=null;let i=n==="forward",o=this.state.lines,r=i?o.length:-1,s=i?1:-1;for(let a=this.state.cursorLine;a!==r;a+=s){let l=o[a]||"",u=a===this.state.cursorLine?i?this.state.cursorCol+1:this.state.cursorCol-1:void 0,d=i?l.indexOf(e,u):l.lastIndexOf(e,u);if(d!==-1){this.state.cursorLine=a,this.setCursorCol(d);return}}}moveWordForwards(){this.lastAction=null;let e=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>=e.length){this.state.cursorLine<this.state.lines.length-1&&(this.state.cursorLine++,this.setCursorCol(0));return}this.setCursorCol(Fp(e,this.state.cursorCol,{segment:n=>this.segment(n,"word"),isAtomicSegment:qa}))}isSlashMenuAllowed(){return this.state.cursorLine===0}isAtStartOfMessage(){if(!this.isSlashMenuAllowed())return!1;let n=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);return n.trim()===""||n.trim()==="/"}isInSlashCommandContext(e){return this.isSlashMenuAllowed()&&e.trimStart().startsWith("/")}getBestAutocompleteMatchIndex(e,n){if(!n)return-1;let i=-1;for(let o=0;o<e.length;o++){let r=e[o].value;if(r===n)return o;i===-1&&r.startsWith(n)&&(i=o)}return i}createAutocompleteList(e,n){let i=e.startsWith("/")?EN:void 0;return new Ht(n,this.autocompleteMaxVisible,this.theme.selectList,i)}tryTriggerAutocomplete(e=!1){this.requestAutocomplete({force:!1,explicitTab:e})}handleTabCompletion(){if(!this.autocompleteProvider)return;let n=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(n)&&!n.trimStart().includes(" ")?this.handleSlashCommandCompletion():this.forceFileAutocomplete(!0)}handleSlashCommandCompletion(){this.requestAutocomplete({force:!1,explicitTab:!0})}forceFileAutocomplete(e=!1){this.requestAutocomplete({force:!0,explicitTab:e})}requestAutocomplete(e){if(!this.autocompleteProvider||e.force&&!(!this.autocompleteProvider.shouldTriggerFileCompletion||this.autocompleteProvider.shouldTriggerFileCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol)))return;this.cancelAutocompleteRequest();let n=++this.autocompleteStartToken,i=this.getAutocompleteDebounceMs(e);if(i>0){this.autocompleteDebounceTimer=setTimeout(()=>{this.autocompleteDebounceTimer=void 0,this.startAutocompleteRequest(n,e)},i);return}this.startAutocompleteRequest(n,e)}async startAutocompleteRequest(e,n){let i=this.autocompleteRequestTask;this.autocompleteRequestTask=(async()=>{if(await i,e!==this.autocompleteStartToken||!this.autocompleteProvider)return;let o=new AbortController;this.autocompleteAbort=o;let r=++this.autocompleteRequestId,s=this.getText(),a=this.state.cursorLine,l=this.state.cursorCol;await this.runAutocompleteRequest(r,o,s,a,l,n)})(),await this.autocompleteRequestTask}setAutocompleteTriggerCharacters(e){let n=[...sR];for(let i of e)i.length!==1||i==="/"||Mn(i)||n.includes(i)||n.push(i);this.autocompleteTriggerCharacters=n,this.autocompleteTriggerPattern=aR(n),this.autocompleteDebouncePattern=lR(n)}getAutocompleteDebounceMs(e){if(e.explicitTab||e.force)return 0;let i=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);return this.autocompleteDebouncePattern.test(i)?AN:0}async runAutocompleteRequest(e,n,i,o,r,s){if(!this.autocompleteProvider)return;let a=await this.autocompleteProvider.getSuggestions(this.state.lines,this.state.cursorLine,this.state.cursorCol,{signal:n.signal,force:s.force});if(this.isAutocompleteRequestCurrent(e,n,i,o,r)){if(this.autocompleteAbort=void 0,!a||!Array.isArray(a.items)||a.items.length===0){this.cancelAutocomplete(),this.tui.requestRender();return}if(s.force&&s.explicitTab&&a.items.length===1){let l=a.items[0];this.pushUndoSnapshot(),this.lastAction=null;let c=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,l,a.prefix);this.state.lines=c.lines,this.state.cursorLine=c.cursorLine,this.setCursorCol(c.cursorCol),this.onChange&&this.onChange(this.getText()),this.tui.requestRender();return}this.applyAutocompleteSuggestions(a,s.force?"force":"regular"),this.tui.requestRender()}}isAutocompleteRequestCurrent(e,n,i,o,r){return!n.signal.aborted&&e===this.autocompleteRequestId&&this.getText()===i&&this.state.cursorLine===o&&this.state.cursorCol===r}applyAutocompleteSuggestions(e,n){this.autocompletePrefix=e.prefix,this.autocompleteList=this.createAutocompleteList(e.prefix,e.items);let i=this.getBestAutocompleteMatchIndex(e.items,e.prefix);i>=0&&this.autocompleteList.setSelectedIndex(i),this.autocompleteState=n}cancelAutocompleteRequest(){this.autocompleteStartToken+=1,this.autocompleteDebounceTimer&&(clearTimeout(this.autocompleteDebounceTimer),this.autocompleteDebounceTimer=void 0),this.autocompleteAbort?.abort(),this.autocompleteAbort=void 0}clearAutocompleteUi(){this.autocompleteState=null,this.autocompleteList=void 0,this.autocompletePrefix=""}cancelAutocomplete(){this.cancelAutocompleteRequest(),this.clearAutocompleteUi()}isShowingAutocomplete(){return this.autocompleteState!==null}updateAutocomplete(){!this.autocompleteState||!this.autocompleteProvider||this.requestAutocomplete({force:this.autocompleteState==="force",explicitTab:!1})}};var Ur=class{constructor(e,n,i,o={},r){this.base64Data=e,this.mimeType=n,this.theme=i,this.options=o,this.dimensions=r||Fc(e,n)||{widthPx:800,heightPx:600},this.imageId=o.imageId}getImageId(){return this.imageId}invalidate(){this.cachedLines=void 0,this.cachedWidth=void 0}render(e){if(this.cachedLines&&this.cachedWidth===e)return this.cachedLines;let n=Math.max(1,Math.min(e-2,this.options.maxWidthCells??60)),i=Lp(),o=Math.max(1,Math.ceil(n*i.widthPx/i.heightPx)),r=this.options.maxHeightCells??o,s=ft(),a;if(s.images){s.images==="kitty"&&this.imageId===void 0&&(this.imageId=fv());let l=bv(this.base64Data,this.dimensions,{maxWidthCells:n,maxHeightCells:r,imageId:this.imageId,moveCursor:!1});if(l)if(l.imageId&&(this.imageId=l.imageId),s.images==="kitty"){a=[l.sequence];for(let c=0;c<l.rows-1;c++)a.push("")}else{a=[];for(let d=0;d<l.rows-1;d++)a.push("");let c=l.rows-1,u=c>0?`\x1B[${c}A`:"";a.push(u+l.sequence)}else{let c=Na(this.mimeType,this.dimensions,this.options.filename);a=[this.theme.fallbackColor(c)]}}else{let l=Na(this.mimeType,this.dimensions,this.options.filename);a=[this.theme.fallbackColor(l)]}return this.cachedLines=a,this.cachedWidth=e,a}};var Dc=Cp(),Xe=class{constructor(){this.value="";this.cursor=0;this.focused=!1;this.pasteBuffer="";this.isInPaste=!1;this.killRing=new Ua;this.lastAction=null;this.undoStack=new ja}getValue(){return this.value}setValue(e){this.value=e,this.cursor=Math.min(this.cursor,e.length)}handleInput(e){if(e.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",e=e.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=e;let r=this.pasteBuffer.indexOf("\x1B[201~");if(r!==-1){let s=this.pasteBuffer.substring(0,r);this.handlePaste(s),this.isInPaste=!1;let a=this.pasteBuffer.substring(r+6);this.pasteBuffer="",a&&this.handleInput(a)}return}let n=we();if(n.matches(e,"tui.select.cancel")){this.onEscape&&this.onEscape();return}if(n.matches(e,"tui.editor.undo")){this.undo();return}if(n.matches(e,"tui.input.submit")||e===`
67
67
  `){this.onSubmit&&this.onSubmit(this.value);return}if(n.matches(e,"tui.editor.deleteCharBackward")){this.handleBackspace();return}if(n.matches(e,"tui.editor.deleteCharForward")){this.handleForwardDelete();return}if(n.matches(e,"tui.editor.deleteWordBackward")){this.deleteWordBackwards();return}if(n.matches(e,"tui.editor.deleteWordForward")){this.deleteWordForward();return}if(n.matches(e,"tui.editor.deleteToLineStart")){this.deleteToLineStart();return}if(n.matches(e,"tui.editor.deleteToLineEnd")){this.deleteToLineEnd();return}if(n.matches(e,"tui.editor.yank")){this.yank();return}if(n.matches(e,"tui.editor.yankPop")){this.yankPop();return}if(n.matches(e,"tui.editor.cursorLeft")){if(this.lastAction=null,this.cursor>0){let r=this.value.slice(0,this.cursor),s=[...Dc.segment(r)],a=s[s.length-1];this.cursor-=a?a.segment.length:1}return}if(n.matches(e,"tui.editor.cursorRight")){if(this.lastAction=null,this.cursor<this.value.length){let r=this.value.slice(this.cursor),a=[...Dc.segment(r)][0];this.cursor+=a?a.segment.length:1}return}if(n.matches(e,"tui.editor.cursorLineStart")){this.lastAction=null,this.cursor=0;return}if(n.matches(e,"tui.editor.cursorLineEnd")){this.lastAction=null,this.cursor=this.value.length;return}if(n.matches(e,"tui.editor.cursorWordLeft")){this.moveWordBackwards();return}if(n.matches(e,"tui.editor.cursorWordRight")){this.moveWordForwards();return}let i=_p(e);if(i!==void 0){this.insertCharacter(i);return}[...e].some(r=>{let s=r.charCodeAt(0);return s<32||s===127||s>=128&&s<=159})||this.insertCharacter(e)}insertCharacter(e){(Mn(e)||this.lastAction!=="type-word")&&this.pushUndo(),this.lastAction="type-word",this.value=this.value.slice(0,this.cursor)+e+this.value.slice(this.cursor),this.cursor+=e.length}handleBackspace(){if(this.lastAction=null,this.cursor>0){this.pushUndo();let e=this.value.slice(0,this.cursor),n=[...Dc.segment(e)],i=n[n.length-1],o=i?i.segment.length:1;this.value=this.value.slice(0,this.cursor-o)+this.value.slice(this.cursor),this.cursor-=o}}handleForwardDelete(){if(this.lastAction=null,this.cursor<this.value.length){this.pushUndo();let e=this.value.slice(this.cursor),i=[...Dc.segment(e)][0],o=i?i.segment.length:1;this.value=this.value.slice(0,this.cursor)+this.value.slice(this.cursor+o)}}deleteToLineStart(){if(this.cursor===0)return;this.pushUndo();let e=this.value.slice(0,this.cursor);this.killRing.push(e,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.value=this.value.slice(this.cursor),this.cursor=0}deleteToLineEnd(){if(this.cursor>=this.value.length)return;this.pushUndo();let e=this.value.slice(this.cursor);this.killRing.push(e,{prepend:!1,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.value=this.value.slice(0,this.cursor)}deleteWordBackwards(){if(this.cursor===0)return;let e=this.lastAction==="kill";this.pushUndo();let n=this.cursor;this.moveWordBackwards();let i=this.cursor;this.cursor=n;let o=this.value.slice(i,this.cursor);this.killRing.push(o,{prepend:!0,accumulate:e}),this.lastAction="kill",this.value=this.value.slice(0,i)+this.value.slice(this.cursor),this.cursor=i}deleteWordForward(){if(this.cursor>=this.value.length)return;let e=this.lastAction==="kill";this.pushUndo();let n=this.cursor;this.moveWordForwards();let i=this.cursor;this.cursor=n;let o=this.value.slice(this.cursor,i);this.killRing.push(o,{prepend:!1,accumulate:e}),this.lastAction="kill",this.value=this.value.slice(0,this.cursor)+this.value.slice(i)}yank(){let e=this.killRing.peek();e&&(this.pushUndo(),this.value=this.value.slice(0,this.cursor)+e+this.value.slice(this.cursor),this.cursor+=e.length,this.lastAction="yank")}yankPop(){if(this.lastAction!=="yank"||this.killRing.length<=1)return;this.pushUndo();let e=this.killRing.peek()||"";this.value=this.value.slice(0,this.cursor-e.length)+this.value.slice(this.cursor),this.cursor-=e.length,this.killRing.rotate();let n=this.killRing.peek()||"";this.value=this.value.slice(0,this.cursor)+n+this.value.slice(this.cursor),this.cursor+=n.length,this.lastAction="yank"}pushUndo(){this.undoStack.push({value:this.value,cursor:this.cursor})}undo(){let e=this.undoStack.pop();e&&(this.value=e.value,this.cursor=e.cursor,this.lastAction=null)}moveWordBackwards(){this.cursor!==0&&(this.lastAction=null,this.cursor=Wp(this.value,this.cursor))}moveWordForwards(){this.cursor>=this.value.length||(this.lastAction=null,this.cursor=Fp(this.value,this.cursor))}handlePaste(e){this.lastAction=null,this.pushUndo();let n=e.replace(/\r\n/g,"").replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g," ");this.value=this.value.slice(0,this.cursor)+n+this.value.slice(this.cursor),this.cursor+=n.length}invalidate(){}render(e){let i=e-2;if(i<=0)return["> "];let o="",r=this.cursor,s=j(this.value);if(s<i)o=this.value;else{let x=this.cursor===this.value.length?i-1:i,y=j(this.value.slice(0,this.cursor));if(x>0){let T=Math.floor(x/2),P=0;y<T?P=0:y>s-T?P=Math.max(0,s-x):P=Math.max(0,y-T),o=no(this.value,P,x,!0),r=no(this.value,P,Math.max(0,y-P),!0).length}else o="",r=0}let l=[...Dc.segment(o.slice(r))][0],c=o.slice(0,r),u=l?.segment??" ",d=o.slice(r+u.length),p=this.focused?Wr:"",m=`\x1B[7m${u}\x1B[27m`,g=c+p+m+d,h=j(g),f=" ".repeat(Math.max(0,i-h));return["> "+g+f]}};import{Marked as _N,Tokenizer as ON}from"marked";var LN=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,Tv=class extends ON{del(e){let n=LN.exec(e);if(!n)return;let i=n[2];return{type:"del",raw:n[0],text:i,tokens:this.lexer.inlineTokens(i)}}};function Cv(t){let e=t[t.length-1];if(e?.type==="list"){Cv(e.items[e.items.length-1]?.tokens??[]);return}if(e?.type==="blockquote"){Cv(e.tokens??[]);return}if(e?.type!=="code")return;let n=/^(`{3,}|~{3,})/.exec(e.raw)?.[1],i=e.raw.split(`
68
68
  `).pop();!n||!i||i.length>=n.length||i!==n[0]?.repeat(i.length)||(e.text=e.text.slice(0,-i.length).replace(/\n$/,""))}var mR=new _N;mR.setOptions({tokenizer:new Tv});var Ze=class{constructor(e,n,i,o,r,s){this.text=e,this.paddingX=n,this.paddingY=i,this.theme=o,this.defaultTextStyle=r,this.options=s?{...s}:{}}setText(e){this.text=e,this.invalidate()}invalidate(){this.cachedText=void 0,this.cachedWidth=void 0,this.cachedLines=void 0}render(e){if(this.cachedLines&&this.cachedText===this.text&&this.cachedWidth===e)return this.cachedLines;let n=Math.max(1,e-this.paddingX*2);if(!this.text||this.text.trim()===""){let g=[];return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=g,g}let i=this.text.replace(/\t/g," "),o=mR.lexer(i);Cv(o);let r=[];for(let g=0;g<o.length;g++){let h=o[g],f=o[g+1],b=this.renderToken(h,n,f?.type);for(let x of b)r.push(x)}let s=[];for(let g of r)if(oo(g))s.push(g);else for(let h of rn(g,n))s.push(h);let a=" ".repeat(this.paddingX),l=" ".repeat(this.paddingX),c=this.defaultTextStyle?.bgColor,u=[];for(let g of s){if(oo(g)){u.push(g);continue}let h=a+g+l;if(c)u.push(Bo(h,e,c));else{let f=j(h),b=Math.max(0,e-f);u.push(h+" ".repeat(b))}}let d=" ".repeat(e),p=[];for(let g=0;g<this.paddingY;g++){let h=c?Bo(d,e,c):d;p.push(h)}let m=p.concat(u,p);return this.cachedText=this.text,this.cachedWidth=e,this.cachedLines=m,m.length>0?m:[""]}applyDefaultStyle(e){if(!this.defaultTextStyle)return e;let n=e;return this.defaultTextStyle.color&&(n=this.defaultTextStyle.color(n)),this.defaultTextStyle.bold&&(n=this.theme.bold(n)),this.defaultTextStyle.italic&&(n=this.theme.italic(n)),this.defaultTextStyle.strikethrough&&(n=this.theme.strikethrough(n)),this.defaultTextStyle.underline&&(n=this.theme.underline(n)),n}getDefaultStylePrefix(){if(!this.defaultTextStyle)return"";if(this.defaultStylePrefix!==void 0)return this.defaultStylePrefix;let e="\0",n=e;this.defaultTextStyle.color&&(n=this.defaultTextStyle.color(n)),this.defaultTextStyle.bold&&(n=this.theme.bold(n)),this.defaultTextStyle.italic&&(n=this.theme.italic(n)),this.defaultTextStyle.strikethrough&&(n=this.theme.strikethrough(n)),this.defaultTextStyle.underline&&(n=this.theme.underline(n));let i=n.indexOf(e);return this.defaultStylePrefix=i>=0?n.slice(0,i):"",this.defaultStylePrefix}getStylePrefix(e){let i=e("\0"),o=i.indexOf("\0");return o>=0?i.slice(0,o):""}getDefaultInlineStyleContext(){return{applyText:e=>this.applyDefaultStyle(e),stylePrefix:this.getDefaultStylePrefix()}}renderToken(e,n,i,o){let r=[];switch(e.type){case"heading":{let s=e.depth,a=`${"#".repeat(s)} `,l;s===1?l=p=>this.theme.heading(this.theme.bold(this.theme.underline(p))):l=p=>this.theme.heading(this.theme.bold(p));let c={applyText:l,stylePrefix:this.getStylePrefix(l)},u=this.renderInlineTokens(e.tokens||[],c),d=s>=3?l(a)+u:u;r.push(d),i&&i!=="space"&&r.push("");break}case"paragraph":{let s=this.renderInlineTokens(e.tokens||[],o);r.push(s),i&&i!=="list"&&i!=="space"&&r.push("");break}case"text":r.push(this.renderInlineTokens([e],o));break;case"code":{let s=this.theme.codeBlockIndent??" ";if(r.push(this.theme.codeBlockBorder(`\`\`\`${e.lang||""}`)),this.theme.highlightCode){let a=this.theme.highlightCode(e.text,e.lang);for(let l of a)r.push(`${s}${l}`)}else{let a=e.text.split(`
69
69
  `);for(let l of a)r.push(`${s}${this.theme.codeBlock(l)}`)}r.push(this.theme.codeBlockBorder("```")),i&&i!=="space"&&r.push("");break}case"list":{let s=this.renderList(e,0,n,o);r.push(...s);break}case"table":{let s=this.renderTable(e,n,i,o);r.push(...s);break}case"blockquote":{let s=m=>this.theme.quote(this.theme.italic(m)),a=this.getStylePrefix(s),l=m=>{if(!a)return s(m);let g=m.replace(/\x1b\[0m/g,`\x1B[0m${a}`);return s(g)},c=Math.max(1,n-2),u={applyText:m=>m,stylePrefix:a},d=e.tokens||[],p=[];for(let m=0;m<d.length;m++){let g=d[m],h=d[m+1];p.push(...this.renderToken(g,c,h?.type,u))}for(;p.length>0&&p[p.length-1]==="";)p.pop();for(let m of p){let g=l(m),h=rn(g,c);for(let f of h)r.push(this.theme.quoteBorder("\u2502 ")+f)}i&&i!=="space"&&r.push("");break}case"hr":r.push(this.theme.hr("\u2500".repeat(Math.min(n,80)))),i&&i!=="space"&&r.push("");break;case"html":"raw"in e&&typeof e.raw=="string"&&r.push(this.applyDefaultStyle(e.raw.trim()));break;case"space":r.push("");break;default:"text"in e&&typeof e.text=="string"&&r.push(e.text)}return r}renderInlineTokens(e,n){let i="",o=n??this.getDefaultInlineStyleContext(),{applyText:r,stylePrefix:s}=o,a=l=>l.split(`
70
70
  `).map(u=>r(u)).join(`
71
71
  `);for(let l of e)switch(l.type){case"escape":i+=a(this.options.preserveBackslashEscapes?l.raw:l.text);break;case"text":l.tokens&&l.tokens.length>0?i+=this.renderInlineTokens(l.tokens,o):i+=a(l.text);break;case"paragraph":i+=this.renderInlineTokens(l.tokens||[],o);break;case"strong":{let c=this.renderInlineTokens(l.tokens||[],o);i+=this.theme.bold(c)+s;break}case"em":{let c=this.renderInlineTokens(l.tokens||[],o);i+=this.theme.italic(c)+s;break}case"codespan":i+=this.theme.code(l.text)+s;break;case"link":{let c=this.renderInlineTokens(l.tokens||[],o),u=this.theme.link(this.theme.underline(c));if(ft().hyperlinks)i+=Lr(u,l.href)+s;else{let d=l.href.startsWith("mailto:")?l.href.slice(7):l.href;l.text===l.href||l.text===d?i+=u+s:i+=u+this.theme.linkUrl(` (${l.href})`)+s}break}case"br":i+=`
72
- `;break;case"del":{let c=this.renderInlineTokens(l.tokens||[],o);i+=this.theme.strikethrough(c)+s;break}case"html":"raw"in l&&typeof l.raw=="string"&&(i+=a(l.raw));break;default:"text"in l&&typeof l.text=="string"&&(i+=a(l.text))}for(;s&&i.endsWith(s);)i=i.slice(0,-s.length);return i}getOrderedListMarker(e){let n=/^(?: {0,3})(\d{1,9}[.)])[ \t]+/.exec(e.raw);return n?`${n[1]} `:void 0}getUnorderedListMarker(e){let n=/^(?: {0,3})([-+*])(?:[ \t]+|(?=\r?\n|$))/.exec(e.raw);return n?`${n[1]} `:void 0}renderList(e,n,i,o){let r=[],s=" ".repeat(n),a=typeof e.start=="number"?e.start:1;for(let l=0;l<e.items.length;l++){let c=e.items[l],u=l===e.items.length-1,d=e.ordered?this.options.preserveOrderedListMarkers?this.getOrderedListMarker(c)??`${a+l}. `:`${a+l}. `:this.options.preserveOrderedListMarkers?this.getUnorderedListMarker(c)??"- ":"- ",p=c.task?`[${c.checked?"x":" "}] `:"",m=d+p,g=s+this.theme.listBullet(m),h=s+" ".repeat(j(m)),f=Math.max(1,i-j(g)),b=!1;for(let x of c.tokens){if(x.type==="list"){r.push(...this.renderList(x,n+1,i,o)),b=!0;continue}let y=this.renderToken(x,f,void 0,o);for(let T of y)for(let P of rn(T,f)){let I=b?h:g;r.push(I+P),b=!0}}b||r.push(g),e.loose&&!u&&r.push("")}return r}getLongestWordWidth(e,n){let i=e.split(/\s+/).filter(r=>r.length>0),o=0;for(let r of i)o=Math.max(o,j(r));return n===void 0?o:Math.min(o,n)}wrapCellText(e,n){return rn(e,Math.max(1,n))}renderTable(e,n,i,o){let r=[],s=e.header.length;if(s===0)return r;let a=3*s+1,l=n-a;if(l<s){let I=e.raw?rn(e.raw,n):[];return i&&i!=="space"&&I.push(""),I}let c=30,u=[],d=[];for(let I=0;I<s;I++){let W=this.renderInlineTokens(e.header[I].tokens||[],o);u[I]=j(W),d[I]=Math.max(1,this.getLongestWordWidth(W,c))}for(let I of e.rows)for(let W=0;W<I.length;W++){let D=this.renderInlineTokens(I[W].tokens||[],o);u[W]=Math.max(u[W]||0,j(D)),d[W]=Math.max(d[W]||1,this.getLongestWordWidth(D,c))}let p=d,m=p.reduce((I,W)=>I+W,0);if(m>l){p=new Array(s).fill(1);let I=l-s;if(I>0){let W=d.reduce((O,R)=>O+Math.max(0,R-1),0),D=d.map(O=>{let R=Math.max(0,O-1);return W>0?Math.floor(R/W*I):0});for(let O=0;O<s;O++)p[O]+=D[O]??0;let _=D.reduce((O,R)=>O+R,0),F=I-_;for(let O=0;F>0&&O<s;O++)p[O]++,F--}m=p.reduce((W,D)=>W+D,0)}let g=u.reduce((I,W)=>I+W,0)+a,h;if(g<=n)h=u.map((I,W)=>Math.max(I,p[W]));else{let I=u.reduce((F,O,R)=>F+Math.max(0,O-p[R]),0),W=Math.max(0,l-m);h=p.map((F,O)=>{let R=u[O],E=Math.max(0,R-F),U=0;return I>0&&(U=Math.floor(E/I*W)),F+U});let D=h.reduce((F,O)=>F+O,0),_=l-D;for(;_>0;){let F=!1;for(let O=0;O<s&&_>0;O++)h[O]<u[O]&&(h[O]++,_--,F=!0);if(!F)break}}let f=h.map(I=>"\u2500".repeat(I));r.push(`\u250C\u2500${f.join("\u2500\u252C\u2500")}\u2500\u2510`);let b=e.header.map((I,W)=>{let D=this.renderInlineTokens(I.tokens||[],o);return this.wrapCellText(D,h[W])}),x=Math.max(...b.map(I=>I.length));for(let I=0;I<x;I++){let W=b.map((D,_)=>{let F=D[I]||"",O=F+" ".repeat(Math.max(0,h[_]-j(F)));return this.theme.bold(O)});r.push(`\u2502 ${W.join(" \u2502 ")} \u2502`)}let T=`\u251C\u2500${h.map(I=>"\u2500".repeat(I)).join("\u2500\u253C\u2500")}\u2500\u2524`;r.push(T);for(let I=0;I<e.rows.length;I++){let D=e.rows[I].map((F,O)=>{let R=this.renderInlineTokens(F.tokens||[],o);return this.wrapCellText(R,h[O])}),_=Math.max(...D.map(F=>F.length));for(let F=0;F<_;F++){let O=D.map((R,E)=>{let U=R[F]||"";return U+" ".repeat(Math.max(0,h[E]-j(U)))});r.push(`\u2502 ${O.join(" \u2502 ")} \u2502`)}I<e.rows.length-1&&r.push(T)}let P=h.map(I=>"\u2500".repeat(I));return r.push(`\u2514\u2500${P.join("\u2500\u2534\u2500")}\u2500\u2518`),i&&i!=="space"&&r.push(""),r}};var $r=class{constructor(e,n,i,o,r,s={}){this.selectedIndex=0;this.submenuComponent=null;this.submenuItemIndex=null;this.items=e,this.filteredItems=e,this.maxVisible=n,this.theme=i,this.onChange=o,this.onCancel=r,this.searchEnabled=s.enableSearch??!1,this.searchEnabled&&(this.searchInput=new Xe)}updateValue(e,n){let i=this.items.find(o=>o.id===e);i&&(i.currentValue=n)}invalidate(){this.submenuComponent?.invalidate?.()}render(e){return this.submenuComponent?this.submenuComponent.render(e):this.renderMainList(e)}renderMainList(e){let n=[];if(this.searchEnabled&&this.searchInput&&(n.push(...this.searchInput.render(e)),n.push("")),this.items.length===0)return n.push(this.theme.hint(" No settings available")),this.searchEnabled&&this.addHintLine(n,e),n;let i=this.searchEnabled?this.filteredItems:this.items;if(i.length===0)return n.push(te(this.theme.hint(" No matching settings"),e)),this.addHintLine(n,e),n;let o=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),i.length-this.maxVisible)),r=Math.min(o+this.maxVisible,i.length),s=Math.min(30,Math.max(...this.items.map(l=>j(l.label))));for(let l=o;l<r;l++){let c=i[l];if(!c)continue;let u=l===this.selectedIndex,d=u?this.theme.cursor:" ",p=j(d),m=c.label+" ".repeat(Math.max(0,s-j(c.label))),g=this.theme.label(m,u),h=" ",f=p+s+j(h),b=e-f-2,x=this.theme.value(te(c.currentValue,b,""),u);n.push(te(d+g+h+x,e))}if(o>0||r<i.length){let l=` (${this.selectedIndex+1}/${i.length})`;n.push(this.theme.hint(te(l,e-2,"")))}let a=i[this.selectedIndex];if(a?.description){n.push("");let l=rn(a.description,e-4);for(let c of l)n.push(this.theme.description(` ${c}`))}return this.addHintLine(n,e),n}handleInput(e){if(this.submenuComponent){this.submenuComponent.handleInput?.(e);return}let n=ke(),i=this.searchEnabled?this.filteredItems:this.items;if(n.matches(e,"tui.select.up")){if(i.length===0)return;this.selectedIndex=this.selectedIndex===0?i.length-1:this.selectedIndex-1}else if(n.matches(e,"tui.select.down")){if(i.length===0)return;this.selectedIndex=this.selectedIndex===i.length-1?0:this.selectedIndex+1}else if(n.matches(e,"tui.select.confirm")||e===" ")this.activateItem();else if(n.matches(e,"tui.select.cancel"))this.onCancel();else if(this.searchEnabled&&this.searchInput){let o=e.replace(/ /g,"");if(!o)return;this.searchInput.handleInput(o),this.applyFilter(this.searchInput.getValue())}}activateItem(){let e=this.searchEnabled?this.filteredItems[this.selectedIndex]:this.items[this.selectedIndex];if(e){if(e.submenu)this.submenuItemIndex=this.selectedIndex,this.submenuComponent=e.submenu(e.currentValue,n=>{n!==void 0&&(e.currentValue=n,this.onChange(e.id,n)),this.closeSubmenu()});else if(e.values&&e.values.length>0){let i=(e.values.indexOf(e.currentValue)+1)%e.values.length,o=e.values[i];e.currentValue=o,this.onChange(e.id,o)}}}closeSubmenu(){this.submenuComponent=null,this.submenuItemIndex!==null&&(this.selectedIndex=this.submenuItemIndex,this.submenuItemIndex=null)}applyFilter(e){this.filteredItems=Gt(this.items,e,n=>n.label),this.selectedIndex=0}addHintLine(e,n){e.push(""),e.push(te(this.theme.hint(this.searchEnabled?" Type to search \xB7 Enter/Space to change \xB7 Esc to cancel":" Enter/Space to change \xB7 Esc to cancel"),n))}};var L=class{constructor(e=1){this.lines=e}setLines(e){this.lines=e}invalidate(){}render(e){let n=[];for(let i=0;i<this.lines;i++)n.push("");return n}};var Kn=class{constructor(e,n=0,i=0){this.text=e,this.paddingX=n,this.paddingY=i}invalidate(){}render(e){let n=[],i=" ".repeat(e);for(let g=0;g<this.paddingY;g++)n.push(i);let o=Math.max(1,e-this.paddingX*2),r=this.text,s=this.text.indexOf(`
72
+ `;break;case"del":{let c=this.renderInlineTokens(l.tokens||[],o);i+=this.theme.strikethrough(c)+s;break}case"html":"raw"in l&&typeof l.raw=="string"&&(i+=a(l.raw));break;default:"text"in l&&typeof l.text=="string"&&(i+=a(l.text))}for(;s&&i.endsWith(s);)i=i.slice(0,-s.length);return i}getOrderedListMarker(e){let n=/^(?: {0,3})(\d{1,9}[.)])[ \t]+/.exec(e.raw);return n?`${n[1]} `:void 0}getUnorderedListMarker(e){let n=/^(?: {0,3})([-+*])(?:[ \t]+|(?=\r?\n|$))/.exec(e.raw);return n?`${n[1]} `:void 0}renderList(e,n,i,o){let r=[],s=" ".repeat(n),a=typeof e.start=="number"?e.start:1;for(let l=0;l<e.items.length;l++){let c=e.items[l],u=l===e.items.length-1,d=e.ordered?this.options.preserveOrderedListMarkers?this.getOrderedListMarker(c)??`${a+l}. `:`${a+l}. `:this.options.preserveOrderedListMarkers?this.getUnorderedListMarker(c)??"- ":"- ",p=c.task?`[${c.checked?"x":" "}] `:"",m=d+p,g=s+this.theme.listBullet(m),h=s+" ".repeat(j(m)),f=Math.max(1,i-j(g)),b=!1;for(let x of c.tokens){if(x.type==="list"){r.push(...this.renderList(x,n+1,i,o)),b=!0;continue}let y=this.renderToken(x,f,void 0,o);for(let T of y)for(let P of rn(T,f)){let I=b?h:g;r.push(I+P),b=!0}}b||r.push(g),e.loose&&!u&&r.push("")}return r}getLongestWordWidth(e,n){let i=e.split(/\s+/).filter(r=>r.length>0),o=0;for(let r of i)o=Math.max(o,j(r));return n===void 0?o:Math.min(o,n)}wrapCellText(e,n){return rn(e,Math.max(1,n))}renderTable(e,n,i,o){let r=[],s=e.header.length;if(s===0)return r;let a=3*s+1,l=n-a;if(l<s){let I=e.raw?rn(e.raw,n):[];return i&&i!=="space"&&I.push(""),I}let c=30,u=[],d=[];for(let I=0;I<s;I++){let W=this.renderInlineTokens(e.header[I].tokens||[],o);u[I]=j(W),d[I]=Math.max(1,this.getLongestWordWidth(W,c))}for(let I of e.rows)for(let W=0;W<I.length;W++){let D=this.renderInlineTokens(I[W].tokens||[],o);u[W]=Math.max(u[W]||0,j(D)),d[W]=Math.max(d[W]||1,this.getLongestWordWidth(D,c))}let p=d,m=p.reduce((I,W)=>I+W,0);if(m>l){p=new Array(s).fill(1);let I=l-s;if(I>0){let W=d.reduce((O,R)=>O+Math.max(0,R-1),0),D=d.map(O=>{let R=Math.max(0,O-1);return W>0?Math.floor(R/W*I):0});for(let O=0;O<s;O++)p[O]+=D[O]??0;let _=D.reduce((O,R)=>O+R,0),F=I-_;for(let O=0;F>0&&O<s;O++)p[O]++,F--}m=p.reduce((W,D)=>W+D,0)}let g=u.reduce((I,W)=>I+W,0)+a,h;if(g<=n)h=u.map((I,W)=>Math.max(I,p[W]));else{let I=u.reduce((F,O,R)=>F+Math.max(0,O-p[R]),0),W=Math.max(0,l-m);h=p.map((F,O)=>{let R=u[O],E=Math.max(0,R-F),U=0;return I>0&&(U=Math.floor(E/I*W)),F+U});let D=h.reduce((F,O)=>F+O,0),_=l-D;for(;_>0;){let F=!1;for(let O=0;O<s&&_>0;O++)h[O]<u[O]&&(h[O]++,_--,F=!0);if(!F)break}}let f=h.map(I=>"\u2500".repeat(I));r.push(`\u250C\u2500${f.join("\u2500\u252C\u2500")}\u2500\u2510`);let b=e.header.map((I,W)=>{let D=this.renderInlineTokens(I.tokens||[],o);return this.wrapCellText(D,h[W])}),x=Math.max(...b.map(I=>I.length));for(let I=0;I<x;I++){let W=b.map((D,_)=>{let F=D[I]||"",O=F+" ".repeat(Math.max(0,h[_]-j(F)));return this.theme.bold(O)});r.push(`\u2502 ${W.join(" \u2502 ")} \u2502`)}let T=`\u251C\u2500${h.map(I=>"\u2500".repeat(I)).join("\u2500\u253C\u2500")}\u2500\u2524`;r.push(T);for(let I=0;I<e.rows.length;I++){let D=e.rows[I].map((F,O)=>{let R=this.renderInlineTokens(F.tokens||[],o);return this.wrapCellText(R,h[O])}),_=Math.max(...D.map(F=>F.length));for(let F=0;F<_;F++){let O=D.map((R,E)=>{let U=R[F]||"";return U+" ".repeat(Math.max(0,h[E]-j(U)))});r.push(`\u2502 ${O.join(" \u2502 ")} \u2502`)}I<e.rows.length-1&&r.push(T)}let P=h.map(I=>"\u2500".repeat(I));return r.push(`\u2514\u2500${P.join("\u2500\u2534\u2500")}\u2500\u2518`),i&&i!=="space"&&r.push(""),r}};var $r=class{constructor(e,n,i,o,r,s={}){this.selectedIndex=0;this.submenuComponent=null;this.submenuItemIndex=null;this.items=e,this.filteredItems=e,this.maxVisible=n,this.theme=i,this.onChange=o,this.onCancel=r,this.searchEnabled=s.enableSearch??!1,this.searchEnabled&&(this.searchInput=new Xe)}updateValue(e,n){let i=this.items.find(o=>o.id===e);i&&(i.currentValue=n)}invalidate(){this.submenuComponent?.invalidate?.()}render(e){return this.submenuComponent?this.submenuComponent.render(e):this.renderMainList(e)}renderMainList(e){let n=[];if(this.searchEnabled&&this.searchInput&&(n.push(...this.searchInput.render(e)),n.push("")),this.items.length===0)return n.push(this.theme.hint(" No settings available")),this.searchEnabled&&this.addHintLine(n,e),n;let i=this.searchEnabled?this.filteredItems:this.items;if(i.length===0)return n.push(te(this.theme.hint(" No matching settings"),e)),this.addHintLine(n,e),n;let o=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),i.length-this.maxVisible)),r=Math.min(o+this.maxVisible,i.length),s=Math.min(30,Math.max(...this.items.map(l=>j(l.label))));for(let l=o;l<r;l++){let c=i[l];if(!c)continue;let u=l===this.selectedIndex,d=u?this.theme.cursor:" ",p=j(d),m=c.label+" ".repeat(Math.max(0,s-j(c.label))),g=this.theme.label(m,u),h=" ",f=p+s+j(h),b=e-f-2,x=this.theme.value(te(c.currentValue,b,""),u);n.push(te(d+g+h+x,e))}if(o>0||r<i.length){let l=` (${this.selectedIndex+1}/${i.length})`;n.push(this.theme.hint(te(l,e-2,"")))}let a=i[this.selectedIndex];if(a?.description){n.push("");let l=rn(a.description,e-4);for(let c of l)n.push(this.theme.description(` ${c}`))}return this.addHintLine(n,e),n}handleInput(e){if(this.submenuComponent){this.submenuComponent.handleInput?.(e);return}let n=we(),i=this.searchEnabled?this.filteredItems:this.items;if(n.matches(e,"tui.select.up")){if(i.length===0)return;this.selectedIndex=this.selectedIndex===0?i.length-1:this.selectedIndex-1}else if(n.matches(e,"tui.select.down")){if(i.length===0)return;this.selectedIndex=this.selectedIndex===i.length-1?0:this.selectedIndex+1}else if(n.matches(e,"tui.select.confirm")||e===" ")this.activateItem();else if(n.matches(e,"tui.select.cancel"))this.onCancel();else if(this.searchEnabled&&this.searchInput){let o=e.replace(/ /g,"");if(!o)return;this.searchInput.handleInput(o),this.applyFilter(this.searchInput.getValue())}}activateItem(){let e=this.searchEnabled?this.filteredItems[this.selectedIndex]:this.items[this.selectedIndex];if(e){if(e.submenu)this.submenuItemIndex=this.selectedIndex,this.submenuComponent=e.submenu(e.currentValue,n=>{n!==void 0&&(e.currentValue=n,this.onChange(e.id,n)),this.closeSubmenu()});else if(e.values&&e.values.length>0){let i=(e.values.indexOf(e.currentValue)+1)%e.values.length,o=e.values[i];e.currentValue=o,this.onChange(e.id,o)}}}closeSubmenu(){this.submenuComponent=null,this.submenuItemIndex!==null&&(this.selectedIndex=this.submenuItemIndex,this.submenuItemIndex=null)}applyFilter(e){this.filteredItems=Gt(this.items,e,n=>n.label),this.selectedIndex=0}addHintLine(e,n){e.push(""),e.push(te(this.theme.hint(this.searchEnabled?" Type to search \xB7 Enter/Space to change \xB7 Esc to cancel":" Enter/Space to change \xB7 Esc to cancel"),n))}};var L=class{constructor(e=1){this.lines=e}setLines(e){this.lines=e}invalidate(){}render(e){let n=[];for(let i=0;i<this.lines;i++)n.push("");return n}};var Kn=class{constructor(e,n=0,i=0){this.text=e,this.paddingX=n,this.paddingY=i}invalidate(){}render(e){let n=[],i=" ".repeat(e);for(let g=0;g<this.paddingY;g++)n.push(i);let o=Math.max(1,e-this.paddingX*2),r=this.text,s=this.text.indexOf(`
73
73
  `);s!==-1&&(r=this.text.substring(0,s));let a=te(r,o),l=" ".repeat(this.paddingX),c=" ".repeat(this.paddingX),u=l+a+c,d=j(u),p=Math.max(0,e-d),m=u+" ".repeat(p);n.push(m);for(let g=0;g<this.paddingY;g++)n.push(i);return n}};import{EventEmitter as WN}from"events";var Ci="\x1B",hR="\x1B[200~",Dp="\x1B[201~";function FN(t){if(!t.startsWith(Ci))return"not-escape";if(t.length===1)return"incomplete";let e=t.slice(1);return e.startsWith("[")?e.startsWith("[M")?t.length>=6?"complete":"incomplete":DN(t):e.startsWith("]")?UN(t):e.startsWith("P")?$N(t):e.startsWith("_")?NN(t):e.startsWith("O")?e.length>=2?"complete":"incomplete":(e.length===1,"complete")}function DN(t){if(!t.startsWith(`${Ci}[`))return"complete";if(t.length<3)return"incomplete";let e=t.slice(2),n=e[e.length-1],i=n.charCodeAt(0);if(i>=64&&i<=126){if(e.startsWith("<")){if(/^<\d+;\d+;\d+[Mm]$/.test(e))return"complete";if(n==="M"||n==="m"){let r=e.slice(1,-1).split(";");if(r.length===3&&r.every(s=>/^\d+$/.test(s)))return"complete"}return"incomplete"}return"complete"}return"incomplete"}function UN(t){return!t.startsWith(`${Ci}]`)||t.endsWith(`${Ci}\\`)||t.endsWith("\x07")?"complete":"incomplete"}function $N(t){return!t.startsWith(`${Ci}P`)||t.endsWith(`${Ci}\\`)?"complete":"incomplete"}function NN(t){return!t.startsWith(`${Ci}_`)||t.endsWith(`${Ci}\\`)?"complete":"incomplete"}function BN(t){let e=t.match(/^\x1b\[(\d+)(?::\d*)?(?::\d+)?u$/);if(!e)return;let n=parseInt(e[1],10);return n>=32?n:void 0}function gR(t){let e=[],n=0;for(;n<t.length;){let i=t.slice(n);if(i.startsWith(Ci)){let o=1;for(;o<=i.length;){let r=i.slice(0,o),s=FN(r);if(s==="complete"){if(r==="\x1B\x1B"){let a=i[o];if(a==="["||a==="]"||a==="O"||a==="P"||a==="_"){e.push(Ci),n+=1;break}}e.push(r),n+=o;break}else if(s==="incomplete")o++;else{e.push(r),n+=o;break}}if(o>i.length)return{sequences:e,remainder:i}}else e.push(i[0]),n++}return{sequences:e,remainder:""}}var Uc=class extends WN{constructor(n={}){super();this.buffer="";this.timeout=null;this.pasteMode=!1;this.pasteBuffer="";this.timeoutMs=n.timeout??10}process(n){this.timeout&&(clearTimeout(this.timeout),this.timeout=null);let i;if(Buffer.isBuffer(n))if(n.length===1&&n[0]>127){let s=n[0]-128;i=`\x1B${String.fromCharCode(s)}`}else i=n.toString();else i=n;if(i.length===0&&this.buffer.length===0){this.emitDataSequence("");return}if(this.buffer+=i,this.pasteMode){this.pasteBuffer+=this.buffer,this.buffer="";let s=this.pasteBuffer.indexOf(Dp);if(s!==-1){let a=this.pasteBuffer.slice(0,s),l=this.pasteBuffer.slice(s+Dp.length);this.pasteMode=!1,this.pasteBuffer="",this.pendingKittyPrintableCodepoint=void 0,this.emit("paste",a),l.length>0&&this.process(l)}return}let o=this.buffer.indexOf(hR);if(o!==-1){if(o>0){let a=this.buffer.slice(0,o),l=gR(a);for(let c of l.sequences)this.emitDataSequence(c)}this.pendingKittyPrintableCodepoint=void 0,this.buffer=this.buffer.slice(o+hR.length),this.pasteMode=!0,this.pasteBuffer=this.buffer,this.buffer="";let s=this.pasteBuffer.indexOf(Dp);if(s!==-1){let a=this.pasteBuffer.slice(0,s),l=this.pasteBuffer.slice(s+Dp.length);this.pasteMode=!1,this.pasteBuffer="",this.pendingKittyPrintableCodepoint=void 0,this.emit("paste",a),l.length>0&&this.process(l)}return}let r=gR(this.buffer);this.buffer=r.remainder;for(let s of r.sequences)this.emitDataSequence(s);this.buffer.length>0&&(this.timeout=setTimeout(()=>{let s=this.flush();for(let a of s)this.emitDataSequence(a)},this.timeoutMs))}emitDataSequence(n){let i=n.length===1?n.codePointAt(0):void 0;if(i!==void 0&&i===this.pendingKittyPrintableCodepoint){this.pendingKittyPrintableCodepoint=void 0;return}this.pendingKittyPrintableCodepoint=BN(n),this.emit("data",n)}flush(){if(this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.buffer.length===0)return[];let n=[this.buffer];return this.buffer="",this.pendingKittyPrintableCodepoint=void 0,n}clear(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.buffer="",this.pasteMode=!1,this.pasteBuffer="",this.pendingKittyPrintableCodepoint=void 0}getBuffer(){return this.buffer}destroy(){this.clear()}};import*as $p from"node:fs";import{createRequire as HN}from"node:module";import*as ro from"node:path";import{fileURLToPath as VN}from"node:url";import{createRequire as jN}from"node:module";import*as qo from"node:path";import{fileURLToPath as qN}from"node:url";var KN=jN(import.meta.url),Up;function GN(t){return typeof t!="object"||t===null?!1:typeof t.isModifierPressed=="function"}function zN(){if(Up!==void 0)return Up??void 0;if(Up=null,process.platform!=="darwin")return;let t=process.arch;if(t!=="x64"&&t!=="arm64")return;let e=qo.dirname(qN(import.meta.url)),n=qo.join("native","darwin","prebuilds",`darwin-${t}`,"darwin-modifiers.node"),i=[qo.join(e,"..",n),qo.join(e,n),qo.join(qo.dirname(process.execPath),n)];for(let o of i)try{let r=KN(o);if(GN(r))return Up=r,r}catch{}}function fR(t){let e=zN();if(!e)return!1;try{return e.isModifierPressed(t)===!0}catch{return!1}}var QN=HN(import.meta.url),YN=1e3,vR="\x1B]9;4;3\x07",bR="\x1B]9;4;0;\x07",JN="\x1B[13;2u",XN=7,ZN=150,eB=`\x1B[>${XN}u\x1B[?u\x1B[c`;function xR(t){let e=t.match(/^\x1b\[\?(\d+)u$/);if(e)return{type:"kitty-flags",flags:Number.parseInt(e[1],10)};if(/^\x1b\[\?[\d;]*c$/.test(t))return{type:"device-attributes"}}function yR(t){return t==="\x1B["||/^\x1b\[\?[\d;]*$/.test(t)}function tB(){return process.platform==="darwin"&&process.env.TERM_PROGRAM==="Apple_Terminal"}function nB(t,e,n){return e&&t==="\r"&&n?JN:t}var Nr=class{constructor(){this.wasRaw=!1;this._kittyProtocolActive=!1;this._modifyOtherKeysActive=!1;this.keyboardProtocolPushed=!1;this.keyboardProtocolNegotiationBuffer="";this.writeLogPath=(()=>{let e=process.env.PI_TUI_WRITE_LOG||"";if(!e)return"";try{if($p.statSync(e).isDirectory()){let n=new Date,i=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}_${String(n.getHours()).padStart(2,"0")}-${String(n.getMinutes()).padStart(2,"0")}-${String(n.getSeconds()).padStart(2,"0")}`;return ro.join(e,`tui-${i}-${process.pid}.log`)}}catch{}return e})()}get kittyProtocolActive(){return this._kittyProtocolActive}get modifyOtherKeysActive(){return this._modifyOtherKeysActive}start(e,n){this.inputHandler=e,this.resizeHandler=n,this.wasRaw=process.stdin.isRaw||!1,process.stdin.setRawMode&&process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),process.stdout.write("\x1B[?2004h"),process.stdout.on("resize",this.resizeHandler),process.platform!=="win32"&&process.kill(process.pid,"SIGWINCH"),this.enableWindowsVTInput(),this.queryAndEnableKittyProtocol()}setupStdinBuffer(){this.stdinBuffer=new Uc({timeout:10}),this.stdinBuffer.on("data",e=>{let n=this.readKeyboardProtocolNegotiationSequence(e);if(n==="pending"){this.scheduleKeyboardProtocolNegotiationBufferFlush();return}this.handleKeyboardProtocolNegotiationSequence(n)||this.forwardInputSequence(e)}),this.stdinBuffer.on("paste",e=>{this.inputHandler&&this.inputHandler(`\x1B[200~${e}\x1B[201~`)}),this.stdinDataHandler=e=>{this.stdinBuffer.process(e)}}queryAndEnableKittyProtocol(){this.setupStdinBuffer(),process.stdin.on("data",this.stdinDataHandler),this.keyboardProtocolPushed=!0,this.clearKeyboardProtocolNegotiationBuffer(),process.stdout.write(eB)}handleKeyboardProtocolNegotiationSequence(e){return e?(this.clearKeyboardProtocolNegotiationBuffer(),e.type==="kitty-flags"?(e.flags!==0?(this.disableModifyOtherKeys(),this._kittyProtocolActive||(this._kittyProtocolActive=!0,Oc(!0))):this.enableModifyOtherKeys(),!0):(this._kittyProtocolActive||this.enableModifyOtherKeys(),!0)):!1}readKeyboardProtocolNegotiationSequence(e){if(this.keyboardProtocolNegotiationBuffer){let i=this.keyboardProtocolNegotiationBuffer+e,o=xR(i);if(o)return this.clearKeyboardProtocolNegotiationBuffer(),o;if(yR(i))return this.setKeyboardProtocolNegotiationBuffer(i),"pending";this.flushKeyboardProtocolNegotiationBufferAsInput()}let n=xR(e);if(n)return n;if(yR(e))return this.setKeyboardProtocolNegotiationBuffer(e),"pending"}setKeyboardProtocolNegotiationBuffer(e){this.clearKeyboardProtocolNegotiationBufferFlushTimer(),this.keyboardProtocolNegotiationBuffer=e}clearKeyboardProtocolNegotiationBuffer(){this.clearKeyboardProtocolNegotiationBufferFlushTimer(),this.keyboardProtocolNegotiationBuffer=""}flushKeyboardProtocolNegotiationBufferAsInput(){if(!this.keyboardProtocolNegotiationBuffer)return;let e=this.keyboardProtocolNegotiationBuffer;this.clearKeyboardProtocolNegotiationBuffer(),this.forwardInputSequence(e)}scheduleKeyboardProtocolNegotiationBufferFlush(){!this.keyboardProtocolNegotiationBuffer||this.keyboardProtocolBufferFlushTimer||(this.keyboardProtocolBufferFlushTimer=setTimeout(()=>{this.keyboardProtocolBufferFlushTimer=void 0,this.flushKeyboardProtocolNegotiationBufferAsInput()},ZN))}clearKeyboardProtocolNegotiationBufferFlushTimer(){this.keyboardProtocolBufferFlushTimer&&(clearTimeout(this.keyboardProtocolBufferFlushTimer),this.keyboardProtocolBufferFlushTimer=void 0)}forwardInputSequence(e){if(!this.inputHandler)return;let n=e==="\r"&&tB(),i=nB(e,n,n&&fR("shift"));this.inputHandler(i)}enableModifyOtherKeys(){this._kittyProtocolActive||this._modifyOtherKeysActive||(process.stdout.write("\x1B[>4;2m"),this._modifyOtherKeysActive=!0)}disableModifyOtherKeys(){this._modifyOtherKeysActive&&(process.stdout.write("\x1B[>4;0m"),this._modifyOtherKeysActive=!1)}enableWindowsVTInput(){if(process.platform==="win32")try{let e=process.arch;if(e!=="x64"&&e!=="arm64")return;let n=ro.dirname(VN(import.meta.url)),i=ro.join("native","win32","prebuilds",`win32-${e}`,"win32-console-mode.node"),o=[ro.join(n,"..",i),ro.join(n,i),ro.join(ro.dirname(process.execPath),i)];for(let r of o)try{QN(r).enableVirtualTerminalInput?.();return}catch{}}catch{}}async drainInput(e=1e3,n=50){let i=this.keyboardProtocolPushed||this._kittyProtocolActive;this.clearKeyboardProtocolNegotiationBuffer(),i&&(process.stdout.write("\x1B[<u"),this.keyboardProtocolPushed=!1,this._kittyProtocolActive=!1,Oc(!1)),this.disableModifyOtherKeys();let o=this.inputHandler;this.inputHandler=void 0;let r=Date.now(),s=()=>{r=Date.now()};process.stdin.on("data",s);let a=Date.now()+e;try{for(;;){let l=Date.now(),c=a-l;if(c<=0||l-r>=n)break;await new Promise(u=>setTimeout(u,Math.min(n,c)))}}finally{process.stdin.removeListener("data",s),this.inputHandler=o}}stop(){this.clearProgressInterval()&&process.stdout.write(bR),process.stdout.write("\x1B[?2004l");let e=this.keyboardProtocolPushed||this._kittyProtocolActive;this.clearKeyboardProtocolNegotiationBuffer(),e&&(process.stdout.write("\x1B[<u"),this.keyboardProtocolPushed=!1,this._kittyProtocolActive=!1,Oc(!1)),this.disableModifyOtherKeys(),this.stdinBuffer&&(this.stdinBuffer.destroy(),this.stdinBuffer=void 0),this.stdinDataHandler&&(process.stdin.removeListener("data",this.stdinDataHandler),this.stdinDataHandler=void 0),this.inputHandler=void 0,this.resizeHandler&&(process.stdout.removeListener("resize",this.resizeHandler),this.resizeHandler=void 0),process.stdin.pause(),process.stdin.setRawMode&&process.stdin.setRawMode(this.wasRaw)}write(e){if(process.stdout.write(e),this.writeLogPath)try{$p.appendFileSync(this.writeLogPath,e,{encoding:"utf8"})}catch{}}get columns(){return process.stdout.columns||Number(process.env.COLUMNS)||80}get rows(){return process.stdout.rows||Number(process.env.LINES)||24}moveBy(e){e>0?process.stdout.write(`\x1B[${e}B`):e<0&&process.stdout.write(`\x1B[${-e}A`)}hideCursor(){process.stdout.write("\x1B[?25l")}showCursor(){process.stdout.write("\x1B[?25h")}clearLine(){process.stdout.write("\x1B[K")}clearFromCursor(){process.stdout.write("\x1B[J")}clearScreen(){process.stdout.write("\x1B[2J\x1B[H")}setTitle(e){process.stdout.write(`\x1B]0;${e}\x07`)}setProgress(e){e?(process.stdout.write(vR),this.progressInterval||(this.progressInterval=setInterval(()=>{process.stdout.write(vR)},YN))):(this.clearProgressInterval(),process.stdout.write(bR))}clearProgressInterval(){return this.progressInterval?(clearInterval(this.progressInterval),this.progressInterval=void 0,!0):!1}};import Ga from"chalk";import{Type as Wt}from"typebox";import{Compile as dB}from"typebox/compile";import{watch as oB}from"node:fs";var wR=5e3;function Br(t){if(t)try{t.close()}catch{}}function Ka(t,e,n){try{let i=oB(t,e);return i.on("error",n),i}catch{return n(),null}}import Mv from"highlight.js/lib/index.js";function kR(t){if(!(!Number.isInteger(t)||t<0||t>1114111))return String.fromCodePoint(t)}function rB(t){switch(t){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'"}if(t.startsWith("#x")||t.startsWith("#X"))return kR(Number.parseInt(t.slice(2),16));if(t.startsWith("#"))return kR(Number.parseInt(t.slice(1),10))}function SR(t,e){let n=t.indexOf(";",e+1);if(n===-1||n-e>16)return;let i=t.slice(e+1,n),o=rB(i);if(o!==void 0)return{text:o,length:n-e+1}}var TR="</span>",CR="hljs-";function sB(t){let e=/\sclass\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(t),n=e?.[1]??e?.[2];if(n){for(let i of n.split(/\s+/))if(i.startsWith(CR))return i.slice(CR.length)}}function aB(t,e){let n=e[t];if(n)return n;let i=t.indexOf(".");if(i!==-1){let r=e[t.slice(0,i)];if(r)return r}let o=t.indexOf("-");if(o!==-1){let r=e[t.slice(0,o)];if(r)return r}}function lB(t,e){for(let n=t.length-1;n>=0;n--){let i=t[n];if(!i)continue;let o=aB(i,e);if(o)return o}return e.default}function cB(t,e){if(!t.startsWith("<span",e))return!1;let n=t[e+5];return n===">"||n===" "||n===" "||n===`
74
74
  `||n==="\r"}function uB(t,e={}){let n="",i="",o=[],r=()=>{if(!i)return;let a=lB(o,e);n+=a?a(i):i,i=""},s=0;for(;s<t.length;){if(cB(t,s)){let a=t.indexOf(">",s+5);if(a!==-1){r();let l=t.slice(s,a+1),c=sB(l);o.push(c),s=a+1;continue}}if(t.startsWith(TR,s)){r(),o.length>0&&o.pop(),s+=TR.length;continue}if(t[s]==="&"){let a=SR(t,s);if(a){i+=a.text,s+=a.length;continue}}i+=t[s],s++}return r(),n}function Rv(t,e={}){let n=e.language?Mv.highlight(t,{language:e.language,ignoreIllegals:e.ignoreIllegals}).value:Mv.highlightAuto(t,e.languageSubset).value;return uB(n,e.theme)}function Pv(t){return Mv.getLanguage(t)!==void 0}var de=Wt.Union([Wt.String(),Wt.Integer({minimum:0,maximum:255})]),pB=Wt.Object({$schema:Wt.Optional(Wt.String()),name:Wt.String(),vars:Wt.Optional(Wt.Record(Wt.String(),de)),colors:Wt.Object({accent:de,border:de,borderAccent:de,borderMuted:de,success:de,error:de,warning:de,muted:de,dim:de,text:de,thinkingText:de,selectedBg:de,userMessageBg:de,userMessageText:de,customMessageBg:de,customMessageText:de,customMessageLabel:de,toolPendingBg:de,toolSuccessBg:de,toolErrorBg:de,toolTitle:de,toolOutput:de,mdHeading:de,mdLink:de,mdLinkUrl:de,mdCode:de,mdCodeBlock:de,mdCodeBlockBorder:de,mdQuote:de,mdQuoteBorder:de,mdHr:de,mdListBullet:de,toolDiffAdded:de,toolDiffRemoved:de,toolDiffContext:de,syntaxComment:de,syntaxKeyword:de,syntaxFunction:de,syntaxVariable:de,syntaxString:de,syntaxNumber:de,syntaxType:de,syntaxOperator:de,syntaxPunctuation:de,thinkingOff:de,thinkingMinimal:de,thinkingLow:de,thinkingMedium:de,thinkingHigh:de,thinkingXhigh:de,thinkingMax:Wt.Optional(de),bashMode:de}),export:Wt.Optional(Wt.Object({pageBg:Wt.Optional(de),cardBg:Wt.Optional(de),infoBg:Wt.Optional(de)}))}),MR=dB(pB);function Np(t){let e=t.replace("#","");if(e.length!==6)throw new Error(`Invalid hex color: ${t}`);let n=parseInt(e.substring(0,2),16),i=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16);if(Number.isNaN(n)||Number.isNaN(i)||Number.isNaN(o))throw new Error(`Invalid hex color: ${t}`);return{r:n,g:i,b:o}}var $c=[0,95,135,175,215,255],_v=Array.from({length:24},(t,e)=>8+e*10);function Iv(t){let e=1/0,n=0;for(let i=0;i<$c.length;i++){let o=Math.abs(t-$c[i]);o<e&&(e=o,n=i)}return n}function mB(t){let e=1/0,n=0;for(let i=0;i<_v.length;i++){let o=Math.abs(t-_v[i]);o<e&&(e=o,n=i)}return n}function RR(t,e,n,i,o,r){let s=t-i,a=e-o,l=n-r;return s*s*.299+a*a*.587+l*l*.114}function hB(t,e,n){let i=Iv(t),o=Iv(e),r=Iv(n),s=$c[i],a=$c[o],l=$c[r],c=16+36*i+6*o+r,u=RR(t,e,n,s,a,l),d=Math.round(.299*t+.587*e+.114*n),p=mB(d),m=_v[p],g=232+p,h=RR(t,e,n,m,m,m),f=Math.max(t,e,n),b=Math.min(t,e,n);return f-b<10&&h<u?g:c}function IR(t){let{r:e,g:n,b:i}=Np(t);return hB(e,n,i)}function gB(t,e){if(t==="")return"\x1B[39m";if(typeof t=="number")return`\x1B[38;5;${t}m`;if(t.startsWith("#"))if(e==="truecolor"){let{r:n,g:i,b:o}=Np(t);return`\x1B[38;2;${n};${i};${o}m`}else return`\x1B[38;5;${IR(t)}m`;throw new Error(`Invalid color value: ${t}`)}function fB(t,e){if(t==="")return"\x1B[49m";if(typeof t=="number")return`\x1B[48;5;${t}m`;if(t.startsWith("#"))if(e==="truecolor"){let{r:n,g:i,b:o}=Np(t);return`\x1B[48;2;${n};${i};${o}m`}else return`\x1B[48;5;${IR(t)}m`;throw new Error(`Invalid color value: ${t}`)}function ER(t,e,n=new Set){if(typeof t=="number"||t===""||t.startsWith("#"))return t;if(n.has(t))throw new Error(`Circular variable reference detected: ${t}`);if(!(t in e))throw new Error(`Variable reference not found: ${t}`);return n.add(t),ER(e[t],e,n)}function vB(t,e={}){let n={};for(let[i,o]of Object.entries(t))n[i]=ER(o,e);return n}function bB(t){return{...t,thinkingMax:t.thinkingMax??t.thinkingXhigh}}var za=class{constructor(e,n,i,o={}){this.name=o.name,this.sourcePath=o.sourcePath,this.sourceInfo=o.sourceInfo,this.mode=i,this.fgColors=new Map;let r={...e,thinkingMax:e.thinkingMax??e.thinkingXhigh};for(let[s,a]of Object.entries(r))this.fgColors.set(s,gB(a,i));this.bgColors=new Map;for(let[s,a]of Object.entries(n))this.bgColors.set(s,fB(a,i))}fg(e,n){let i=this.fgColors.get(e);if(!i)throw new Error(`Unknown theme color: ${e}`);return`${i}${n}\x1B[39m`}bg(e,n){let i=this.bgColors.get(e);if(!i)throw new Error(`Unknown theme background color: ${e}`);return`${i}${n}\x1B[49m`}bold(e){return Ga.bold(e)}italic(e){return Ga.italic(e)}underline(e){return Ga.underline(e)}inverse(e){return Ga.inverse(e)}strikethrough(e){return Ga.strikethrough(e)}getFgAnsi(e){let n=this.fgColors.get(e);if(!n)throw new Error(`Unknown theme color: ${e}`);return n}getBgAnsi(e){let n=this.bgColors.get(e);if(!n)throw new Error(`Unknown theme background color: ${e}`);return n}getColorMode(){return this.mode}getThinkingBorderColor(e){switch(e){case"off":return n=>this.fg("thinkingOff",n);case"minimal":return n=>this.fg("thinkingMinimal",n);case"low":return n=>this.fg("thinkingLow",n);case"medium":return n=>this.fg("thinkingMedium",n);case"high":return n=>this.fg("thinkingHigh",n);case"xhigh":return n=>this.fg("thinkingXhigh",n);case"max":return n=>this.fg("thinkingMax",n);default:return n=>this.fg("thinkingOff",n)}}getBashModeBorderColor(){return e=>this.fg("bashMode",e)}},Ev;function AR(){if(!Ev){let t=df(),e=qr.join(t,"dark.json"),n=qr.join(t,"light.json");Ev={dark:JSON.parse(Pn.readFileSync(e,"utf-8")),light:JSON.parse(Pn.readFileSync(n,"utf-8"))}}return Ev}function Lv(){return Wv().map(({name:t})=>t)}function Wv(){let t=df(),e=[],n=new Set,i=o=>{n.has(o.name)||(n.add(o.name),e.push(o))};for(let o of Object.keys(AR()))i({name:o,path:qr.join(t,`${o}.json`)});for(let o of xB())i(o);for(let[o,r]of Va.entries())i({name:o,path:r.sourcePath});return e.sort((o,r)=>o.name.localeCompare(r.name))}function xB(){let t=Kd(),e=[];if(!Pn.existsSync(t))return e;for(let n of Pn.readdirSync(t)){if(!n.endsWith(".json"))continue;let i=qr.join(t,n);try{let o=Bp(i);o.name&&e.push({name:o.name,path:i})}catch{}}return e}function _R(t){if(t.includes("/"))throw new Error(`Invalid theme name "${t}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`)}function yB(t,e){if(!MR.Check(e)){let i=Array.from(MR.Errors(e)),o=new Set,r=[];for(let a of i){if(a.keyword==="required"&&a.instancePath==="/colors"){let c=a.params.requiredProperties;for(let u of c??[])o.add(u);continue}let l=a.instancePath||"/";r.push(` - ${l}: ${a.message}`)}let s=`Invalid theme "${t}":
75
75
  `;throw o.size>0&&(s+=`
@@ -109,7 +109,7 @@ ${n.map(s=>` ${s}`).join(`
109
109
  `);else{let i=Jp(this.sessionFile,"wx");try{for(let o of this.fileEntries)Kv(i,`${JSON.stringify(o)}
110
110
  `)}finally{Yp(i)}this.flushed=!0}}_appendEntry(e){this.fileEntries.push(e),this.byId.set(e.id,e),this.leafId=e.id,this._persist(e)}appendMessage(e){let n={type:"message",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),message:e};return this._appendEntry(n),n.id}appendThinkingLevelChange(e){let n={type:"thinking_level_change",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),thinkingLevel:e};return this._appendEntry(n),n.id}appendModelChange(e,n){let i={type:"model_change",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),provider:e,modelId:n};return this._appendEntry(i),i.id}appendCompaction(e,n,i,o,r,s){let a={type:"compaction",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),summary:e,firstKeptEntryId:n,tokensBefore:i,details:o,usage:s,fromHook:r};return this._appendEntry(a),a.id}appendCustomEntry(e,n){let i={type:"custom",customType:e,data:n,id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString()};return this._appendEntry(i),i.id}appendSessionInfo(e){let n=e.replace(/[\r\n]+/g," ").trim(),i={type:"session_info",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),name:n};return this._appendEntry(i),i.id}getSessionName(){let e=this.getEntries();for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.type==="session_info")return i.name?.trim()||void 0}}appendCustomMessageEntry(e,n,i,o){let r={type:"custom_message",customType:e,content:n,display:i,details:o,id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString()};return this._appendEntry(r),r.id}getLeafId(){return this.leafId}getLeafEntry(){return this.leafId?this.byId.get(this.leafId):void 0}getEntry(e){return this.byId.get(e)}getChildren(e){let n=[];for(let i of this.byId.values())i.parentId===e&&n.push(i);return n}getLabel(e){return this.labelsById.get(e)}appendLabelChange(e,n){if(!this.byId.has(e))throw new Error(`Entry ${e} not found`);let i={type:"label",id:Gn(this.byId),parentId:this.leafId,timestamp:new Date().toISOString(),targetId:e,label:n};return this._appendEntry(i),n?(this.labelsById.set(e,n),this.labelTimestampsById.set(e,i.timestamp)):(this.labelsById.delete(e),this.labelTimestampsById.delete(e)),i.id}getBranch(e){let n=[],i=e??this.leafId,o=i?this.byId.get(i):void 0;for(;o;)n.push(o),o=o.parentId?this.byId.get(o.parentId):void 0;return n.reverse(),n}buildContextEntries(){return Xv(this.getEntries(),this.leafId,this.byId)}buildSessionContext(){return Zv(this.getEntries(),this.leafId,this.byId)}getHeader(){let e=this.fileEntries.find(n=>n.type==="session");return e||null}getEntries(){return this.fileEntries.filter(e=>e.type!=="session")}getTree(){let e=this.getEntries(),n=new Map,i=[];for(let r of e){let s=this.labelsById.get(r.id),a=this.labelTimestampsById.get(r.id);n.set(r.id,{entry:r,children:[],label:s,labelTimestamp:a})}for(let r of e){let s=n.get(r.id);if(r.parentId===null||r.parentId===r.id)i.push(s);else{let a=n.get(r.parentId);a?a.children.push(s):i.push(s)}}let o=[...i];for(;o.length>0;){let r=o.pop();r.children.sort((s,a)=>new Date(s.entry.timestamp).getTime()-new Date(a.entry.timestamp).getTime()),o.push(...r.children)}return i}branch(e){if(!this.byId.has(e))throw new Error(`Entry ${e} not found`);this.leafId=e}resetLeaf(){this.leafId=null}branchWithSummary(e,n,i,o,r){if(e!==null&&!this.byId.has(e))throw new Error(`Entry ${e} not found`);this.leafId=e;let s={type:"branch_summary",id:Gn(this.byId),parentId:e,timestamp:new Date().toISOString(),fromId:e??"root",summary:n,details:i,usage:r,fromHook:o};return this._appendEntry(s),s.id}createBranchedSession(e){let n=this.sessionFile,i=this.getBranch(e);if(i.length===0)throw new Error(`Entry ${e} not found`);let o=[],r=null;for(let h of i)h.type!=="label"&&(o.push({...h,parentId:r}),r=h.id);let s=Vp(),a=new Date().toISOString(),l=a.replace(/[:.]/g,"-"),c=Ho(this.getSessionDir(),`${l}_${s}.jsonl`),u={type:"session",version:Xa,id:s,timestamp:a,cwd:this.cwd,parentSession:this.persist?n:void 0},d=new Set(o.map(h=>h.id)),p=[];for(let[h,f]of this.labelsById)d.has(h)&&p.push({targetId:h,label:f,timestamp:this.labelTimestampsById.get(h)});if(this.persist){let f=o[o.length-1]?.id||null,b=[];for(let{targetId:y,label:T,timestamp:P}of p){let I={type:"label",id:Gn(new Set(d)),parentId:f,timestamp:P,targetId:y,label:T};d.add(I.id),b.push(I),f=I.id}return this.fileEntries=[u,...o,...b],this.sessionId=s,this.sessionFile=c,this._buildIndex(),this.fileEntries.some(y=>y.type==="message"&&y.message.role==="assistant")?(this._rewriteFile(),this.flushed=!0):this.flushed=!1,c}let m=[],g=o[o.length-1]?.id||null;for(let{targetId:h,label:f,timestamp:b}of p){let x={type:"label",id:Gn(new Set([...d,...m.map(y=>y.id)])),parentId:g,timestamp:b,targetId:h,label:f};m.push(x),g=x.id}this.fileEntries=[u,...o,...m],this.sessionId=s,this._buildIndex()}static create(e,n,i){let o=n?tt(n):Yc(e);return new t(e,o,void 0,!0,i)}static open(e,n,i){let o=Se(e),r=null,s;if(i===void 0&&zo(o))try{r=JR(o)}catch(c){if(!(c instanceof Xp))throw c;s=Gv(o);let u=s[0];r=u?.type==="session"?u:null}let a=i??(r?XR(r):void 0)??process.cwd(),l=n?tt(n):DB(o,"..");return new t(a,l,o,!0,void 0,s)}static continueRecent(e,n){let i=n?tt(n):Yc(e),o=n!==void 0&&i!==Qp(e),r=HB(i,o?e:void 0);return r?new t(e,i,r,!0):new t(e,i,void 0,!0)}static inMemory(e=process.cwd(),n){return new t(e,"",void 0,!1,n)}static forkFrom(e,n,i,o){let r=Se(e),s=Se(n),a=Gv(r);if(a.length===0)throw new Error(`Cannot fork: source session file is empty or invalid: ${r}`);if(!a.find(h=>h.type==="session"))throw new Error(`Cannot fork: source session has no header: ${r}`);let c=i?tt(i):Yc(s);zo(c)||Hv(c,{recursive:!0}),o?.id!==void 0&&Yv(o.id);let u=o?.id??Vp(),d=new Date().toISOString(),p=d.replace(/[:.]/g,"-"),m=Ho(c,`${p}_${u}.jsonl`);Kv(m,`${JSON.stringify({type:"session",version:Xa,id:u,timestamp:d,cwd:s,parentSession:r})}
111
111
  `,{flag:"wx"});for(let h of a)h.type!=="session"&&qv(m,`${JSON.stringify(h)}
112
- `);return new t(s,c,m,!0)}static async list(e,n,i){let o=n?tt(n):Yc(e),r=n!==void 0&&o!==Qp(e),s=Se(e),a=(await HR(o,i)).filter(l=>!r||ZR(l.cwd,s));return a.sort((l,c)=>c.modified.getTime()-l.modified.getTime()),a}static async listAll(e,n){let i=typeof e=="string"?tt(e):void 0,o=typeof e=="function"?e:n;if(i){let s=await HR(i,o);return s.sort((a,l)=>l.modified.getTime()-a.modified.getTime()),s}let r=cS();try{if(!zo(r))return[];let a=(await Qv(r,{withFileTypes:!0})).filter(g=>g.isDirectory()).map(g=>Ho(r,g.name)),l=0,c=[];for(let g of a)try{let h=(await Qv(g)).filter(f=>f.endsWith(".jsonl"));c.push(h.map(f=>Ho(g,f))),l+=h.length}catch{c.push([])}let u=0,d=[],p=c.flat(),m=await tP(p,()=>{u++,o?.(u,l)});for(let g of m)g&&d.push(g);return d.sort((g,h)=>h.modified.getTime()-g.modified.getTime()),d}catch{return[]}}};import{createRequire as i6}from"node:module";import*as QMe from"@earendil-works/pi-agent-core";import{createJiti as JMe}from"jiti/static";import*as XMe from"typebox";import*as ZMe from"typebox/compile";import*as eRe from"typebox/value";var GMe=process.env.PI_TIMING==="1";var aRe=i6(import.meta.url);function tm(t){return t.toolName==="edit"}function nm(t){return t.toolName==="write"}function Vr(t,e){return e.toolName===t}import NRe from"ignore";import{constants as T6}from"node:fs";import{access as C6}from"node:fs/promises";import{spawn as M6}from"child_process";import{Type as om}from"typebox";function f6(t,e){let n=process.platform==="darwin"&&t.toLowerCase()==="alt"?"option":t;return e.capitalize?n.charAt(0).toUpperCase()+n.slice(1):n}function Yr(t,e={}){return t.split("/").map(n=>n.split("+").map(i=>f6(i,e)).join("+")).join("/")}function uP(t,e={}){return t.length===0?"":Yr(t.join("/"),e)}function Re(t){return uP(ke().getKeys(t))}function Xc(t){return uP(ke().getKeys(t),{capitalize:!0})}function le(t,e){return v.fg("dim",Re(t))+v.fg("muted",` ${e}`)}function lt(t,e){return v.fg("dim",Yr(t))+v.fg("muted",` ${e}`)}function Za(t,e,n,i=0){if(!t)return{visualLines:[],skippedCount:0};let r=new A(t,i,0).render(n);if(r.length<=e)return{visualLines:r,skippedCount:0};let s=r.slice(-e),a=r.length-e;return{visualLines:s,skippedCount:a}}import{randomBytes as v6}from"node:crypto";import{createWriteStream as b6}from"node:fs";import{tmpdir as x6}from"node:os";import{join as y6}from"node:path";function w6(t){let e=v6(8).toString("hex");return y6(x6(),`${t}-${e}.log`)}function t0(t){return Buffer.byteLength(t,"utf-8")}var im=class{constructor(e={}){this.decoder=new TextDecoder;this.rawChunks=[];this.tailText="";this.tailBytes=0;this.tailStartsAtLineBoundary=!0;this.totalRawBytes=0;this.totalDecodedBytes=0;this.completedLines=0;this.totalLines=0;this.currentLineBytes=0;this.hasOpenLine=!1;this.finished=!1;this.maxLines=e.maxLines??2e3,this.maxBytes=e.maxBytes??51200,this.maxRollingBytes=Math.max(this.maxBytes*2,1),this.tempFilePrefix=e.tempFilePrefix??"pi-output"}append(e){if(this.finished)throw new Error("Cannot append to a finished output accumulator");this.totalRawBytes+=e.length,this.appendDecodedText(this.decoder.decode(e,{stream:!0})),this.tempFileStream||this.shouldUseTempFile()?(this.ensureTempFile(),this.tempFileStream?.write(e)):e.length>0&&this.rawChunks.push(e)}finish(){this.finished||(this.finished=!0,this.appendDecodedText(this.decoder.decode()),this.shouldUseTempFile()&&this.ensureTempFile())}snapshot(e={}){let n=Hr(this.getSnapshotText(),{maxLines:this.maxLines,maxBytes:this.maxBytes}),i=this.totalLines>this.maxLines||this.totalDecodedBytes>this.maxBytes,o=i?n.truncatedBy??(this.totalDecodedBytes>this.maxBytes?"bytes":"lines"):null,r={...n,truncated:i,truncatedBy:o,totalLines:this.totalLines,totalBytes:this.totalDecodedBytes,maxLines:this.maxLines,maxBytes:this.maxBytes};return e.persistIfTruncated&&r.truncated&&this.ensureTempFile(),{content:r.content,truncation:r,fullOutputPath:this.tempFilePath}}async closeTempFile(){if(!this.tempFileStream)return;let e=this.tempFileStream;this.tempFileStream=void 0,await new Promise((n,i)=>{let o=s=>{e.off("finish",r),i(s)},r=()=>{e.off("error",o),n()};e.once("error",o),e.once("finish",r),e.end()})}getLastLineBytes(){return this.currentLineBytes}appendDecodedText(e){if(e.length===0)return;let n=t0(e);this.totalDecodedBytes+=n,this.tailText+=e,this.tailBytes+=n,this.tailBytes>this.maxRollingBytes*2&&this.trimTail();let i=0,o=-1;for(let r=e.indexOf(`
112
+ `);return new t(s,c,m,!0)}static async list(e,n,i){let o=n?tt(n):Yc(e),r=n!==void 0&&o!==Qp(e),s=Se(e),a=(await HR(o,i)).filter(l=>!r||ZR(l.cwd,s));return a.sort((l,c)=>c.modified.getTime()-l.modified.getTime()),a}static async listAll(e,n){let i=typeof e=="string"?tt(e):void 0,o=typeof e=="function"?e:n;if(i){let s=await HR(i,o);return s.sort((a,l)=>l.modified.getTime()-a.modified.getTime()),s}let r=cS();try{if(!zo(r))return[];let a=(await Qv(r,{withFileTypes:!0})).filter(g=>g.isDirectory()).map(g=>Ho(r,g.name)),l=0,c=[];for(let g of a)try{let h=(await Qv(g)).filter(f=>f.endsWith(".jsonl"));c.push(h.map(f=>Ho(g,f))),l+=h.length}catch{c.push([])}let u=0,d=[],p=c.flat(),m=await tP(p,()=>{u++,o?.(u,l)});for(let g of m)g&&d.push(g);return d.sort((g,h)=>h.modified.getTime()-g.modified.getTime()),d}catch{return[]}}};import{createRequire as i6}from"node:module";import*as QMe from"@earendil-works/pi-agent-core";import{createJiti as JMe}from"jiti/static";import*as XMe from"typebox";import*as ZMe from"typebox/compile";import*as eRe from"typebox/value";var GMe=process.env.PI_TIMING==="1";var aRe=i6(import.meta.url);function tm(t){return t.toolName==="edit"}function nm(t){return t.toolName==="write"}function Vr(t,e){return e.toolName===t}import NRe from"ignore";import{constants as T6}from"node:fs";import{access as C6}from"node:fs/promises";import{spawn as M6}from"child_process";import{Type as om}from"typebox";function f6(t,e){let n=process.platform==="darwin"&&t.toLowerCase()==="alt"?"option":t;return e.capitalize?n.charAt(0).toUpperCase()+n.slice(1):n}function Yr(t,e={}){return t.split("/").map(n=>n.split("+").map(i=>f6(i,e)).join("+")).join("/")}function uP(t,e={}){return t.length===0?"":Yr(t.join("/"),e)}function Re(t){return uP(we().getKeys(t))}function Xc(t){return uP(we().getKeys(t),{capitalize:!0})}function le(t,e){return v.fg("dim",Re(t))+v.fg("muted",` ${e}`)}function lt(t,e){return v.fg("dim",Yr(t))+v.fg("muted",` ${e}`)}function Za(t,e,n,i=0){if(!t)return{visualLines:[],skippedCount:0};let r=new A(t,i,0).render(n);if(r.length<=e)return{visualLines:r,skippedCount:0};let s=r.slice(-e),a=r.length-e;return{visualLines:s,skippedCount:a}}import{randomBytes as v6}from"node:crypto";import{createWriteStream as b6}from"node:fs";import{tmpdir as x6}from"node:os";import{join as y6}from"node:path";function w6(t){let e=v6(8).toString("hex");return y6(x6(),`${t}-${e}.log`)}function t0(t){return Buffer.byteLength(t,"utf-8")}var im=class{constructor(e={}){this.decoder=new TextDecoder;this.rawChunks=[];this.tailText="";this.tailBytes=0;this.tailStartsAtLineBoundary=!0;this.totalRawBytes=0;this.totalDecodedBytes=0;this.completedLines=0;this.totalLines=0;this.currentLineBytes=0;this.hasOpenLine=!1;this.finished=!1;this.maxLines=e.maxLines??2e3,this.maxBytes=e.maxBytes??51200,this.maxRollingBytes=Math.max(this.maxBytes*2,1),this.tempFilePrefix=e.tempFilePrefix??"pi-output"}append(e){if(this.finished)throw new Error("Cannot append to a finished output accumulator");this.totalRawBytes+=e.length,this.appendDecodedText(this.decoder.decode(e,{stream:!0})),this.tempFileStream||this.shouldUseTempFile()?(this.ensureTempFile(),this.tempFileStream?.write(e)):e.length>0&&this.rawChunks.push(e)}finish(){this.finished||(this.finished=!0,this.appendDecodedText(this.decoder.decode()),this.shouldUseTempFile()&&this.ensureTempFile())}snapshot(e={}){let n=Hr(this.getSnapshotText(),{maxLines:this.maxLines,maxBytes:this.maxBytes}),i=this.totalLines>this.maxLines||this.totalDecodedBytes>this.maxBytes,o=i?n.truncatedBy??(this.totalDecodedBytes>this.maxBytes?"bytes":"lines"):null,r={...n,truncated:i,truncatedBy:o,totalLines:this.totalLines,totalBytes:this.totalDecodedBytes,maxLines:this.maxLines,maxBytes:this.maxBytes};return e.persistIfTruncated&&r.truncated&&this.ensureTempFile(),{content:r.content,truncation:r,fullOutputPath:this.tempFilePath}}async closeTempFile(){if(!this.tempFileStream)return;let e=this.tempFileStream;this.tempFileStream=void 0,await new Promise((n,i)=>{let o=s=>{e.off("finish",r),i(s)},r=()=>{e.off("error",o),n()};e.once("error",o),e.once("finish",r),e.end()})}getLastLineBytes(){return this.currentLineBytes}appendDecodedText(e){if(e.length===0)return;let n=t0(e);this.totalDecodedBytes+=n,this.tailText+=e,this.tailBytes+=n,this.tailBytes>this.maxRollingBytes*2&&this.trimTail();let i=0,o=-1;for(let r=e.indexOf(`
113
113
  `);r!==-1;r=e.indexOf(`
114
114
  `,r+1))i++,o=r;if(i===0)this.currentLineBytes+=n,this.hasOpenLine=!0;else{this.completedLines+=i;let r=e.slice(o+1);this.currentLineBytes=t0(r),this.hasOpenLine=r.length>0}this.totalLines=this.completedLines+(this.hasOpenLine?1:0)}trimTail(){let e=Buffer.from(this.tailText,"utf-8");if(e.length<=this.maxRollingBytes){this.tailBytes=e.length;return}let n=e.length-this.maxRollingBytes;for(;n<e.length&&(e[n]&192)===128;)n++;this.tailStartsAtLineBoundary=n===0?this.tailStartsAtLineBoundary:e[n-1]===10,this.tailText=e.subarray(n).toString("utf-8"),this.tailBytes=t0(this.tailText)}getSnapshotText(){if(this.tailStartsAtLineBoundary)return this.tailText;let e=this.tailText.indexOf(`
115
115
  `);return e===-1?this.tailText:this.tailText.slice(e+1)}shouldUseTempFile(){return this.totalRawBytes>this.maxBytes||this.totalDecodedBytes>this.maxBytes||this.totalLines>this.maxLines}ensureTempFile(){if(!this.tempFilePath){this.tempFilePath=w6(this.tempFilePrefix),this.tempFileStream=b6(this.tempFilePath);for(let e of this.rawChunks)this.tempFileStream.write(e);this.rawChunks=[]}}};import*as dP from"node:os";import{pathToFileURL as k6}from"node:url";function Zc(t){if(typeof t!="string")return"";let e=dP.homedir();return t.startsWith(e)?`~${t.slice(e.length)}`:t}function S6(t,e,n){if(!ft().hyperlinks)return t;let i=Se(e,n);return Lr(t,k6(i).href)}function it(t){return typeof t=="string"?t:t==null?"":null}function so(t){return t.replace(/\t/g," ")}function eu(t){return t.replace(/\r/g,"")}function Hn(t,e){if(!t)return"";let n=t.content.filter(s=>s.type==="text"),i=t.content.filter(s=>s.type==="image"),o=n.map(s=>Nv(zc(s.text||"")).replace(/\r/g,"")).join(`
@@ -167,12 +167,12 @@ ${n.fg("warning",`[Truncated: ${l.join(", ")}]`)}`}return r}function dm(t,e){let
167
167
  ${d.map(m=>n.fg("toolOutput",m)).join(`
168
168
  `)}`,p>0&&(r+=`${n.fg("muted",`
169
169
  ... (${p} more lines,`)} ${le("app.tools.expand","to expand")}${n.fg("muted",")")}`)}let s=t.details?.matchLimitReached,a=t.details?.truncation,l=t.details?.linesTruncated;if(s||a?.truncated||l){let c=[];s&&c.push(`${s} matches limit`),a?.truncated&&c.push(`${nt(a.maxBytes??51200)} limit`),l&&c.push("some lines truncated"),r+=`
170
- ${n.fg("warning",`[Truncated: ${c.join(", ")}]`)}`}return r}function pm(t,e){let n=e?.operations;return{name:"grep",label:"grep",description:`Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${OP} matches or ${51200/1024}KB (whichever is hit first). Long lines are truncated to ${500} chars.`,promptSnippet:"Search file contents for patterns (respects .gitignore)",parameters:Hj,async execute(i,{pattern:o,path:r,glob:s,ignoreCase:a,literal:l,context:c,limit:u},d,p,m){return new Promise((g,h)=>{if(d?.aborted){h(new Error("Operation aborted"));return}let f=!1,b=x=>{f||(f=!0,x())};(async()=>{try{let x=await Zr("rg",!0);if(!x){b(()=>h(new Error("ripgrep (rg) is not available and could not be downloaded")));return}let y=Vt(r||".",t),T=n??Vj,P;try{P=await T.isDirectory(y)}catch{b(()=>h(new Error(`Path not found: ${y}`)));return}let I=c&&c>0?c:0,W=Math.max(1,u??OP),D=oe=>{if(P){let we=_P.relative(y,oe);if(we&&!we.startsWith(".."))return we.replace(/\\/g,"/")}return _P.basename(oe)},_=new Map,F=async oe=>{let we=_.get(oe);if(!we){try{we=(await T.readFile(oe)).replace(/\r\n/g,`
170
+ ${n.fg("warning",`[Truncated: ${c.join(", ")}]`)}`}return r}function pm(t,e){let n=e?.operations;return{name:"grep",label:"grep",description:`Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${OP} matches or ${51200/1024}KB (whichever is hit first). Long lines are truncated to ${500} chars.`,promptSnippet:"Search file contents for patterns (respects .gitignore)",parameters:Hj,async execute(i,{pattern:o,path:r,glob:s,ignoreCase:a,literal:l,context:c,limit:u},d,p,m){return new Promise((g,h)=>{if(d?.aborted){h(new Error("Operation aborted"));return}let f=!1,b=x=>{f||(f=!0,x())};(async()=>{try{let x=await Zr("rg",!0);if(!x){b(()=>h(new Error("ripgrep (rg) is not available and could not be downloaded")));return}let y=Vt(r||".",t),T=n??Vj,P;try{P=await T.isDirectory(y)}catch{b(()=>h(new Error(`Path not found: ${y}`)));return}let I=c&&c>0?c:0,W=Math.max(1,u??OP),D=oe=>{if(P){let ye=_P.relative(y,oe);if(ye&&!ye.startsWith(".."))return ye.replace(/\\/g,"/")}return _P.basename(oe)},_=new Map,F=async oe=>{let ye=_.get(oe);if(!ye){try{ye=(await T.readFile(oe)).replace(/\r\n/g,`
171
171
  `).replace(/\r/g,`
172
172
  `).split(`
173
- `)}catch{we=[]}_.set(oe,we)}return we},O=["--json","--line-number","--color=never","--hidden"];a&&O.push("--ignore-case"),l&&O.push("--fixed-strings"),s&&O.push("--glob",s),O.push("--",o,y);let R=zj(x,O,{stdio:["ignore","pipe","pipe"]}),E=Gj({input:R.stdout}),U="",G=0,q=!1,Z=!1,Y=!1,se=!1,xe=[],rt=()=>{E.close(),d?.removeEventListener("abort",At)},Qe=(oe=!1)=>{R.killed||(se=oe,R.kill())},At=()=>{Y=!0,Qe()};d?.addEventListener("abort",At,{once:!0}),R.stderr?.on("data",oe=>{U+=oe.toString()});let _t=async(oe,we)=>{let Ce=D(oe),dt=await F(oe);if(!dt.length)return[`${Ce}:${we}: (unable to read file)`];let jt=[],Ki=I>0?Math.max(1,we-I):we,nn=I>0?Math.min(dt.length,we+I):we;for(let Ln=Ki;Ln<=nn;Ln++){let pc=(dt[Ln-1]??"").replace(/\r/g,""),Tr=Ln===we,{text:mc,wasTruncated:Zg}=Vc(pc);Zg&&(Z=!0),Tr?jt.push(`${Ce}:${Ln}: ${mc}`):jt.push(`${Ce}-${Ln}- ${mc}`)}return jt},kn=[];E.on("line",oe=>{if(!oe.trim()||G>=W)return;let we;try{we=JSON.parse(oe)}catch{return}if(we.type==="match"){G++;let Ce=we.data?.path?.text,dt=we.data?.line_number,jt=we.data?.lines?.text;Ce&&typeof dt=="number"&&kn.push({filePath:Ce,lineNumber:dt,lineText:jt}),G>=W&&(q=!0,Qe(!0))}}),R.on("error",oe=>{rt(),b(()=>h(new Error(`Failed to run ripgrep: ${oe.message}`)))}),R.on("close",async oe=>{if(rt(),Y){b(()=>h(new Error("Operation aborted")));return}if(!se&&oe!==0&&oe!==1){let nn=U.trim()||`ripgrep exited with code ${oe}`;b(()=>h(new Error(nn)));return}if(G===0){b(()=>g({content:[{type:"text",text:"No matches found"}],details:void 0}));return}for(let nn of kn)if(I===0&&nn.lineText!==void 0){let Ln=D(nn.filePath),Gi=nn.lineText.replace(/\r\n/g,`
174
- `).replace(/\r/g,"").replace(/\n$/,""),{text:pc,wasTruncated:Tr}=Vc(Gi);Tr&&(Z=!0),xe.push(`${Ln}:${nn.lineNumber}: ${pc}`)}else{let Ln=await _t(nn.filePath,nn.lineNumber);xe.push(...Ln)}let we=xe.join(`
175
- `),Ce=ui(we,{maxLines:Number.MAX_SAFE_INTEGER}),dt=Ce.content,jt={},Ki=[];q&&(Ki.push(`${W} matches limit reached. Use limit=${W*2} for more, or refine pattern`),jt.matchLimitReached=W),Ce.truncated&&(Ki.push(`${nt(51200)} limit reached`),jt.truncation=Ce),Z&&(Ki.push(`Some lines truncated to ${500} chars. Use read tool to see full lines`),jt.linesTruncated=!0),Ki.length>0&&(dt+=`
173
+ `)}catch{ye=[]}_.set(oe,ye)}return ye},O=["--json","--line-number","--color=never","--hidden"];a&&O.push("--ignore-case"),l&&O.push("--fixed-strings"),s&&O.push("--glob",s),O.push("--",o,y);let R=zj(x,O,{stdio:["ignore","pipe","pipe"]}),E=Gj({input:R.stdout}),U="",G=0,q=!1,Z=!1,Y=!1,se=!1,xe=[],rt=()=>{E.close(),d?.removeEventListener("abort",At)},Qe=(oe=!1)=>{R.killed||(se=oe,R.kill())},At=()=>{Y=!0,Qe()};d?.addEventListener("abort",At,{once:!0}),R.stderr?.on("data",oe=>{U+=oe.toString()});let _t=async(oe,ye)=>{let Ce=D(oe),dt=await F(oe);if(!dt.length)return[`${Ce}:${ye}: (unable to read file)`];let jt=[],Ki=I>0?Math.max(1,ye-I):ye,nn=I>0?Math.min(dt.length,ye+I):ye;for(let Ln=Ki;Ln<=nn;Ln++){let pc=(dt[Ln-1]??"").replace(/\r/g,""),Tr=Ln===ye,{text:mc,wasTruncated:Zg}=Vc(pc);Zg&&(Z=!0),Tr?jt.push(`${Ce}:${Ln}: ${mc}`):jt.push(`${Ce}-${Ln}- ${mc}`)}return jt},kn=[];E.on("line",oe=>{if(!oe.trim()||G>=W)return;let ye;try{ye=JSON.parse(oe)}catch{return}if(ye.type==="match"){G++;let Ce=ye.data?.path?.text,dt=ye.data?.line_number,jt=ye.data?.lines?.text;Ce&&typeof dt=="number"&&kn.push({filePath:Ce,lineNumber:dt,lineText:jt}),G>=W&&(q=!0,Qe(!0))}}),R.on("error",oe=>{rt(),b(()=>h(new Error(`Failed to run ripgrep: ${oe.message}`)))}),R.on("close",async oe=>{if(rt(),Y){b(()=>h(new Error("Operation aborted")));return}if(!se&&oe!==0&&oe!==1){let nn=U.trim()||`ripgrep exited with code ${oe}`;b(()=>h(new Error(nn)));return}if(G===0){b(()=>g({content:[{type:"text",text:"No matches found"}],details:void 0}));return}for(let nn of kn)if(I===0&&nn.lineText!==void 0){let Ln=D(nn.filePath),Gi=nn.lineText.replace(/\r\n/g,`
174
+ `).replace(/\r/g,"").replace(/\n$/,""),{text:pc,wasTruncated:Tr}=Vc(Gi);Tr&&(Z=!0),xe.push(`${Ln}:${nn.lineNumber}: ${pc}`)}else{let Ln=await _t(nn.filePath,nn.lineNumber);xe.push(...Ln)}let ye=xe.join(`
175
+ `),Ce=ui(ye,{maxLines:Number.MAX_SAFE_INTEGER}),dt=Ce.content,jt={},Ki=[];q&&(Ki.push(`${W} matches limit reached. Use limit=${W*2} for more, or refine pattern`),jt.matchLimitReached=W),Ce.truncated&&(Ki.push(`${nt(51200)} limit reached`),jt.truncation=Ce),Z&&(Ki.push(`Some lines truncated to ${500} chars. Use read tool to see full lines`),jt.linesTruncated=!0),Ki.length>0&&(dt+=`
176
176
 
177
177
  [${Ki.join(". ")}]`),b(()=>g({content:[{type:"text",text:dt}],details:Object.keys(jt).length>0?jt:void 0}))})}catch(x){b(()=>h(x))}})()})},renderCall(i,o,r){let s=r.lastComponent??new A("",0,0);return s.setText(Qj(i,o)),s},renderResult(i,o,r,s){let a=s.lastComponent??new A("",0,0);return a.setText(Yj(i,o,r,s.showImages)),a}}}import{readdir as Jj,stat as Xj}from"node:fs/promises";import Zj from"path";import{Type as lu}from"typebox";var e8=lu.Object({path:lu.Optional(lu.String({description:"Directory to list (default: current directory)"})),limit:lu.Optional(lu.Number({description:"Maximum number of entries to return (default: 500)"}))}),LP=500,t8={exists:Ri,stat:Xj,readdir:Jj};function n8(t,e,n){let i=t?.limit,o=Vo(it(t?.path),e,n,{emptyFallback:"."}),r=`${e.fg("toolTitle",e.bold("ls"))} ${o}`;return i!==void 0&&(r+=e.fg("toolOutput",` (limit ${i})`)),r}function i8(t,e,n,i){let o=Hn(t,i).trim(),r="";if(o){let l=o.split(`
178
178
  `),c=e.expanded?l.length:20,u=l.slice(0,c),d=l.length-c;r+=`
@@ -224,10 +224,10 @@ ${t.sessionCwd}
224
224
 
225
225
  continue in current cwd
226
226
  ${t.fallbackCwd}`}var pl=class extends Error{constructor(e){super(p7(e)),this.name="MissingSessionCwdError",this.issue=e}};var Lm=class extends Error{constructor(e){super(`File not found: ${e}`),this.name="SessionImportFileNotFoundError",this.filePath=e}};v7(CM);import{existsSync as J0,mkdirSync as CI,readFileSync as b7,writeFileSync as x7}from"node:fs";import{homedir as y7}from"node:os";import{dirname as vu,join as fu}from"node:path";import w7 from"proper-lockfile";var k7=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"];function Wm(t){return ri(Se(t))}function S7(t,e){let n=Wm(e);for(;;){let i=t[n];if(i===!0||i===!1)return{path:n,decision:i};let o=vu(n);if(o===n)return null;n=o}}function T7(t){let e=Wm(t),n=vu(e);return n===e?void 0:n}function X0(t,e){let n=Wm(t),i=[{label:"Trust",trusted:!0,updates:[{path:n,decision:!0}],savedPath:n}],o=T7(t);return o!==void 0&&i.push({label:`Trust parent folder (${o})`,trusted:!0,updates:[{path:o,decision:!0},{path:n,decision:null}],savedPath:o}),e?.includeSessionOnly&&i.push({label:"Trust (this session only)",trusted:!0,updates:[]}),i.push({label:"Do not trust",trusted:!1,updates:[{path:n,decision:!1}],savedPath:n}),e?.includeSessionOnly&&i.push({label:"Do not trust (this session only)",trusted:!1,updates:[]}),i}function SI(t){if(!J0(t))return{};let e;try{e=JSON.parse(b7(t,"utf-8"))}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to read trust store ${t}: ${o}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Invalid trust store ${t}: expected an object`);let n={};for(let[i,o]of Object.entries(e)){if(o!==!0&&o!==!1&&o!==null)throw new Error(`Invalid trust store ${t}: value for ${JSON.stringify(i)} must be true, false, or null`);n[i]=o}return n}function C7(t,e){let n={};for(let i of Object.keys(e).sort()){let o=e[i];(o===!0||o===!1||o===null)&&(n[i]=o)}CI(vu(t),{recursive:!0}),x7(t,`${JSON.stringify(n,null,2)}
227
- `,"utf-8")}function M7(t){let e=vu(t);CI(e,{recursive:!0});let n=10,i=20,o;for(let r=1;r<=n;r++)try{return w7.lockSync(e,{realpath:!1,lockfilePath:`${t}.lock`})}catch(s){if((typeof s=="object"&&s!==null&&"code"in s?String(s.code):void 0)!=="ELOCKED"||r===n)throw s;o=s;let l=Date.now();for(;Date.now()-l<i;);}throw o instanceof Error?o:new Error("Failed to acquire trust store lock")}function TI(t,e){let n=M7(t);try{return e()}finally{n()}}function os(t){let e=ri(Se(process.env.HOME||y7())),n=fu(e,".agents","skills"),i=ri(Se(t)),o=fu(i,Je);if(k7.some(r=>J0(fu(o,r))))return!0;for(;;){let r=fu(i,".agents","skills");if(r!==n&&J0(r))return!0;let s=vu(i);if(s===i)return!1;i=s}}var Yo=class{constructor(e){this.trustPath=fu(Se(e),"trust.json")}get(e){return this.getEntry(e)?.decision??null}getEntry(e){return TI(this.trustPath,()=>{let n=SI(this.trustPath);return S7(n,e)})}set(e,n){this.setMany([{path:e,decision:n}])}setMany(e){TI(this.trustPath,()=>{let n=SI(this.trustPath);for(let{path:i,decision:o}of e){let r=Wm(i);o===null?delete n[r]:n[r]=o}C7(this.trustPath,n)})}};import RDe from"chalk";import pOe from"chalk";import yOe from"chalk";import u5e from"chalk";function Z0(){return process.env.PI_EXPERIMENTAL==="1"}import{existsSync as R7,readFileSync as P7}from"fs";import{join as I7}from"path";var MI={...Da,"app.interrupt":{defaultKeys:"escape",description:"Cancel or abort"},"app.clear":{defaultKeys:"ctrl+c",description:"Clear editor"},"app.exit":{defaultKeys:"ctrl+d",description:"Exit when editor is empty"},"app.suspend":{defaultKeys:process.platform==="win32"?[]:"ctrl+z",description:"Suspend to background"},"app.thinking.cycle":{defaultKeys:"shift+tab",description:"Cycle thinking level"},"app.model.cycleForward":{defaultKeys:"ctrl+p",description:"Cycle to next model"},"app.model.cycleBackward":{defaultKeys:"shift+ctrl+p",description:"Cycle to previous model"},"app.model.select":{defaultKeys:"ctrl+l",description:"Open model selector"},"app.tools.expand":{defaultKeys:"ctrl+o",description:"Toggle tool output"},"app.thinking.toggle":{defaultKeys:"ctrl+t",description:"Toggle thinking blocks"},"app.session.toggleNamedFilter":{defaultKeys:"ctrl+n",description:"Toggle named session filter"},"app.editor.external":{defaultKeys:"ctrl+g",description:"Open external editor"},"app.message.copy":{defaultKeys:"ctrl+x",description:"Copy message to clipboard"},"app.message.followUp":{defaultKeys:"alt+enter",description:"Queue follow-up message"},"app.message.dequeue":{defaultKeys:"alt+up",description:"Restore queued messages"},"app.clipboard.pasteImage":{defaultKeys:process.platform==="win32"?"alt+v":"ctrl+v",description:"Paste image from clipboard (text fallback)"},"app.session.new":{defaultKeys:[],description:"Start a new session"},"app.session.tree":{defaultKeys:[],description:"Open session tree"},"app.session.fork":{defaultKeys:[],description:"Fork current session"},"app.session.resume":{defaultKeys:[],description:"Resume a session"},"app.tree.foldOrUp":{defaultKeys:process.platform==="darwin"?["alt+left","ctrl+left"]:["ctrl+left","alt+left"],description:"Fold tree branch or move up"},"app.tree.unfoldOrDown":{defaultKeys:process.platform==="darwin"?["alt+right","ctrl+right"]:["ctrl+right","alt+right"],description:"Unfold tree branch or move down"},"app.tree.editLabel":{defaultKeys:"shift+l",description:"Edit tree label"},"app.tree.toggleLabelTimestamp":{defaultKeys:"shift+t",description:"Toggle tree label timestamps"},"app.session.togglePath":{defaultKeys:"ctrl+p",description:"Toggle session path display"},"app.session.toggleSort":{defaultKeys:"ctrl+s",description:"Toggle session sort mode"},"app.session.rename":{defaultKeys:"ctrl+r",description:"Rename session"},"app.session.delete":{defaultKeys:"ctrl+d",description:"Delete session"},"app.session.deleteNoninvasive":{defaultKeys:"ctrl+backspace",description:"Delete session when query is empty"},"app.models.save":{defaultKeys:"ctrl+s",description:"Save model selection"},"app.models.enableAll":{defaultKeys:"ctrl+a",description:"Enable all models"},"app.models.clearAll":{defaultKeys:"ctrl+x",description:"Clear all models"},"app.models.toggleProvider":{defaultKeys:"ctrl+p",description:"Toggle all models for provider"},"app.models.reorderUp":{defaultKeys:"alt+up",description:"Move model up in order"},"app.models.reorderDown":{defaultKeys:"alt+down",description:"Move model down in order"},"app.tree.filter.default":{defaultKeys:"ctrl+d",description:"Tree filter: default view"},"app.tree.filter.noTools":{defaultKeys:"ctrl+t",description:"Tree filter: hide tool results"},"app.tree.filter.userOnly":{defaultKeys:"ctrl+u",description:"Tree filter: user messages only"},"app.tree.filter.labeledOnly":{defaultKeys:"ctrl+l",description:"Tree filter: labeled entries only"},"app.tree.filter.all":{defaultKeys:"ctrl+a",description:"Tree filter: show all entries"},"app.tree.filter.cycleForward":{defaultKeys:"ctrl+o",description:"Tree filter: cycle forward"},"app.tree.filter.cycleBackward":{defaultKeys:"shift+ctrl+o",description:"Tree filter: cycle backward"}},RI={cursorUp:"tui.editor.cursorUp",cursorDown:"tui.editor.cursorDown",cursorLeft:"tui.editor.cursorLeft",cursorRight:"tui.editor.cursorRight",cursorWordLeft:"tui.editor.cursorWordLeft",cursorWordRight:"tui.editor.cursorWordRight",cursorLineStart:"tui.editor.cursorLineStart",cursorLineEnd:"tui.editor.cursorLineEnd",jumpForward:"tui.editor.jumpForward",jumpBackward:"tui.editor.jumpBackward",pageUp:"tui.editor.pageUp",pageDown:"tui.editor.pageDown",deleteCharBackward:"tui.editor.deleteCharBackward",deleteCharForward:"tui.editor.deleteCharForward",deleteWordBackward:"tui.editor.deleteWordBackward",deleteWordForward:"tui.editor.deleteWordForward",deleteToLineStart:"tui.editor.deleteToLineStart",deleteToLineEnd:"tui.editor.deleteToLineEnd",yank:"tui.editor.yank",yankPop:"tui.editor.yankPop",undo:"tui.editor.undo",newLine:"tui.input.newLine",submit:"tui.input.submit",tab:"tui.input.tab",copy:"tui.input.copy",selectUp:"tui.select.up",selectDown:"tui.select.down",selectPageUp:"tui.select.pageUp",selectPageDown:"tui.select.pageDown",selectConfirm:"tui.select.confirm",selectCancel:"tui.select.cancel",interrupt:"app.interrupt",clear:"app.clear",exit:"app.exit",suspend:"app.suspend",cycleThinkingLevel:"app.thinking.cycle",cycleModelForward:"app.model.cycleForward",cycleModelBackward:"app.model.cycleBackward",selectModel:"app.model.select",expandTools:"app.tools.expand",toggleThinking:"app.thinking.toggle",toggleSessionNamedFilter:"app.session.toggleNamedFilter",externalEditor:"app.editor.external",followUp:"app.message.followUp",dequeue:"app.message.dequeue",pasteImage:"app.clipboard.pasteImage",newSession:"app.session.new",tree:"app.session.tree",fork:"app.session.fork",resume:"app.session.resume",treeFoldOrUp:"app.tree.foldOrUp",treeUnfoldOrDown:"app.tree.unfoldOrDown",treeEditLabel:"app.tree.editLabel",treeToggleLabelTimestamp:"app.tree.toggleLabelTimestamp",toggleSessionPath:"app.session.togglePath",toggleSessionSort:"app.session.toggleSort",renameSession:"app.session.rename",deleteSession:"app.session.delete",deleteSessionNoninvasive:"app.session.deleteNoninvasive"};function E7(t){return t in RI}function A7(t){let e={};for(let[n,i]of Object.entries(t)){if(typeof i=="string"){e[n]=i;continue}Array.isArray(i)&&i.every(o=>typeof o=="string")&&(e[n]=i)}return e}function PI(t){let e={},n=!1;for(let[i,o]of Object.entries(t)){let r=E7(i)?RI[i]:i;if(r!==i&&(n=!0),i!==r&&Object.hasOwn(t,r)){n=!0;continue}e[r]=o}return{config:_7(e),migrated:n}}function _7(t){let e={};for(let i of Object.keys(MI))Object.hasOwn(t,i)&&(e[i]=t[i]);let n=Object.keys(t).filter(i=>!Object.hasOwn(e,i)).sort();for(let i of n)e[i]=t[i];return e}function O7(t){if(R7(t))try{let e=JSON.parse(P7(t,"utf-8"));return typeof e!="object"||e===null?void 0:e}catch{return}}var Jo=class t extends Fa{constructor(e={},n){super(MI,e),this.configPath=n}static create(e=_e()){let n=I7(e,"keybindings.json"),i=t.loadFromFile(n);return new t(i,n)}reload(){this.configPath&&this.setUserBindings(t.loadFromFile(this.configPath))}getEffectiveConfig(){return this.getResolvedBindings()}static loadFromFile(e){let n=O7(e);return n?A7(PI(n).config):{}}};var Xo=class{constructor(e,n,i,o){this.tui=n,this.onTick=i,this.onExpire=o,this.remainingSeconds=Math.ceil(e/1e3),this.onTick(this.remainingSeconds),this.intervalId=setInterval(()=>{this.remainingSeconds--,this.onTick(this.remainingSeconds),this.tui?.requestRender(),this.remainingSeconds<=0&&(this.dispose(),this.onExpire())},1e3)}dispose(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}};var H=class{constructor(e=n=>v.fg("border",n)){this.color=e}invalidate(){}render(e){return[this.color("\u2500".repeat(Math.max(1,e)))]}};var rs=class extends z{constructor(n,i,o,r,s){super();this._focused=!1;this.onSubmitCallback=o,this.onCancelCallback=r,this.baseTitle=n,this.addChild(new H),this.addChild(new L(1)),this.titleText=new A(v.fg("accent",n),1,0),this.addChild(this.titleText),this.addChild(new L(1)),s?.timeout&&s.timeout>0&&s.tui&&(this.countdown=new Xo(s.timeout,s.tui,a=>this.titleText.setText(v.fg("accent",`${this.baseTitle} (${a}s)`)),()=>this.onCancelCallback())),this.input=new Xe,this.addChild(this.input),this.addChild(new L(1)),this.addChild(new A(`${le("tui.select.confirm","submit")} ${le("tui.select.cancel","cancel")}`,1,0)),this.addChild(new L(1)),this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.input.focused=n}handleInput(n){let i=ke();i.matches(n,"tui.select.confirm")||n===`
228
- `?this.onSubmitCallback(this.input.getValue()):i.matches(n,"tui.select.cancel")?this.onCancelCallback():this.input.handleInput(n)}dispose(){this.countdown?.dispose()}};var lo=class extends z{constructor(n,i,o,r,s){super();this.selectedIndex=0;this.options=i,this.onSelectCallback=o,this.onCancelCallback=r,this.onToggleToolsExpanded=s?.onToggleToolsExpanded,this.baseTitle=n,this.addChild(new H),this.addChild(new L(1)),this.titleText=new A(v.fg("accent",v.bold(n)),1,0),this.addChild(this.titleText),this.addChild(new L(1)),s?.timeout&&s.timeout>0&&s.tui&&(this.countdown=new Xo(s.timeout,s.tui,a=>this.titleText.setText(v.fg("accent",v.bold(`${this.baseTitle} (${a}s)`))),()=>this.onCancelCallback())),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new A(lt("\u2191\u2193","navigate")+" "+le("tui.select.confirm","select")+" "+le("tui.select.cancel","cancel"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.updateList()}updateList(){this.listContainer.clear();for(let n=0;n<this.options.length;n++){let o=n===this.selectedIndex?v.fg("accent","\u2192 ")+v.fg("accent",this.options[n]):` ${v.fg("text",this.options[n])}`;this.listContainer.addChild(new A(o,1,0))}}handleInput(n){let i=ke();if(i.matches(n,"app.tools.expand"))this.onToggleToolsExpanded?.();else if(i.matches(n,"tui.select.up")||n==="k")this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList();else if(i.matches(n,"tui.select.down")||n==="j")this.selectedIndex=Math.min(this.options.length-1,this.selectedIndex+1),this.updateList();else if(i.matches(n,"tui.select.confirm")||n===`
229
- `){let o=this.options[this.selectedIndex];o&&this.onSelectCallback(o)}else i.matches(n,"tui.select.cancel")&&this.onCancelCallback()}dispose(){this.countdown?.dispose()}};import{spawnSync as $7}from"node:child_process";import{existsSync as N7}from"node:fs";import{unlink as B7}from"node:fs/promises";import*as OI from"node:os";function II(t){return t.toLowerCase().replace(/\s+/g," ").trim()}function F7(t){return`${t.id} ${t.name??""} ${t.allMessagesText} ${t.cwd}`}function eb(t){return!!t.name?.trim()}function D7(t,e){return e==="all"?!0:eb(t)}function U7(t){let e=t.trim();if(!e)return{mode:"tokens",tokens:[],regex:null};if(e.startsWith("re:")){let a=e.slice(3).trim();if(!a)return{mode:"regex",tokens:[],regex:null,error:"Empty regex"};try{return{mode:"regex",tokens:[],regex:new RegExp(a,"i")}}catch(l){let c=l instanceof Error?l.message:String(l);return{mode:"regex",tokens:[],regex:null,error:c}}}let n=[],i="",o=!1,r=!1,s=a=>{let l=i.trim();i="",l&&n.push({kind:a,value:l})};for(let a=0;a<e.length;a++){let l=e[a];if(l==='"'){o?(s("phrase"),o=!1):(s("fuzzy"),o=!0);continue}if(!o&&/\s/.test(l)){s("fuzzy");continue}i+=l}return o&&(r=!0),r?{mode:"tokens",tokens:e.split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0).map(a=>({kind:"fuzzy",value:a})),regex:null}:(s(o?"phrase":"fuzzy"),{mode:"tokens",tokens:n,regex:null})}function EI(t,e){let n=F7(t);if(e.mode==="regex"){if(!e.regex)return{matches:!1,score:0};let r=n.search(e.regex);return r<0?{matches:!1,score:0}:{matches:!0,score:r*.1}}if(e.tokens.length===0)return{matches:!0,score:0};let i=0,o=null;for(let r of e.tokens){if(r.kind==="phrase"){o===null&&(o=II(n));let a=II(r.value);if(!a)continue;let l=o.indexOf(a);if(l<0)return{matches:!1,score:0};i+=l*.1;continue}let s=Sp(r.value,n);if(!s.matches)return{matches:!1,score:0};i+=s.score}return{matches:!0,score:i}}function AI(t,e,n,i="all"){let o=i==="all"?t:t.filter(l=>D7(l,i));if(!e.trim())return o;let s=U7(e);if(s.error)return[];if(n==="recent"){let l=[];for(let c of o)EI(c,s).matches&&l.push(c);return l}let a=[];for(let l of o){let c=EI(l,s);c.matches&&a.push({session:l,score:c.score})}return a.sort((l,c)=>l.score!==c.score?l.score-c.score:c.session.modified.getTime()-l.session.modified.getTime()),a.map(l=>l.session)}function _I(t){let e=OI.homedir();return t&&(t.startsWith(e)?`~${t.slice(e.length)}`:t)}function j7(t){let n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),o=Math.floor(n/36e5),r=Math.floor(n/864e5);return i<1?"now":i<60?`${i}m`:o<24?`${o}h`:r<7?`${r}d`:r<30?`${Math.floor(r/7)}w`:r<365?`${Math.floor(r/30)}mo`:`${Math.floor(r/365)}y`}function bu(t){return t&&ri(t)}var tb=class{constructor(e,n,i,o){this.loading=!1;this.loadProgress=null;this.showPath=!1;this.confirmingDeletePath=null;this.statusMessage=null;this.statusTimeout=null;this.showRenameHint=!1;this.scope=e,this.sortMode=n,this.nameFilter=i,this.requestRender=o}setScope(e){this.scope=e}setSortMode(e){this.sortMode=e}setNameFilter(e){this.nameFilter=e}setLoading(e){this.loading=e,this.loadProgress=null}setProgress(e,n){this.loadProgress={loaded:e,total:n}}setShowPath(e){this.showPath=e}setShowRenameHint(e){this.showRenameHint=e}setConfirmingDeletePath(e){this.confirmingDeletePath=e}clearStatusTimeout(){this.statusTimeout&&(clearTimeout(this.statusTimeout),this.statusTimeout=null)}setStatusMessage(e,n){this.clearStatusTimeout(),this.statusMessage=e,!(!e||!n)&&(this.statusTimeout=setTimeout(()=>{this.statusMessage=null,this.statusTimeout=null,this.requestRender()},n))}invalidate(){}render(e){let n=this.scope==="current"?"Resume Session (Current Folder)":"Resume Session (All)",i=v.bold(n),o=this.sortMode==="threaded"?"Threaded":this.sortMode==="recent"?"Recent":"Fuzzy",r=v.fg("muted","Sort: ")+v.fg("accent",o),s=this.nameFilter==="all"?"All":"Named",a=v.fg("muted","Name: ")+v.fg("accent",s),l;if(this.loading){let h=this.loadProgress?`${this.loadProgress.loaded}/${this.loadProgress.total}`:"...";l=`${v.fg("muted","\u25CB Current Folder | ")}${v.fg("accent",`Loading ${h}`)}`}else this.scope==="current"?l=`${v.fg("accent","\u25C9 Current Folder")}${v.fg("muted"," | \u25CB All")}`:l=`${v.fg("muted","\u25CB Current Folder | ")}${v.fg("accent","\u25C9 All")}`;let c=te(`${l} ${a} ${r}`,e,""),u=Math.max(0,e-j(c)-1),d=te(i,u,""),p=Math.max(0,e-j(d)-j(c)),m,g;if(this.confirmingDeletePath!==null){let h=`Delete session? ${le("tui.select.confirm","confirm")} \xB7 ${le("tui.select.cancel","cancel")}`;m=v.fg("error",te(h,e,"\u2026")),g=""}else if(this.statusMessage){let h=this.statusMessage.type==="error"?"error":"accent";m=v.fg(h,te(this.statusMessage.message,e,"\u2026")),g=""}else{let h=this.showPath?"(on)":"(off)",f=v.fg("muted"," \xB7 "),b=le("tui.input.tab","scope")+f+v.fg("muted",'re:<pattern> regex \xB7 "phrase" exact'),x=[le("app.session.toggleSort","sort"),le("app.session.toggleNamedFilter","named"),le("app.session.delete","delete"),le("app.session.togglePath",`path ${h}`)];this.showRenameHint&&x.push(le("app.session.rename","rename"));let y=x.join(f);m=te(b,e,"\u2026"),g=te(y,e,"\u2026")}return[`${d}${" ".repeat(p)}${c}`,m,g]}};function q7(t){let e=new Map;for(let r of t){let s=bu(r.path)??r.path;e.set(s,{session:r,children:[],latestActivity:r.modified.getTime()})}let n=[];for(let r of t){let s=bu(r.path)??r.path,a=e.get(s),l=bu(r.parentSessionPath);l&&e.has(l)?e.get(l).children.push(a):n.push(a)}let i=r=>{let s=r.session.modified.getTime();for(let a of r.children)s=Math.max(s,i(a));return r.latestActivity=s,s};for(let r of n)i(r);let o=r=>{r.sort((s,a)=>a.latestActivity-s.latestActivity);for(let s of r)o(s.children)};return o(n),n}function K7(t){let e=[],n=(i,o,r,s)=>{e.push({session:i.session,depth:o,isLast:s,ancestorContinues:r});for(let a=0;a<i.children.length;a++){let l=a===i.children.length-1,c=o>0?!s:!1;n(i.children[a],o+1,[...r,c],l)}};for(let i=0;i<t.length;i++)n(t[i],0,[],i===t.length-1);return e}var nb=class{constructor(e,n,i,o,r,s){this.allSessions=[];this.filteredSessions=[];this.selectedIndex=0;this.showCwd=!1;this.sortMode="threaded";this.nameFilter="all";this.showPath=!1;this.confirmingDeletePath=null;this.onExit=()=>{};this.maxVisible=10;this._focused=!1;this.allSessions=e,this.filteredSessions=[],this.searchInput=new Xe,this.showCwd=n,this.sortMode=i,this.nameFilter=o,this.keybindings=r,this.currentSessionCanonicalPath=bu(s),this.filterSessions(""),this.searchInput.onSubmit=()=>{if(this.filteredSessions[this.selectedIndex]){let a=this.filteredSessions[this.selectedIndex];this.onSelect&&this.onSelect(a.session.path)}}}getSelectedSessionPath(){return this.filteredSessions[this.selectedIndex]?.session.path}get focused(){return this._focused}set focused(e){this._focused=e,this.searchInput.focused=e}setSortMode(e){this.sortMode=e,this.filterSessions(this.searchInput.getValue())}setNameFilter(e){this.nameFilter=e,this.filterSessions(this.searchInput.getValue())}setSessions(e,n){this.allSessions=e,this.showCwd=n,this.filterSessions(this.searchInput.getValue())}filterSessions(e){let n=e.trim(),i=this.nameFilter==="all"?this.allSessions:this.allSessions.filter(o=>eb(o));if(this.sortMode==="threaded"&&!n){let o=q7(i);this.filteredSessions=K7(o)}else{let o=AI(i,e,this.sortMode,"all");this.filteredSessions=o.map(r=>({session:r,depth:0,isLast:!0,ancestorContinues:[]}))}this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredSessions.length-1))}setConfirmingDeletePath(e){this.confirmingDeletePath=e,this.onDeleteConfirmationChange?.(e)}startDeleteConfirmationForSelectedSession(){let e=this.filteredSessions[this.selectedIndex];if(e){if(this.isCurrentSessionPath(e.session.path)){this.onError?.("Cannot delete the currently active session");return}this.setConfirmingDeletePath(e.session.path)}}isCurrentSessionPath(e){return this.currentSessionCanonicalPath?(bu(e)??e)===this.currentSessionCanonicalPath:!1}invalidate(){}render(e){let n=[];if(n.push(...this.searchInput.render(e)),n.push(""),this.filteredSessions.length===0){let r;if(this.nameFilter==="named"){let s=Re("app.session.toggleNamedFilter");this.showCwd?r=` No named sessions found. Press ${s} to show all.`:r=` No named sessions in current folder. Press ${s} to show all, or Tab to view all.`}else this.showCwd?r=" No sessions found":r=" No sessions in current folder. Press Tab to view all.";return n.push(v.fg("muted",te(r,e,"\u2026"))),n}let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredSessions.length-this.maxVisible)),o=Math.min(i+this.maxVisible,this.filteredSessions.length);for(let r=i;r<o;r++){let s=this.filteredSessions[r],a=s.session,l=r===this.selectedIndex,c=a.path===this.confirmingDeletePath,u=this.isCurrentSessionPath(a.path),d=this.buildTreePrefix(s),p=!!a.name,g=(a.name??a.firstMessage).replace(/[\x00-\x1f\x7f]/g," ").trim(),h=j7(a.modified),b=`${String(a.messageCount)} ${h}`;this.showCwd&&a.cwd&&(b=`${_I(a.cwd)} ${b}`),this.showPath&&(b=`${_I(a.path)} ${b}`);let x=l?v.fg("accent","\u203A "):" ",y=j(d),T=j(b)+2,P=e-2-y-T,I=te(g,Math.max(10,P),"\u2026"),W=null;c?W="error":u?W="accent":p&&(W="warning");let D=W?v.fg(W,I):I;l&&(D=v.bold(D));let _=x+v.fg("dim",d)+D,F=j(_),O=Math.max(1,e-F-j(b)),R=v.fg(c?"error":"dim",b),E=_+" ".repeat(O)+R;l&&(E=v.bg("selectedBg",E)),n.push(te(E,e))}if(i>0||o<this.filteredSessions.length){let r=` (${this.selectedIndex+1}/${this.filteredSessions.length})`,s=v.fg("muted",te(r,e,""));n.push(s)}return n}buildTreePrefix(e){if(e.depth===0)return"";let n=e.ancestorContinues.map(o=>o?"\u2502 ":" "),i=e.isLast?"\u2514\u2500 ":"\u251C\u2500 ";return n.join("")+i}handleInput(e){let n=ke();if(this.confirmingDeletePath!==null){if(n.matches(e,"tui.select.confirm")){let i=this.confirmingDeletePath;this.setConfirmingDeletePath(null),this.onDeleteSession?.(i);return}if(n.matches(e,"tui.select.cancel")){this.setConfirmingDeletePath(null);return}return}if(n.matches(e,"tui.input.tab")){this.onToggleScope&&this.onToggleScope();return}if(n.matches(e,"app.session.toggleSort")){this.onToggleSort?.();return}if(this.keybindings.matches(e,"app.session.toggleNamedFilter")){this.onToggleNameFilter?.();return}if(n.matches(e,"app.session.togglePath")){this.showPath=!this.showPath,this.onTogglePath?.(this.showPath);return}if(n.matches(e,"app.session.delete")){this.startDeleteConfirmationForSelectedSession();return}if(n.matches(e,"app.session.rename")){let i=this.filteredSessions[this.selectedIndex];i&&this.onRenameSession?.(i.session.path);return}if(n.matches(e,"app.session.deleteNoninvasive")){if(this.searchInput.getValue().length>0){this.searchInput.handleInput(e),this.filterSessions(this.searchInput.getValue());return}this.startDeleteConfirmationForSelectedSession();return}if(n.matches(e,"tui.select.up"))this.selectedIndex=Math.max(0,this.selectedIndex-1);else if(n.matches(e,"tui.select.down"))this.selectedIndex=Math.min(this.filteredSessions.length-1,this.selectedIndex+1);else if(n.matches(e,"tui.select.pageUp"))this.selectedIndex=Math.max(0,this.selectedIndex-this.maxVisible);else if(n.matches(e,"tui.select.pageDown"))this.selectedIndex=Math.min(this.filteredSessions.length-1,this.selectedIndex+this.maxVisible);else if(n.matches(e,"tui.select.confirm")){let i=this.filteredSessions[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.session.path)}else n.matches(e,"tui.select.cancel")?this.onCancel&&this.onCancel():(this.searchInput.handleInput(e),this.filterSessions(this.searchInput.getValue()))}};async function G7(t){let e=t.startsWith("-")?["--",t]:[t],n=$7("trash",e,{encoding:"utf-8"}),i=()=>{let o=[];n.error&&o.push(n.error.message);let r=n.stderr?.trim();return r&&o.push(r.split(`
230
- `)[0]??r),o.length===0?null:`trash: ${o.join(" \xB7 ").slice(0,200)}`};if(n.status===0||!N7(t))return{ok:!0,method:"trash"};try{return await B7(t),{ok:!0,method:"unlink"}}catch(o){let r=o instanceof Error?o.message:String(o),s=i();return{ok:!1,method:"unlink",error:s?`${r} (${s})`:r}}}var ss=class extends z{constructor(n,i,o,r,s,a,l,c){super();this.canRename=!0;this.scope="current";this.sortMode="threaded";this.nameFilter="all";this.currentSessions=null;this.allSessions=null;this.currentLoading=!1;this.allLoading=!1;this.allLoadSeq=0;this.mode="list";this.renameInput=new Xe;this.renameTargetPath=null;this._focused=!1;this.keybindings=l?.keybindings??Jo.create(),this.currentSessionsLoader=n,this.allSessionsLoader=i,this.requestRender=a,this.header=new tb(this.scope,this.sortMode,this.nameFilter,this.requestRender);let u=l?.renameSession;this.renameSession=u,this.canRename=!!u,this.header.setShowRenameHint(l?.showRenameHint??this.canRename),this.sessionList=new nb([],!1,this.sortMode,this.nameFilter,this.keybindings,c),this.buildBaseLayout(this.sessionList),this.renameInput.onSubmit=p=>{this.confirmRename(p)};let d=()=>this.header.setStatusMessage(null);this.sessionList.onSelect=p=>{d(),o(p)},this.sessionList.onCancel=()=>{d(),r()},this.sessionList.onExit=()=>{d(),s()},this.sessionList.onToggleScope=()=>this.toggleScope(),this.sessionList.onToggleSort=()=>this.toggleSortMode(),this.sessionList.onToggleNameFilter=()=>this.toggleNameFilter(),this.sessionList.onRenameSession=p=>{if(!u||this.scope==="current"&&this.currentLoading||this.scope==="all"&&this.allLoading)return;let g=(this.scope==="all"?this.allSessions??[]:this.currentSessions??[]).find(h=>h.path===p);this.enterRenameMode(p,g?.name)},this.sessionList.onTogglePath=p=>{this.header.setShowPath(p),this.requestRender()},this.sessionList.onDeleteConfirmationChange=p=>{this.header.setConfirmingDeletePath(p),this.requestRender()},this.sessionList.onError=p=>{this.header.setStatusMessage({type:"error",message:p},3e3),this.requestRender()},this.sessionList.onDeleteSession=async p=>{let m=await G7(p);if(m.ok){this.currentSessions&&(this.currentSessions=this.currentSessions.filter(b=>b.path!==p)),this.allSessions&&(this.allSessions=this.allSessions.filter(b=>b.path!==p));let g=this.scope==="all"?this.allSessions??[]:this.currentSessions??[],h=this.scope==="all";this.sessionList.setSessions(g,h);let f=m.method==="trash"?"Session moved to trash":"Session deleted";this.header.setStatusMessage({type:"info",message:f},2e3),await this.refreshSessionsAfterMutation()}else{let g=m.error??"Unknown error";this.header.setStatusMessage({type:"error",message:`Failed to delete: ${g}`},3e3)}this.requestRender()},this.loadCurrentSessions()}handleInput(n){if(this.mode==="rename"){if(ke().matches(n,"tui.select.cancel")){this.exitRenameMode();return}this.renameInput.handleInput(n);return}this.sessionList.handleInput(n)}get focused(){return this._focused}set focused(n){this._focused=n,this.sessionList.focused=n,this.renameInput.focused=n,n&&this.mode==="rename"&&(this.renameInput.focused=!0)}buildBaseLayout(n,i){this.clear(),this.addChild(new L(1)),this.addChild(new H(o=>v.fg("accent",o))),this.addChild(new L(1)),(i?.showHeader??!0)&&(this.addChild(this.header),this.addChild(new L(1))),this.addChild(n),this.addChild(new L(1)),this.addChild(new H(o=>v.fg("accent",o)))}loadCurrentSessions(){this.loadScope("current","initial")}enterRenameMode(n,i){this.mode="rename",this.renameTargetPath=n,this.renameInput.setValue(i??""),this.renameInput.focused=!0;let o=new z;o.addChild(new A(v.bold("Rename Session"),1,0)),o.addChild(new L(1)),o.addChild(this.renameInput),o.addChild(new L(1)),o.addChild(new A(v.fg("muted",`${Re("tui.select.confirm")} to save \xB7 ${Re("tui.select.cancel")} to cancel`),1,0)),this.buildBaseLayout(o,{showHeader:!1}),this.requestRender()}exitRenameMode(){this.mode="list",this.renameTargetPath=null,this.buildBaseLayout(this.sessionList),this.requestRender()}async confirmRename(n){let i=n.trim();if(!i)return;let o=this.renameTargetPath;if(!o){this.exitRenameMode();return}let r=this.renameSession;if(!r){this.exitRenameMode();return}try{await r(o,i),await this.refreshSessionsAfterMutation()}finally{this.exitRenameMode()}}async loadScope(n,i){let o=n==="all";n==="current"?this.currentLoading=!0:this.allLoading=!0;let r=n==="all"?++this.allLoadSeq:void 0;this.header.setScope(n),this.header.setLoading(!0),this.requestRender();let s=(a,l)=>{n===this.scope&&(r!==void 0&&r!==this.allLoadSeq||(this.header.setProgress(a,l),this.requestRender()))};try{let a=await(n==="current"?this.currentSessionsLoader(s):this.allSessionsLoader(s));if(n==="current"?(this.currentSessions=a,this.currentLoading=!1):(this.allSessions=a,this.allLoading=!1),n!==this.scope||r!==void 0&&r!==this.allLoadSeq)return;this.header.setLoading(!1),this.sessionList.setSessions(a,o),this.requestRender()}catch(a){if(n==="current"?this.currentLoading=!1:this.allLoading=!1,n!==this.scope||r!==void 0&&r!==this.allLoadSeq)return;let l=a instanceof Error?a.message:String(a);this.header.setLoading(!1),this.header.setStatusMessage({type:"error",message:`Failed to load sessions: ${l}`},4e3),i==="initial"&&this.sessionList.setSessions([],o),this.requestRender()}}toggleSortMode(){this.sortMode=this.sortMode==="threaded"?"recent":this.sortMode==="recent"?"relevance":"threaded",this.header.setSortMode(this.sortMode),this.sessionList.setSortMode(this.sortMode),this.requestRender()}toggleNameFilter(){this.nameFilter=this.nameFilter==="all"?"named":"all",this.header.setNameFilter(this.nameFilter),this.sessionList.setNameFilter(this.nameFilter),this.requestRender()}async refreshSessionsAfterMutation(){await this.loadScope(this.scope,"refresh")}toggleScope(){if(this.scope==="current"){if(this.scope="all",this.header.setScope(this.scope),this.allSessions!==null){this.header.setLoading(!1),this.sessionList.setSessions(this.allSessions,!0),this.requestRender();return}this.allLoading||this.loadScope("all","toggle");return}this.scope="current",this.header.setScope(this.scope),this.header.setLoading(this.currentLoading),this.sessionList.setSessions(this.currentSessions??[],!1),this.requestRender()}getSessionList(){return this.sessionList}};import cLe from"chalk";import*as CE from"node:crypto";import*as En from"node:fs";import*as _l from"node:os";import*as et from"node:path";import AG from"chalk";import{spawn as kb,spawnSync as _G}from"child_process";function LI(t,e,n){let i=e.usage,o=i.input+i.cacheRead+i.cacheWrite;if(!t||o<=0||i.cacheRead+i.cacheWrite===0&&!t.reportedCache)return;let r=Math.min(t.promptTokens,o)-i.cacheRead;if(r<=1024)return;let s=i.input+i.cacheWrite,a=s>0?(i.cost.input+i.cost.cacheWrite)/s:0,l=i.cacheRead>0?i.cost.cacheRead/i.cacheRead:(n.getModel(e.provider,e.model)?.cost.cacheRead??0)/1e6;return{missedTokens:r,missedCost:r*Math.max(0,a-l),idleMs:Math.max(0,e.timestamp-t.timestamp),modelChanged:`${e.provider}/${e.model}`!==t.modelKey}}function V7(t,e){let n=t.usage,i=n.input+n.cacheRead+n.cacheWrite;if(!(i<=0))return{promptTokens:i,modelKey:`${t.provider}/${t.model}`,timestamp:t.timestamp,reportedCache:e||n.cacheRead+n.cacheWrite>0}}function ib(t,e){let n,i={missedTokens:0,missedCost:0,missCount:0},o=new Map;for(let r of t){if(r.type==="compaction"||r.type==="branch_summary"){n=void 0;continue}if(r.type==="message"&&r.message.role==="assistant"){let s=LI(n,r.message,e);s&&(i.missedTokens+=s.missedTokens,i.missedCost+=s.missedCost,i.missCount+=1,o.set(r.message,s)),n=V7(r.message,n?.reportedCache??!1)??n}}return{prev:n,totals:i,misses:o}}function WI(t,e){return ib(t,e).totals}function FI(t,e){return ib(t,e).misses}function DI(t,e,n){return LI(ib(t,n).prev,e,n)}import{execFile as Q7,spawnSync as Y7}from"child_process";import{existsSync as ml,readFileSync as Fm,statSync as J7,unwatchFile as UI,watchFile as $I}from"fs";import{dirname as jI,join as hl,resolve as NI}from"path";function BI(t){let e=t;for(;;){let n=hl(e,".git");if(ml(n))try{let o=J7(n);if(o.isFile()){let r=Fm(n,"utf8").trim();if(r.startsWith("gitdir: ")){let s=NI(e,r.slice(8).trim()),a=hl(s,"HEAD");if(!ml(a))return null;let l=hl(s,"commondir"),c=ml(l)?NI(s,Fm(l,"utf8").trim()):s;return{repoDir:e,commonGitDir:c,headPath:a}}}else if(o.isDirectory()){let r=hl(n,"HEAD");return ml(r)?{repoDir:e,commonGitDir:n,headPath:r}:null}}catch{return null}let i=jI(e);if(i===e)return null;e=i}}function X7(t){let e=Y7("git",["--no-optional-locks","symbolic-ref","--quiet","--short","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]});return(e.status===0?e.stdout.trim():"")||null}function Z7(t){return new Promise(e=>{Q7("git",["--no-optional-locks","symbolic-ref","--quiet","--short","HEAD"],{cwd:t,encoding:"utf8"},(n,i)=>{if(n){e(null);return}let o=i.trim();e(o||null)})})}function eK(){return process.platform==="linux"&&!!(process.env.WSL_DISTRO_NAME||process.env.WSL_INTEROP)}function tK(t){return/^\/mnt\/[a-z](?:\/|$)/i.test(t)}function nK(t){return eK()&&tK(t)}var Dm=class t{constructor(e){this.extensionStatuses=new Map;this.cachedBranch=void 0;this.gitPaths=void 0;this.headWatcher=null;this.headWatchFilePath=null;this.headWatchFileListener=null;this.reftableWatcher=null;this.reftableTablesListWatcher=null;this.reftableTablesListPath=null;this.branchChangeCallbacks=new Set;this.availableProviderCount=0;this.refreshTimer=null;this.gitWatcherRetryTimer=null;this.refreshInFlight=!1;this.refreshPending=!1;this.disposed=!1;this.cwd=e,this.gitPaths=BI(e),this.setupGitWatcher()}static{this.WATCH_DEBOUNCE_MS=500}getGitBranch(){return this.cachedBranch===void 0&&(this.cachedBranch=this.resolveGitBranchSync()),this.cachedBranch}getExtensionStatuses(){return this.extensionStatuses}onBranchChange(e){return this.branchChangeCallbacks.add(e),()=>this.branchChangeCallbacks.delete(e)}setExtensionStatus(e,n){n===void 0?this.extensionStatuses.delete(e):this.extensionStatuses.set(e,n)}clearExtensionStatuses(){this.extensionStatuses.clear()}getAvailableProviderCount(){return this.availableProviderCount}setAvailableProviderCount(e){this.availableProviderCount=e}setCwd(e){this.cwd!==e&&(this.cwd=e,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),this.clearGitWatchers(),this.cachedBranch=void 0,this.gitPaths=BI(e),this.setupGitWatcher(),this.notifyBranchChange())}dispose(){this.disposed=!0,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),this.clearGitWatchers(),this.branchChangeCallbacks.clear()}notifyBranchChange(){for(let e of this.branchChangeCallbacks)e()}scheduleRefresh(){if(!(this.disposed||this.refreshTimer)){if(this.refreshInFlight){this.refreshPending=!0;return}this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,this.refreshGitBranchAsync()},t.WATCH_DEBOUNCE_MS)}}async refreshGitBranchAsync(){if(!this.disposed){if(this.refreshInFlight){this.refreshPending=!0;return}this.refreshInFlight=!0;try{let e=await this.resolveGitBranchAsync();if(this.disposed)return;if(this.cachedBranch!==void 0&&this.cachedBranch!==e){this.cachedBranch=e,this.notifyBranchChange();return}this.cachedBranch=e}finally{this.refreshInFlight=!1,this.refreshPending&&!this.disposed&&(this.refreshPending=!1,this.scheduleRefresh())}}}resolveGitBranchSync(){try{if(!this.gitPaths)return null;let e=Fm(this.gitPaths.headPath,"utf8").trim();if(e.startsWith("ref: refs/heads/")){let n=e.slice(16);return n===".invalid"?X7(this.gitPaths.repoDir)??"detached":n}return"detached"}catch{return null}}async resolveGitBranchAsync(){try{if(!this.gitPaths)return null;let e=Fm(this.gitPaths.headPath,"utf8").trim();if(e.startsWith("ref: refs/heads/")){let n=e.slice(16);return n===".invalid"?await Z7(this.gitPaths.repoDir)??"detached":n}return"detached"}catch{return null}}clearGitWatchers(){Br(this.headWatcher),this.headWatcher=null,this.headWatchFilePath&&this.headWatchFileListener&&(UI(this.headWatchFilePath,this.headWatchFileListener),this.headWatchFilePath=null,this.headWatchFileListener=null),Br(this.reftableWatcher),this.reftableWatcher=null,Br(this.reftableTablesListWatcher),this.reftableTablesListWatcher=null,this.reftableTablesListPath&&(UI(this.reftableTablesListPath),this.reftableTablesListPath=null),this.gitWatcherRetryTimer&&(clearTimeout(this.gitWatcherRetryTimer),this.gitWatcherRetryTimer=null)}scheduleGitWatcherRetry(){this.disposed||this.gitWatcherRetryTimer||(this.gitWatcherRetryTimer=setTimeout(()=>{this.gitWatcherRetryTimer=null,this.setupGitWatcher()},wR))}handleGitWatcherError(){this.clearGitWatchers(),this.scheduleGitWatcherRetry()}setupGitWatcher(){if(this.clearGitWatchers(),!this.gitPaths)return;let e=nK(this.gitPaths.repoDir);if(this.headWatcher=Ka(jI(this.gitPaths.headPath),(i,o)=>{(!o||o==="HEAD")&&this.scheduleRefresh()},()=>this.handleGitWatcherError()),e&&(this.headWatchFilePath=this.gitPaths.headPath,this.headWatchFileListener=(i,o)=>{(i.mtimeMs!==o.mtimeMs||i.ctimeMs!==o.ctimeMs||i.size!==o.size)&&this.scheduleRefresh()},$I(this.headWatchFilePath,{interval:1e3},this.headWatchFileListener)),!this.headWatcher&&!e)return;let n=hl(this.gitPaths.commonGitDir,"reftable");if(ml(n)){if(this.reftableWatcher=Ka(n,()=>{this.scheduleRefresh()},()=>this.handleGitWatcherError()),!this.reftableWatcher)return;let i=hl(n,"tables.list");if(ml(i)){if(this.reftableTablesListPath=i,this.reftableTablesListWatcher=Ka(i,()=>{this.scheduleRefresh()},()=>this.handleGitWatcherError()),!this.reftableTablesListWatcher)return;$I(i,{interval:250},(o,r)=>{(o.mtimeMs!==r.mtimeMs||o.ctimeMs!==r.ctimeMs||o.size!==r.size)&&this.scheduleRefresh()})}}}};var ob=[{name:"settings",description:"Open settings menu"},{name:"model",description:"Select model (opens selector UI)",argumentHint:"<provider/model>"},{name:"scoped-models",description:"Enable/disable models for Ctrl+P cycling"},{name:"export",description:"Export session (HTML default, or specify path: .html/.jsonl)"},{name:"import",description:"Import and resume a session from a JSONL file"},{name:"share",description:"Share session as a secret GitHub gist"},{name:"copy",description:"Copy last agent message to clipboard"},{name:"name",description:"Set session display name"},{name:"session",description:"Show session info and stats"},{name:"changelog",description:"Show changelog entries"},{name:"hotkeys",description:"Show all keyboard shortcuts"},{name:"fork",description:"Create a new fork from a previous user message"},{name:"clone",description:"Duplicate the current session at the current position"},{name:"tree",description:"Navigate session tree (switch branches)"},{name:"trust",description:"Save project trust decision for future sessions"},{name:"login",description:"Configure provider authentication",argumentHint:"<provider>"},{name:"logout",description:"Remove provider authentication"},{name:"new",description:"Start a new session"},{name:"compact",description:"Manually compact the session context"},{name:"resume",description:"Resume a different session"},{name:"reload",description:"Reload keybindings, extensions, skills, prompts, themes, and context files"},{name:"quit",description:`Quit ${wt}`}];import Um from"node:path";import{existsSync as iK,readFileSync as oK}from"fs";var rb="earendil-works/pi",rK="packages/coding-agent",sK=/^https:\/\/github\.com\/(?:badlogic|earendil-works)\/pi-mono(?=\/|$)/,aK=/^[a-z][a-z0-9+.-]*:/i,lK=/(!?\[[^\]\n]+\]\()([^\s)]+)((?:\s+[^)]*)?\))/g;function cK(t){return`${t.major}.${t.minor}.${t.patch}`}function uK(t){let e=typeof t=="string"?t:cK(t);return e.startsWith("v")?e:`v${e}`}function dK(t){let e=t.indexOf("#"),n=e===-1?t:t.slice(0,e),i=e===-1?"":t.slice(e),o=n.indexOf("?");return o===-1?{fragment:i,pathPart:n,query:""}:{fragment:i,pathPart:n.slice(0,o),query:n.slice(o)}}function pK(t){return t.replaceAll("\\","/")}function mK(t){let e=pK(t),n=e.startsWith("/")?Um.posix.normalize(e.replace(/^\/+/,"")):Um.posix.normalize(Um.posix.join(rK,e));if(!(n==="."||n.startsWith("../")||n===".."))return n}function hK(t,e){return t.endsWith("/")?!0:!Um.posix.basename(e).includes(".")}function gK(t,e){let n=t.replace(sK,`https://github.com/${rb}`),i=`https://github.com/${rb}`;for(let c of["blob","tree"])for(let u of["main","master"]){let d=`${i}/${c}/${u}/`;n.startsWith(d)&&(n=`${i}/${c}/${e}/${n.slice(d.length)}`)}if(n.startsWith("#")||n.startsWith("//")||aK.test(n))return n;let{fragment:o,pathPart:r,query:s}=dK(n);if(!r)return n;let a=mK(r);if(!a)return n;let l=hK(r,a)?"tree":"blob";return`https://github.com/${rb}/${l}/${e}/${encodeURI(a)}${s}${o}`}function sb(t,e){let n=uK(e);return t.replace(lK,(i,o,r,s)=>`${o}${gK(r,n)}${s}`)}function ab(t){if(!iK(t))return[];try{let n=oK(t,"utf-8").split(`
227
+ `,"utf-8")}function M7(t){let e=vu(t);CI(e,{recursive:!0});let n=10,i=20,o;for(let r=1;r<=n;r++)try{return w7.lockSync(e,{realpath:!1,lockfilePath:`${t}.lock`})}catch(s){if((typeof s=="object"&&s!==null&&"code"in s?String(s.code):void 0)!=="ELOCKED"||r===n)throw s;o=s;let l=Date.now();for(;Date.now()-l<i;);}throw o instanceof Error?o:new Error("Failed to acquire trust store lock")}function TI(t,e){let n=M7(t);try{return e()}finally{n()}}function os(t){let e=ri(Se(process.env.HOME||y7())),n=fu(e,".agents","skills"),i=ri(Se(t)),o=fu(i,Je);if(k7.some(r=>J0(fu(o,r))))return!0;for(;;){let r=fu(i,".agents","skills");if(r!==n&&J0(r))return!0;let s=vu(i);if(s===i)return!1;i=s}}var Yo=class{constructor(e){this.trustPath=fu(Se(e),"trust.json")}get(e){return this.getEntry(e)?.decision??null}getEntry(e){return TI(this.trustPath,()=>{let n=SI(this.trustPath);return S7(n,e)})}set(e,n){this.setMany([{path:e,decision:n}])}setMany(e){TI(this.trustPath,()=>{let n=SI(this.trustPath);for(let{path:i,decision:o}of e){let r=Wm(i);o===null?delete n[r]:n[r]=o}C7(this.trustPath,n)})}};import RDe from"chalk";import pOe from"chalk";import yOe from"chalk";import u5e from"chalk";function Z0(){return process.env.PI_EXPERIMENTAL==="1"}import{existsSync as R7,readFileSync as P7}from"fs";import{join as I7}from"path";var MI={...Da,"app.interrupt":{defaultKeys:"escape",description:"Cancel or abort"},"app.clear":{defaultKeys:"ctrl+c",description:"Clear editor"},"app.exit":{defaultKeys:"ctrl+d",description:"Exit when editor is empty"},"app.suspend":{defaultKeys:process.platform==="win32"?[]:"ctrl+z",description:"Suspend to background"},"app.thinking.cycle":{defaultKeys:"shift+tab",description:"Cycle thinking level"},"app.model.cycleForward":{defaultKeys:"ctrl+p",description:"Cycle to next model"},"app.model.cycleBackward":{defaultKeys:"shift+ctrl+p",description:"Cycle to previous model"},"app.model.select":{defaultKeys:"ctrl+l",description:"Open model selector"},"app.tools.expand":{defaultKeys:"ctrl+o",description:"Toggle tool output"},"app.thinking.toggle":{defaultKeys:"ctrl+t",description:"Toggle thinking blocks"},"app.session.toggleNamedFilter":{defaultKeys:"ctrl+n",description:"Toggle named session filter"},"app.editor.external":{defaultKeys:"ctrl+g",description:"Open external editor"},"app.message.copy":{defaultKeys:"ctrl+x",description:"Copy message to clipboard"},"app.message.followUp":{defaultKeys:"alt+enter",description:"Queue follow-up message"},"app.message.dequeue":{defaultKeys:"alt+up",description:"Restore queued messages"},"app.clipboard.pasteImage":{defaultKeys:process.platform==="win32"?"alt+v":"ctrl+v",description:"Paste image from clipboard (text fallback)"},"app.session.new":{defaultKeys:[],description:"Start a new session"},"app.session.tree":{defaultKeys:[],description:"Open session tree"},"app.session.fork":{defaultKeys:[],description:"Fork current session"},"app.session.resume":{defaultKeys:[],description:"Resume a session"},"app.tree.foldOrUp":{defaultKeys:process.platform==="darwin"?["alt+left","ctrl+left"]:["ctrl+left","alt+left"],description:"Fold tree branch or move up"},"app.tree.unfoldOrDown":{defaultKeys:process.platform==="darwin"?["alt+right","ctrl+right"]:["ctrl+right","alt+right"],description:"Unfold tree branch or move down"},"app.tree.editLabel":{defaultKeys:"shift+l",description:"Edit tree label"},"app.tree.toggleLabelTimestamp":{defaultKeys:"shift+t",description:"Toggle tree label timestamps"},"app.session.togglePath":{defaultKeys:"ctrl+p",description:"Toggle session path display"},"app.session.toggleSort":{defaultKeys:"ctrl+s",description:"Toggle session sort mode"},"app.session.rename":{defaultKeys:"ctrl+r",description:"Rename session"},"app.session.delete":{defaultKeys:"ctrl+d",description:"Delete session"},"app.session.deleteNoninvasive":{defaultKeys:"ctrl+backspace",description:"Delete session when query is empty"},"app.models.save":{defaultKeys:"ctrl+s",description:"Save model selection"},"app.models.enableAll":{defaultKeys:"ctrl+a",description:"Enable all models"},"app.models.clearAll":{defaultKeys:"ctrl+x",description:"Clear all models"},"app.models.toggleProvider":{defaultKeys:"ctrl+p",description:"Toggle all models for provider"},"app.models.reorderUp":{defaultKeys:"alt+up",description:"Move model up in order"},"app.models.reorderDown":{defaultKeys:"alt+down",description:"Move model down in order"},"app.tree.filter.default":{defaultKeys:"ctrl+d",description:"Tree filter: default view"},"app.tree.filter.noTools":{defaultKeys:"ctrl+t",description:"Tree filter: hide tool results"},"app.tree.filter.userOnly":{defaultKeys:"ctrl+u",description:"Tree filter: user messages only"},"app.tree.filter.labeledOnly":{defaultKeys:"ctrl+l",description:"Tree filter: labeled entries only"},"app.tree.filter.all":{defaultKeys:"ctrl+a",description:"Tree filter: show all entries"},"app.tree.filter.cycleForward":{defaultKeys:"ctrl+o",description:"Tree filter: cycle forward"},"app.tree.filter.cycleBackward":{defaultKeys:"shift+ctrl+o",description:"Tree filter: cycle backward"}},RI={cursorUp:"tui.editor.cursorUp",cursorDown:"tui.editor.cursorDown",cursorLeft:"tui.editor.cursorLeft",cursorRight:"tui.editor.cursorRight",cursorWordLeft:"tui.editor.cursorWordLeft",cursorWordRight:"tui.editor.cursorWordRight",cursorLineStart:"tui.editor.cursorLineStart",cursorLineEnd:"tui.editor.cursorLineEnd",jumpForward:"tui.editor.jumpForward",jumpBackward:"tui.editor.jumpBackward",pageUp:"tui.editor.pageUp",pageDown:"tui.editor.pageDown",deleteCharBackward:"tui.editor.deleteCharBackward",deleteCharForward:"tui.editor.deleteCharForward",deleteWordBackward:"tui.editor.deleteWordBackward",deleteWordForward:"tui.editor.deleteWordForward",deleteToLineStart:"tui.editor.deleteToLineStart",deleteToLineEnd:"tui.editor.deleteToLineEnd",yank:"tui.editor.yank",yankPop:"tui.editor.yankPop",undo:"tui.editor.undo",newLine:"tui.input.newLine",submit:"tui.input.submit",tab:"tui.input.tab",copy:"tui.input.copy",selectUp:"tui.select.up",selectDown:"tui.select.down",selectPageUp:"tui.select.pageUp",selectPageDown:"tui.select.pageDown",selectConfirm:"tui.select.confirm",selectCancel:"tui.select.cancel",interrupt:"app.interrupt",clear:"app.clear",exit:"app.exit",suspend:"app.suspend",cycleThinkingLevel:"app.thinking.cycle",cycleModelForward:"app.model.cycleForward",cycleModelBackward:"app.model.cycleBackward",selectModel:"app.model.select",expandTools:"app.tools.expand",toggleThinking:"app.thinking.toggle",toggleSessionNamedFilter:"app.session.toggleNamedFilter",externalEditor:"app.editor.external",followUp:"app.message.followUp",dequeue:"app.message.dequeue",pasteImage:"app.clipboard.pasteImage",newSession:"app.session.new",tree:"app.session.tree",fork:"app.session.fork",resume:"app.session.resume",treeFoldOrUp:"app.tree.foldOrUp",treeUnfoldOrDown:"app.tree.unfoldOrDown",treeEditLabel:"app.tree.editLabel",treeToggleLabelTimestamp:"app.tree.toggleLabelTimestamp",toggleSessionPath:"app.session.togglePath",toggleSessionSort:"app.session.toggleSort",renameSession:"app.session.rename",deleteSession:"app.session.delete",deleteSessionNoninvasive:"app.session.deleteNoninvasive"};function E7(t){return t in RI}function A7(t){let e={};for(let[n,i]of Object.entries(t)){if(typeof i=="string"){e[n]=i;continue}Array.isArray(i)&&i.every(o=>typeof o=="string")&&(e[n]=i)}return e}function PI(t){let e={},n=!1;for(let[i,o]of Object.entries(t)){let r=E7(i)?RI[i]:i;if(r!==i&&(n=!0),i!==r&&Object.hasOwn(t,r)){n=!0;continue}e[r]=o}return{config:_7(e),migrated:n}}function _7(t){let e={};for(let i of Object.keys(MI))Object.hasOwn(t,i)&&(e[i]=t[i]);let n=Object.keys(t).filter(i=>!Object.hasOwn(e,i)).sort();for(let i of n)e[i]=t[i];return e}function O7(t){if(R7(t))try{let e=JSON.parse(P7(t,"utf-8"));return typeof e!="object"||e===null?void 0:e}catch{return}}var Jo=class t extends Fa{constructor(e={},n){super(MI,e),this.configPath=n}static create(e=_e()){let n=I7(e,"keybindings.json"),i=t.loadFromFile(n);return new t(i,n)}reload(){this.configPath&&this.setUserBindings(t.loadFromFile(this.configPath))}getEffectiveConfig(){return this.getResolvedBindings()}static loadFromFile(e){let n=O7(e);return n?A7(PI(n).config):{}}};var Xo=class{constructor(e,n,i,o){this.tui=n,this.onTick=i,this.onExpire=o,this.remainingSeconds=Math.ceil(e/1e3),this.onTick(this.remainingSeconds),this.intervalId=setInterval(()=>{this.remainingSeconds--,this.onTick(this.remainingSeconds),this.tui?.requestRender(),this.remainingSeconds<=0&&(this.dispose(),this.onExpire())},1e3)}dispose(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}};var H=class{constructor(e=n=>v.fg("border",n)){this.color=e}invalidate(){}render(e){return[this.color("\u2500".repeat(Math.max(1,e)))]}};var rs=class extends z{constructor(n,i,o,r,s){super();this._focused=!1;this.onSubmitCallback=o,this.onCancelCallback=r,this.baseTitle=n,this.addChild(new H),this.addChild(new L(1)),this.titleText=new A(v.fg("accent",n),1,0),this.addChild(this.titleText),this.addChild(new L(1)),s?.timeout&&s.timeout>0&&s.tui&&(this.countdown=new Xo(s.timeout,s.tui,a=>this.titleText.setText(v.fg("accent",`${this.baseTitle} (${a}s)`)),()=>this.onCancelCallback())),this.input=new Xe,this.addChild(this.input),this.addChild(new L(1)),this.addChild(new A(`${le("tui.select.confirm","submit")} ${le("tui.select.cancel","cancel")}`,1,0)),this.addChild(new L(1)),this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.input.focused=n}handleInput(n){let i=we();i.matches(n,"tui.select.confirm")||n===`
228
+ `?this.onSubmitCallback(this.input.getValue()):i.matches(n,"tui.select.cancel")?this.onCancelCallback():this.input.handleInput(n)}dispose(){this.countdown?.dispose()}};var lo=class extends z{constructor(n,i,o,r,s){super();this.selectedIndex=0;this.options=i,this.onSelectCallback=o,this.onCancelCallback=r,this.onToggleToolsExpanded=s?.onToggleToolsExpanded,this.baseTitle=n,this.addChild(new H),this.addChild(new L(1)),this.titleText=new A(v.fg("accent",v.bold(n)),1,0),this.addChild(this.titleText),this.addChild(new L(1)),s?.timeout&&s.timeout>0&&s.tui&&(this.countdown=new Xo(s.timeout,s.tui,a=>this.titleText.setText(v.fg("accent",v.bold(`${this.baseTitle} (${a}s)`))),()=>this.onCancelCallback())),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new A(lt("\u2191\u2193","navigate")+" "+le("tui.select.confirm","select")+" "+le("tui.select.cancel","cancel"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.updateList()}updateList(){this.listContainer.clear();for(let n=0;n<this.options.length;n++){let o=n===this.selectedIndex?v.fg("accent","\u2192 ")+v.fg("accent",this.options[n]):` ${v.fg("text",this.options[n])}`;this.listContainer.addChild(new A(o,1,0))}}handleInput(n){let i=we();if(i.matches(n,"app.tools.expand"))this.onToggleToolsExpanded?.();else if(i.matches(n,"tui.select.up")||n==="k")this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList();else if(i.matches(n,"tui.select.down")||n==="j")this.selectedIndex=Math.min(this.options.length-1,this.selectedIndex+1),this.updateList();else if(i.matches(n,"tui.select.confirm")||n===`
229
+ `){let o=this.options[this.selectedIndex];o&&this.onSelectCallback(o)}else i.matches(n,"tui.select.cancel")&&this.onCancelCallback()}dispose(){this.countdown?.dispose()}};import{spawnSync as $7}from"node:child_process";import{existsSync as N7}from"node:fs";import{unlink as B7}from"node:fs/promises";import*as OI from"node:os";function II(t){return t.toLowerCase().replace(/\s+/g," ").trim()}function F7(t){return`${t.id} ${t.name??""} ${t.allMessagesText} ${t.cwd}`}function eb(t){return!!t.name?.trim()}function D7(t,e){return e==="all"?!0:eb(t)}function U7(t){let e=t.trim();if(!e)return{mode:"tokens",tokens:[],regex:null};if(e.startsWith("re:")){let a=e.slice(3).trim();if(!a)return{mode:"regex",tokens:[],regex:null,error:"Empty regex"};try{return{mode:"regex",tokens:[],regex:new RegExp(a,"i")}}catch(l){let c=l instanceof Error?l.message:String(l);return{mode:"regex",tokens:[],regex:null,error:c}}}let n=[],i="",o=!1,r=!1,s=a=>{let l=i.trim();i="",l&&n.push({kind:a,value:l})};for(let a=0;a<e.length;a++){let l=e[a];if(l==='"'){o?(s("phrase"),o=!1):(s("fuzzy"),o=!0);continue}if(!o&&/\s/.test(l)){s("fuzzy");continue}i+=l}return o&&(r=!0),r?{mode:"tokens",tokens:e.split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0).map(a=>({kind:"fuzzy",value:a})),regex:null}:(s(o?"phrase":"fuzzy"),{mode:"tokens",tokens:n,regex:null})}function EI(t,e){let n=F7(t);if(e.mode==="regex"){if(!e.regex)return{matches:!1,score:0};let r=n.search(e.regex);return r<0?{matches:!1,score:0}:{matches:!0,score:r*.1}}if(e.tokens.length===0)return{matches:!0,score:0};let i=0,o=null;for(let r of e.tokens){if(r.kind==="phrase"){o===null&&(o=II(n));let a=II(r.value);if(!a)continue;let l=o.indexOf(a);if(l<0)return{matches:!1,score:0};i+=l*.1;continue}let s=Sp(r.value,n);if(!s.matches)return{matches:!1,score:0};i+=s.score}return{matches:!0,score:i}}function AI(t,e,n,i="all"){let o=i==="all"?t:t.filter(l=>D7(l,i));if(!e.trim())return o;let s=U7(e);if(s.error)return[];if(n==="recent"){let l=[];for(let c of o)EI(c,s).matches&&l.push(c);return l}let a=[];for(let l of o){let c=EI(l,s);c.matches&&a.push({session:l,score:c.score})}return a.sort((l,c)=>l.score!==c.score?l.score-c.score:c.session.modified.getTime()-l.session.modified.getTime()),a.map(l=>l.session)}function _I(t){let e=OI.homedir();return t&&(t.startsWith(e)?`~${t.slice(e.length)}`:t)}function j7(t){let n=new Date().getTime()-t.getTime(),i=Math.floor(n/6e4),o=Math.floor(n/36e5),r=Math.floor(n/864e5);return i<1?"now":i<60?`${i}m`:o<24?`${o}h`:r<7?`${r}d`:r<30?`${Math.floor(r/7)}w`:r<365?`${Math.floor(r/30)}mo`:`${Math.floor(r/365)}y`}function bu(t){return t&&ri(t)}var tb=class{constructor(e,n,i,o){this.loading=!1;this.loadProgress=null;this.showPath=!1;this.confirmingDeletePath=null;this.statusMessage=null;this.statusTimeout=null;this.showRenameHint=!1;this.scope=e,this.sortMode=n,this.nameFilter=i,this.requestRender=o}setScope(e){this.scope=e}setSortMode(e){this.sortMode=e}setNameFilter(e){this.nameFilter=e}setLoading(e){this.loading=e,this.loadProgress=null}setProgress(e,n){this.loadProgress={loaded:e,total:n}}setShowPath(e){this.showPath=e}setShowRenameHint(e){this.showRenameHint=e}setConfirmingDeletePath(e){this.confirmingDeletePath=e}clearStatusTimeout(){this.statusTimeout&&(clearTimeout(this.statusTimeout),this.statusTimeout=null)}setStatusMessage(e,n){this.clearStatusTimeout(),this.statusMessage=e,!(!e||!n)&&(this.statusTimeout=setTimeout(()=>{this.statusMessage=null,this.statusTimeout=null,this.requestRender()},n))}invalidate(){}render(e){let n=this.scope==="current"?"Resume Session (Current Folder)":"Resume Session (All)",i=v.bold(n),o=this.sortMode==="threaded"?"Threaded":this.sortMode==="recent"?"Recent":"Fuzzy",r=v.fg("muted","Sort: ")+v.fg("accent",o),s=this.nameFilter==="all"?"All":"Named",a=v.fg("muted","Name: ")+v.fg("accent",s),l;if(this.loading){let h=this.loadProgress?`${this.loadProgress.loaded}/${this.loadProgress.total}`:"...";l=`${v.fg("muted","\u25CB Current Folder | ")}${v.fg("accent",`Loading ${h}`)}`}else this.scope==="current"?l=`${v.fg("accent","\u25C9 Current Folder")}${v.fg("muted"," | \u25CB All")}`:l=`${v.fg("muted","\u25CB Current Folder | ")}${v.fg("accent","\u25C9 All")}`;let c=te(`${l} ${a} ${r}`,e,""),u=Math.max(0,e-j(c)-1),d=te(i,u,""),p=Math.max(0,e-j(d)-j(c)),m,g;if(this.confirmingDeletePath!==null){let h=`Delete session? ${le("tui.select.confirm","confirm")} \xB7 ${le("tui.select.cancel","cancel")}`;m=v.fg("error",te(h,e,"\u2026")),g=""}else if(this.statusMessage){let h=this.statusMessage.type==="error"?"error":"accent";m=v.fg(h,te(this.statusMessage.message,e,"\u2026")),g=""}else{let h=this.showPath?"(on)":"(off)",f=v.fg("muted"," \xB7 "),b=le("tui.input.tab","scope")+f+v.fg("muted",'re:<pattern> regex \xB7 "phrase" exact'),x=[le("app.session.toggleSort","sort"),le("app.session.toggleNamedFilter","named"),le("app.session.delete","delete"),le("app.session.togglePath",`path ${h}`)];this.showRenameHint&&x.push(le("app.session.rename","rename"));let y=x.join(f);m=te(b,e,"\u2026"),g=te(y,e,"\u2026")}return[`${d}${" ".repeat(p)}${c}`,m,g]}};function q7(t){let e=new Map;for(let r of t){let s=bu(r.path)??r.path;e.set(s,{session:r,children:[],latestActivity:r.modified.getTime()})}let n=[];for(let r of t){let s=bu(r.path)??r.path,a=e.get(s),l=bu(r.parentSessionPath);l&&e.has(l)?e.get(l).children.push(a):n.push(a)}let i=r=>{let s=r.session.modified.getTime();for(let a of r.children)s=Math.max(s,i(a));return r.latestActivity=s,s};for(let r of n)i(r);let o=r=>{r.sort((s,a)=>a.latestActivity-s.latestActivity);for(let s of r)o(s.children)};return o(n),n}function K7(t){let e=[],n=(i,o,r,s)=>{e.push({session:i.session,depth:o,isLast:s,ancestorContinues:r});for(let a=0;a<i.children.length;a++){let l=a===i.children.length-1,c=o>0?!s:!1;n(i.children[a],o+1,[...r,c],l)}};for(let i=0;i<t.length;i++)n(t[i],0,[],i===t.length-1);return e}var nb=class{constructor(e,n,i,o,r,s){this.allSessions=[];this.filteredSessions=[];this.selectedIndex=0;this.showCwd=!1;this.sortMode="threaded";this.nameFilter="all";this.showPath=!1;this.confirmingDeletePath=null;this.onExit=()=>{};this.maxVisible=10;this._focused=!1;this.allSessions=e,this.filteredSessions=[],this.searchInput=new Xe,this.showCwd=n,this.sortMode=i,this.nameFilter=o,this.keybindings=r,this.currentSessionCanonicalPath=bu(s),this.filterSessions(""),this.searchInput.onSubmit=()=>{if(this.filteredSessions[this.selectedIndex]){let a=this.filteredSessions[this.selectedIndex];this.onSelect&&this.onSelect(a.session.path)}}}getSelectedSessionPath(){return this.filteredSessions[this.selectedIndex]?.session.path}get focused(){return this._focused}set focused(e){this._focused=e,this.searchInput.focused=e}setSortMode(e){this.sortMode=e,this.filterSessions(this.searchInput.getValue())}setNameFilter(e){this.nameFilter=e,this.filterSessions(this.searchInput.getValue())}setSessions(e,n){this.allSessions=e,this.showCwd=n,this.filterSessions(this.searchInput.getValue())}filterSessions(e){let n=e.trim(),i=this.nameFilter==="all"?this.allSessions:this.allSessions.filter(o=>eb(o));if(this.sortMode==="threaded"&&!n){let o=q7(i);this.filteredSessions=K7(o)}else{let o=AI(i,e,this.sortMode,"all");this.filteredSessions=o.map(r=>({session:r,depth:0,isLast:!0,ancestorContinues:[]}))}this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredSessions.length-1))}setConfirmingDeletePath(e){this.confirmingDeletePath=e,this.onDeleteConfirmationChange?.(e)}startDeleteConfirmationForSelectedSession(){let e=this.filteredSessions[this.selectedIndex];if(e){if(this.isCurrentSessionPath(e.session.path)){this.onError?.("Cannot delete the currently active session");return}this.setConfirmingDeletePath(e.session.path)}}isCurrentSessionPath(e){return this.currentSessionCanonicalPath?(bu(e)??e)===this.currentSessionCanonicalPath:!1}invalidate(){}render(e){let n=[];if(n.push(...this.searchInput.render(e)),n.push(""),this.filteredSessions.length===0){let r;if(this.nameFilter==="named"){let s=Re("app.session.toggleNamedFilter");this.showCwd?r=` No named sessions found. Press ${s} to show all.`:r=` No named sessions in current folder. Press ${s} to show all, or Tab to view all.`}else this.showCwd?r=" No sessions found":r=" No sessions in current folder. Press Tab to view all.";return n.push(v.fg("muted",te(r,e,"\u2026"))),n}let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredSessions.length-this.maxVisible)),o=Math.min(i+this.maxVisible,this.filteredSessions.length);for(let r=i;r<o;r++){let s=this.filteredSessions[r],a=s.session,l=r===this.selectedIndex,c=a.path===this.confirmingDeletePath,u=this.isCurrentSessionPath(a.path),d=this.buildTreePrefix(s),p=!!a.name,g=(a.name??a.firstMessage).replace(/[\x00-\x1f\x7f]/g," ").trim(),h=j7(a.modified),b=`${String(a.messageCount)} ${h}`;this.showCwd&&a.cwd&&(b=`${_I(a.cwd)} ${b}`),this.showPath&&(b=`${_I(a.path)} ${b}`);let x=l?v.fg("accent","\u203A "):" ",y=j(d),T=j(b)+2,P=e-2-y-T,I=te(g,Math.max(10,P),"\u2026"),W=null;c?W="error":u?W="accent":p&&(W="warning");let D=W?v.fg(W,I):I;l&&(D=v.bold(D));let _=x+v.fg("dim",d)+D,F=j(_),O=Math.max(1,e-F-j(b)),R=v.fg(c?"error":"dim",b),E=_+" ".repeat(O)+R;l&&(E=v.bg("selectedBg",E)),n.push(te(E,e))}if(i>0||o<this.filteredSessions.length){let r=` (${this.selectedIndex+1}/${this.filteredSessions.length})`,s=v.fg("muted",te(r,e,""));n.push(s)}return n}buildTreePrefix(e){if(e.depth===0)return"";let n=e.ancestorContinues.map(o=>o?"\u2502 ":" "),i=e.isLast?"\u2514\u2500 ":"\u251C\u2500 ";return n.join("")+i}handleInput(e){let n=we();if(this.confirmingDeletePath!==null){if(n.matches(e,"tui.select.confirm")){let i=this.confirmingDeletePath;this.setConfirmingDeletePath(null),this.onDeleteSession?.(i);return}if(n.matches(e,"tui.select.cancel")){this.setConfirmingDeletePath(null);return}return}if(n.matches(e,"tui.input.tab")){this.onToggleScope&&this.onToggleScope();return}if(n.matches(e,"app.session.toggleSort")){this.onToggleSort?.();return}if(this.keybindings.matches(e,"app.session.toggleNamedFilter")){this.onToggleNameFilter?.();return}if(n.matches(e,"app.session.togglePath")){this.showPath=!this.showPath,this.onTogglePath?.(this.showPath);return}if(n.matches(e,"app.session.delete")){this.startDeleteConfirmationForSelectedSession();return}if(n.matches(e,"app.session.rename")){let i=this.filteredSessions[this.selectedIndex];i&&this.onRenameSession?.(i.session.path);return}if(n.matches(e,"app.session.deleteNoninvasive")){if(this.searchInput.getValue().length>0){this.searchInput.handleInput(e),this.filterSessions(this.searchInput.getValue());return}this.startDeleteConfirmationForSelectedSession();return}if(n.matches(e,"tui.select.up"))this.selectedIndex=Math.max(0,this.selectedIndex-1);else if(n.matches(e,"tui.select.down"))this.selectedIndex=Math.min(this.filteredSessions.length-1,this.selectedIndex+1);else if(n.matches(e,"tui.select.pageUp"))this.selectedIndex=Math.max(0,this.selectedIndex-this.maxVisible);else if(n.matches(e,"tui.select.pageDown"))this.selectedIndex=Math.min(this.filteredSessions.length-1,this.selectedIndex+this.maxVisible);else if(n.matches(e,"tui.select.confirm")){let i=this.filteredSessions[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.session.path)}else n.matches(e,"tui.select.cancel")?this.onCancel&&this.onCancel():(this.searchInput.handleInput(e),this.filterSessions(this.searchInput.getValue()))}};async function G7(t){let e=t.startsWith("-")?["--",t]:[t],n=$7("trash",e,{encoding:"utf-8"}),i=()=>{let o=[];n.error&&o.push(n.error.message);let r=n.stderr?.trim();return r&&o.push(r.split(`
230
+ `)[0]??r),o.length===0?null:`trash: ${o.join(" \xB7 ").slice(0,200)}`};if(n.status===0||!N7(t))return{ok:!0,method:"trash"};try{return await B7(t),{ok:!0,method:"unlink"}}catch(o){let r=o instanceof Error?o.message:String(o),s=i();return{ok:!1,method:"unlink",error:s?`${r} (${s})`:r}}}var ss=class extends z{constructor(n,i,o,r,s,a,l,c){super();this.canRename=!0;this.scope="current";this.sortMode="threaded";this.nameFilter="all";this.currentSessions=null;this.allSessions=null;this.currentLoading=!1;this.allLoading=!1;this.allLoadSeq=0;this.mode="list";this.renameInput=new Xe;this.renameTargetPath=null;this._focused=!1;this.keybindings=l?.keybindings??Jo.create(),this.currentSessionsLoader=n,this.allSessionsLoader=i,this.requestRender=a,this.header=new tb(this.scope,this.sortMode,this.nameFilter,this.requestRender);let u=l?.renameSession;this.renameSession=u,this.canRename=!!u,this.header.setShowRenameHint(l?.showRenameHint??this.canRename),this.sessionList=new nb([],!1,this.sortMode,this.nameFilter,this.keybindings,c),this.buildBaseLayout(this.sessionList),this.renameInput.onSubmit=p=>{this.confirmRename(p)};let d=()=>this.header.setStatusMessage(null);this.sessionList.onSelect=p=>{d(),o(p)},this.sessionList.onCancel=()=>{d(),r()},this.sessionList.onExit=()=>{d(),s()},this.sessionList.onToggleScope=()=>this.toggleScope(),this.sessionList.onToggleSort=()=>this.toggleSortMode(),this.sessionList.onToggleNameFilter=()=>this.toggleNameFilter(),this.sessionList.onRenameSession=p=>{if(!u||this.scope==="current"&&this.currentLoading||this.scope==="all"&&this.allLoading)return;let g=(this.scope==="all"?this.allSessions??[]:this.currentSessions??[]).find(h=>h.path===p);this.enterRenameMode(p,g?.name)},this.sessionList.onTogglePath=p=>{this.header.setShowPath(p),this.requestRender()},this.sessionList.onDeleteConfirmationChange=p=>{this.header.setConfirmingDeletePath(p),this.requestRender()},this.sessionList.onError=p=>{this.header.setStatusMessage({type:"error",message:p},3e3),this.requestRender()},this.sessionList.onDeleteSession=async p=>{let m=await G7(p);if(m.ok){this.currentSessions&&(this.currentSessions=this.currentSessions.filter(b=>b.path!==p)),this.allSessions&&(this.allSessions=this.allSessions.filter(b=>b.path!==p));let g=this.scope==="all"?this.allSessions??[]:this.currentSessions??[],h=this.scope==="all";this.sessionList.setSessions(g,h);let f=m.method==="trash"?"Session moved to trash":"Session deleted";this.header.setStatusMessage({type:"info",message:f},2e3),await this.refreshSessionsAfterMutation()}else{let g=m.error??"Unknown error";this.header.setStatusMessage({type:"error",message:`Failed to delete: ${g}`},3e3)}this.requestRender()},this.loadCurrentSessions()}handleInput(n){if(this.mode==="rename"){if(we().matches(n,"tui.select.cancel")){this.exitRenameMode();return}this.renameInput.handleInput(n);return}this.sessionList.handleInput(n)}get focused(){return this._focused}set focused(n){this._focused=n,this.sessionList.focused=n,this.renameInput.focused=n,n&&this.mode==="rename"&&(this.renameInput.focused=!0)}buildBaseLayout(n,i){this.clear(),this.addChild(new L(1)),this.addChild(new H(o=>v.fg("accent",o))),this.addChild(new L(1)),(i?.showHeader??!0)&&(this.addChild(this.header),this.addChild(new L(1))),this.addChild(n),this.addChild(new L(1)),this.addChild(new H(o=>v.fg("accent",o)))}loadCurrentSessions(){this.loadScope("current","initial")}enterRenameMode(n,i){this.mode="rename",this.renameTargetPath=n,this.renameInput.setValue(i??""),this.renameInput.focused=!0;let o=new z;o.addChild(new A(v.bold("Rename Session"),1,0)),o.addChild(new L(1)),o.addChild(this.renameInput),o.addChild(new L(1)),o.addChild(new A(v.fg("muted",`${Re("tui.select.confirm")} to save \xB7 ${Re("tui.select.cancel")} to cancel`),1,0)),this.buildBaseLayout(o,{showHeader:!1}),this.requestRender()}exitRenameMode(){this.mode="list",this.renameTargetPath=null,this.buildBaseLayout(this.sessionList),this.requestRender()}async confirmRename(n){let i=n.trim();if(!i)return;let o=this.renameTargetPath;if(!o){this.exitRenameMode();return}let r=this.renameSession;if(!r){this.exitRenameMode();return}try{await r(o,i),await this.refreshSessionsAfterMutation()}finally{this.exitRenameMode()}}async loadScope(n,i){let o=n==="all";n==="current"?this.currentLoading=!0:this.allLoading=!0;let r=n==="all"?++this.allLoadSeq:void 0;this.header.setScope(n),this.header.setLoading(!0),this.requestRender();let s=(a,l)=>{n===this.scope&&(r!==void 0&&r!==this.allLoadSeq||(this.header.setProgress(a,l),this.requestRender()))};try{let a=await(n==="current"?this.currentSessionsLoader(s):this.allSessionsLoader(s));if(n==="current"?(this.currentSessions=a,this.currentLoading=!1):(this.allSessions=a,this.allLoading=!1),n!==this.scope||r!==void 0&&r!==this.allLoadSeq)return;this.header.setLoading(!1),this.sessionList.setSessions(a,o),this.requestRender()}catch(a){if(n==="current"?this.currentLoading=!1:this.allLoading=!1,n!==this.scope||r!==void 0&&r!==this.allLoadSeq)return;let l=a instanceof Error?a.message:String(a);this.header.setLoading(!1),this.header.setStatusMessage({type:"error",message:`Failed to load sessions: ${l}`},4e3),i==="initial"&&this.sessionList.setSessions([],o),this.requestRender()}}toggleSortMode(){this.sortMode=this.sortMode==="threaded"?"recent":this.sortMode==="recent"?"relevance":"threaded",this.header.setSortMode(this.sortMode),this.sessionList.setSortMode(this.sortMode),this.requestRender()}toggleNameFilter(){this.nameFilter=this.nameFilter==="all"?"named":"all",this.header.setNameFilter(this.nameFilter),this.sessionList.setNameFilter(this.nameFilter),this.requestRender()}async refreshSessionsAfterMutation(){await this.loadScope(this.scope,"refresh")}toggleScope(){if(this.scope==="current"){if(this.scope="all",this.header.setScope(this.scope),this.allSessions!==null){this.header.setLoading(!1),this.sessionList.setSessions(this.allSessions,!0),this.requestRender();return}this.allLoading||this.loadScope("all","toggle");return}this.scope="current",this.header.setScope(this.scope),this.header.setLoading(this.currentLoading),this.sessionList.setSessions(this.currentSessions??[],!1),this.requestRender()}getSessionList(){return this.sessionList}};import cLe from"chalk";import*as CE from"node:crypto";import*as En from"node:fs";import*as _l from"node:os";import*as et from"node:path";import AG from"chalk";import{spawn as kb,spawnSync as _G}from"child_process";function LI(t,e,n){let i=e.usage,o=i.input+i.cacheRead+i.cacheWrite;if(!t||o<=0||i.cacheRead+i.cacheWrite===0&&!t.reportedCache)return;let r=Math.min(t.promptTokens,o)-i.cacheRead;if(r<=1024)return;let s=i.input+i.cacheWrite,a=s>0?(i.cost.input+i.cost.cacheWrite)/s:0,l=i.cacheRead>0?i.cost.cacheRead/i.cacheRead:(n.getModel(e.provider,e.model)?.cost.cacheRead??0)/1e6;return{missedTokens:r,missedCost:r*Math.max(0,a-l),idleMs:Math.max(0,e.timestamp-t.timestamp),modelChanged:`${e.provider}/${e.model}`!==t.modelKey}}function V7(t,e){let n=t.usage,i=n.input+n.cacheRead+n.cacheWrite;if(!(i<=0))return{promptTokens:i,modelKey:`${t.provider}/${t.model}`,timestamp:t.timestamp,reportedCache:e||n.cacheRead+n.cacheWrite>0}}function ib(t,e){let n,i={missedTokens:0,missedCost:0,missCount:0},o=new Map;for(let r of t){if(r.type==="compaction"||r.type==="branch_summary"){n=void 0;continue}if(r.type==="message"&&r.message.role==="assistant"){let s=LI(n,r.message,e);s&&(i.missedTokens+=s.missedTokens,i.missedCost+=s.missedCost,i.missCount+=1,o.set(r.message,s)),n=V7(r.message,n?.reportedCache??!1)??n}}return{prev:n,totals:i,misses:o}}function WI(t,e){return ib(t,e).totals}function FI(t,e){return ib(t,e).misses}function DI(t,e,n){return LI(ib(t,n).prev,e,n)}import{execFile as Q7,spawnSync as Y7}from"child_process";import{existsSync as ml,readFileSync as Fm,statSync as J7,unwatchFile as UI,watchFile as $I}from"fs";import{dirname as jI,join as hl,resolve as NI}from"path";function BI(t){let e=t;for(;;){let n=hl(e,".git");if(ml(n))try{let o=J7(n);if(o.isFile()){let r=Fm(n,"utf8").trim();if(r.startsWith("gitdir: ")){let s=NI(e,r.slice(8).trim()),a=hl(s,"HEAD");if(!ml(a))return null;let l=hl(s,"commondir"),c=ml(l)?NI(s,Fm(l,"utf8").trim()):s;return{repoDir:e,commonGitDir:c,headPath:a}}}else if(o.isDirectory()){let r=hl(n,"HEAD");return ml(r)?{repoDir:e,commonGitDir:n,headPath:r}:null}}catch{return null}let i=jI(e);if(i===e)return null;e=i}}function X7(t){let e=Y7("git",["--no-optional-locks","symbolic-ref","--quiet","--short","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]});return(e.status===0?e.stdout.trim():"")||null}function Z7(t){return new Promise(e=>{Q7("git",["--no-optional-locks","symbolic-ref","--quiet","--short","HEAD"],{cwd:t,encoding:"utf8"},(n,i)=>{if(n){e(null);return}let o=i.trim();e(o||null)})})}function eK(){return process.platform==="linux"&&!!(process.env.WSL_DISTRO_NAME||process.env.WSL_INTEROP)}function tK(t){return/^\/mnt\/[a-z](?:\/|$)/i.test(t)}function nK(t){return eK()&&tK(t)}var Dm=class t{constructor(e){this.extensionStatuses=new Map;this.cachedBranch=void 0;this.gitPaths=void 0;this.headWatcher=null;this.headWatchFilePath=null;this.headWatchFileListener=null;this.reftableWatcher=null;this.reftableTablesListWatcher=null;this.reftableTablesListPath=null;this.branchChangeCallbacks=new Set;this.availableProviderCount=0;this.refreshTimer=null;this.gitWatcherRetryTimer=null;this.refreshInFlight=!1;this.refreshPending=!1;this.disposed=!1;this.cwd=e,this.gitPaths=BI(e),this.setupGitWatcher()}static{this.WATCH_DEBOUNCE_MS=500}getGitBranch(){return this.cachedBranch===void 0&&(this.cachedBranch=this.resolveGitBranchSync()),this.cachedBranch}getExtensionStatuses(){return this.extensionStatuses}onBranchChange(e){return this.branchChangeCallbacks.add(e),()=>this.branchChangeCallbacks.delete(e)}setExtensionStatus(e,n){n===void 0?this.extensionStatuses.delete(e):this.extensionStatuses.set(e,n)}clearExtensionStatuses(){this.extensionStatuses.clear()}getAvailableProviderCount(){return this.availableProviderCount}setAvailableProviderCount(e){this.availableProviderCount=e}setCwd(e){this.cwd!==e&&(this.cwd=e,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),this.clearGitWatchers(),this.cachedBranch=void 0,this.gitPaths=BI(e),this.setupGitWatcher(),this.notifyBranchChange())}dispose(){this.disposed=!0,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),this.clearGitWatchers(),this.branchChangeCallbacks.clear()}notifyBranchChange(){for(let e of this.branchChangeCallbacks)e()}scheduleRefresh(){if(!(this.disposed||this.refreshTimer)){if(this.refreshInFlight){this.refreshPending=!0;return}this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,this.refreshGitBranchAsync()},t.WATCH_DEBOUNCE_MS)}}async refreshGitBranchAsync(){if(!this.disposed){if(this.refreshInFlight){this.refreshPending=!0;return}this.refreshInFlight=!0;try{let e=await this.resolveGitBranchAsync();if(this.disposed)return;if(this.cachedBranch!==void 0&&this.cachedBranch!==e){this.cachedBranch=e,this.notifyBranchChange();return}this.cachedBranch=e}finally{this.refreshInFlight=!1,this.refreshPending&&!this.disposed&&(this.refreshPending=!1,this.scheduleRefresh())}}}resolveGitBranchSync(){try{if(!this.gitPaths)return null;let e=Fm(this.gitPaths.headPath,"utf8").trim();if(e.startsWith("ref: refs/heads/")){let n=e.slice(16);return n===".invalid"?X7(this.gitPaths.repoDir)??"detached":n}return"detached"}catch{return null}}async resolveGitBranchAsync(){try{if(!this.gitPaths)return null;let e=Fm(this.gitPaths.headPath,"utf8").trim();if(e.startsWith("ref: refs/heads/")){let n=e.slice(16);return n===".invalid"?await Z7(this.gitPaths.repoDir)??"detached":n}return"detached"}catch{return null}}clearGitWatchers(){Br(this.headWatcher),this.headWatcher=null,this.headWatchFilePath&&this.headWatchFileListener&&(UI(this.headWatchFilePath,this.headWatchFileListener),this.headWatchFilePath=null,this.headWatchFileListener=null),Br(this.reftableWatcher),this.reftableWatcher=null,Br(this.reftableTablesListWatcher),this.reftableTablesListWatcher=null,this.reftableTablesListPath&&(UI(this.reftableTablesListPath),this.reftableTablesListPath=null),this.gitWatcherRetryTimer&&(clearTimeout(this.gitWatcherRetryTimer),this.gitWatcherRetryTimer=null)}scheduleGitWatcherRetry(){this.disposed||this.gitWatcherRetryTimer||(this.gitWatcherRetryTimer=setTimeout(()=>{this.gitWatcherRetryTimer=null,this.setupGitWatcher()},wR))}handleGitWatcherError(){this.clearGitWatchers(),this.scheduleGitWatcherRetry()}setupGitWatcher(){if(this.clearGitWatchers(),!this.gitPaths)return;let e=nK(this.gitPaths.repoDir);if(this.headWatcher=Ka(jI(this.gitPaths.headPath),(i,o)=>{(!o||o==="HEAD")&&this.scheduleRefresh()},()=>this.handleGitWatcherError()),e&&(this.headWatchFilePath=this.gitPaths.headPath,this.headWatchFileListener=(i,o)=>{(i.mtimeMs!==o.mtimeMs||i.ctimeMs!==o.ctimeMs||i.size!==o.size)&&this.scheduleRefresh()},$I(this.headWatchFilePath,{interval:1e3},this.headWatchFileListener)),!this.headWatcher&&!e)return;let n=hl(this.gitPaths.commonGitDir,"reftable");if(ml(n)){if(this.reftableWatcher=Ka(n,()=>{this.scheduleRefresh()},()=>this.handleGitWatcherError()),!this.reftableWatcher)return;let i=hl(n,"tables.list");if(ml(i)){if(this.reftableTablesListPath=i,this.reftableTablesListWatcher=Ka(i,()=>{this.scheduleRefresh()},()=>this.handleGitWatcherError()),!this.reftableTablesListWatcher)return;$I(i,{interval:250},(o,r)=>{(o.mtimeMs!==r.mtimeMs||o.ctimeMs!==r.ctimeMs||o.size!==r.size)&&this.scheduleRefresh()})}}}};var ob=[{name:"settings",description:"Open settings menu"},{name:"model",description:"Select model (opens selector UI)",argumentHint:"<provider/model>"},{name:"scoped-models",description:"Enable/disable models for Ctrl+P cycling"},{name:"export",description:"Export session (HTML default, or specify path: .html/.jsonl)"},{name:"import",description:"Import and resume a session from a JSONL file"},{name:"share",description:"Share session as a secret GitHub gist"},{name:"copy",description:"Copy last agent message to clipboard"},{name:"name",description:"Set session display name"},{name:"session",description:"Show session info and stats"},{name:"changelog",description:"Show changelog entries"},{name:"hotkeys",description:"Show all keyboard shortcuts"},{name:"fork",description:"Create a new fork from a previous user message"},{name:"clone",description:"Duplicate the current session at the current position"},{name:"tree",description:"Navigate session tree (switch branches)"},{name:"trust",description:"Save project trust decision for future sessions"},{name:"login",description:"Configure provider authentication",argumentHint:"<provider>"},{name:"logout",description:"Remove provider authentication"},{name:"new",description:"Start a new session"},{name:"compact",description:"Manually compact the session context"},{name:"resume",description:"Resume a different session"},{name:"reload",description:"Reload keybindings, extensions, skills, prompts, themes, and context files"},{name:"quit",description:`Quit ${wt}`}];import Um from"node:path";import{existsSync as iK,readFileSync as oK}from"fs";var rb="earendil-works/pi",rK="packages/coding-agent",sK=/^https:\/\/github\.com\/(?:badlogic|earendil-works)\/pi-mono(?=\/|$)/,aK=/^[a-z][a-z0-9+.-]*:/i,lK=/(!?\[[^\]\n]+\]\()([^\s)]+)((?:\s+[^)]*)?\))/g;function cK(t){return`${t.major}.${t.minor}.${t.patch}`}function uK(t){let e=typeof t=="string"?t:cK(t);return e.startsWith("v")?e:`v${e}`}function dK(t){let e=t.indexOf("#"),n=e===-1?t:t.slice(0,e),i=e===-1?"":t.slice(e),o=n.indexOf("?");return o===-1?{fragment:i,pathPart:n,query:""}:{fragment:i,pathPart:n.slice(0,o),query:n.slice(o)}}function pK(t){return t.replaceAll("\\","/")}function mK(t){let e=pK(t),n=e.startsWith("/")?Um.posix.normalize(e.replace(/^\/+/,"")):Um.posix.normalize(Um.posix.join(rK,e));if(!(n==="."||n.startsWith("../")||n===".."))return n}function hK(t,e){return t.endsWith("/")?!0:!Um.posix.basename(e).includes(".")}function gK(t,e){let n=t.replace(sK,`https://github.com/${rb}`),i=`https://github.com/${rb}`;for(let c of["blob","tree"])for(let u of["main","master"]){let d=`${i}/${c}/${u}/`;n.startsWith(d)&&(n=`${i}/${c}/${e}/${n.slice(d.length)}`)}if(n.startsWith("#")||n.startsWith("//")||aK.test(n))return n;let{fragment:o,pathPart:r,query:s}=dK(n);if(!r)return n;let a=mK(r);if(!a)return n;let l=hK(r,a)?"tree":"blob";return`https://github.com/${rb}/${l}/${e}/${encodeURI(a)}${s}${o}`}function sb(t,e){let n=uK(e);return t.replace(lK,(i,o,r,s)=>`${o}${gK(r,n)}${s}`)}function ab(t){if(!iK(t))return[];try{let n=oK(t,"utf-8").split(`
231
231
  `),i=[],o=[],r=null;for(let s of n)if(s.startsWith("## ")){r&&o.length>0&&i.push({...r,content:o.join(`
232
232
  `).trim()});let a=s.match(/##\s+\[?(\d+)\.(\d+)\.(\d+)\]?/);a?(r={major:Number.parseInt(a[1],10),minor:Number.parseInt(a[2],10),patch:Number.parseInt(a[3],10)},o=[s]):(r=null,o=[])}else r&&o.push(s);return r&&o.length>0&&i.push({...r,content:o.join(`
233
233
  `).trim()}),i}catch(e){return console.error(`Warning: Could not parse changelog: ${e}`),[]}}function fK(t,e){return t.major!==e.major?t.major-e.major:t.minor!==e.minor?t.minor-e.minor:t.patch-e.patch}function qI(t,e){let n=e.split(".").map(Number),i={major:n[0]||0,minor:n[1]||0,patch:n[2]||0,content:""};return t.filter(o=>fK(o,i)>0)}import{execSync as fl,spawn as DK}from"child_process";import{platform as UK}from"os";import{spawnSync as TK}from"child_process";import{randomUUID as CK}from"crypto";import{readFileSync as HI,unlinkSync as MK}from"fs";import{tmpdir as RK}from"os";import{join as PK}from"path";import{createRequire as KI}from"module";import{dirname as vK,join as bK}from"path";import{pathToFileURL as xK}from"url";var yK=KI(import.meta.url),wK=KI(xK(bK(vK(process.execPath),"package.json")).href),kK=process.platform!=="linux"||!!(process.env.DISPLAY||process.env.WAYLAND_DISPLAY);function SK(t=[yK,wK]){for(let e of t)try{return e("@mariozechner/clipboard")}catch{}return null}var co=!process.env.TERMUX_VERSION&&kK?SK():null;var $m=["image/png","image/jpeg","image/webp","image/gif"],lb=1e3,IK=3e3,EK=5e3,AK=50*1024*1024;function cb(t=process.env){return!!t.WAYLAND_DISPLAY||t.XDG_SESSION_TYPE==="wayland"}function xu(t){return t.split(";")[0]?.trim().toLowerCase()??t.toLowerCase()}function VI(t){switch(xu(t)){case"image/png":return"png";case"image/jpeg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";default:return null}}function QI(t){let e=t.map(i=>i.trim()).filter(Boolean).map(i=>({raw:i,base:xu(i)}));for(let i of $m){let o=e.find(r=>r.base===i);if(o)return o.raw}return e.find(i=>i.base.startsWith("image/"))?.raw??null}function _K(t){let e=xu(t);return $m.some(n=>n===e)}async function OK(t){let e=await al();if(!e)return null;try{let n=e.PhotonImage.new_from_byteslice(t);try{return n.get_bytes()}finally{n.free()}}catch{return null}}function gl(t,e,n){let i=n?.timeoutMs??IK,o=n?.maxBufferBytes??AK,r=TK(t,e,{timeout:i,maxBuffer:o,env:n?.env});return r.error?{ok:!1,stdout:Buffer.alloc(0)}:r.status!==0?{ok:!1,stdout:Buffer.alloc(0)}:{ok:!0,stdout:Buffer.isBuffer(r.stdout)?r.stdout:Buffer.from(r.stdout??"",typeof r.stdout=="string"?"utf-8":void 0)}}function LK(){let t=gl("wl-paste",["--list-types"],{timeoutMs:lb});if(!t.ok)return null;let e=t.stdout.toString("utf-8").split(/\r?\n/).map(o=>o.trim()).filter(Boolean),n=QI(e);if(!n)return null;let i=gl("wl-paste",["--type",n,"--no-newline"]);return!i.ok||i.stdout.length===0?null:{bytes:i.stdout,mimeType:xu(n)}}function WK(t=process.env){if(t.WSL_DISTRO_NAME||t.WSLENV)return!0;try{let e=HI("/proc/version","utf-8");return/microsoft|wsl/i.test(e)}catch{return!1}}function FK(){let t=PK(RK(),`pi-wsl-clip-${CK()}.png`);try{let e=gl("wslpath",["-w",t],{timeoutMs:lb});if(!e.ok)return null;let n=e.stdout.toString("utf-8").trim();if(!n)return null;let o=["Add-Type -AssemblyName System.Windows.Forms","Add-Type -AssemblyName System.Drawing",`$path = '${n.replaceAll("'","''")}'`,"$img = [System.Windows.Forms.Clipboard]::GetImage()","if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }"].join("; "),r=gl("powershell.exe",["-NoProfile","-Command",o],{timeoutMs:EK});if(!r.ok||r.stdout.toString("utf-8").trim()!=="ok")return null;let a=HI(t);return a.length===0?null:{bytes:new Uint8Array(a),mimeType:"image/png"}}catch{return null}finally{try{MK(t)}catch{}}}function GI(){let t=gl("xclip",["-selection","clipboard","-t","TARGETS","-o"],{timeoutMs:lb}),e=[];t.ok&&(e=t.stdout.toString("utf-8").split(/\r?\n/).map(o=>o.trim()).filter(Boolean));let n=e.length>0?QI(e):null,i=n?[n,...$m]:[...$m];for(let o of i){let r=gl("xclip",["-selection","clipboard","-t",o,"-o"]);if(r.ok&&r.stdout.length>0)return{bytes:r.stdout,mimeType:xu(o)}}return null}async function zI(){if(!co||!co.hasImage())return null;let t=await co.getImageBinary();return!t||t.length===0?null:{bytes:t instanceof Uint8Array?t:Uint8Array.from(t),mimeType:"image/png"}}async function YI(t){let e=t?.env??process.env,n=t?.platform??process.platform;if(e.TERMUX_VERSION)return null;let i=null;if(n==="linux"){let o=WK(e),r=cb(e);(r||o)&&(i=LK()??GI()),!i&&o&&(i=FK()),!i&&!r&&(i=await zI()??GI())}else i=await zI();if(!i)return null;if(!_K(i.mimeType)){let o=await OK(i.bytes);return o?{bytes:o,mimeType:"image/png"}:null}return i}function JI(t){try{fl("xclip -selection clipboard",t)}catch{fl("xsel --clipboard --input",t)}}var $K=1e5;function NK(t=process.env){return!!(t.SSH_CONNECTION||t.SSH_CLIENT||t.MOSH_CONNECTION)}function BK(t){let e=Buffer.from(t).toString("base64");return e.length>$K?!1:(process.stdout.write(`\x1B]52;c;${e}\x07`),!0)}async function XI(){if(!co)return null;try{return await co.getText()||null}catch{return null}}async function vl(t){let e=!1,n=UK();try{co&&n!=="linux"&&(await co.setText(t),e=!0)}catch{}let i=NK();if(e&&!i)return;let o={input:t,timeout:5e3,stdio:["pipe","ignore","ignore"]};if(!e)try{if(n==="darwin")fl("pbcopy",o),e=!0;else if(n==="win32")fl("clip",o),e=!0;else{if(process.env.TERMUX_VERSION)try{fl("termux-clipboard-set",o),e=!0}catch{}if(!e){let r=!!process.env.WAYLAND_DISPLAY,s=!!process.env.DISPLAY;if(cb()&&r)try{fl("which wl-copy",{stdio:"ignore"});let l=DK("wl-copy",[],{stdio:["pipe","ignore","ignore"]});l.stdin.on("error",()=>{}),l.stdin.write(t),l.stdin.end(),l.unref(),e=!0}catch{s&&(JI(o),e=!0)}else s&&(JI(o),e=!0)}}}catch{}if(i||!e){let r=BK(t);e=e||r}if(!e)throw new Error("Failed to copy to clipboard")}import{compare as jK,valid as ZI}from"semver";var qK="https://pi.dev/api/latest-version",KK=1e4;function GK(t,e){let n=ZI(t.trim()),i=ZI(e.trim());if(!(!n||!i))return jK(n,i)}function eE(t,e){let n=GK(t,e);return n!==void 0?n>0:t.trim()!==e.trim()}async function tE(t,e={}){if(process.env.PI_SKIP_VERSION_CHECK||process.env.PI_OFFLINE)return;let n=await fetch(qK,{headers:{"User-Agent":cu(t),accept:"application/json"},signal:AbortSignal.timeout(e.timeoutMs??KK)});if(!n.ok)return;let i=await n.json();if(typeof i.version!="string"||!i.version.trim())return;let o=typeof i.packageName=="string"&&i.packageName.trim()?i.packageName.trim():void 0,r=typeof i.note=="string"&&i.note.trim()?i.note.trim():void 0;return{version:i.version.trim(),packageName:o,...r?{note:r}:{}}}async function nE(t){try{let e=await tE(t);return e&&eE(e.version,t)?e:void 0}catch{return}}var In=31,rE=36,zK=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,255,7,140,124,255,15,206,120,255,255,207,127,255,255,207,120,255,255,223,120,255,255,223,125,255,255,63,126,255,255,255,127],HK=Math.ceil(In/8),Mt=Math.ceil(rE/2),iE=["typewriter","scanline","rain","fade","crt","glitch","dissolve"];function oE(t,e){if(e>=rE)return!1;let n=e*HK+Math.floor(t/8),i=t%8;return(zK[n]>>i&1)===0}function VK(t,e){let n=oE(t,e*2),i=oE(t,e*2+1);return n&&i?"\u2588":n?"\u2580":i?"\u2584":" "}function QK(){let t=[];for(let e=0;e<Mt;e++){let n=[];for(let i=0;i<In;i++)n.push(VK(i,e));t.push(n)}return t}var bl=class{constructor(e){this.interval=null;this.effectState={};this.cachedLines=[];this.cachedWidth=0;this.gridVersion=0;this.cachedVersion=-1;this.ui=e,this.effect=iE[Math.floor(Math.random()*iE.length)],this.finalGrid=QK(),this.currentGrid=this.createEmptyGrid(),this.initEffect(),this.startAnimation()}invalidate(){this.cachedWidth=0}render(e){if(e===this.cachedWidth&&this.cachedVersion===this.gridVersion)return this.cachedLines;let n=1,i=e-n;this.cachedLines=this.currentGrid.map(s=>{let a=s.slice(0,i).join(""),l=Math.max(0,e-n-a.length);return` ${v.fg("accent",a)}${" ".repeat(l)}`});let o="ARMIN SAYS HI",r=Math.max(0,e-n-o.length);return this.cachedLines.push(` ${v.fg("accent",o)}${" ".repeat(r)}`),this.cachedWidth=e,this.cachedVersion=this.gridVersion,this.cachedLines}createEmptyGrid(){return Array.from({length:Mt},()=>Array(In).fill(" "))}initEffect(){switch(this.effect){case"typewriter":this.effectState={pos:0};break;case"scanline":this.effectState={row:0};break;case"rain":this.effectState={drops:Array.from({length:In},()=>({y:-Math.floor(Math.random()*Mt*2),settled:0}))};break;case"fade":{let e=[];for(let n=0;n<Mt;n++)for(let i=0;i<In;i++)e.push([n,i]);for(let n=e.length-1;n>0;n--){let i=Math.floor(Math.random()*(n+1));[e[n],e[i]]=[e[i],e[n]]}this.effectState={positions:e,idx:0};break}case"crt":this.effectState={expansion:0};break;case"glitch":this.effectState={phase:0,glitchFrames:8};break;case"dissolve":{this.currentGrid=Array.from({length:Mt},()=>Array.from({length:In},()=>{let n=[" ","\u2591","\u2592","\u2593","\u2588","\u2580","\u2584"];return n[Math.floor(Math.random()*n.length)]}));let e=[];for(let n=0;n<Mt;n++)for(let i=0;i<In;i++)e.push([n,i]);for(let n=e.length-1;n>0;n--){let i=Math.floor(Math.random()*(n+1));[e[n],e[i]]=[e[i],e[n]]}this.effectState={positions:e,idx:0};break}}}startAnimation(){let e=this.effect==="glitch"?60:30;this.interval=setInterval(()=>{let n=this.tickEffect();this.updateDisplay(),this.ui.requestRender(),n&&this.stopAnimation()},1e3/e)}stopAnimation(){this.interval&&(clearInterval(this.interval),this.interval=null)}tickEffect(){switch(this.effect){case"typewriter":return this.tickTypewriter();case"scanline":return this.tickScanline();case"rain":return this.tickRain();case"fade":return this.tickFade();case"crt":return this.tickCrt();case"glitch":return this.tickGlitch();case"dissolve":return this.tickDissolve();default:return!0}}tickTypewriter(){let e=this.effectState,n=3;for(let i=0;i<n;i++){let o=Math.floor(e.pos/In),r=e.pos%In;if(o>=Mt)return!0;this.currentGrid[o][r]=this.finalGrid[o][r],e.pos++}return!1}tickScanline(){let e=this.effectState;if(e.row>=Mt)return!0;for(let n=0;n<In;n++)this.currentGrid[e.row][n]=this.finalGrid[e.row][n];return e.row++,!1}tickRain(){let e=this.effectState,n=!0;this.currentGrid=this.createEmptyGrid();for(let i=0;i<In;i++){let o=e.drops[i];for(let s=Mt-1;s>=Mt-o.settled;s--)s>=0&&(this.currentGrid[s][i]=this.finalGrid[s][i]);if(o.settled>=Mt)continue;n=!1;let r=-1;for(let s=Mt-1-o.settled;s>=0;s--)if(this.finalGrid[s][i]!==" "){r=s;break}o.y++,o.y>=0&&o.y<Mt&&(r>=0&&o.y>=r?(o.settled=Mt-r,o.y=-Math.floor(Math.random()*5)-1):this.currentGrid[o.y][i]="\u2593")}return n}tickFade(){let e=this.effectState,n=15;for(let i=0;i<n;i++){if(e.idx>=e.positions.length)return!0;let[o,r]=e.positions[e.idx];this.currentGrid[o][r]=this.finalGrid[o][r],e.idx++}return!1}tickCrt(){let e=this.effectState,n=Math.floor(Mt/2);this.currentGrid=this.createEmptyGrid();let i=n-e.expansion,o=n+e.expansion;for(let r=Math.max(0,i);r<=Math.min(Mt-1,o);r++)for(let s=0;s<In;s++)this.currentGrid[r][s]=this.finalGrid[r][s];return e.expansion++,e.expansion>Mt}tickGlitch(){let e=this.effectState;return e.phase<e.glitchFrames?(this.currentGrid=this.finalGrid.map(n=>{let i=Math.floor(Math.random()*7)-3,o=[...n];if(Math.random()<.3)return o.slice(i).concat(o.slice(0,i)).slice(0,In);if(Math.random()<.2){let r=Math.floor(Math.random()*Mt);return[...this.finalGrid[r]]}return o}),e.phase++,!1):(this.currentGrid=this.finalGrid.map(n=>[...n]),!0)}tickDissolve(){let e=this.effectState,n=20;for(let i=0;i<n;i++){if(e.idx>=e.positions.length)return!0;let[o,r]=e.positions[e.idx];this.currentGrid[o][r]=this.finalGrid[o][r],e.idx++}return!1}updateDisplay(){this.gridVersion++}dispose(){this.stopAnimation()}};var YK="\x1B]133;A\x07",JK="\x1B]133;B\x07",XK="\x1B]133;C\x07",_i=class extends z{constructor(n,i=!1,o=Ft(),r="Thinking...",s=1){super();this.hasToolCalls=!1;this.hideThinkingBlock=i,this.markdownTheme=o,this.hiddenThinkingLabel=r,this.outputPad=s,this.contentContainer=new z,this.addChild(this.contentContainer),n&&this.updateContent(n)}invalidate(){super.invalidate(),this.lastMessage&&this.updateContent(this.lastMessage)}setHideThinkingBlock(n){this.hideThinkingBlock=n,this.lastMessage&&this.updateContent(this.lastMessage)}setHiddenThinkingLabel(n){this.hiddenThinkingLabel=n,this.lastMessage&&this.updateContent(this.lastMessage)}setOutputPad(n){this.outputPad=n,this.lastMessage&&this.updateContent(this.lastMessage)}render(n){let i=super.render(n);return this.hasToolCalls||i.length===0||(i[0]=YK+i[0],i[i.length-1]=JK+XK+i[i.length-1]),i}updateContent(n){this.lastMessage=n,this.contentContainer.clear(),n.content.some(r=>r.type==="text"&&r.text.trim()||r.type==="thinking"&&r.thinking.trim())&&this.contentContainer.addChild(new L(1));for(let r=0;r<n.content.length;r++){let s=n.content[r];if(s.type==="text"&&s.text.trim())this.contentContainer.addChild(new Ze(s.text.trim(),this.outputPad,0,this.markdownTheme));else if(s.type==="thinking"){let a=[];for(;r<n.content.length;r++){let c=n.content[r];if(c.type!=="thinking")break;let u=c.thinking.trim();u&&a.push(u)}if(r--,a.length===0)continue;let l=n.content.slice(r+1).some(c=>c.type==="text"&&c.text.trim()||c.type==="thinking"&&c.thinking.trim());this.hideThinkingBlock?this.contentContainer.addChild(new A(v.italic(v.fg("thinkingText",this.hiddenThinkingLabel)),this.outputPad,0)):this.contentContainer.addChild(new Ze(a.join(`
@@ -249,16 +249,16 @@ ${l.join(`
249
249
  `;this.addChild(new Ze(i+this.message.summary,0,0,this.markdownTheme,{color:o=>v.fg("customMessageText",o)}))}else this.addChild(new A(v.fg("customMessageText","Branch summary (")+v.fg("dim",Re("app.tools.expand"))+v.fg("customMessageText"," to expand)"),0,0))}};var wl=class extends pt{constructor(n,i=Ft()){super(1,1,o=>v.bg("customMessageBg",o));this.expanded=!1;this.message=n,this.markdownTheme=i,this.updateDisplay()}setExpanded(n){this.expanded=n,this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){this.clear();let n=this.message.tokensBefore.toLocaleString(),i=v.fg("customMessageLabel","\x1B[1m[compaction]\x1B[22m");if(this.addChild(new A(i,0,0)),this.addChild(new L(1)),this.expanded){let o=`**Compacted from ${n} tokens**
250
250
 
251
251
  `;this.addChild(new Ze(o+this.message.summary,0,0,this.markdownTheme,{color:r=>v.fg("customMessageText",r)}))}else this.addChild(new A(v.fg("customMessageText",`Compacted from ${n} tokens (`)+v.fg("dim",Re("app.tools.expand"))+v.fg("customMessageText"," to expand)"),0,0))}};var er=class extends Dr{constructor(n,i,o,r){super(n,i,r);this.actionHandlers=new Map;this.keybindings=o}onAction(n,i){this.actionHandlers.set(n,i)}handleInput(n){if(!this.onExtensionShortcut?.(n)){if(this.keybindings.matches(n,"app.clipboard.pasteImage")){this.onPasteImage?.();return}if(this.keybindings.matches(n,"app.interrupt")){if(!this.isShowingAutocomplete()){let i=this.onEscape??this.actionHandlers.get("app.interrupt");if(i){i();return}}super.handleInput(n);return}if(this.keybindings.matches(n,"app.exit")&&this.getText().length===0){let i=this.onCtrlD??this.actionHandlers.get("app.exit");i&&i();return}for(let[i,o]of this.actionHandlers)if(i!=="app.interrupt"&&i!=="app.exit"&&this.keybindings.matches(n,i)){o();return}super.handleInput(n)}}};var Nm=class extends z{constructor(n,i){super();this._expanded=!1;this.entry=n,this.renderer=i,this.rebuild()}hasContent(){return this.customComponent!==void 0}setExpanded(n){this._expanded!==n&&(this._expanded=n,this.rebuild())}invalidate(){super.invalidate(),this.rebuild()}rebuild(){this.clear(),this.customComponent=void 0;let n;try{n=this.renderer(this.entry,{expanded:this._expanded},v)}catch(i){let o=i instanceof Error?i.message:String(i),r=new pt(1,1,s=>v.bg("customMessageBg",s));r.addChild(new A(v.fg("error",`[${this.entry.customType}] renderer failed: ${o}`),0,0)),n=r}n&&(this.customComponent=n,this.addChild(new L(1)),this.addChild(n))}};var kl=class extends z{constructor(n,i,o=Ft()){super();this._expanded=!1;this.message=n,this.customRenderer=i,this.markdownTheme=o,this.addChild(new L(1)),this.box=new pt(1,1,r=>v.bg("customMessageBg",r)),this.rebuild()}setExpanded(n){this._expanded!==n&&(this._expanded=n,this.rebuild())}invalidate(){super.invalidate(),this.rebuild()}rebuild(){if(this.customComponent&&(this.removeChild(this.customComponent),this.customComponent=void 0),this.removeChild(this.box),this.customRenderer)try{let o=this.customRenderer(this.message,{expanded:this._expanded},v);if(o){this.customComponent=o,this.addChild(o);return}}catch{}this.addChild(this.box),this.box.clear();let n=v.fg("customMessageLabel",`\x1B[1m[${this.message.customType}]\x1B[22m`);this.box.addChild(new A(n,0,0)),this.box.addChild(new L(1));let i;typeof this.message.content=="string"?i=this.message.content:i=this.message.content.filter(o=>o.type==="text").map(o=>o.text).join(`
252
- `),this.box.addChild(new Ze(i,0,0,this.markdownTheme,{color:o=>v.fg("customMessageText",o)}))}};var ub="bbbab8b9b9b6b9b8b5bcbbb8b8b7b4b7b5b2b6b5b2b8b7b4b7b6b3b6b4b1bdbcb8bab8b6bbb8b5b8b5b1bbb8b4c2bebbc1bebac0bdbabfbcb9c1bebabfbebbc0bfbcc0bdbabbb8b5c1bfbcbfbcb8bbb9b6bfbcb8c2bfbcc1bfbcbfbbb8bdb9b6b8b7b5b9b8b5b8b8b5b5b5b2b6b5b2b8b7b4b9b8b5b9b8b5b6b5b3bab8b5bcbab7bbb9b6bbb8b5bfb9b5bdb2abbcb0a8beb2aabeb5afbfbab6bebab7c0bfbcbebdbabebbb8c0bdbabfbebbc2bebbbdbab7c3c0bdc3c0bdc1bebbc2bebabfbcb8bab9b6b7b6b3b2b1aeb6b5b2b5b4b1b5b4b2b6b5b2b7b6b4b9b8b6b7b6b3bbbab7b2afaba5988fb49e90b09481b79a88b39683b09583b7a395bfb6b0c0bdbabdbbb8bebcb9c1bfbcc0bebbbdbab7bebbb8c2bfbcc0bdbac0bcb9bdb9b6c0bcb8b5b4b2b4b3b0bab9b6b9b9b6b5b4b1b5b4b1b6b5b3b9b8b5b9b8b6b9b8b6b2aeaa968174a6836eaa856eab846eaf8973ac8973b08f79b18f7ab39786b7a89dbbb3aebfbab6c2c0bdbebcb9bfbdbac3c1bdc2bebbc0bcb9bdb9b6c1bdbabfbbb8b4b3b0b9b8b5b8b7b5b4b3b1b5b4b1b8b7b4b8b7b5bab9b6bbbab7b1afad8c7a719d735ca47860a87d65a98069ae8972ae8c75af8d77aa826ba98067aa8974b39e90b6a79dbbb2adc0bdbac1bfbdbfbbb8c1bdb9bebab6c0bdb9bfbbb8c1bdbab4b2b0b7b6b4b7b6b3b4b2b0bab9b7b6b5b2b6b5b2bab9b6bab9b6958c87977663aa836bac8772b08f7aad8c77b2917db0917db0907cac8971a77d64a87f67ac8972b29887b8a89dbfbab5bfbdbac1bebac0bcb9c0bcb9c0bcb9c1bebabebab7b8b7b4b7b6b4b5b4b1b5b4b2b7b6b3b5b4b2bab9b7bab9b6b4b1ada88f7fad8973ae8d78b19684b19685b29786b69a89b29582b1917daa856ea87e66a97e66ad866ea9826baf9280b8ada6bdbbb8bebab7bfbbb8c1bdbabfbbb8bcb8b4bcb8b5b6b4b2b7b5b3b6b5b2b8b7b4b3b2afb8b7b4b6b5b2b3b2b0b3a59aab856fad8d78b0917eb19886b49b8bb49a89b39785b0917eaf8f7cab866fa77d65a77a61a87d64a9816ab08f79b5a296c1bcb8c3bfbcc2bebbbebab7bfbbb7bdbab6c2bebab8b7b4b7b6b4b6b5b3b7b6b3b6b5b2b9b8b6b4b3b1b6b1acac8f7ca9826bae8f7aaf9583b49c8cb49c8bb79d8cb59987b19380ad8e79ae8c77af8e78ac8771a3775faa826bae8972b39888bbb6b2bebbb8bfbbb8bfbbb8c0bdb9bebbb7c0bdb9b6b5b2b9b8b5b4b3b1b8b7b5b4b3b0b7b6b4b6b5b3b1a7a0aa8772a77d65a88570b49887b19b8d9c887c907a6d987f71aa907faf917daf8e7aad8c78ac8b77a8836ca9836cac8770b49b8abdb6b2c0bcb9c0bdb9bfbbb8bebab7bfbcb9bebab7b9b8b6b5b4b2b9b8b5b8b7b5b8b7b4b7b6b4b5b4b2b3a9a2ad8973a1755da9856fb398858c776a65544b776358725d526e594d9c7f6eb1907ba68672ad8e7aab8771ac856db18f79b3a092beb9b5c1bdbabdb9b5bebab7bfbbb7bebab7bcb9b6b7b6b4b6b6b3b8b7b4b5b4b2b8b6b4b7b6b3b4b3b0b4aba4a6826ba3775fb08e79b19584a88e7daa8e7db29481ad8f7c997e6da38674ac8d79ac8e7aae917f9a7c6a896a599a7c6ab3a398c1bdbabdb9b6bcb8b5bebab6bebab7bdb9b5bdb9b6b5b4b1b7b5b3b5b4b2b7b6b3b7b6b4b3b3b0b3b2b0b4aca5a7846fa97f68ae8f7bae9383b59c8bb2937fae8e79ac8b76af927eaf927eb29683b39885b2988891786a72594c6e594d978d86bdbab7bab7b3c0bcb9c0bcb9bebab7bebbb7bdb9b6b3b2b0b4b3b0b5b4b2b4b4b1b4b3b1b4b3b1b4b3b0b6ada5aa8670a57a62ad8e7ab29b8cb69d8dab856fa9826aa88069ab8771af907db49987b19684b29886b59987b39480b09787b5a9a1bcb8b5bebab7bdb9b5bebab7bfbbb8bfbbb7bbb7b4b3b2afb8b7b5b8b7b5b3b2b0b5b4b2b6b5b3b6b4b1afa299a98975a9826baf907cb39988b49a89af8e7aac8973aa856eaf8c74b1917dae907dac907db39988b29785b49785b7a090b9aca3bfbab7bcb8b5bdb9b6bcb8b4bcb8b5bdb9b5bcb8b4b5b4b2b6b5b3b4b3b0b4b3b0b9b8b5b8b6b4908b88887467aa8f7ea78976ad8973b08b74b59885b69e8eb29888b1917cb1917db1937fae907cb19686b39a8ab29886b59b8ab8a192b6aaa3b7b2afbcb8b4bcb8b5bbb7b4c0bcb9bebab7c0bcb9b6b5b2b6b5b3b4b3b0bab9b7b7b6b4b1b0ae7b716ba083709b806f716158967764b08870b29481b69b8ab69f8fb39a89b69f90b49d8db39a89b29988b49c8cb6a090b8a496baa49593867f8f8986bfbbb7bdb9b5bcb7b4bab6b3b9b5b2bab6b2b4b3b1b3b3b0b6b5b3b8b7b5b4b2b0a7a5a38f837dae917ea084725a504c63544da28370b39784b59e8db2a093a698909b918b998e8790857e95877dad998bb39c8cb5a091b9a2938d827c95908dbebab6bbb7b3bdbab7bbb7b4bdb9b6bbb7b4b4b3b0b5b4b1b8b7b5b6b5b3b8b8b5b4b2af968f8ab29a8bab9485544b483a323073655d96887f70655f61595547403e453e3c453f3d57504f655e5b90847db39c8db7a090b6a09189807aaba6a3bdb9b6c0bcb9bebab7bcb7b4bebab7bbb7b4b3b2b0b6b5b3b2b1afb7b6b4b8b7b4b5b4b1aeaba8b5a89fac998d4d44412d25244d46444e4744322b293a3230423937433a37352d2a59504c534b48524a48988a81b59f8fb19c8d827974b2afacbdb9b5bcb8b4bdb9b5bcb8b5bdb9b6bab6b2b8b7b5b5b4b2b6b6b3b9b8b5b7b6b3b6b5b2b8b6b3b9b4b1b2a9a26c64612d25242d2625312a28352d2c453d3a78675c8d7a6ea09792aea6a0615854332b29524a479f8e82b09d90a49b96c1bdb9bebab7bfbbb8bbb8b4b9b5b1b8b4b0b9b4b0b7b6b4b8b7b5b8b7b4b6b5b3b8b6b3bab9b6b9b8b5b4b3b0b7b5b2a5a29f453d3b261e1d261f1e2e2625413936857268977865b19482b5a69caca5a07c7572453d3b746963a0948cc5bfbbc0bbb8beb9b6bbb7b3bbb6b3b7b3afb8b4b0b9b5b1b7b6b3b6b5b3b5b4b2b5b4b2b7b6b3b7b6b3b8b6b3b4b2afb7b6b3b3b1ae6d6765251f1e1e18172a22212d2523443b3971625ab19888b09482a89182877e792c25243e3634766d6abeb9b5bfbbb7bebab6bcb7b3bbb6b3b9b5b1b7b3afb8b4b0b4b3b0b5b4b1b5b4b1b4b3b1b5b4b2b8b6b4b5b3b0b9b6b4b5b4b1b6b4b27f79762a2322221c1b2d2524221b1a443e3c47413f6f676281766f867971675e5a3e37352a222166605dbab7b3bdb9b5beb9b5bcb7b3bcb7b3b9b4b0bab6b2bab6b2b5b3b0b6b4b2b3b2afb7b6b3b4b4b1b4b3b0b6b4b1b5b4b1b4b3b0b9b6b29a8c8252474230292828201f181212322c2c231e1d1c16162c26252923222d26252d2523332b2a8e8885bcb8b5bcb7b3bbb6b2bcb7b3b9b4b1b9b5b1b7b2afb7b2ae7a838e9b9b9caeadacb3b2b0b3b2afb7b7b4b6b5b3b6b6b3b7b6b3b9ada4a991808e7b6f50453f2b24231a14142923221f19181d17161f18182620201d17162a22215d5654b7b3b0bbb7b3bbb6b2b8b4b0bab5b1bbb6b2bab5b1b8b4b0bab6b22c496b4c5d735f68766e727a828285929090adaba8b7b2aeb6a59ab39682a28470a387748e76674e403a1a14141d1716181211221c1c1f1918221c1b2f2827342d2c8d8884bab6b3b9b5b2bab5b1bab5b1b9b4b0bab6b2b8b4b0b9b4b0b7b2ae325e8b365f8a3a5d833f5b7a545f70646469706b6aa08f84b08e78b18e769f7e689e7f6b9e816d907766584940362d2a1c1615201b1a1a1413201a1a251e1d393331a39e9bbab5b1bcb7b3bab6b2b8b3afb8b4b0b9b4b0b9b4b1bab5b2b5b0ac3d6c9843729d44719c426e98415f805a64716f6a699d8677b1927eb3947faa89749d7a649f7f6ba487749e837186716454463f2c25231e181837302e3a33317a7471beb9b6bcb8b4bbb6b2b6b2aebab5b1b9b5b1b8b3afbab6b2b6b1adb5aeaa4877a14c7aa44e7ba345719a3a5d80586b7f767475927b6eb1927faf8e79b08e78a78169a07861a17f6aa58570a688749b83738270666f66618a8480a49e99b7b2aebab6b2bcb8b4b9b5b1b7b2aebab5b1b9b4b0b6b1aeb6b1adb2aca8b2aca84876a04a78a2517fa74771973a5d80405c7a6161677c695fac8a75b08d77b4917aaf8971ad876fa5816aa6846ea78670a98a76ac9484ab9f96b2aca8bdb8b4bcb7b3bcb8b4bcb8b4b8b3afb7b2aeb9b4b0b8b3afb8b2aeb6afabb3aeaab2aeaa4878a14b7aa34c7ba44a759b3d63873b5f825b67766f5f569c7e6caf8c77b18f79b28f78b5927caf8e78a98872aa8a76a98a76ac917fada199b7b0acb9b3afbfb9b5c1bab6bdb6b2b8b3afbab5b1b9b4b0b6afabb7b1adb3ada9b3aeaab0aba8",yu=32,aE=32;function ZK(){let t=[];for(let e=0;e<aE;e++){let n=[];for(let i=0;i<yu;i++){let o=(e*yu+i)*6,r=parseInt(ub.slice(o,o+2),16),s=parseInt(ub.slice(o+2,o+4),16),a=parseInt(ub.slice(o+4,o+6),16);n.push([r,s,a])}t.push(n)}return t}function db(t,e,n,i=!1){return`\x1B[${i?48:38};2;${t};${e};${n}m`}var lE="\x1B[0m";function eG(){let t=ZK(),e=[];for(let n=0;n<aE;n+=2){let i="";for(let o=0;o<yu;o++){let r=t[n][o],s=t[n+1]?.[o]??r;i+=`${db(s[0],s[1],s[2])}${db(r[0],r[1],r[2],!0)}\u2584`}i+=lE,e.push(i)}return e}var wu=class{constructor(e){this.interval=null;this.tick=0;this.maxTicks=25;this.cachedLines=[];this.cachedWidth=0;this.cachedTick=-1;this.ui=e,this.image=eG(),this.startAnimation()}invalidate(){this.cachedWidth=0}startAnimation(){this.interval=setInterval(()=>{this.tick++,this.tick>=this.maxTicks&&this.stopAnimation(),this.cachedWidth=0,this.ui.requestRender()},80)}stopAnimation(){this.interval&&(clearInterval(this.interval),this.interval=null)}render(e){if(e===this.cachedWidth&&this.cachedTick===this.tick)return this.cachedLines;let n=v,i=[],o=a=>{let l=a.replace(/\x1b\[[0-9;]*m/g,"").length,c=Math.max(0,Math.floor((e-l)/2));return" ".repeat(c)+a};i.push("");let r=Math.min(this.image.length,Math.floor(this.tick/this.maxTicks*(this.image.length+3)));for(let a=0;a<this.image.length;a++)if(a<r)i.push(o(this.image[a]));else if(a===r){let l="\u2593".repeat(yu);i.push(o(db(100,200,255)+l+lE))}else i.push(o(" ".repeat(yu)));i.push("");let s=Math.max(0,this.tick-this.maxTicks*.6);return s>0||this.tick>=this.maxTicks?(i.push(o(n.fg("accent","Free Kimi K2.5 via OpenCode Zen"))),i.push(o(n.fg("success",'"Powered by daxnuts"'))),i.push(o(n.fg("muted","\u2014 @thdxr")))):(i.push(""),i.push(""),i.push("")),i.push(""),s>2||this.tick>=this.maxTicks?(i.push(o(n.fg("dim","Try OpenCode"))),i.push(o(n.fg("mdLink","https://mistral.ai/news/mistral-vibe-2-0")))):(i.push(""),i.push("")),i.push(""),this.cachedLines=i,this.cachedWidth=e,this.cachedTick=this.tick,i}dispose(){this.stopAnimation()}};import*as uE from"node:fs";var tG="https://mariozechner.at/posts/2026-04-08-ive-sold-out/",dE="clankolas.png",Bm,cE=!1;function nG(){if(cE)return Bm;cE=!0;try{Bm=uE.readFileSync(iS(dE)).toString("base64")}catch{Bm=void 0}return Bm}var jm=class extends z{constructor(){super(),this.addChild(new H(n=>v.fg("accent",n))),this.addChild(new A(v.bold(v.fg("accent","pi has joined Earendil")),1,0)),this.addChild(new L(1)),this.addChild(new A(v.fg("muted","Read the blog post:"),1,0)),this.addChild(new A(v.fg("mdLink",tG),1,0)),this.addChild(new L(1));let e=nG();e&&(this.addChild(new Ur(e,"image/png",{fallbackColor:n=>v.fg("muted",n)},{maxWidthCells:56,filename:dE})),this.addChild(new L(1))),this.addChild(new H(n=>v.fg("accent",n)))}};import{spawn as iG}from"node:child_process";import*as Tl from"node:fs";import*as pE from"node:os";import*as mE from"node:path";var Sl=class extends z{constructor(n,i,o,r,s,a,l,c){super();this._focused=!1;this.tui=n,this.keybindings=i,this.externalEditorCommand=c,this.onSubmitCallback=s,this.onCancelCallback=a,this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",o),1,0)),this.addChild(new L(1)),this.editor=new Dr(n,Kc(),l),r&&this.editor.setText(r),this.editor.onSubmit=p=>{this.onSubmitCallback(p)},this.addChild(this.editor),this.addChild(new L(1));let u=!!this.getExternalEditorCommand(),d=le("tui.select.confirm","submit")+" "+le("tui.input.newLine","newline")+" "+le("tui.select.cancel","cancel")+(u?` ${le("app.editor.external","external editor")}`:"");this.addChild(new A(d,1,0)),this.addChild(new L(1)),this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.editor.focused=n}handleInput(n){if(ke().matches(n,"tui.select.cancel")){this.onCancelCallback();return}if(this.keybindings.matches(n,"app.editor.external")){this.openExternalEditor();return}this.editor.handleInput(n)}getExternalEditorCommand(){let n=this.externalEditorCommand||process.env.VISUAL||process.env.EDITOR;return n||(process.platform==="win32"?"notepad":"nano")}async openExternalEditor(){let n=this.getExternalEditorCommand();if(!n)return;let i=this.editor.getText(),o=mE.join(pE.tmpdir(),`pi-extension-editor-${Date.now()}.md`);try{Tl.writeFileSync(o,i,"utf-8"),this.tui.stop();let[r,...s]=n.split(" ");if(process.stdout.write(`Launching external editor: ${n}
252
+ `),this.box.addChild(new Ze(i,0,0,this.markdownTheme,{color:o=>v.fg("customMessageText",o)}))}};var ub="bbbab8b9b9b6b9b8b5bcbbb8b8b7b4b7b5b2b6b5b2b8b7b4b7b6b3b6b4b1bdbcb8bab8b6bbb8b5b8b5b1bbb8b4c2bebbc1bebac0bdbabfbcb9c1bebabfbebbc0bfbcc0bdbabbb8b5c1bfbcbfbcb8bbb9b6bfbcb8c2bfbcc1bfbcbfbbb8bdb9b6b8b7b5b9b8b5b8b8b5b5b5b2b6b5b2b8b7b4b9b8b5b9b8b5b6b5b3bab8b5bcbab7bbb9b6bbb8b5bfb9b5bdb2abbcb0a8beb2aabeb5afbfbab6bebab7c0bfbcbebdbabebbb8c0bdbabfbebbc2bebbbdbab7c3c0bdc3c0bdc1bebbc2bebabfbcb8bab9b6b7b6b3b2b1aeb6b5b2b5b4b1b5b4b2b6b5b2b7b6b4b9b8b6b7b6b3bbbab7b2afaba5988fb49e90b09481b79a88b39683b09583b7a395bfb6b0c0bdbabdbbb8bebcb9c1bfbcc0bebbbdbab7bebbb8c2bfbcc0bdbac0bcb9bdb9b6c0bcb8b5b4b2b4b3b0bab9b6b9b9b6b5b4b1b5b4b1b6b5b3b9b8b5b9b8b6b9b8b6b2aeaa968174a6836eaa856eab846eaf8973ac8973b08f79b18f7ab39786b7a89dbbb3aebfbab6c2c0bdbebcb9bfbdbac3c1bdc2bebbc0bcb9bdb9b6c1bdbabfbbb8b4b3b0b9b8b5b8b7b5b4b3b1b5b4b1b8b7b4b8b7b5bab9b6bbbab7b1afad8c7a719d735ca47860a87d65a98069ae8972ae8c75af8d77aa826ba98067aa8974b39e90b6a79dbbb2adc0bdbac1bfbdbfbbb8c1bdb9bebab6c0bdb9bfbbb8c1bdbab4b2b0b7b6b4b7b6b3b4b2b0bab9b7b6b5b2b6b5b2bab9b6bab9b6958c87977663aa836bac8772b08f7aad8c77b2917db0917db0907cac8971a77d64a87f67ac8972b29887b8a89dbfbab5bfbdbac1bebac0bcb9c0bcb9c0bcb9c1bebabebab7b8b7b4b7b6b4b5b4b1b5b4b2b7b6b3b5b4b2bab9b7bab9b6b4b1ada88f7fad8973ae8d78b19684b19685b29786b69a89b29582b1917daa856ea87e66a97e66ad866ea9826baf9280b8ada6bdbbb8bebab7bfbbb8c1bdbabfbbb8bcb8b4bcb8b5b6b4b2b7b5b3b6b5b2b8b7b4b3b2afb8b7b4b6b5b2b3b2b0b3a59aab856fad8d78b0917eb19886b49b8bb49a89b39785b0917eaf8f7cab866fa77d65a77a61a87d64a9816ab08f79b5a296c1bcb8c3bfbcc2bebbbebab7bfbbb7bdbab6c2bebab8b7b4b7b6b4b6b5b3b7b6b3b6b5b2b9b8b6b4b3b1b6b1acac8f7ca9826bae8f7aaf9583b49c8cb49c8bb79d8cb59987b19380ad8e79ae8c77af8e78ac8771a3775faa826bae8972b39888bbb6b2bebbb8bfbbb8bfbbb8c0bdb9bebbb7c0bdb9b6b5b2b9b8b5b4b3b1b8b7b5b4b3b0b7b6b4b6b5b3b1a7a0aa8772a77d65a88570b49887b19b8d9c887c907a6d987f71aa907faf917daf8e7aad8c78ac8b77a8836ca9836cac8770b49b8abdb6b2c0bcb9c0bdb9bfbbb8bebab7bfbcb9bebab7b9b8b6b5b4b2b9b8b5b8b7b5b8b7b4b7b6b4b5b4b2b3a9a2ad8973a1755da9856fb398858c776a65544b776358725d526e594d9c7f6eb1907ba68672ad8e7aab8771ac856db18f79b3a092beb9b5c1bdbabdb9b5bebab7bfbbb7bebab7bcb9b6b7b6b4b6b6b3b8b7b4b5b4b2b8b6b4b7b6b3b4b3b0b4aba4a6826ba3775fb08e79b19584a88e7daa8e7db29481ad8f7c997e6da38674ac8d79ac8e7aae917f9a7c6a896a599a7c6ab3a398c1bdbabdb9b6bcb8b5bebab6bebab7bdb9b5bdb9b6b5b4b1b7b5b3b5b4b2b7b6b3b7b6b4b3b3b0b3b2b0b4aca5a7846fa97f68ae8f7bae9383b59c8bb2937fae8e79ac8b76af927eaf927eb29683b39885b2988891786a72594c6e594d978d86bdbab7bab7b3c0bcb9c0bcb9bebab7bebbb7bdb9b6b3b2b0b4b3b0b5b4b2b4b4b1b4b3b1b4b3b1b4b3b0b6ada5aa8670a57a62ad8e7ab29b8cb69d8dab856fa9826aa88069ab8771af907db49987b19684b29886b59987b39480b09787b5a9a1bcb8b5bebab7bdb9b5bebab7bfbbb8bfbbb7bbb7b4b3b2afb8b7b5b8b7b5b3b2b0b5b4b2b6b5b3b6b4b1afa299a98975a9826baf907cb39988b49a89af8e7aac8973aa856eaf8c74b1917dae907dac907db39988b29785b49785b7a090b9aca3bfbab7bcb8b5bdb9b6bcb8b4bcb8b5bdb9b5bcb8b4b5b4b2b6b5b3b4b3b0b4b3b0b9b8b5b8b6b4908b88887467aa8f7ea78976ad8973b08b74b59885b69e8eb29888b1917cb1917db1937fae907cb19686b39a8ab29886b59b8ab8a192b6aaa3b7b2afbcb8b4bcb8b5bbb7b4c0bcb9bebab7c0bcb9b6b5b2b6b5b3b4b3b0bab9b7b7b6b4b1b0ae7b716ba083709b806f716158967764b08870b29481b69b8ab69f8fb39a89b69f90b49d8db39a89b29988b49c8cb6a090b8a496baa49593867f8f8986bfbbb7bdb9b5bcb7b4bab6b3b9b5b2bab6b2b4b3b1b3b3b0b6b5b3b8b7b5b4b2b0a7a5a38f837dae917ea084725a504c63544da28370b39784b59e8db2a093a698909b918b998e8790857e95877dad998bb39c8cb5a091b9a2938d827c95908dbebab6bbb7b3bdbab7bbb7b4bdb9b6bbb7b4b4b3b0b5b4b1b8b7b5b6b5b3b8b8b5b4b2af968f8ab29a8bab9485544b483a323073655d96887f70655f61595547403e453e3c453f3d57504f655e5b90847db39c8db7a090b6a09189807aaba6a3bdb9b6c0bcb9bebab7bcb7b4bebab7bbb7b4b3b2b0b6b5b3b2b1afb7b6b4b8b7b4b5b4b1aeaba8b5a89fac998d4d44412d25244d46444e4744322b293a3230423937433a37352d2a59504c534b48524a48988a81b59f8fb19c8d827974b2afacbdb9b5bcb8b4bdb9b5bcb8b5bdb9b6bab6b2b8b7b5b5b4b2b6b6b3b9b8b5b7b6b3b6b5b2b8b6b3b9b4b1b2a9a26c64612d25242d2625312a28352d2c453d3a78675c8d7a6ea09792aea6a0615854332b29524a479f8e82b09d90a49b96c1bdb9bebab7bfbbb8bbb8b4b9b5b1b8b4b0b9b4b0b7b6b4b8b7b5b8b7b4b6b5b3b8b6b3bab9b6b9b8b5b4b3b0b7b5b2a5a29f453d3b261e1d261f1e2e2625413936857268977865b19482b5a69caca5a07c7572453d3b746963a0948cc5bfbbc0bbb8beb9b6bbb7b3bbb6b3b7b3afb8b4b0b9b5b1b7b6b3b6b5b3b5b4b2b5b4b2b7b6b3b7b6b3b8b6b3b4b2afb7b6b3b3b1ae6d6765251f1e1e18172a22212d2523443b3971625ab19888b09482a89182877e792c25243e3634766d6abeb9b5bfbbb7bebab6bcb7b3bbb6b3b9b5b1b7b3afb8b4b0b4b3b0b5b4b1b5b4b1b4b3b1b5b4b2b8b6b4b5b3b0b9b6b4b5b4b1b6b4b27f79762a2322221c1b2d2524221b1a443e3c47413f6f676281766f867971675e5a3e37352a222166605dbab7b3bdb9b5beb9b5bcb7b3bcb7b3b9b4b0bab6b2bab6b2b5b3b0b6b4b2b3b2afb7b6b3b4b4b1b4b3b0b6b4b1b5b4b1b4b3b0b9b6b29a8c8252474230292828201f181212322c2c231e1d1c16162c26252923222d26252d2523332b2a8e8885bcb8b5bcb7b3bbb6b2bcb7b3b9b4b1b9b5b1b7b2afb7b2ae7a838e9b9b9caeadacb3b2b0b3b2afb7b7b4b6b5b3b6b6b3b7b6b3b9ada4a991808e7b6f50453f2b24231a14142923221f19181d17161f18182620201d17162a22215d5654b7b3b0bbb7b3bbb6b2b8b4b0bab5b1bbb6b2bab5b1b8b4b0bab6b22c496b4c5d735f68766e727a828285929090adaba8b7b2aeb6a59ab39682a28470a387748e76674e403a1a14141d1716181211221c1c1f1918221c1b2f2827342d2c8d8884bab6b3b9b5b2bab5b1bab5b1b9b4b0bab6b2b8b4b0b9b4b0b7b2ae325e8b365f8a3a5d833f5b7a545f70646469706b6aa08f84b08e78b18e769f7e689e7f6b9e816d907766584940362d2a1c1615201b1a1a1413201a1a251e1d393331a39e9bbab5b1bcb7b3bab6b2b8b3afb8b4b0b9b4b0b9b4b1bab5b2b5b0ac3d6c9843729d44719c426e98415f805a64716f6a699d8677b1927eb3947faa89749d7a649f7f6ba487749e837186716454463f2c25231e181837302e3a33317a7471beb9b6bcb8b4bbb6b2b6b2aebab5b1b9b5b1b8b3afbab6b2b6b1adb5aeaa4877a14c7aa44e7ba345719a3a5d80586b7f767475927b6eb1927faf8e79b08e78a78169a07861a17f6aa58570a688749b83738270666f66618a8480a49e99b7b2aebab6b2bcb8b4b9b5b1b7b2aebab5b1b9b4b0b6b1aeb6b1adb2aca8b2aca84876a04a78a2517fa74771973a5d80405c7a6161677c695fac8a75b08d77b4917aaf8971ad876fa5816aa6846ea78670a98a76ac9484ab9f96b2aca8bdb8b4bcb7b3bcb8b4bcb8b4b8b3afb7b2aeb9b4b0b8b3afb8b2aeb6afabb3aeaab2aeaa4878a14b7aa34c7ba44a759b3d63873b5f825b67766f5f569c7e6caf8c77b18f79b28f78b5927caf8e78a98872aa8a76a98a76ac917fada199b7b0acb9b3afbfb9b5c1bab6bdb6b2b8b3afbab5b1b9b4b0b6afabb7b1adb3ada9b3aeaab0aba8",yu=32,aE=32;function ZK(){let t=[];for(let e=0;e<aE;e++){let n=[];for(let i=0;i<yu;i++){let o=(e*yu+i)*6,r=parseInt(ub.slice(o,o+2),16),s=parseInt(ub.slice(o+2,o+4),16),a=parseInt(ub.slice(o+4,o+6),16);n.push([r,s,a])}t.push(n)}return t}function db(t,e,n,i=!1){return`\x1B[${i?48:38};2;${t};${e};${n}m`}var lE="\x1B[0m";function eG(){let t=ZK(),e=[];for(let n=0;n<aE;n+=2){let i="";for(let o=0;o<yu;o++){let r=t[n][o],s=t[n+1]?.[o]??r;i+=`${db(s[0],s[1],s[2])}${db(r[0],r[1],r[2],!0)}\u2584`}i+=lE,e.push(i)}return e}var wu=class{constructor(e){this.interval=null;this.tick=0;this.maxTicks=25;this.cachedLines=[];this.cachedWidth=0;this.cachedTick=-1;this.ui=e,this.image=eG(),this.startAnimation()}invalidate(){this.cachedWidth=0}startAnimation(){this.interval=setInterval(()=>{this.tick++,this.tick>=this.maxTicks&&this.stopAnimation(),this.cachedWidth=0,this.ui.requestRender()},80)}stopAnimation(){this.interval&&(clearInterval(this.interval),this.interval=null)}render(e){if(e===this.cachedWidth&&this.cachedTick===this.tick)return this.cachedLines;let n=v,i=[],o=a=>{let l=a.replace(/\x1b\[[0-9;]*m/g,"").length,c=Math.max(0,Math.floor((e-l)/2));return" ".repeat(c)+a};i.push("");let r=Math.min(this.image.length,Math.floor(this.tick/this.maxTicks*(this.image.length+3)));for(let a=0;a<this.image.length;a++)if(a<r)i.push(o(this.image[a]));else if(a===r){let l="\u2593".repeat(yu);i.push(o(db(100,200,255)+l+lE))}else i.push(o(" ".repeat(yu)));i.push("");let s=Math.max(0,this.tick-this.maxTicks*.6);return s>0||this.tick>=this.maxTicks?(i.push(o(n.fg("accent","Free Kimi K2.5 via OpenCode Zen"))),i.push(o(n.fg("success",'"Powered by daxnuts"'))),i.push(o(n.fg("muted","\u2014 @thdxr")))):(i.push(""),i.push(""),i.push("")),i.push(""),s>2||this.tick>=this.maxTicks?(i.push(o(n.fg("dim","Try OpenCode"))),i.push(o(n.fg("mdLink","https://mistral.ai/news/mistral-vibe-2-0")))):(i.push(""),i.push("")),i.push(""),this.cachedLines=i,this.cachedWidth=e,this.cachedTick=this.tick,i}dispose(){this.stopAnimation()}};import*as uE from"node:fs";var tG="https://mariozechner.at/posts/2026-04-08-ive-sold-out/",dE="clankolas.png",Bm,cE=!1;function nG(){if(cE)return Bm;cE=!0;try{Bm=uE.readFileSync(iS(dE)).toString("base64")}catch{Bm=void 0}return Bm}var jm=class extends z{constructor(){super(),this.addChild(new H(n=>v.fg("accent",n))),this.addChild(new A(v.bold(v.fg("accent","pi has joined Earendil")),1,0)),this.addChild(new L(1)),this.addChild(new A(v.fg("muted","Read the blog post:"),1,0)),this.addChild(new A(v.fg("mdLink",tG),1,0)),this.addChild(new L(1));let e=nG();e&&(this.addChild(new Ur(e,"image/png",{fallbackColor:n=>v.fg("muted",n)},{maxWidthCells:56,filename:dE})),this.addChild(new L(1))),this.addChild(new H(n=>v.fg("accent",n)))}};import{spawn as iG}from"node:child_process";import*as Tl from"node:fs";import*as pE from"node:os";import*as mE from"node:path";var Sl=class extends z{constructor(n,i,o,r,s,a,l,c){super();this._focused=!1;this.tui=n,this.keybindings=i,this.externalEditorCommand=c,this.onSubmitCallback=s,this.onCancelCallback=a,this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",o),1,0)),this.addChild(new L(1)),this.editor=new Dr(n,Kc(),l),r&&this.editor.setText(r),this.editor.onSubmit=p=>{this.onSubmitCallback(p)},this.addChild(this.editor),this.addChild(new L(1));let u=!!this.getExternalEditorCommand(),d=le("tui.select.confirm","submit")+" "+le("tui.input.newLine","newline")+" "+le("tui.select.cancel","cancel")+(u?` ${le("app.editor.external","external editor")}`:"");this.addChild(new A(d,1,0)),this.addChild(new L(1)),this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.editor.focused=n}handleInput(n){if(we().matches(n,"tui.select.cancel")){this.onCancelCallback();return}if(this.keybindings.matches(n,"app.editor.external")){this.openExternalEditor();return}this.editor.handleInput(n)}getExternalEditorCommand(){let n=this.externalEditorCommand||process.env.VISUAL||process.env.EDITOR;return n||(process.platform==="win32"?"notepad":"nano")}async openExternalEditor(){let n=this.getExternalEditorCommand();if(!n)return;let i=this.editor.getText(),o=mE.join(pE.tmpdir(),`pi-extension-editor-${Date.now()}.md`);try{Tl.writeFileSync(o,i,"utf-8"),this.tui.stop();let[r,...s]=n.split(" ");if(process.stdout.write(`Launching external editor: ${n}
253
253
  Pi will resume when the editor exits.
254
- `),await new Promise(l=>{let c=iG(r,[...s,o],{stdio:"inherit",shell:process.platform==="win32"});c.on("error",()=>l(null)),c.on("close",u=>l(u))})===0){let l=Tl.readFileSync(o,"utf-8").replace(/\n$/,"");this.editor.setText(l)}}finally{try{Tl.unlinkSync(o)}catch{}this.tui.start(),this.tui.requestRender(!0)}}};import{isAbsolute as oG,relative as rG,resolve as hE,sep as gE}from"node:path";function sG(t){return t.replace(/[\r\n\t]/g," ").replace(/ +/g," ").trim()}function uo(t){return t<1e3?t.toString():t<1e4?`${(t/1e3).toFixed(1)}k`:t<1e6?`${Math.round(t/1e3)}k`:t<1e7?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e6)}M`}function aG(t,e){if(!e)return t;let n=hE(t),i=hE(e),o=rG(i,n);return o===""||o!==".."&&!o.startsWith(`..${gE}`)&&!oG(o)?o===""?"~":`~${gE}${o}`:t}var Cl=class{constructor(e,n){this.autoCompactEnabled=!0;this.session=e,this.footerData=n}setSession(e){this.session=e}setAutoCompactEnabled(e){this.autoCompactEnabled=e}invalidate(){}dispose(){}render(e){let n=this.session.state,i=km(),o;for(let q of this.session.sessionManager.getEntries())if(q.type==="message"&&q.message.role==="assistant"){cl(i,q.message.usage);let Z=q.message.usage.input+q.message.usage.cacheRead+q.message.usage.cacheWrite;o=Z>0?q.message.usage.cacheRead/Z*100:void 0}else q.type==="message"&&q.message.role==="toolResult"&&q.message.usage?cl(i,q.message.usage):(q.type==="branch_summary"||q.type==="compaction")&&q.usage&&cl(i,q.usage);let r=this.session.getContextUsage(),s=r?.contextWindow??n.model?.contextWindow??0,a=r?.percent??0,l=r?.percent!==null?a.toFixed(1):"?",c=aG(this.session.sessionManager.getCwd(),process.env.HOME||process.env.USERPROFILE),u=this.footerData.getGitBranch();u&&(c=`${c} (${u})`);let d=this.session.sessionManager.getSessionName();d&&(c=`${c} \u2022 ${d}`);let p=[];i.input&&p.push(`\u2191${uo(i.input)}`),i.output&&p.push(`\u2193${uo(i.output)}`),i.cacheRead&&p.push(`R${uo(i.cacheRead)}`),i.cacheWrite&&p.push(`W${uo(i.cacheWrite)}`),(i.cacheRead>0||i.cacheWrite>0)&&o!==void 0&&p.push(`CH${o.toFixed(1)}%`);let m=n.model?n.model.provider==="kimi-coding"||this.session.modelRuntime.isUsingOAuth(n.model.provider):!1;if(i.cost||m){let q=`$${i.cost.toFixed(3)}${m?" (sub)":""}`;p.push(q)}let g,h=this.autoCompactEnabled?" (auto)":"",f=l==="?"?`?/${uo(s)}${h}`:`${l}%/${uo(s)}${h}`;a>90?g=v.fg("error",f):a>70?g=v.fg("warning",f):g=f,p.push(g),Z0()&&p.push(`${v.fg("dim","\u2022")} ${v.bold(v.fg("warning","xp"))}`);let b=p.join(" "),x=n.model?.id||"no-model",y=j(b);y>e&&(b=te(b,e,"..."),y=j(b));let T=2,P=x;if(n.model?.reasoning){let q=n.thinkingLevel||"off";P=q==="off"?`${x} \u2022 thinking off`:`${x} \u2022 ${q}`}let I=P;this.footerData.getAvailableProviderCount()>1&&n.model&&(I=`(${n.model.provider}) ${P}`,y+T+j(I)>e&&(I=P));let W=j(I),D=y+T+W,_;if(D<=e){let q=" ".repeat(e-y-W);_=b+q+I}else{let q=e-y-T;if(q>0){let Z=te(I,q,""),Y=j(Z),se=" ".repeat(Math.max(0,e-y-Y));_=b+se+Z}else _=b}let F=v.fg("dim",b),O=_.slice(b.length),R=v.fg("dim",O),U=[te(v.fg("dim",c),e,v.fg("dim","...")),F+R],G=this.footerData.getExtensionStatuses();if(G.size>0){let Z=Array.from(G.entries()).sort(([Y],[se])=>Y.localeCompare(se)).map(([,Y])=>sG(Y)).join(" ");U.push(te(Z,e,v.fg("dim","...")))}return U}};import{spawn as lG}from"node:child_process";function fE(t){let[e,n]=process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:["xdg-open",[t]];lG(e,n,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}var tr=class extends z{constructor(n,i,o,r,s){super();this.abortController=new AbortController;this._focused=!1;this.tui=n,this.onComplete=o;let l=s??`Login to ${r||i}`;this.addChild(new H),this.addChild(new A(v.fg("accent",v.bold(l)),1,0)),this.contentContainer=new z,this.addChild(this.contentContainer),this.input=new Xe,this.input.onSubmit=()=>{if(this.inputResolver){let c=this.input.getValue();this.replaceInputWithSubmittedText(c),this.inputResolver(c),this.inputResolver=void 0,this.inputRejecter=void 0}},this.input.onEscape=()=>{this.cancel()},this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.input.focused=n}get signal(){return this.abortController.signal}replaceInputWithSubmittedText(n){this.contentContainer.children=this.contentContainer.children.map(i=>i===this.input?new A(`> ${n}`,0,0):i)}cancel(){this.abortController.abort(),this.inputRejecter&&(this.inputRejecter(new Error("Login cancelled")),this.inputResolver=void 0,this.inputRejecter=void 0),this.onComplete(!1,"Login cancelled")}showAuth(n,i){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));let o=`\x1B]8;;${n}\x07${n}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",o),1,0));let r=process.platform==="darwin"?"Cmd+click to open":"Ctrl+click to open",s=`\x1B]8;;${n}\x07${r}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("dim",s),1,0)),i&&(this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("warning",i),1,0))),fE(n),this.tui.requestRender()}showDeviceCode(n){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));let i=`\x1B]8;;${n.verificationUri}\x07${n.verificationUri}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",i),1,0));let o=process.platform==="darwin"?"Cmd+click to open":"Ctrl+click to open",r=`\x1B]8;;${n.verificationUri}\x07${o}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("dim",r),1,0)),this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("warning",`Enter code: ${n.userCode}`),1,0)),this.tui.requestRender()}showManualInput(n){return this.input.setValue(""),this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.contentContainer.addChild(this.input),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel")})`,1,0)),this.tui.requestRender(),new Promise((i,o)=>{this.inputResolver=i,this.inputRejecter=o})}showPrompt(n,i){return this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("text",n),1,0)),i&&this.contentContainer.addChild(new A(v.fg("dim",`e.g., ${i}`),1,0)),this.contentContainer.addChild(this.input),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel,")} ${le("tui.select.confirm","to submit")})`,1,0)),this.input.setValue(""),this.tui.requestRender(),new Promise((o,r)=>{this.inputResolver=o,this.inputRejecter=r})}showDetails(n){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));for(let i of n)this.contentContainer.addChild(new A(i,1,0));this.tui.requestRender()}showInfo(n,i=[],o=!1){this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("text",n),1,0));for(let r of i){let s=r.label?`${r.label}: ${r.url}`:r.url,a=`\x1B]8;;${r.url}\x07${s}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",a),1,0))}o&&(this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to close")})`,1,0))),this.tui.requestRender()}showWaiting(n){this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel")})`,1,0)),this.tui.requestRender()}showProgress(n){this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.tui.requestRender()}handleInput(n){if(ke().matches(n,"tui.select.cancel")){this.cancel();return}this.input.handleInput(n)}};function qm(t){let{id:e,provider:n}=t,i=t.name?` ${t.name}`:"";return`${e} ${n} ${n}/${e} ${n} ${e}${i}`}function vE(t){let{id:e,provider:n}=t,i=t.name?` ${t.name}`:"";return`${n} ${n}/${e} ${n} ${e}${i}`}var Ml=class extends z{constructor(n,i,o,r,s,a,l,c){super();this._focused=!1;this.allModels=[];this.scopedModelItems=[];this.activeModels=[];this.filteredModels=[];this.selectedIndex=0;this.refreshStatusMessage="Refreshing model catalogs\u2026";this.refreshStatusSuccess=!1;this.scope="all";this.refreshAbortController=new AbortController;this.closed=!1;if(this.tui=n,this.currentModel=i,this.settingsManager=o,this.modelRuntime=r,this.scopedModels=s,this.scope=s.length>0?"scoped":"all",this.onSelectCallback=a,this.onCancelCallback=l,this.addChild(new H),this.addChild(new L(1)),s.length>0)this.scopeText=new A(this.getScopeText(),0,0),this.addChild(this.scopeText),this.scopeHintText=new A(this.getScopeHintText(),0,0),this.addChild(this.scopeHintText);else{let u="Only showing models from configured providers. Use /login to add providers.";this.addChild(new A(v.fg("warning",u),0,0))}this.addChild(new L(1)),this.searchInput=new Xe,c&&this.searchInput.setValue(c),this.searchInput.onSubmit=()=>{this.filteredModels[this.selectedIndex]&&this.handleSelect(this.filteredModels[this.selectedIndex].model)},this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new H),this.loadModelsFromSnapshot(),c?this.filterModels(c):this.updateList(),this.tui.requestRender(),this.refreshModels()}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}loadModelsFromSnapshot(){let n=this.modelRuntime.getAvailableSnapshot().map(o=>({provider:o.provider,id:o.id,model:o}));this.allModels=this.sortModels(n),this.scopedModels=this.scopedModels.map(o=>{let r=this.modelRuntime.getModel(o.model.provider,o.model.id);return r?{...o,model:r}:o}),this.scopedModelItems=this.scopedModels.map(o=>({provider:o.model.provider,id:o.model.id,model:o.model})),this.activeModels=this.scope==="scoped"?this.scopedModelItems:this.allModels,this.filteredModels=this.activeModels;let i=this.filteredModels.findIndex(o=>Qi(this.currentModel,o.model));this.selectedIndex=i>=0?i:Math.min(this.selectedIndex,Math.max(0,this.filteredModels.length-1))}async refreshModels(){let i=!1;this.refreshTimeout=setTimeout(()=>{i=!0,this.refreshAbortController.abort()},15e3);try{let o=await this.modelRuntime.refresh({signal:this.refreshAbortController.signal});if(this.closed)return;this.refreshStatusMessage="",o.aborted&&i?this.errorMessage="Model refresh timed out; showing cached models.":o.errors.size===1?this.errorMessage=`Could not refresh ${o.errors.keys().next().value}; showing cached models.`:o.errors.size>1?this.errorMessage=`Could not refresh ${o.errors.size} model catalogs; showing cached models.`:(this.errorMessage=this.modelRuntime.getError(),this.errorMessage||(this.refreshStatusMessage="Model catalogs refreshed.",this.refreshStatusSuccess=!0)),this.loadModelsFromSnapshot(),this.filterModels(this.searchInput.getValue()),this.tui.requestRender()}finally{this.refreshTimeout&&clearTimeout(this.refreshTimeout)}}close(){this.closed=!0,this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshAbortController.abort()}sortModels(n){let i=[...n];return i.sort((o,r)=>{let s=Qi(this.currentModel,o.model),a=Qi(this.currentModel,r.model);return s&&!a?-1:!s&&a?1:o.provider.localeCompare(r.provider)}),i}getScopeText(){let n=this.scope==="all"?v.fg("accent","all"):v.fg("muted","all"),i=this.scope==="scoped"?v.fg("accent","scoped"):v.fg("muted","scoped");return`${v.fg("muted","Scope: ")}${n}${v.fg("muted"," | ")}${i}`}getScopeHintText(){return le("tui.input.tab","scope")+v.fg("muted"," (all/scoped)")}setScope(n){if(this.scope===n)return;this.scope=n,this.activeModels=this.scope==="scoped"?this.scopedModelItems:this.allModels;let i=this.activeModels.findIndex(o=>Qi(this.currentModel,o.model));this.selectedIndex=i>=0?i:0,this.filterModels(this.searchInput.getValue()),this.scopeText&&this.scopeText.setText(this.getScopeText())}filterModels(n){this.filteredModels=n?Gt(this.activeModels,n,({id:i,provider:o,model:r})=>vE({id:i,provider:o,name:r.name})):this.activeModels,this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredModels.length-1)),this.updateList()}updateList(){this.listContainer.clear();let n=10,i=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),this.filteredModels.length-n)),o=Math.min(i+n,this.filteredModels.length);for(let r=i;r<o;r++){let s=this.filteredModels[r];if(!s)continue;let a=r===this.selectedIndex,l=Qi(this.currentModel,s.model),c="";if(a){let u=v.fg("accent","\u2192 "),d=`${s.id}`,p=v.fg("muted",`[${s.provider}]`),m=l?v.fg("success"," \u2713"):"";c=`${u+v.fg("accent",d)} ${p}${m}`}else{let u=` ${s.id}`,d=v.fg("muted",`[${s.provider}]`),p=l?v.fg("success"," \u2713"):"";c=`${u} ${d}${p}`}this.listContainer.addChild(new A(c,0,0))}if(i>0||o<this.filteredModels.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.filteredModels.length})`);this.listContainer.addChild(new A(r,0,0))}if(this.errorMessage){let r=this.errorMessage.split(`
255
- `);for(let s of r)this.listContainer.addChild(new A(v.fg("error",s),0,0))}else if(this.filteredModels.length===0)this.listContainer.addChild(new A(v.fg("muted"," No matching models"),0,0));else{let r=this.filteredModels[this.selectedIndex];this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg("muted",` Model Name: ${r.model.name}`),0,0))}this.refreshStatusMessage&&(this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg(this.refreshStatusSuccess?"success":"muted",` ${this.refreshStatusMessage}`),0,0)))}handleInput(n){let i=ke();if(i.matches(n,"tui.input.tab")){if(this.scopedModelItems.length>0){let o=this.scope==="all"?"scoped":"all";this.setScope(o),this.scopeHintText&&this.scopeHintText.setText(this.getScopeHintText())}return}if(i.matches(n,"tui.select.up")){if(this.filteredModels.length===0)return;this.selectedIndex=this.selectedIndex===0?this.filteredModels.length-1:this.selectedIndex-1,this.updateList()}else if(i.matches(n,"tui.select.down")){if(this.filteredModels.length===0)return;this.selectedIndex=this.selectedIndex===this.filteredModels.length-1?0:this.selectedIndex+1,this.updateList()}else if(i.matches(n,"tui.select.confirm")){let o=this.filteredModels[this.selectedIndex];o&&this.handleSelect(o.model)}else i.matches(n,"tui.select.cancel")?(this.close(),this.onCancelCallback()):(this.searchInput.handleInput(n),this.filterModels(this.searchInput.getValue()))}handleSelect(n){this.close(),this.settingsManager.setDefaultModelAndProvider(n.provider,n.id),this.onSelectCallback(n)}getSearchInput(){return this.searchInput}};function Km(t){return t==="oauth"?"subscription":"API key"}var as=class extends z{constructor(n,i,o,r,s){super();this._focused=!1;this.selectedIndex=0;this.mode=n,this.allProviders=i,this.filteredProviders=i,this.showAuthTypeLabels=new Set(i.map(l=>l.authType)).size>1,this.onSelectCallback=o,this.onCancelCallback=r,this.addChild(new H),this.addChild(new L(1));let a=n==="login"?"Select provider to configure:":"Select provider to logout:";this.addChild(new Kn(v.fg("accent",v.bold(a)),1,0)),this.addChild(new L(1)),this.searchInput=new Xe,s&&this.searchInput.setValue(s),this.searchInput.onSubmit=()=>{let l=this.filteredProviders[this.selectedIndex];l&&this.onSelectCallback(l.id,l.authType)},this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new H),this.filterProviders(s??"")}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}filterProviders(n){this.filteredProviders=n?Gt(this.allProviders,n,i=>`${i.name} ${i.id} ${i.authType} ${i.method?.name??""}`):this.allProviders,this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,this.filteredProviders.length-1))),this.updateList()}updateList(){this.listContainer.clear();let n=8,i=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),this.filteredProviders.length-n)),o=Math.min(i+n,this.filteredProviders.length);for(let r=i;r<o;r++){let s=this.filteredProviders[r];if(!s)continue;let a=r===this.selectedIndex,l=this.formatStatusIndicator(s),c=this.showAuthTypeLabels?v.fg("muted",` [${Km(s.authType)}]`):"",u="";if(a){let d=v.fg("accent","\u2192 "),p=v.fg("accent",s.name);u=d+p+c+l}else u=` ${v.fg("text",s.name)}`+c+l;this.listContainer.addChild(new Kn(u,1,0))}if(i>0||o<this.filteredProviders.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.filteredProviders.length})`);this.listContainer.addChild(new Kn(r,1,0))}if(this.filteredProviders.length===0){let r=this.allProviders.length===0?this.mode==="login"?"No providers available":"No providers logged in. Use /login first.":"No matching providers";this.listContainer.addChild(new Kn(v.fg("muted",` ${r}`),1,0))}}formatStatusIndicator(n){if(!n.status)return v.fg("muted"," \u2022 unconfigured");if(n.status.type!==n.authType){let o=n.status.type==="oauth"?"subscription configured":"API key configured";return v.fg("muted"," \u2022 ")+v.fg("warning",o)}if(!n.status.source||n.status.source==="OAuth"||n.status.source==="stored credential")return v.fg("success"," \u2713 configured");let i=/^[A-Z][A-Z0-9_]*(?:, [A-Z][A-Z0-9_]*)*$/.test(n.status.source)?`env: ${n.status.source}`:n.status.source;return v.fg("success",` \u2713 ${i}`)}handleInput(n){let i=ke();if(i.matches(n,"tui.select.up")){if(this.filteredProviders.length===0)return;this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList()}else if(i.matches(n,"tui.select.down")){if(this.filteredProviders.length===0)return;this.selectedIndex=Math.min(this.filteredProviders.length-1,this.selectedIndex+1),this.updateList()}else if(i.matches(n,"tui.select.confirm")){let o=this.filteredProviders[this.selectedIndex];o&&this.onSelectCallback(o.id,o.authType)}else i.matches(n,"tui.select.cancel")?this.onCancelCallback():(this.searchInput.handleInput(n),this.filterProviders(this.searchInput.getValue()))}};function pb(t,e){return t===null||t.includes(e)}function cG(t,e){if(t===null)return[e];let n=t.indexOf(e);return n>=0?[...t.slice(0,n),...t.slice(n+1)]:[...t,e]}function bE(t,e,n){if(t===null)return null;let i=n??e,o=[...t];for(let r of i)o.includes(r)||o.push(r);return o.length===e.length?null:o}function xE(t,e,n){if(t===null)return n?e.filter(o=>!n.includes(o)):[];let i=new Set(n??t);return t.filter(o=>!i.has(o))}function uG(t,e,n){if(t===null)return null;let i=[...t],o=i.indexOf(e);if(o<0)return i;let r=o+n;if(r<0||r>=i.length)return i;let s=[...i];return[s[o],s[r]]=[s[r],s[o]],s}function dG(t,e){if(t===null)return e;let n=new Set(t);return[...t,...e.filter(i=>!n.has(i))]}var ku=class extends z{constructor(n,i){super();this.modelsById=new Map;this.allIds=[];this.enabledIds=null;this.filteredItems=[];this.selectedIndex=0;this._focused=!1;this.maxVisible=8;this.isDirty=!1;this.callbacks=i;for(let o of n.allModels){let r=`${o.provider}/${o.id}`;this.modelsById.set(r,o),this.allIds.push(r)}this.enabledIds=n.enabledModelIds===null?null:[...n.enabledModelIds],this.filteredItems=this.buildItems(),this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",v.bold("Model Configuration")),0,0)),this.addChild(new A(v.fg("muted",`Session-only. ${Re("app.models.save")} to save to settings.`),0,0)),this.addChild(new L(1)),this.searchInput=new Xe,this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.footerText=new A(this.getFooterText(),0,0),this.addChild(this.footerText),this.addChild(new H),this.updateList()}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}buildItems(){return dG(this.enabledIds,this.allIds).filter(n=>this.modelsById.has(n)).map(n=>({fullId:n,model:this.modelsById.get(n),enabled:pb(this.enabledIds,n)}))}getFooterText(){let n=this.enabledIds?.length??this.allIds.length,o=this.enabledIds===null?"all enabled":`${n}/${this.allIds.length} enabled`,r=[`${Re("tui.select.confirm")} toggle`,`${Re("app.models.enableAll")} all`,`${Re("app.models.clearAll")} clear`,`${Re("app.models.toggleProvider")} provider`,`${Re("app.models.reorderUp")}/${Re("app.models.reorderDown")} reorder`,`${Re("app.models.save")} save`,o];return this.isDirty?v.fg("dim",` ${r.join(" \xB7 ")} `)+v.fg("warning","(unsaved)"):v.fg("dim",` ${r.join(" \xB7 ")}`)}refresh(){let n=this.searchInput.getValue(),i=this.buildItems();this.filteredItems=n?Gt(i,n,o=>qm({id:o.model.id,provider:o.model.provider,name:o.model.name})):i,this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredItems.length-1)),this.updateList(),this.footerText.setText(this.getFooterText())}notifyChange(){this.callbacks.onChange(this.enabledIds===null?null:[...this.enabledIds])}updateList(){if(this.listContainer.clear(),this.filteredItems.length===0){this.listContainer.addChild(new A(v.fg("muted"," No matching models"),0,0));return}let n=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredItems.length-this.maxVisible)),i=Math.min(n+this.maxVisible,this.filteredItems.length),o=this.enabledIds===null;for(let r=n;r<i;r++){let s=this.filteredItems[r],a=r===this.selectedIndex,l=a?v.fg("accent","\u2192 "):" ",c=a?v.fg("accent",s.model.id):s.model.id,u=v.fg("muted",` [${s.model.provider}]`),d=o?"":s.enabled?v.fg("success"," \u2713"):v.fg("dim"," \u2717");this.listContainer.addChild(new A(`${l}${c}${u}${d}`,0,0))}if((n>0||i<this.filteredItems.length)&&this.listContainer.addChild(new A(v.fg("muted",` (${this.selectedIndex+1}/${this.filteredItems.length})`),0,0)),this.filteredItems.length>0){let r=this.filteredItems[this.selectedIndex];this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg("muted",` Model Name: ${r.model.name}`),0,0))}}handleInput(n){let i=ke();if(i.matches(n,"tui.select.up")){if(this.filteredItems.length===0)return;this.selectedIndex=this.selectedIndex===0?this.filteredItems.length-1:this.selectedIndex-1,this.updateList();return}if(i.matches(n,"tui.select.down")){if(this.filteredItems.length===0)return;this.selectedIndex=this.selectedIndex===this.filteredItems.length-1?0:this.selectedIndex+1,this.updateList();return}let o=i.matches(n,"app.models.reorderUp"),r=i.matches(n,"app.models.reorderDown");if(o||r){if(this.enabledIds===null)return;let s=this.filteredItems[this.selectedIndex];if(s&&pb(this.enabledIds,s.fullId)){let a=o?-1:1,c=this.enabledIds.indexOf(s.fullId)+a;c>=0&&c<this.enabledIds.length&&(this.enabledIds=uG(this.enabledIds,s.fullId,a),this.isDirty=!0,this.selectedIndex+=a,this.refresh(),this.notifyChange())}return}if(i.matches(n,"tui.select.confirm")){let s=this.filteredItems[this.selectedIndex];s&&(this.enabledIds=cG(this.enabledIds,s.fullId),this.isDirty=!0,this.refresh(),this.notifyChange());return}if(i.matches(n,"app.models.enableAll")){let s=this.searchInput.getValue()?this.filteredItems.map(a=>a.fullId):void 0;this.enabledIds=bE(this.enabledIds,this.allIds,s),this.isDirty=!0,this.refresh(),this.notifyChange();return}if(i.matches(n,"app.models.clearAll")){let s=this.searchInput.getValue()?this.filteredItems.map(a=>a.fullId):void 0;this.enabledIds=xE(this.enabledIds,this.allIds,s),this.isDirty=!0,this.refresh(),this.notifyChange();return}if(i.matches(n,"app.models.toggleProvider")){let s=this.filteredItems[this.selectedIndex];if(s){let a=s.model.provider,l=this.allIds.filter(u=>this.modelsById.get(u).provider===a),c=l.every(u=>pb(this.enabledIds,u));this.enabledIds=c?xE(this.enabledIds,this.allIds,l):bE(this.enabledIds,this.allIds,l),this.isDirty=!0,this.refresh(),this.notifyChange()}return}if(i.matches(n,"app.models.save")){this.callbacks.onPersist(this.enabledIds===null?null:[...this.enabledIds]),this.isDirty=!1,this.footerText.setText(this.getFooterText());return}if(Fe(n,Or.ctrl("c"))){this.searchInput.getValue()?(this.searchInput.setValue(""),this.refresh()):this.callbacks.onCancel();return}if(Fe(n,Or.escape)){this.callbacks.onCancel();return}this.searchInput.handleInput(n),this.refresh()}getSearchInput(){return this.searchInput}};var pG={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},mG={off:"No reasoning",minimal:"Very brief reasoning (~1k tokens)",low:"Light reasoning (~2k tokens)",medium:"Moderate reasoning (~8k tokens)",high:"Deep reasoning (~16k tokens)",xhigh:"Extra-high reasoning (~32k tokens)",max:"Maximum reasoning"},mb={ask:"Ask",always:"Always trust",never:"Never trust"},hG=new Map(Object.entries(mb).map(([t,e])=>[e,t])),hb=class extends z{constructor(e,n,i){super(),this.state={...e};let o=[{id:"anthropic-extra-usage",label:"Anthropic extra usage",description:"Warn when Anthropic subscription auth may use paid extra usage",currentValue:this.state.anthropicExtraUsage??!0?"true":"false",values:["true","false"]}];this.settingsList=new $r(o,Math.min(o.length,10),Gc(),(r,s)=>{r==="anthropic-extra-usage"&&(this.state={...this.state,anthropicExtraUsage:s==="true"},n({...this.state}))},i),this.addChild(this.settingsList)}handleInput(e){this.settingsList.handleInput(e)}},Su=class extends z{constructor(e,n,i,o,r,s,a){super(),this.addChild(new A(v.bold(v.fg("accent",e)),0,0)),n&&(this.addChild(new L(1)),this.addChild(new A(v.fg("muted",n),0,0))),this.addChild(new L(1)),this.selectList=new Ht(i,Math.min(i.length,10),zr(),pG);let l=i.findIndex(c=>c.value===o);l!==-1&&this.selectList.setSelectedIndex(l),this.selectList.onSelect=c=>{r(c.value)},this.selectList.onCancel=s,a&&(this.selectList.onSelectionChange=c=>{a(c.value)}),this.addChild(this.selectList),this.addChild(new L(1)),this.addChild(new A(v.fg("dim"," Enter to select \xB7 Esc to go back"),0,0))}handleInput(e){this.selectList.handleInput(e)}};function yE(t){return t.map(e=>({value:e,label:e}))}var gb="/";function gG(t){return[{value:gb,label:"Automatic",description:"Use separate themes for light and dark terminal appearance"},...yE(t)]}function wE(t,e,n){return e&&t.includes(e)?e:t.includes(n)?n:t[0]??n}function fG(t,e){let n=Ko(t);if(n)return n;let i=t.includes("/")?void 0:t,o=wE(e,i,"dark");return{lightTheme:o,darkTheme:o}}var fb=class extends z{constructor(e,n,i,o,r){super(),this.callbacks=o,this.availableThemes=i,this.terminalTheme=n,this.onDone=r,this.originalThemeSetting=e;let s=Ko(e),a=fG(e,i),l=s||e.includes("/")?void 0:e;this.mode=s?"automatic":"single",this.lightTheme=a.lightTheme,this.darkTheme=a.darkTheme,this.singleTheme=wE(i,l??(s?this.getActiveAutomaticTheme():void 0),"dark"),this.mode==="automatic"?this.showAutomaticMenu():this.showSingleMenu()}handleInput(e){this.inputComponent?.handleInput?.(e)}setContent(e,n=e){this.clear(),this.addChild(e),this.inputComponent=n}showSingleMenu(){this.mode="single";let e=new Su("Theme","Select a theme, or choose Automatic to follow terminal appearance.",gG(this.availableThemes),this.singleTheme,n=>{if(n===gb){this.mode="automatic",this.callbacks.onThemePreview?.(this.getThemeSetting()),this.showAutomaticMenu();return}this.singleTheme=n,this.apply(n)},()=>this.cancel(),n=>{this.callbacks.onThemePreview?.(n===gb?this.getAutomaticThemeSetting():n)});this.setContent(e)}showAutomaticMenu(){this.mode="automatic";let e=new z;e.addChild(new A(v.bold(v.fg("accent","Automatic Theme")),0,0)),e.addChild(new L(1)),e.addChild(new A(v.fg("muted","Choose themes for terminal light and dark appearance."),0,0)),e.addChild(new A(v.fg("muted","Light/dark detection requires terminal support."),0,0)),e.addChild(new L(1));let n=[{id:"light-theme",label:"Light theme",description:"Theme to use in automatic mode when the terminal is light",currentValue:this.lightTheme,submenu:(o,r)=>this.createThemeSelect("Light Theme","Select the theme to use for light terminal appearance",o,r,s=>{this.lightTheme=s,this.callbacks.onThemePreview?.(this.getThemeSetting()),r(s)})},{id:"dark-theme",label:"Dark theme",description:"Theme to use in automatic mode when the terminal is dark",currentValue:this.darkTheme,submenu:(o,r)=>this.createThemeSelect("Dark Theme","Select the theme to use for dark terminal appearance",o,r,s=>{this.darkTheme=s,this.callbacks.onThemePreview?.(this.getThemeSetting()),r(s)})},{id:"apply",label:"Apply",description:"Save and go back",currentValue:"save and go back",values:["save and go back"]},{id:"single-mode",label:"Change mode",description:"Switch to one theme for light and dark",currentValue:"switch to single theme",values:["switch to single theme"]}],i=new $r(n,Math.min(n.length,10),Gc(),o=>{switch(o){case"single-mode":this.mode="single",this.singleTheme=this.getActiveAutomaticTheme(),this.callbacks.onThemePreview?.(this.singleTheme),this.showSingleMenu();break;case"apply":this.apply(this.getAutomaticThemeSetting());break}},()=>this.cancel());e.addChild(i),this.setContent(e,i)}createThemeSelect(e,n,i,o,r){return new Su(e,n,yE(this.availableThemes),i,r,()=>{this.callbacks.onThemePreview?.(this.getThemeSetting()),o()},s=>this.callbacks.onThemePreview?.(s))}getThemeSetting(){return this.mode==="automatic"?this.getAutomaticThemeSetting():this.singleTheme}getActiveAutomaticTheme(){return this.terminalTheme==="light"?this.lightTheme:this.darkTheme}getAutomaticThemeSetting(){return`${this.lightTheme}/${this.darkTheme}`}apply(e){this.onDone(e)}cancel(){this.callbacks.onThemePreview?.(this.originalThemeSetting),this.onDone()}},Rl=class extends z{constructor(e,n){super();let i=ft().images,o=Xc("app.message.followUp"),r={...e.warnings},s=[{id:"autocompact",label:"Auto-compact",description:"Automatically compact context when it gets too large",currentValue:e.autoCompact?"true":"false",values:["true","false"]},{id:"steering-mode",label:"Steering mode",description:"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.",currentValue:e.steeringMode,values:["one-at-a-time","all"]},{id:"follow-up-mode",label:"Follow-up mode",description:`${o} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,currentValue:e.followUpMode,values:["one-at-a-time","all"]},{id:"transport",label:"Transport",description:"Preferred transport for providers that support multiple transports",currentValue:e.transport,values:["sse","websocket","websocket-cached","auto"]},{id:"http-idle-timeout",label:"HTTP idle timeout",description:"Maximum idle gap while waiting for HTTP headers or body chunks. Disable for local models that pause longer than five minutes.",currentValue:Om(e.httpIdleTimeoutMs),values:Am.map(h=>h.label)},{id:"hide-thinking",label:"Hide thinking",description:"Hide thinking blocks in assistant responses",currentValue:e.hideThinkingBlock?"true":"false",values:["true","false"]},{id:"cache-miss-notices",label:"Cache miss notices",description:"Show transcript notices for significant prompt-cache misses",currentValue:e.showCacheMissNotices?"true":"false",values:["true","false"]},{id:"collapse-changelog",label:"Collapse changelog",description:"Show condensed changelog after updates",currentValue:e.collapseChangelog?"true":"false",values:["true","false"]},{id:"quiet-startup",label:"Quiet startup",description:"Disable verbose printing at startup",currentValue:e.quietStartup?"true":"false",values:["true","false"]},{id:"install-telemetry",label:"Install telemetry",description:"Send an anonymous version/update ping after changelog-detected updates",currentValue:e.enableInstallTelemetry?"true":"false",values:["true","false"]},{id:"default-project-trust",label:"Default project trust",description:"Fallback behavior when no extension or saved trust decision decides project trust",currentValue:mb[e.defaultProjectTrust],values:Object.values(mb)},{id:"double-escape-action",label:"Double-escape action",description:"Action when pressing Escape twice with empty editor",currentValue:e.doubleEscapeAction,values:["tree","fork","none"]},{id:"tree-filter-mode",label:"Tree filter mode",description:"Default filter when opening /tree",currentValue:e.treeFilterMode,values:["default","no-tools","user-only","labeled-only","all"]},{id:"warnings",label:"Warnings",description:"Enable or disable individual warnings",currentValue:"configure",submenu:(h,f)=>new hb(r,b=>{r=b,n.onWarningsChange(b)},()=>f())},{id:"thinking",label:"Thinking level",description:"Reasoning depth for thinking-capable models",currentValue:e.thinkingLevel,submenu:(h,f)=>new Su("Thinking Level","Select reasoning depth for thinking-capable models",e.availableThinkingLevels.map(b=>({value:b,label:b,description:mG[b]})),h,b=>{n.onThinkingLevelChange(b),f(b)},()=>f())},{id:"theme",label:"Theme",description:"Color theme for the interface",currentValue:e.currentTheme,submenu:(h,f)=>new fb(h,e.terminalTheme,e.availableThemes,n,f)}];i&&(s.splice(1,0,{id:"show-images",label:"Show images",description:"Render images inline in terminal",currentValue:e.showImages?"true":"false",values:["true","false"]}),s.splice(2,0,{id:"image-width-cells",label:"Image width",description:"Preferred inline image width in terminal cells",currentValue:String(e.imageWidthCells),values:["60","80","120"]})),s.splice(i?3:1,0,{id:"auto-resize-images",label:"Auto-resize images",description:"Resize large images to 2000x2000 max for better model compatibility",currentValue:e.autoResizeImages?"true":"false",values:["true","false"]});let a=s.findIndex(h=>h.id==="auto-resize-images");s.splice(a+1,0,{id:"block-images",label:"Block images",description:"Prevent images from being sent to LLM providers",currentValue:e.blockImages?"true":"false",values:["true","false"]});let l=s.findIndex(h=>h.id==="block-images");s.splice(l+1,0,{id:"skill-commands",label:"Skill commands",description:"Register skills as /skill:name commands",currentValue:e.enableSkillCommands?"true":"false",values:["true","false"]});let c=s.findIndex(h=>h.id==="skill-commands");s.splice(c+1,0,{id:"show-hardware-cursor",label:"Show hardware cursor",description:"Show the terminal cursor while still positioning it for IME support",currentValue:e.showHardwareCursor?"true":"false",values:["true","false"]});let u=s.findIndex(h=>h.id==="show-hardware-cursor");s.splice(u+1,0,{id:"editor-padding",label:"Editor padding",description:"Horizontal padding for input editor (0-3)",currentValue:String(e.editorPaddingX),values:["0","1","2","3"]});let d=s.findIndex(h=>h.id==="editor-padding");s.splice(d+1,0,{id:"output-padding",label:"Output padding",description:"Horizontal padding for user messages, assistant messages, and thinking",currentValue:String(e.outputPad),values:["0","1"]});let p=s.findIndex(h=>h.id==="output-padding");s.splice(p+1,0,{id:"autocomplete-max-visible",label:"Autocomplete max items",description:"Max visible items in autocomplete dropdown (3-20)",currentValue:String(e.autocompleteMaxVisible),values:["3","5","7","10","15","20"]});let m=s.findIndex(h=>h.id==="autocomplete-max-visible");s.splice(m+1,0,{id:"clear-on-shrink",label:"Clear on shrink",description:"Clear empty rows when content shrinks (may cause flicker)",currentValue:e.clearOnShrink?"true":"false",values:["true","false"]});let g=s.findIndex(h=>h.id==="clear-on-shrink");s.splice(g+1,0,{id:"terminal-progress",label:"Terminal progress",description:"Show OSC 9;4 progress indicators in the terminal tab bar",currentValue:e.showTerminalProgress?"true":"false",values:["true","false"]}),this.addChild(new H),this.settingsList=new $r(s,10,Gc(),(h,f)=>{switch(h){case"autocompact":n.onAutoCompactChange(f==="true");break;case"show-images":n.onShowImagesChange(f==="true");break;case"image-width-cells":n.onImageWidthCellsChange(parseInt(f,10));break;case"auto-resize-images":n.onAutoResizeImagesChange(f==="true");break;case"block-images":n.onBlockImagesChange(f==="true");break;case"skill-commands":n.onEnableSkillCommandsChange(f==="true");break;case"steering-mode":n.onSteeringModeChange(f);break;case"follow-up-mode":n.onFollowUpModeChange(f);break;case"transport":n.onTransportChange(f);break;case"http-idle-timeout":{let b=Am.find(x=>x.label===f);b&&n.onHttpIdleTimeoutMsChange(b.timeoutMs);break}case"hide-thinking":n.onHideThinkingBlockChange(f==="true");break;case"cache-miss-notices":n.onShowCacheMissNoticesChange(f==="true");break;case"collapse-changelog":n.onCollapseChangelogChange(f==="true");break;case"quiet-startup":n.onQuietStartupChange(f==="true");break;case"install-telemetry":n.onEnableInstallTelemetryChange(f==="true");break;case"default-project-trust":{let b=hG.get(f);b&&n.onDefaultProjectTrustChange(b);break}case"double-escape-action":n.onDoubleEscapeActionChange(f);break;case"tree-filter-mode":n.onTreeFilterModeChange(f);break;case"show-hardware-cursor":n.onShowHardwareCursorChange(f==="true");break;case"editor-padding":n.onEditorPaddingXChange(parseInt(f,10));break;case"output-padding":n.onOutputPadChange(f==="0"?0:1);break;case"autocomplete-max-visible":n.onAutocompleteMaxVisibleChange(parseInt(f,10));break;case"clear-on-shrink":n.onClearOnShrinkChange(f==="true");break;case"terminal-progress":n.onShowTerminalProgressChange(f==="true");break;case"theme":n.onThemeChange(f);break}},n.onCancel,{enableSearch:!0}),this.addChild(this.settingsList),this.addChild(new H)}getSettingsList(){return this.settingsList}};var Pl=class extends pt{constructor(n,i=Ft()){super(1,1,o=>v.bg("customMessageBg",o));this.expanded=!1;this.skillBlock=n,this.markdownTheme=i,this.updateDisplay()}setExpanded(n){this.expanded=n,this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){if(this.clear(),this.expanded){let n=v.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m");this.addChild(new A(n,0,0));let i=`**${this.skillBlock.name}**
254
+ `),await new Promise(l=>{let c=iG(r,[...s,o],{stdio:"inherit",shell:process.platform==="win32"});c.on("error",()=>l(null)),c.on("close",u=>l(u))})===0){let l=Tl.readFileSync(o,"utf-8").replace(/\n$/,"");this.editor.setText(l)}}finally{try{Tl.unlinkSync(o)}catch{}this.tui.start(),this.tui.requestRender(!0)}}};import{isAbsolute as oG,relative as rG,resolve as hE,sep as gE}from"node:path";function sG(t){return t.replace(/[\r\n\t]/g," ").replace(/ +/g," ").trim()}function uo(t){return t<1e3?t.toString():t<1e4?`${(t/1e3).toFixed(1)}k`:t<1e6?`${Math.round(t/1e3)}k`:t<1e7?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e6)}M`}function aG(t,e){if(!e)return t;let n=hE(t),i=hE(e),o=rG(i,n);return o===""||o!==".."&&!o.startsWith(`..${gE}`)&&!oG(o)?o===""?"~":`~${gE}${o}`:t}var Cl=class{constructor(e,n){this.autoCompactEnabled=!0;this.session=e,this.footerData=n}setSession(e){this.session=e}setAutoCompactEnabled(e){this.autoCompactEnabled=e}invalidate(){}dispose(){}render(e){let n=this.session.state,i=km(),o;for(let q of this.session.sessionManager.getEntries())if(q.type==="message"&&q.message.role==="assistant"){cl(i,q.message.usage);let Z=q.message.usage.input+q.message.usage.cacheRead+q.message.usage.cacheWrite;o=Z>0?q.message.usage.cacheRead/Z*100:void 0}else q.type==="message"&&q.message.role==="toolResult"&&q.message.usage?cl(i,q.message.usage):(q.type==="branch_summary"||q.type==="compaction")&&q.usage&&cl(i,q.usage);let r=this.session.getContextUsage(),s=r?.contextWindow??n.model?.contextWindow??0,a=r?.percent??0,l=r?.percent!==null?a.toFixed(1):"?",c=aG(this.session.sessionManager.getCwd(),process.env.HOME||process.env.USERPROFILE),u=this.footerData.getGitBranch();u&&(c=`${c} (${u})`);let d=this.session.sessionManager.getSessionName();d&&(c=`${c} \u2022 ${d}`);let p=[];i.input&&p.push(`\u2191${uo(i.input)}`),i.output&&p.push(`\u2193${uo(i.output)}`),i.cacheRead&&p.push(`R${uo(i.cacheRead)}`),i.cacheWrite&&p.push(`W${uo(i.cacheWrite)}`),(i.cacheRead>0||i.cacheWrite>0)&&o!==void 0&&p.push(`CH${o.toFixed(1)}%`);let m=n.model?n.model.provider==="kimi-coding"||this.session.modelRuntime.isUsingOAuth(n.model.provider):!1;if(i.cost||m){let q=`$${i.cost.toFixed(3)}${m?" (sub)":""}`;p.push(q)}let g,h=this.autoCompactEnabled?" (auto)":"",f=l==="?"?`?/${uo(s)}${h}`:`${l}%/${uo(s)}${h}`;a>90?g=v.fg("error",f):a>70?g=v.fg("warning",f):g=f,p.push(g),Z0()&&p.push(`${v.fg("dim","\u2022")} ${v.bold(v.fg("warning","xp"))}`);let b=p.join(" "),x=n.model?.id||"no-model",y=j(b);y>e&&(b=te(b,e,"..."),y=j(b));let T=2,P=x;if(n.model?.reasoning){let q=n.thinkingLevel||"off";P=q==="off"?`${x} \u2022 thinking off`:`${x} \u2022 ${q}`}let I=P;this.footerData.getAvailableProviderCount()>1&&n.model&&(I=`(${n.model.provider}) ${P}`,y+T+j(I)>e&&(I=P));let W=j(I),D=y+T+W,_;if(D<=e){let q=" ".repeat(e-y-W);_=b+q+I}else{let q=e-y-T;if(q>0){let Z=te(I,q,""),Y=j(Z),se=" ".repeat(Math.max(0,e-y-Y));_=b+se+Z}else _=b}let F=v.fg("dim",b),O=_.slice(b.length),R=v.fg("dim",O),U=[te(v.fg("dim",c),e,v.fg("dim","...")),F+R],G=this.footerData.getExtensionStatuses();if(G.size>0){let Z=Array.from(G.entries()).sort(([Y],[se])=>Y.localeCompare(se)).map(([,Y])=>sG(Y)).join(" ");U.push(te(Z,e,v.fg("dim","...")))}return U}};import{spawn as lG}from"node:child_process";function fE(t){let[e,n]=process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:["xdg-open",[t]];lG(e,n,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}var tr=class extends z{constructor(n,i,o,r,s){super();this.abortController=new AbortController;this._focused=!1;this.tui=n,this.onComplete=o;let l=s??`Login to ${r||i}`;this.addChild(new H),this.addChild(new A(v.fg("accent",v.bold(l)),1,0)),this.contentContainer=new z,this.addChild(this.contentContainer),this.input=new Xe,this.input.onSubmit=()=>{if(this.inputResolver){let c=this.input.getValue();this.replaceInputWithSubmittedText(c),this.inputResolver(c),this.inputResolver=void 0,this.inputRejecter=void 0}},this.input.onEscape=()=>{this.cancel()},this.addChild(new H)}get focused(){return this._focused}set focused(n){this._focused=n,this.input.focused=n}get signal(){return this.abortController.signal}replaceInputWithSubmittedText(n){this.contentContainer.children=this.contentContainer.children.map(i=>i===this.input?new A(`> ${n}`,0,0):i)}cancel(){this.abortController.abort(),this.inputRejecter&&(this.inputRejecter(new Error("Login cancelled")),this.inputResolver=void 0,this.inputRejecter=void 0),this.onComplete(!1,"Login cancelled")}showAuth(n,i){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));let o=`\x1B]8;;${n}\x07${n}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",o),1,0));let r=process.platform==="darwin"?"Cmd+click to open":"Ctrl+click to open",s=`\x1B]8;;${n}\x07${r}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("dim",s),1,0)),i&&(this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("warning",i),1,0))),fE(n),this.tui.requestRender()}showDeviceCode(n){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));let i=`\x1B]8;;${n.verificationUri}\x07${n.verificationUri}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",i),1,0));let o=process.platform==="darwin"?"Cmd+click to open":"Ctrl+click to open",r=`\x1B]8;;${n.verificationUri}\x07${o}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("dim",r),1,0)),this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("warning",`Enter code: ${n.userCode}`),1,0)),this.tui.requestRender()}showManualInput(n){return this.input.setValue(""),this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.contentContainer.addChild(this.input),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel")})`,1,0)),this.tui.requestRender(),new Promise((i,o)=>{this.inputResolver=i,this.inputRejecter=o})}showPrompt(n,i){return this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("text",n),1,0)),i&&this.contentContainer.addChild(new A(v.fg("dim",`e.g., ${i}`),1,0)),this.contentContainer.addChild(this.input),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel,")} ${le("tui.select.confirm","to submit")})`,1,0)),this.input.setValue(""),this.tui.requestRender(),new Promise((o,r)=>{this.inputResolver=o,this.inputRejecter=r})}showDetails(n){this.contentContainer.clear(),this.contentContainer.addChild(new L(1));for(let i of n)this.contentContainer.addChild(new A(i,1,0));this.tui.requestRender()}showInfo(n,i=[],o=!1){this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("text",n),1,0));for(let r of i){let s=r.label?`${r.label}: ${r.url}`:r.url,a=`\x1B]8;;${r.url}\x07${s}\x1B]8;;\x07`;this.contentContainer.addChild(new A(v.fg("accent",a),1,0))}o&&(this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to close")})`,1,0))),this.tui.requestRender()}showWaiting(n){this.contentContainer.addChild(new L(1)),this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.contentContainer.addChild(new A(`(${le("tui.select.cancel","to cancel")})`,1,0)),this.tui.requestRender()}showProgress(n){this.contentContainer.addChild(new A(v.fg("dim",n),1,0)),this.tui.requestRender()}handleInput(n){if(we().matches(n,"tui.select.cancel")){this.cancel();return}this.input.handleInput(n)}};function qm(t){let{id:e,provider:n}=t,i=t.name?` ${t.name}`:"";return`${e} ${n} ${n}/${e} ${n} ${e}${i}`}function vE(t){let{id:e,provider:n}=t,i=t.name?` ${t.name}`:"";return`${n} ${n}/${e} ${n} ${e}${i}`}var Ml=class extends z{constructor(n,i,o,r,s,a,l,c){super();this._focused=!1;this.allModels=[];this.scopedModelItems=[];this.activeModels=[];this.filteredModels=[];this.selectedIndex=0;this.refreshStatusMessage="Refreshing model catalogs\u2026";this.refreshStatusSuccess=!1;this.scope="all";this.refreshAbortController=new AbortController;this.closed=!1;if(this.tui=n,this.currentModel=i,this.settingsManager=o,this.modelRuntime=r,this.scopedModels=s,this.scope=s.length>0?"scoped":"all",this.onSelectCallback=a,this.onCancelCallback=l,this.addChild(new H),this.addChild(new L(1)),s.length>0)this.scopeText=new A(this.getScopeText(),0,0),this.addChild(this.scopeText),this.scopeHintText=new A(this.getScopeHintText(),0,0),this.addChild(this.scopeHintText);else{let u="Only showing models from configured providers. Use /login to add providers.";this.addChild(new A(v.fg("warning",u),0,0))}this.addChild(new L(1)),this.searchInput=new Xe,c&&this.searchInput.setValue(c),this.searchInput.onSubmit=()=>{this.filteredModels[this.selectedIndex]&&this.handleSelect(this.filteredModels[this.selectedIndex].model)},this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new H),this.loadModelsFromSnapshot(),c?this.filterModels(c):this.updateList(),this.tui.requestRender(),this.refreshModels()}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}loadModelsFromSnapshot(){let n=this.modelRuntime.getAvailableSnapshot().map(o=>({provider:o.provider,id:o.id,model:o}));this.allModels=this.sortModels(n),this.scopedModels=this.scopedModels.map(o=>{let r=this.modelRuntime.getModel(o.model.provider,o.model.id);return r?{...o,model:r}:o}),this.scopedModelItems=this.scopedModels.map(o=>({provider:o.model.provider,id:o.model.id,model:o.model})),this.activeModels=this.scope==="scoped"?this.scopedModelItems:this.allModels,this.filteredModels=this.activeModels;let i=this.filteredModels.findIndex(o=>Qi(this.currentModel,o.model));this.selectedIndex=i>=0?i:Math.min(this.selectedIndex,Math.max(0,this.filteredModels.length-1))}async refreshModels(){let i=!1;this.refreshTimeout=setTimeout(()=>{i=!0,this.refreshAbortController.abort()},15e3);try{let o=await this.modelRuntime.refresh({signal:this.refreshAbortController.signal});if(this.closed)return;this.refreshStatusMessage="",o.aborted&&i?this.errorMessage="Model refresh timed out; showing cached models.":o.errors.size===1?this.errorMessage=`Could not refresh ${o.errors.keys().next().value}; showing cached models.`:o.errors.size>1?this.errorMessage=`Could not refresh ${o.errors.size} model catalogs; showing cached models.`:(this.errorMessage=this.modelRuntime.getError(),this.errorMessage||(this.refreshStatusMessage="Model catalogs refreshed.",this.refreshStatusSuccess=!0)),this.loadModelsFromSnapshot(),this.filterModels(this.searchInput.getValue()),this.tui.requestRender()}finally{this.refreshTimeout&&clearTimeout(this.refreshTimeout)}}close(){this.closed=!0,this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshAbortController.abort()}sortModels(n){let i=[...n];return i.sort((o,r)=>{let s=Qi(this.currentModel,o.model),a=Qi(this.currentModel,r.model);return s&&!a?-1:!s&&a?1:o.provider.localeCompare(r.provider)}),i}getScopeText(){let n=this.scope==="all"?v.fg("accent","all"):v.fg("muted","all"),i=this.scope==="scoped"?v.fg("accent","scoped"):v.fg("muted","scoped");return`${v.fg("muted","Scope: ")}${n}${v.fg("muted"," | ")}${i}`}getScopeHintText(){return le("tui.input.tab","scope")+v.fg("muted"," (all/scoped)")}setScope(n){if(this.scope===n)return;this.scope=n,this.activeModels=this.scope==="scoped"?this.scopedModelItems:this.allModels;let i=this.activeModels.findIndex(o=>Qi(this.currentModel,o.model));this.selectedIndex=i>=0?i:0,this.filterModels(this.searchInput.getValue()),this.scopeText&&this.scopeText.setText(this.getScopeText())}filterModels(n){this.filteredModels=n?Gt(this.activeModels,n,({id:i,provider:o,model:r})=>vE({id:i,provider:o,name:r.name})):this.activeModels,this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredModels.length-1)),this.updateList()}updateList(){this.listContainer.clear();let n=10,i=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),this.filteredModels.length-n)),o=Math.min(i+n,this.filteredModels.length);for(let r=i;r<o;r++){let s=this.filteredModels[r];if(!s)continue;let a=r===this.selectedIndex,l=Qi(this.currentModel,s.model),c="";if(a){let u=v.fg("accent","\u2192 "),d=`${s.id}`,p=v.fg("muted",`[${s.provider}]`),m=l?v.fg("success"," \u2713"):"";c=`${u+v.fg("accent",d)} ${p}${m}`}else{let u=` ${s.id}`,d=v.fg("muted",`[${s.provider}]`),p=l?v.fg("success"," \u2713"):"";c=`${u} ${d}${p}`}this.listContainer.addChild(new A(c,0,0))}if(i>0||o<this.filteredModels.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.filteredModels.length})`);this.listContainer.addChild(new A(r,0,0))}if(this.errorMessage){let r=this.errorMessage.split(`
255
+ `);for(let s of r)this.listContainer.addChild(new A(v.fg("error",s),0,0))}else if(this.filteredModels.length===0)this.listContainer.addChild(new A(v.fg("muted"," No matching models"),0,0));else{let r=this.filteredModels[this.selectedIndex];this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg("muted",` Model Name: ${r.model.name}`),0,0))}this.refreshStatusMessage&&(this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg(this.refreshStatusSuccess?"success":"muted",` ${this.refreshStatusMessage}`),0,0)))}handleInput(n){let i=we();if(i.matches(n,"tui.input.tab")){if(this.scopedModelItems.length>0){let o=this.scope==="all"?"scoped":"all";this.setScope(o),this.scopeHintText&&this.scopeHintText.setText(this.getScopeHintText())}return}if(i.matches(n,"tui.select.up")){if(this.filteredModels.length===0)return;this.selectedIndex=this.selectedIndex===0?this.filteredModels.length-1:this.selectedIndex-1,this.updateList()}else if(i.matches(n,"tui.select.down")){if(this.filteredModels.length===0)return;this.selectedIndex=this.selectedIndex===this.filteredModels.length-1?0:this.selectedIndex+1,this.updateList()}else if(i.matches(n,"tui.select.confirm")){let o=this.filteredModels[this.selectedIndex];o&&this.handleSelect(o.model)}else i.matches(n,"tui.select.cancel")?(this.close(),this.onCancelCallback()):(this.searchInput.handleInput(n),this.filterModels(this.searchInput.getValue()))}handleSelect(n){this.close(),this.settingsManager.setDefaultModelAndProvider(n.provider,n.id),this.onSelectCallback(n)}getSearchInput(){return this.searchInput}};function Km(t){return t==="oauth"?"subscription":"API key"}var as=class extends z{constructor(n,i,o,r,s){super();this._focused=!1;this.selectedIndex=0;this.mode=n,this.allProviders=i,this.filteredProviders=i,this.showAuthTypeLabels=new Set(i.map(l=>l.authType)).size>1,this.onSelectCallback=o,this.onCancelCallback=r,this.addChild(new H),this.addChild(new L(1));let a=n==="login"?"Select provider to configure:":"Select provider to logout:";this.addChild(new Kn(v.fg("accent",v.bold(a)),1,0)),this.addChild(new L(1)),this.searchInput=new Xe,s&&this.searchInput.setValue(s),this.searchInput.onSubmit=()=>{let l=this.filteredProviders[this.selectedIndex];l&&this.onSelectCallback(l.id,l.authType)},this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new H),this.filterProviders(s??"")}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}filterProviders(n){this.filteredProviders=n?Gt(this.allProviders,n,i=>`${i.name} ${i.id} ${i.authType} ${i.method?.name??""}`):this.allProviders,this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,Math.max(0,this.filteredProviders.length-1))),this.updateList()}updateList(){this.listContainer.clear();let n=8,i=Math.max(0,Math.min(this.selectedIndex-Math.floor(n/2),this.filteredProviders.length-n)),o=Math.min(i+n,this.filteredProviders.length);for(let r=i;r<o;r++){let s=this.filteredProviders[r];if(!s)continue;let a=r===this.selectedIndex,l=this.formatStatusIndicator(s),c=this.showAuthTypeLabels?v.fg("muted",` [${Km(s.authType)}]`):"",u="";if(a){let d=v.fg("accent","\u2192 "),p=v.fg("accent",s.name);u=d+p+c+l}else u=` ${v.fg("text",s.name)}`+c+l;this.listContainer.addChild(new Kn(u,1,0))}if(i>0||o<this.filteredProviders.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.filteredProviders.length})`);this.listContainer.addChild(new Kn(r,1,0))}if(this.filteredProviders.length===0){let r=this.allProviders.length===0?this.mode==="login"?"No providers available":"No providers logged in. Use /login first.":"No matching providers";this.listContainer.addChild(new Kn(v.fg("muted",` ${r}`),1,0))}}formatStatusIndicator(n){if(!n.status)return v.fg("muted"," \u2022 unconfigured");if(n.status.type!==n.authType){let o=n.status.type==="oauth"?"subscription configured":"API key configured";return v.fg("muted"," \u2022 ")+v.fg("warning",o)}if(!n.status.source||n.status.source==="OAuth"||n.status.source==="stored credential")return v.fg("success"," \u2713 configured");let i=/^[A-Z][A-Z0-9_]*(?:, [A-Z][A-Z0-9_]*)*$/.test(n.status.source)?`env: ${n.status.source}`:n.status.source;return v.fg("success",` \u2713 ${i}`)}handleInput(n){let i=we();if(i.matches(n,"tui.select.up")){if(this.filteredProviders.length===0)return;this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList()}else if(i.matches(n,"tui.select.down")){if(this.filteredProviders.length===0)return;this.selectedIndex=Math.min(this.filteredProviders.length-1,this.selectedIndex+1),this.updateList()}else if(i.matches(n,"tui.select.confirm")){let o=this.filteredProviders[this.selectedIndex];o&&this.onSelectCallback(o.id,o.authType)}else i.matches(n,"tui.select.cancel")?this.onCancelCallback():(this.searchInput.handleInput(n),this.filterProviders(this.searchInput.getValue()))}};function pb(t,e){return t===null||t.includes(e)}function cG(t,e){if(t===null)return[e];let n=t.indexOf(e);return n>=0?[...t.slice(0,n),...t.slice(n+1)]:[...t,e]}function bE(t,e,n){if(t===null)return null;let i=n??e,o=[...t];for(let r of i)o.includes(r)||o.push(r);return o.length===e.length?null:o}function xE(t,e,n){if(t===null)return n?e.filter(o=>!n.includes(o)):[];let i=new Set(n??t);return t.filter(o=>!i.has(o))}function uG(t,e,n){if(t===null)return null;let i=[...t],o=i.indexOf(e);if(o<0)return i;let r=o+n;if(r<0||r>=i.length)return i;let s=[...i];return[s[o],s[r]]=[s[r],s[o]],s}function dG(t,e){if(t===null)return e;let n=new Set(t);return[...t,...e.filter(i=>!n.has(i))]}var ku=class extends z{constructor(n,i){super();this.modelsById=new Map;this.allIds=[];this.enabledIds=null;this.filteredItems=[];this.selectedIndex=0;this._focused=!1;this.maxVisible=8;this.isDirty=!1;this.callbacks=i;for(let o of n.allModels){let r=`${o.provider}/${o.id}`;this.modelsById.set(r,o),this.allIds.push(r)}this.enabledIds=n.enabledModelIds===null?null:[...n.enabledModelIds],this.filteredItems=this.buildItems(),this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",v.bold("Model Configuration")),0,0)),this.addChild(new A(v.fg("muted",`Session-only. ${Re("app.models.save")} to save to settings.`),0,0)),this.addChild(new L(1)),this.searchInput=new Xe,this.addChild(this.searchInput),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.footerText=new A(this.getFooterText(),0,0),this.addChild(this.footerText),this.addChild(new H),this.updateList()}get focused(){return this._focused}set focused(n){this._focused=n,this.searchInput.focused=n}buildItems(){return dG(this.enabledIds,this.allIds).filter(n=>this.modelsById.has(n)).map(n=>({fullId:n,model:this.modelsById.get(n),enabled:pb(this.enabledIds,n)}))}getFooterText(){let n=this.enabledIds?.length??this.allIds.length,o=this.enabledIds===null?"all enabled":`${n}/${this.allIds.length} enabled`,r=[`${Re("tui.select.confirm")} toggle`,`${Re("app.models.enableAll")} all`,`${Re("app.models.clearAll")} clear`,`${Re("app.models.toggleProvider")} provider`,`${Re("app.models.reorderUp")}/${Re("app.models.reorderDown")} reorder`,`${Re("app.models.save")} save`,o];return this.isDirty?v.fg("dim",` ${r.join(" \xB7 ")} `)+v.fg("warning","(unsaved)"):v.fg("dim",` ${r.join(" \xB7 ")}`)}refresh(){let n=this.searchInput.getValue(),i=this.buildItems();this.filteredItems=n?Gt(i,n,o=>qm({id:o.model.id,provider:o.model.provider,name:o.model.name})):i,this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredItems.length-1)),this.updateList(),this.footerText.setText(this.getFooterText())}notifyChange(){this.callbacks.onChange(this.enabledIds===null?null:[...this.enabledIds])}updateList(){if(this.listContainer.clear(),this.filteredItems.length===0){this.listContainer.addChild(new A(v.fg("muted"," No matching models"),0,0));return}let n=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.filteredItems.length-this.maxVisible)),i=Math.min(n+this.maxVisible,this.filteredItems.length),o=this.enabledIds===null;for(let r=n;r<i;r++){let s=this.filteredItems[r],a=r===this.selectedIndex,l=a?v.fg("accent","\u2192 "):" ",c=a?v.fg("accent",s.model.id):s.model.id,u=v.fg("muted",` [${s.model.provider}]`),d=o?"":s.enabled?v.fg("success"," \u2713"):v.fg("dim"," \u2717");this.listContainer.addChild(new A(`${l}${c}${u}${d}`,0,0))}if((n>0||i<this.filteredItems.length)&&this.listContainer.addChild(new A(v.fg("muted",` (${this.selectedIndex+1}/${this.filteredItems.length})`),0,0)),this.filteredItems.length>0){let r=this.filteredItems[this.selectedIndex];this.listContainer.addChild(new L(1)),this.listContainer.addChild(new A(v.fg("muted",` Model Name: ${r.model.name}`),0,0))}}handleInput(n){let i=we();if(i.matches(n,"tui.select.up")){if(this.filteredItems.length===0)return;this.selectedIndex=this.selectedIndex===0?this.filteredItems.length-1:this.selectedIndex-1,this.updateList();return}if(i.matches(n,"tui.select.down")){if(this.filteredItems.length===0)return;this.selectedIndex=this.selectedIndex===this.filteredItems.length-1?0:this.selectedIndex+1,this.updateList();return}let o=i.matches(n,"app.models.reorderUp"),r=i.matches(n,"app.models.reorderDown");if(o||r){if(this.enabledIds===null)return;let s=this.filteredItems[this.selectedIndex];if(s&&pb(this.enabledIds,s.fullId)){let a=o?-1:1,c=this.enabledIds.indexOf(s.fullId)+a;c>=0&&c<this.enabledIds.length&&(this.enabledIds=uG(this.enabledIds,s.fullId,a),this.isDirty=!0,this.selectedIndex+=a,this.refresh(),this.notifyChange())}return}if(i.matches(n,"tui.select.confirm")){let s=this.filteredItems[this.selectedIndex];s&&(this.enabledIds=cG(this.enabledIds,s.fullId),this.isDirty=!0,this.refresh(),this.notifyChange());return}if(i.matches(n,"app.models.enableAll")){let s=this.searchInput.getValue()?this.filteredItems.map(a=>a.fullId):void 0;this.enabledIds=bE(this.enabledIds,this.allIds,s),this.isDirty=!0,this.refresh(),this.notifyChange();return}if(i.matches(n,"app.models.clearAll")){let s=this.searchInput.getValue()?this.filteredItems.map(a=>a.fullId):void 0;this.enabledIds=xE(this.enabledIds,this.allIds,s),this.isDirty=!0,this.refresh(),this.notifyChange();return}if(i.matches(n,"app.models.toggleProvider")){let s=this.filteredItems[this.selectedIndex];if(s){let a=s.model.provider,l=this.allIds.filter(u=>this.modelsById.get(u).provider===a),c=l.every(u=>pb(this.enabledIds,u));this.enabledIds=c?xE(this.enabledIds,this.allIds,l):bE(this.enabledIds,this.allIds,l),this.isDirty=!0,this.refresh(),this.notifyChange()}return}if(i.matches(n,"app.models.save")){this.callbacks.onPersist(this.enabledIds===null?null:[...this.enabledIds]),this.isDirty=!1,this.footerText.setText(this.getFooterText());return}if(Fe(n,Or.ctrl("c"))){this.searchInput.getValue()?(this.searchInput.setValue(""),this.refresh()):this.callbacks.onCancel();return}if(Fe(n,Or.escape)){this.callbacks.onCancel();return}this.searchInput.handleInput(n),this.refresh()}getSearchInput(){return this.searchInput}};var pG={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},mG={off:"No reasoning",minimal:"Very brief reasoning (~1k tokens)",low:"Light reasoning (~2k tokens)",medium:"Moderate reasoning (~8k tokens)",high:"Deep reasoning (~16k tokens)",xhigh:"Extra-high reasoning (~32k tokens)",max:"Maximum reasoning"},mb={ask:"Ask",always:"Always trust",never:"Never trust"},hG=new Map(Object.entries(mb).map(([t,e])=>[e,t])),hb=class extends z{constructor(e,n,i){super(),this.state={...e};let o=[{id:"anthropic-extra-usage",label:"Anthropic extra usage",description:"Warn when Anthropic subscription auth may use paid extra usage",currentValue:this.state.anthropicExtraUsage??!0?"true":"false",values:["true","false"]}];this.settingsList=new $r(o,Math.min(o.length,10),Gc(),(r,s)=>{r==="anthropic-extra-usage"&&(this.state={...this.state,anthropicExtraUsage:s==="true"},n({...this.state}))},i),this.addChild(this.settingsList)}handleInput(e){this.settingsList.handleInput(e)}},Su=class extends z{constructor(e,n,i,o,r,s,a){super(),this.addChild(new A(v.bold(v.fg("accent",e)),0,0)),n&&(this.addChild(new L(1)),this.addChild(new A(v.fg("muted",n),0,0))),this.addChild(new L(1)),this.selectList=new Ht(i,Math.min(i.length,10),zr(),pG);let l=i.findIndex(c=>c.value===o);l!==-1&&this.selectList.setSelectedIndex(l),this.selectList.onSelect=c=>{r(c.value)},this.selectList.onCancel=s,a&&(this.selectList.onSelectionChange=c=>{a(c.value)}),this.addChild(this.selectList),this.addChild(new L(1)),this.addChild(new A(v.fg("dim"," Enter to select \xB7 Esc to go back"),0,0))}handleInput(e){this.selectList.handleInput(e)}};function yE(t){return t.map(e=>({value:e,label:e}))}var gb="/";function gG(t){return[{value:gb,label:"Automatic",description:"Use separate themes for light and dark terminal appearance"},...yE(t)]}function wE(t,e,n){return e&&t.includes(e)?e:t.includes(n)?n:t[0]??n}function fG(t,e){let n=Ko(t);if(n)return n;let i=t.includes("/")?void 0:t,o=wE(e,i,"dark");return{lightTheme:o,darkTheme:o}}var fb=class extends z{constructor(e,n,i,o,r){super(),this.callbacks=o,this.availableThemes=i,this.terminalTheme=n,this.onDone=r,this.originalThemeSetting=e;let s=Ko(e),a=fG(e,i),l=s||e.includes("/")?void 0:e;this.mode=s?"automatic":"single",this.lightTheme=a.lightTheme,this.darkTheme=a.darkTheme,this.singleTheme=wE(i,l??(s?this.getActiveAutomaticTheme():void 0),"dark"),this.mode==="automatic"?this.showAutomaticMenu():this.showSingleMenu()}handleInput(e){this.inputComponent?.handleInput?.(e)}setContent(e,n=e){this.clear(),this.addChild(e),this.inputComponent=n}showSingleMenu(){this.mode="single";let e=new Su("Theme","Select a theme, or choose Automatic to follow terminal appearance.",gG(this.availableThemes),this.singleTheme,n=>{if(n===gb){this.mode="automatic",this.callbacks.onThemePreview?.(this.getThemeSetting()),this.showAutomaticMenu();return}this.singleTheme=n,this.apply(n)},()=>this.cancel(),n=>{this.callbacks.onThemePreview?.(n===gb?this.getAutomaticThemeSetting():n)});this.setContent(e)}showAutomaticMenu(){this.mode="automatic";let e=new z;e.addChild(new A(v.bold(v.fg("accent","Automatic Theme")),0,0)),e.addChild(new L(1)),e.addChild(new A(v.fg("muted","Choose themes for terminal light and dark appearance."),0,0)),e.addChild(new A(v.fg("muted","Light/dark detection requires terminal support."),0,0)),e.addChild(new L(1));let n=[{id:"light-theme",label:"Light theme",description:"Theme to use in automatic mode when the terminal is light",currentValue:this.lightTheme,submenu:(o,r)=>this.createThemeSelect("Light Theme","Select the theme to use for light terminal appearance",o,r,s=>{this.lightTheme=s,this.callbacks.onThemePreview?.(this.getThemeSetting()),r(s)})},{id:"dark-theme",label:"Dark theme",description:"Theme to use in automatic mode when the terminal is dark",currentValue:this.darkTheme,submenu:(o,r)=>this.createThemeSelect("Dark Theme","Select the theme to use for dark terminal appearance",o,r,s=>{this.darkTheme=s,this.callbacks.onThemePreview?.(this.getThemeSetting()),r(s)})},{id:"apply",label:"Apply",description:"Save and go back",currentValue:"save and go back",values:["save and go back"]},{id:"single-mode",label:"Change mode",description:"Switch to one theme for light and dark",currentValue:"switch to single theme",values:["switch to single theme"]}],i=new $r(n,Math.min(n.length,10),Gc(),o=>{switch(o){case"single-mode":this.mode="single",this.singleTheme=this.getActiveAutomaticTheme(),this.callbacks.onThemePreview?.(this.singleTheme),this.showSingleMenu();break;case"apply":this.apply(this.getAutomaticThemeSetting());break}},()=>this.cancel());e.addChild(i),this.setContent(e,i)}createThemeSelect(e,n,i,o,r){return new Su(e,n,yE(this.availableThemes),i,r,()=>{this.callbacks.onThemePreview?.(this.getThemeSetting()),o()},s=>this.callbacks.onThemePreview?.(s))}getThemeSetting(){return this.mode==="automatic"?this.getAutomaticThemeSetting():this.singleTheme}getActiveAutomaticTheme(){return this.terminalTheme==="light"?this.lightTheme:this.darkTheme}getAutomaticThemeSetting(){return`${this.lightTheme}/${this.darkTheme}`}apply(e){this.onDone(e)}cancel(){this.callbacks.onThemePreview?.(this.originalThemeSetting),this.onDone()}},Rl=class extends z{constructor(e,n){super();let i=ft().images,o=Xc("app.message.followUp"),r={...e.warnings},s=[{id:"autocompact",label:"Auto-compact",description:"Automatically compact context when it gets too large",currentValue:e.autoCompact?"true":"false",values:["true","false"]},{id:"steering-mode",label:"Steering mode",description:"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.",currentValue:e.steeringMode,values:["one-at-a-time","all"]},{id:"follow-up-mode",label:"Follow-up mode",description:`${o} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,currentValue:e.followUpMode,values:["one-at-a-time","all"]},{id:"transport",label:"Transport",description:"Preferred transport for providers that support multiple transports",currentValue:e.transport,values:["sse","websocket","websocket-cached","auto"]},{id:"http-idle-timeout",label:"HTTP idle timeout",description:"Maximum idle gap while waiting for HTTP headers or body chunks. Disable for local models that pause longer than five minutes.",currentValue:Om(e.httpIdleTimeoutMs),values:Am.map(h=>h.label)},{id:"hide-thinking",label:"Hide thinking",description:"Hide thinking blocks in assistant responses",currentValue:e.hideThinkingBlock?"true":"false",values:["true","false"]},{id:"cache-miss-notices",label:"Cache miss notices",description:"Show transcript notices for significant prompt-cache misses",currentValue:e.showCacheMissNotices?"true":"false",values:["true","false"]},{id:"collapse-changelog",label:"Collapse changelog",description:"Show condensed changelog after updates",currentValue:e.collapseChangelog?"true":"false",values:["true","false"]},{id:"quiet-startup",label:"Quiet startup",description:"Disable verbose printing at startup",currentValue:e.quietStartup?"true":"false",values:["true","false"]},{id:"install-telemetry",label:"Install telemetry",description:"Send an anonymous version/update ping after changelog-detected updates",currentValue:e.enableInstallTelemetry?"true":"false",values:["true","false"]},{id:"default-project-trust",label:"Default project trust",description:"Fallback behavior when no extension or saved trust decision decides project trust",currentValue:mb[e.defaultProjectTrust],values:Object.values(mb)},{id:"double-escape-action",label:"Double-escape action",description:"Action when pressing Escape twice with empty editor",currentValue:e.doubleEscapeAction,values:["tree","fork","none"]},{id:"tree-filter-mode",label:"Tree filter mode",description:"Default filter when opening /tree",currentValue:e.treeFilterMode,values:["default","no-tools","user-only","labeled-only","all"]},{id:"warnings",label:"Warnings",description:"Enable or disable individual warnings",currentValue:"configure",submenu:(h,f)=>new hb(r,b=>{r=b,n.onWarningsChange(b)},()=>f())},{id:"thinking",label:"Thinking level",description:"Reasoning depth for thinking-capable models",currentValue:e.thinkingLevel,submenu:(h,f)=>new Su("Thinking Level","Select reasoning depth for thinking-capable models",e.availableThinkingLevels.map(b=>({value:b,label:b,description:mG[b]})),h,b=>{n.onThinkingLevelChange(b),f(b)},()=>f())},{id:"theme",label:"Theme",description:"Color theme for the interface",currentValue:e.currentTheme,submenu:(h,f)=>new fb(h,e.terminalTheme,e.availableThemes,n,f)}];i&&(s.splice(1,0,{id:"show-images",label:"Show images",description:"Render images inline in terminal",currentValue:e.showImages?"true":"false",values:["true","false"]}),s.splice(2,0,{id:"image-width-cells",label:"Image width",description:"Preferred inline image width in terminal cells",currentValue:String(e.imageWidthCells),values:["60","80","120"]})),s.splice(i?3:1,0,{id:"auto-resize-images",label:"Auto-resize images",description:"Resize large images to 2000x2000 max for better model compatibility",currentValue:e.autoResizeImages?"true":"false",values:["true","false"]});let a=s.findIndex(h=>h.id==="auto-resize-images");s.splice(a+1,0,{id:"block-images",label:"Block images",description:"Prevent images from being sent to LLM providers",currentValue:e.blockImages?"true":"false",values:["true","false"]});let l=s.findIndex(h=>h.id==="block-images");s.splice(l+1,0,{id:"skill-commands",label:"Skill commands",description:"Register skills as /skill:name commands",currentValue:e.enableSkillCommands?"true":"false",values:["true","false"]});let c=s.findIndex(h=>h.id==="skill-commands");s.splice(c+1,0,{id:"show-hardware-cursor",label:"Show hardware cursor",description:"Show the terminal cursor while still positioning it for IME support",currentValue:e.showHardwareCursor?"true":"false",values:["true","false"]});let u=s.findIndex(h=>h.id==="show-hardware-cursor");s.splice(u+1,0,{id:"editor-padding",label:"Editor padding",description:"Horizontal padding for input editor (0-3)",currentValue:String(e.editorPaddingX),values:["0","1","2","3"]});let d=s.findIndex(h=>h.id==="editor-padding");s.splice(d+1,0,{id:"output-padding",label:"Output padding",description:"Horizontal padding for user messages, assistant messages, and thinking",currentValue:String(e.outputPad),values:["0","1"]});let p=s.findIndex(h=>h.id==="output-padding");s.splice(p+1,0,{id:"autocomplete-max-visible",label:"Autocomplete max items",description:"Max visible items in autocomplete dropdown (3-20)",currentValue:String(e.autocompleteMaxVisible),values:["3","5","7","10","15","20"]});let m=s.findIndex(h=>h.id==="autocomplete-max-visible");s.splice(m+1,0,{id:"clear-on-shrink",label:"Clear on shrink",description:"Clear empty rows when content shrinks (may cause flicker)",currentValue:e.clearOnShrink?"true":"false",values:["true","false"]});let g=s.findIndex(h=>h.id==="clear-on-shrink");s.splice(g+1,0,{id:"terminal-progress",label:"Terminal progress",description:"Show OSC 9;4 progress indicators in the terminal tab bar",currentValue:e.showTerminalProgress?"true":"false",values:["true","false"]}),this.addChild(new H),this.settingsList=new $r(s,10,Gc(),(h,f)=>{switch(h){case"autocompact":n.onAutoCompactChange(f==="true");break;case"show-images":n.onShowImagesChange(f==="true");break;case"image-width-cells":n.onImageWidthCellsChange(parseInt(f,10));break;case"auto-resize-images":n.onAutoResizeImagesChange(f==="true");break;case"block-images":n.onBlockImagesChange(f==="true");break;case"skill-commands":n.onEnableSkillCommandsChange(f==="true");break;case"steering-mode":n.onSteeringModeChange(f);break;case"follow-up-mode":n.onFollowUpModeChange(f);break;case"transport":n.onTransportChange(f);break;case"http-idle-timeout":{let b=Am.find(x=>x.label===f);b&&n.onHttpIdleTimeoutMsChange(b.timeoutMs);break}case"hide-thinking":n.onHideThinkingBlockChange(f==="true");break;case"cache-miss-notices":n.onShowCacheMissNoticesChange(f==="true");break;case"collapse-changelog":n.onCollapseChangelogChange(f==="true");break;case"quiet-startup":n.onQuietStartupChange(f==="true");break;case"install-telemetry":n.onEnableInstallTelemetryChange(f==="true");break;case"default-project-trust":{let b=hG.get(f);b&&n.onDefaultProjectTrustChange(b);break}case"double-escape-action":n.onDoubleEscapeActionChange(f);break;case"tree-filter-mode":n.onTreeFilterModeChange(f);break;case"show-hardware-cursor":n.onShowHardwareCursorChange(f==="true");break;case"editor-padding":n.onEditorPaddingXChange(parseInt(f,10));break;case"output-padding":n.onOutputPadChange(f==="0"?0:1);break;case"autocomplete-max-visible":n.onAutocompleteMaxVisibleChange(parseInt(f,10));break;case"clear-on-shrink":n.onClearOnShrinkChange(f==="true");break;case"terminal-progress":n.onShowTerminalProgressChange(f==="true");break;case"theme":n.onThemeChange(f);break}},n.onCancel,{enableSearch:!0}),this.addChild(this.settingsList),this.addChild(new H)}getSettingsList(){return this.settingsList}};var Pl=class extends pt{constructor(n,i=Ft()){super(1,1,o=>v.bg("customMessageBg",o));this.expanded=!1;this.skillBlock=n,this.markdownTheme=i,this.updateDisplay()}setExpanded(n){this.expanded=n,this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){if(this.clear(),this.expanded){let n=v.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m");this.addChild(new A(n,0,0));let i=`**${this.skillBlock.name}**
256
256
 
257
257
  `;this.addChild(new Ze(i+this.skillBlock.content,0,0,this.markdownTheme,{color:o=>v.fg("customMessageText",o)}))}else{let n=v.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m ")+v.fg("customMessageText",this.skillBlock.name)+v.fg("dim",` (${Re("app.tools.expand")} to expand)`);this.addChild(new A(n,0,0))}}};var Il=class extends li{constructor(e,n,i,o,r,s){super(n,i,o,r,s),this.kind=e}dispose(){this.stop()}},Tu=class extends Il{constructor(e,n,i){super("working",e,o=>v.fg("accent",o),o=>v.fg("muted",o),n,i)}},Cu=class extends Il{constructor(e,n,i,o){let r=s=>`Retrying (${n}/${i}) in ${s}s... (${Re("app.interrupt")} to cancel)`;super("retry",e,s=>v.fg("warning",s),s=>v.fg("muted",s),r(Math.ceil(o/1e3))),this.countdown=new Xo(o,e,s=>{this.setMessage(r(s))},()=>{this.countdown=void 0})}dispose(){this.countdown?.dispose(),this.countdown=void 0,super.dispose()}},Mu=class extends Il{constructor(e,n){let i=`(${Re("app.interrupt")} to cancel)`,o=n==="manual"?`Compacting context... ${i}`:`${n==="overflow"?"Context overflow detected, ":""}Auto-compacting... ${i}`;super("compaction",e,r=>v.fg("accent",r),r=>v.fg("muted",r),o)}},Ru=class extends Il{constructor(e){super("branchSummary",e,n=>v.fg("accent",n),n=>v.fg("muted",n),`Summarizing branch... (${Re("app.interrupt")} to cancel)`)}},Gm=class{invalidate(){}render(e){let n=" ".repeat(e);return[n,n]}};var Oi=class extends z{constructor(n,i,o,r={},s,a,l){super();this.rendererState={};this.imageComponents=[];this.imageSpacers=[];this.expanded=!1;this.isPartial=!0;this.executionStarted=!1;this.argsComplete=!1;this.convertedImages=new Map;this.hideComponent=!1;this.toolName=n,this.toolCallId=i,this.args=o,this.toolDefinition=s,this.builtInToolDefinition=I0(l)[n],this.showImages=r.showImages??!0,this.imageWidthCells=r.imageWidthCells??60,this.ui=a,this.cwd=l,this.addChild(new L(1)),this.contentBox=new pt(1,1,c=>v.bg("toolPendingBg",c)),this.contentText=new A("",1,1,c=>v.bg("toolPendingBg",c)),this.selfRenderContainer=new z,this.hasRendererDefinition()?this.addChild(this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox):this.addChild(this.contentText),this.updateDisplay()}getCallRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderCall??this.builtInToolDefinition.renderCall:this.builtInToolDefinition.renderCall:this.toolDefinition?.renderCall}getResultRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderResult??this.builtInToolDefinition.renderResult:this.builtInToolDefinition.renderResult:this.toolDefinition?.renderResult}hasRendererDefinition(){return this.builtInToolDefinition!==void 0||this.toolDefinition!==void 0}getRenderShell(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderShell??this.builtInToolDefinition.renderShell??"default":this.builtInToolDefinition.renderShell??"default":this.toolDefinition?.renderShell??"default"}getRenderContext(n){return{args:this.args,toolCallId:this.toolCallId,invalidate:()=>{this.invalidate(),this.ui.requestRender()},lastComponent:n,state:this.rendererState,cwd:this.cwd,executionStarted:this.executionStarted,argsComplete:this.argsComplete,isPartial:this.isPartial,expanded:this.expanded,showImages:this.showImages,isError:this.result?.isError??!1}}createCallFallback(){return new A(v.fg("toolTitle",v.bold(this.toolName)),0,0)}createResultFallback(){let n=this.getTextOutput();if(n)return new A(v.fg("toolOutput",n),0,0)}updateArgs(n){this.args=n,this.updateDisplay()}markExecutionStarted(){this.executionStarted=!0,this.updateDisplay(),this.ui.requestRender()}setArgsComplete(){this.argsComplete=!0,this.updateDisplay(),this.ui.requestRender()}updateResult(n,i=!1){this.result=n,this.isPartial=i,this.updateDisplay(),this.maybeConvertImagesForKitty()}maybeConvertImagesForKitty(){if(ft().images!=="kitty"||!this.result)return;let i=this.result.content.filter(o=>o.type==="image");for(let o=0;o<i.length;o++){let r=i[o];if(!r.data||!r.mimeType||r.mimeType==="image/png"||this.convertedImages.has(o))continue;let s=o;d0(r.data,r.mimeType).then(a=>{a&&(this.convertedImages.set(s,a),this.updateDisplay(),this.ui.requestRender())})}}setExpanded(n){this.expanded=n,this.updateDisplay()}setShowImages(n){this.showImages=n,this.updateDisplay()}setImageWidthCells(n){this.imageWidthCells=Math.max(1,Math.floor(n)),this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}render(n){if(this.hideComponent)return[];if(this.hasRendererDefinition()&&this.getRenderShell()==="self"){let i=this.selfRenderContainer.render(n);if(i.length===0&&this.imageComponents.length===0)return[];let o=[];i.length>0&&(o.push(""),o.push(...i));for(let r=0;r<this.imageComponents.length;r++){let s=this.imageSpacers[r];s&&o.push(...s.render(n));let a=this.imageComponents[r];a&&o.push(...a.render(n))}return o}return super.render(n)}updateDisplay(){let n=this.isPartial?o=>v.bg("toolPendingBg",o):this.result?.isError?o=>v.bg("toolErrorBg",o):o=>v.bg("toolSuccessBg",o),i=!1;if(this.hideComponent=!1,this.hasRendererDefinition()){let o=this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox;o instanceof pt&&o.setBgFn(n),o.clear();let r=this.getCallRenderer();if(!r)o.addChild(this.createCallFallback()),i=!0;else try{let s=r(this.args,v,this.getRenderContext(this.callRendererComponent));this.callRendererComponent=s,o.addChild(s),i=!0}catch{this.callRendererComponent=void 0,o.addChild(this.createCallFallback()),i=!0}if(this.result){let s=this.getResultRenderer();if(s)try{let a=s({content:this.result.content,details:this.result.details},{expanded:this.expanded,isPartial:this.isPartial},v,this.getRenderContext(this.resultRendererComponent));this.resultRendererComponent=a,o.addChild(a),i=!0}catch{this.resultRendererComponent=void 0;let a=this.createResultFallback();a&&(o.addChild(a),i=!0)}else{let a=this.createResultFallback();a&&(o.addChild(a),i=!0)}}}else this.contentText.setCustomBgFn(n),this.contentText.setText(this.formatToolExecution()),i=!0;for(let o of this.imageComponents)this.removeChild(o);this.imageComponents=[];for(let o of this.imageSpacers)this.removeChild(o);if(this.imageSpacers=[],this.result){let o=this.result.content.filter(s=>s.type==="image"),r=ft();for(let s=0;s<o.length;s++){let a=o[s];if(r.images&&this.showImages&&a.data&&a.mimeType){let l=this.convertedImages.get(s),c=l?.data??a.data,u=l?.mimeType??a.mimeType;if(r.images==="kitty"&&u!=="image/png")continue;let d=new L(1);this.addChild(d),this.imageSpacers.push(d);let p=new Ur(c,u,{fallbackColor:m=>v.fg("toolOutput",m)},{maxWidthCells:this.imageWidthCells});this.imageComponents.push(p),this.addChild(p)}}}this.hasRendererDefinition()&&!i&&this.imageComponents.length===0&&(this.hideComponent=!0)}getTextOutput(){return Hn(this.result,this.showImages)}formatToolExecution(){let n=v.fg("toolTitle",v.bold(this.toolName)),i=JSON.stringify(this.args,null,2);i&&(n+=`
258
258
 
259
259
  ${i}`);let o=this.getTextOutput();return o&&(n+=`
260
- ${o}`),n}};var vG=2,bG=4,xG=20,yG=2,wG=12;function kG(t,e){let n=Math.max(0,e-vG),i=t.reduce((a,l)=>Math.max(a,l.bodyWidth),0),o=Math.max(0,i-n),r=t.find(a=>a.isSelected),s=0;if(r&&o>0){let a=Math.min(xG,Math.max(bG,Math.floor(n/3)));if(r.anchorCol>n-a){let l=Math.min(wG,Math.max(yG,Math.floor(n/4)));s=Math.min(o,r.anchorCol-l)}}return t.map(a=>{let l=s>0?`${a.gutter}${no(a.body,s,n,!0)}\x1B[0m`:a.gutter+a.body;return te(l,e,"")})}var vb=class{constructor(e,n,i,o,r){this.flatNodes=[];this.filteredNodes=[];this.selectedIndex=0;this.filterMode="default";this.searchQuery="";this.toolCallMap=new Map;this.multipleRoots=!1;this.showLabelTimestamps=!1;this.activePathIds=new Set;this.visibleParentMap=new Map;this.visibleChildrenMap=new Map;this.lastSelectedId=null;this.foldedNodes=new Set;this.currentLeafId=n,this.maxVisibleLines=i,this.filterMode=r??"default",this.multipleRoots=e.length>1,this.flatNodes=this.flattenTree(e),this.buildActivePath(),this.applyFilter();let s=o??n;this.selectedIndex=this.findNearestVisibleIndex(s),this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??null}findNearestVisibleIndex(e){if(this.filteredNodes.length===0)return 0;let n=new Map;for(let r of this.flatNodes)n.set(r.node.entry.id,r);let i=new Map(this.filteredNodes.map((r,s)=>[r.node.entry.id,s])),o=e;for(;o!==null;){let r=i.get(o);if(r!==void 0)return r;let s=n.get(o);if(!s)break;o=s.node.entry.parentId??null}return this.filteredNodes.length-1}buildActivePath(){if(this.activePathIds.clear(),!this.currentLeafId)return;let e=new Map;for(let i of this.flatNodes)e.set(i.node.entry.id,i);let n=this.currentLeafId;for(;n;){this.activePathIds.add(n);let i=e.get(n);if(!i)break;n=i.node.entry.parentId??null}}flattenTree(e){let n=[];this.toolCallMap.clear();let i=[],o=new Map,r=this.currentLeafId;{let l=[],c=[...e];for(;c.length>0;){let u=c.pop();l.push(u);for(let d=u.children.length-1;d>=0;d--)c.push(u.children[d])}for(let u=l.length-1;u>=0;u--){let d=l[u],p=r!==null&&d.entry.id===r;for(let m of d.children)o.get(m)&&(p=!0);o.set(d,p)}}let s=e.length>1,a=[...e].sort((l,c)=>Number(o.get(c))-Number(o.get(l)));for(let l=a.length-1;l>=0;l--){let c=l===a.length-1;i.push([a[l],s?1:0,s,s,c,[],s])}for(;i.length>0;){let[l,c,u,d,p,m,g]=i.pop(),h=l.entry;if(h.type==="message"&&h.message.role==="assistant"){let D=h.message.content;if(Array.isArray(D)){for(let _ of D)if(typeof _=="object"&&_!==null&&"type"in _&&_.type==="toolCall"){let F=_;this.toolCallMap.set(F.id,{name:F.name,arguments:F.arguments})}}}n.push({node:l,indent:c,showConnector:d,isLast:p,gutters:m,isVirtualRootChild:g});let f=l.children,b=f.length>1,x=(()=>{let D=[],_=[];for(let F of f)o.get(F)?D.push(F):_.push(F);return[...D,..._]})(),y;b||u&&c>0?y=c+1:y=c;let T=d&&!g,P=this.multipleRoots?Math.max(0,c-1):c,I=Math.max(0,P-1),W=T?[...m,{position:I,show:!p}]:m;for(let D=x.length-1;D>=0;D--){let _=D===x.length-1;i.push([x[D],y,b,b,_,W,!1])}}return n}applyFilter(){this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId);let e=this.searchQuery.toLowerCase().split(/\s+/).filter(Boolean);if(this.filteredNodes=this.flatNodes.filter(n=>{let i=n.node.entry,o=i.id===this.currentLeafId;if(i.type==="message"&&i.message.role==="assistant"&&!o){let a=i.message,l=this.hasTextContent(a.content),c=a.stopReason&&a.stopReason!=="stop"&&a.stopReason!=="toolUse";if(!l&&!c)return!1}let r=!0,s=i.type==="label"||i.type==="custom"||i.type==="model_change"||i.type==="thinking_level_change"||i.type==="session_info";switch(this.filterMode){case"user-only":r=i.type==="message"&&i.message.role==="user";break;case"no-tools":r=!s&&!(i.type==="message"&&i.message.role==="toolResult");break;case"labeled-only":r=n.node.label!==void 0;break;case"all":r=!0;break;default:r=!s;break}if(!r)return!1;if(e.length>0){let a=this.getSearchableText(n.node).toLowerCase();return e.every(l=>a.includes(l))}return!0}),this.foldedNodes.size>0){let n=new Set;for(let i of this.flatNodes){let{id:o,parentId:r}=i.node.entry;r!=null&&(this.foldedNodes.has(r)||n.has(r))&&n.add(o)}this.filteredNodes=this.filteredNodes.filter(i=>!n.has(i.node.entry.id))}this.recalculateVisualStructure(),this.lastSelectedId?this.selectedIndex=this.findNearestVisibleIndex(this.lastSelectedId):this.selectedIndex>=this.filteredNodes.length&&(this.selectedIndex=Math.max(0,this.filteredNodes.length-1)),this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId)}recalculateVisualStructure(){if(this.filteredNodes.length===0)return;let e=new Set(this.filteredNodes.map(c=>c.node.entry.id)),n=new Map;for(let c of this.flatNodes)n.set(c.node.entry.id,c);let i=c=>{let u=n.get(c)?.node.entry.parentId??null;for(;u!==null;){if(e.has(u))return u;u=n.get(u)?.node.entry.parentId??null}return null},o=new Map,r=new Map;r.set(null,[]);for(let c of this.filteredNodes){let u=c.node.entry.id,d=i(u);o.set(u,d),r.has(d)||r.set(d,[]),r.get(d).push(u)}let s=r.get(null);this.multipleRoots=s.length>1;let a=new Map;for(let c of this.filteredNodes)a.set(c.node.entry.id,c);let l=[];for(let c=s.length-1;c>=0;c--){let u=c===s.length-1;l.push([s[c],this.multipleRoots?1:0,this.multipleRoots,this.multipleRoots,u,[],this.multipleRoots])}for(;l.length>0;){let[c,u,d,p,m,g,h]=l.pop(),f=a.get(c);if(!f)continue;f.indent=u,f.showConnector=p,f.isLast=m,f.gutters=g,f.isVirtualRootChild=h;let b=r.get(c)||[],x=b.length>1,y;x||d&&u>0?y=u+1:y=u;let T=p&&!h,P=this.multipleRoots?Math.max(0,u-1):u,I=Math.max(0,P-1),W=T?[...g,{position:I,show:!m}]:g;for(let D=b.length-1;D>=0;D--){let _=D===b.length-1;l.push([b[D],y,x,x,_,W,!1])}}this.visibleParentMap=o,this.visibleChildrenMap=r}getSearchableText(e){let n=e.entry,i=[];switch(e.label&&i.push(e.label),n.type){case"message":{let o=n.message;if(i.push(o.role),"content"in o&&o.content&&i.push(this.extractContent(o.content)),o.role==="bashExecution"){let r=o;r.command&&i.push(r.command)}break}case"custom_message":{i.push(n.customType),typeof n.content=="string"?i.push(n.content):i.push(this.extractContent(n.content));break}case"compaction":i.push("compaction");break;case"branch_summary":i.push("branch summary",n.summary);break;case"session_info":i.push("title"),n.name&&i.push(n.name);break;case"model_change":i.push("model",n.modelId);break;case"thinking_level_change":i.push("thinking",n.thinkingLevel);break;case"custom":i.push("custom",n.customType);break;case"label":i.push("label",n.label??"");break}return i.join(" ")}invalidate(){}getSearchQuery(){return this.searchQuery}getSelectedNode(){return this.filteredNodes[this.selectedIndex]?.node}copySelected(){let e=this.getSelectedNode();this.onCopy?.(e?this.getEntryCopyText(e):void 0)}updateNodeLabel(e,n,i){for(let o of this.flatNodes)if(o.node.entry.id===e){o.node.label=n,o.node.labelTimestamp=n?i??new Date().toISOString():void 0;break}}getStatusLabels(){let e="";switch(this.filterMode){case"no-tools":e+=" [no-tools]";break;case"user-only":e+=" [user]";break;case"labeled-only":e+=" [labeled]";break;case"all":e+=" [all]";break}return this.showLabelTimestamps&&(e+=" [+label time]"),e}render(e){let n=[];if(this.filteredNodes.length===0)return n.push(te(v.fg("muted"," No entries found"),e)),n.push(te(v.fg("muted",` (0/0)${this.getStatusLabels()}`),e)),n;let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisibleLines/2),this.filteredNodes.length-this.maxVisibleLines)),o=Math.min(i+this.maxVisibleLines,this.filteredNodes.length),r=[];for(let s=i;s<o;s++){let a=this.filteredNodes[s],l=a.node.entry,c=s===this.selectedIndex,u=c?v.fg("accent","\u203A "):" ",d=this.multipleRoots?Math.max(0,a.indent-1):a.indent,p=a.showConnector&&!a.isVirtualRootChild?a.isLast?"\u2514\u2500 ":"\u251C\u2500 ":"",m=p?d-1:-1,g=d*3,h=[],f=this.foldedNodes.has(l.id);for(let E=0;E<g;E++){let U=Math.floor(E/3),G=E%3,q=a.gutters.find(Z=>Z.position===U);if(q)G===0?h.push(q.show?"\u2502":" "):h.push(" ");else if(p&&U===m)if(G===0)h.push(a.isLast?"\u2514":"\u251C");else if(G===1){let Z=this.isFoldable(l.id);h.push(f?"\u229E":Z?"\u229F":"\u2500")}else h.push(" ");else h.push(" ")}let b=h.join(""),x=a.showConnector&&!a.isVirtualRootChild,y=f&&!x?v.fg("accent","\u229E "):"",P=this.activePathIds.has(l.id)?v.fg("accent","\u2022 "):"",I=a.node.label?v.fg("warning",`[${a.node.label}] `):"",W=this.showLabelTimestamps&&a.node.label&&a.node.labelTimestamp?v.fg("muted",`${this.formatLabelTimestamp(a.node.labelTimestamp)} `):"",D=this.getEntryDisplayText(a.node,c),_=v.fg("dim",b)+y+P,F=j(_),O=u,R=_+I+W+D;c&&(O=v.bg("selectedBg",O),R=v.bg("selectedBg",R)),r.push({gutter:O,body:R,anchorCol:F,bodyWidth:j(R),isSelected:c})}return n.push(...kG(r,e)),n.push(te(v.fg("muted",` (${this.selectedIndex+1}/${this.filteredNodes.length})${this.getStatusLabels()}`),e)),n}getEntryDisplayText(e,n){let i=e.entry,o,r=s=>s.replace(/[\n\t]/g," ").trim();switch(i.type){case"message":{let s=i.message,a=s.role;if(a==="user"){let l=s,c=r(this.extractContent(l.content));o=v.fg("accent","user: ")+c}else if(a==="assistant"){let l=s,c=r(this.extractContent(l.content));if(c)o=v.fg("success","assistant: ")+c;else if(l.stopReason==="aborted")o=v.fg("success","assistant: ")+v.fg("muted","(aborted)");else if(l.errorMessage){let u=r(l.errorMessage).slice(0,80);o=v.fg("success","assistant: ")+v.fg("error",u)}else o=v.fg("success","assistant: ")+v.fg("muted","(no content)")}else if(a==="toolResult"){let l=s,c=l.toolCallId?this.toolCallMap.get(l.toolCallId):void 0;c?o=v.fg("muted",this.formatToolCall(c.name,c.arguments)):o=v.fg("muted",`[${l.toolName??"tool"}]`)}else if(a==="bashExecution"){let l=s;o=v.fg("dim",`[bash]: ${r(l.command??"")}`)}else o=v.fg("dim",`[${a}]`);break}case"custom_message":{let s=typeof i.content=="string"?i.content:i.content.filter(a=>a.type==="text").map(a=>a.text).join("");o=v.fg("customMessageLabel",`[${i.customType}]: `)+r(s);break}case"compaction":{let s=Math.round(i.tokensBefore/1e3);o=v.fg("borderAccent",`[compaction: ${s}k tokens]`);break}case"branch_summary":o=v.fg("warning","[branch summary]: ")+r(i.summary);break;case"model_change":o=v.fg("dim",`[model: ${i.modelId}]`);break;case"thinking_level_change":o=v.fg("dim",`[thinking: ${i.thinkingLevel}]`);break;case"custom":o=v.fg("dim",`[custom: ${i.customType}]`);break;case"label":o=v.fg("dim",`[label: ${i.label??"(cleared)"}]`);break;case"session_info":o=i.name?[v.fg("dim","[title: "),v.fg("dim",i.name),v.fg("dim","]")].join(""):[v.fg("dim","[title: "),v.italic(v.fg("dim","empty")),v.fg("dim","]")].join("");break;default:o=""}return n?v.bold(o):o}formatLabelTimestamp(e){let n=new Date(e),i=new Date,o=n.getHours().toString().padStart(2,"0"),r=n.getMinutes().toString().padStart(2,"0"),s=`${o}:${r}`;if(n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())return s;let a=n.getMonth()+1,l=n.getDate();return n.getFullYear()===i.getFullYear()?`${a}/${l} ${s}`:`${n.getFullYear().toString().slice(-2)}/${a}/${l} ${s}`}extractContent(e){return this.extractFullContent(e).slice(0,200)}extractFullContent(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";let n="";for(let i of e)typeof i=="object"&&i!==null&&"type"in i&&i.type==="text"&&(n+=i.text);return n}getEntryCopyText(e){let n=e.entry,i;switch(n.type){case"message":n.message.role==="bashExecution"?i=n.message.command:"content"in n.message&&(i=this.extractFullContent(n.message.content),!i&&n.message.role==="assistant"&&(i=n.message.errorMessage));break;case"custom_message":i=this.extractFullContent(n.content);break;case"compaction":i=n.summary;break;case"branch_summary":i=n.summary;break}return i?.trim()?i:void 0}hasTextContent(e){if(typeof e=="string")return e.trim().length>0;if(Array.isArray(e)){for(let n of e)if(typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"){let i=n.text;if(i&&i.trim().length>0)return!0}}return!1}formatToolCall(e,n){let i=o=>{let r=process.env.HOME||process.env.USERPROFILE||"";return r&&o.startsWith(r)?`~${o.slice(r.length)}`:o};switch(e){case"read":{let o=i(String(n.path||n.file_path||"")),r=n.offset,s=n.limit,a=o;if(r!==void 0||s!==void 0){let l=r??1,c=s!==void 0?l+s-1:"";a+=`:${l}${c?`-${c}`:""}`}return`[read: ${a}]`}case"write":return`[write: ${i(String(n.path||n.file_path||""))}]`;case"edit":return`[edit: ${i(String(n.path||n.file_path||""))}]`;case"bash":{let o=String(n.command||"");return`[bash: ${o.replace(/[\n\t]/g," ").trim().slice(0,50)}${o.length>50?"...":""}]`}case"grep":{let o=String(n.pattern||""),r=i(String(n.path||"."));return`[grep: /${o}/ in ${r}]`}case"find":{let o=String(n.pattern||""),r=i(String(n.path||"."));return`[find: ${o} in ${r}]`}case"ls":return`[ls: ${i(String(n.path||"."))}]`;default:{let o=JSON.stringify(n).slice(0,40);return`[${e}: ${o}${JSON.stringify(n).length>40?"...":""}]`}}}handleInput(e){let n=ke();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.filteredNodes.length-1:this.selectedIndex-1;else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.filteredNodes.length-1?0:this.selectedIndex+1;else if(n.matches(e,"app.tree.foldOrUp")){let i=this.filteredNodes[this.selectedIndex]?.node.entry.id;i&&this.isFoldable(i)&&!this.foldedNodes.has(i)?(this.foldedNodes.add(i),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("up")}else if(n.matches(e,"app.tree.unfoldOrDown")){let i=this.filteredNodes[this.selectedIndex]?.node.entry.id;i&&this.foldedNodes.has(i)?(this.foldedNodes.delete(i),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("down")}else if(n.matches(e,"tui.editor.cursorLeft")||n.matches(e,"tui.select.pageUp"))this.selectedIndex=Math.max(0,this.selectedIndex-this.maxVisibleLines);else if(n.matches(e,"tui.editor.cursorRight")||n.matches(e,"tui.select.pageDown"))this.selectedIndex=Math.min(this.filteredNodes.length-1,this.selectedIndex+this.maxVisibleLines);else if(n.matches(e,"tui.select.confirm")){let i=this.filteredNodes[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.node.entry.id)}else if(n.matches(e,"app.message.copy"))this.copySelected();else if(n.matches(e,"tui.select.cancel"))this.searchQuery?(this.searchQuery="",this.foldedNodes.clear(),this.applyFilter()):this.onCancel?.();else if(n.matches(e,"app.tree.filter.default"))this.filterMode="default",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.noTools"))this.filterMode=this.filterMode==="no-tools"?"default":"no-tools",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.userOnly"))this.filterMode=this.filterMode==="user-only"?"default":"user-only",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.labeledOnly"))this.filterMode=this.filterMode==="labeled-only"?"default":"labeled-only",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.all"))this.filterMode=this.filterMode==="all"?"default":"all",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.cycleBackward")){let i=["default","no-tools","user-only","labeled-only","all"],o=i.indexOf(this.filterMode);this.filterMode=i[(o-1+i.length)%i.length],this.foldedNodes.clear(),this.applyFilter()}else if(n.matches(e,"app.tree.filter.cycleForward")){let i=["default","no-tools","user-only","labeled-only","all"],o=i.indexOf(this.filterMode);this.filterMode=i[(o+1)%i.length],this.foldedNodes.clear(),this.applyFilter()}else if(n.matches(e,"tui.editor.deleteCharBackward"))this.searchQuery.length>0&&(this.searchQuery=this.searchQuery.slice(0,-1),this.foldedNodes.clear(),this.applyFilter());else if(n.matches(e,"app.tree.editLabel")){let i=this.filteredNodes[this.selectedIndex];i&&this.onLabelEdit&&this.onLabelEdit(i.node.entry.id,i.node.label)}else n.matches(e,"app.tree.toggleLabelTimestamp")?this.showLabelTimestamps=!this.showLabelTimestamps:![...e].some(o=>{let r=o.charCodeAt(0);return r<32||r===127||r>=128&&r<=159})&&e.length>0&&(this.searchQuery+=e,this.foldedNodes.clear(),this.applyFilter())}isFoldable(e){let n=this.visibleChildrenMap.get(e);if(!n||n.length===0)return!1;let i=this.visibleParentMap.get(e);if(i==null)return!0;let o=this.visibleChildrenMap.get(i);return o!==void 0&&o.length>1}findBranchSegmentStart(e){let n=this.filteredNodes[this.selectedIndex]?.node.entry.id;if(!n)return this.selectedIndex;let i=new Map(this.filteredNodes.map((r,s)=>[r.node.entry.id,s])),o=n;if(e==="down")for(;;){let r=this.visibleChildrenMap.get(o)??[];if(r.length===0)return i.get(o);if(r.length>1)return i.get(r[0]);o=r[0]}for(;;){let r=this.visibleParentMap.get(o)??null;if(r===null)return i.get(o);if((this.visibleChildrenMap.get(r)??[]).length>1){let a=i.get(o);if(a<this.selectedIndex)return a}o=r}}},bb=class{constructor(e){this.treeList=e}invalidate(){}render(e){let n=this.treeList.getSearchQuery();return n?[te(` ${v.fg("muted","Type to search:")} ${v.fg("accent",n)}`,e)]:[te(` ${v.fg("muted","Type to search:")}`,e)]}handleInput(e){}},xb=class{invalidate(){}render(e){let n=SG.map(({keys:l,label:c,labelFirst:u})=>{let d=TG(l);return d?u?`${c} ${d}`:`${d} ${c}`:c}),i=Math.max(1,e),o=" ",r=" \xB7 ",s=[],a="";for(let l of n){let c=a?`${a}${r}${l}`:j(`${o}${l}`)<=i?`${o}${l}`:l;if(!a||j(c)<=i){a=c;continue}s.push(...rn(a.trimEnd(),i)),a=j(`${o}${l}`)<=i?`${o}${l}`:l}return a&&s.push(...rn(a.trimEnd(),i)),s.map(l=>v.fg("muted",l))}},SG=[{keys:["tui.select.up","tui.select.down"],label:"move"},{keys:["tui.editor.cursorLeft","tui.editor.cursorRight"],label:"page"},{keys:["app.tree.foldOrUp","app.tree.unfoldOrDown"],label:"branch"},{keys:["app.message.copy"],label:"copy"},{keys:["app.tree.editLabel"],label:"label"},{keys:["app.tree.toggleLabelTimestamp"],label:"label time"},{keys:["app.tree.filter.default","app.tree.filter.noTools","app.tree.filter.userOnly","app.tree.filter.labeledOnly","app.tree.filter.all"],label:"filters",labelFirst:!0},{keys:["app.tree.filter.cycleForward","app.tree.filter.cycleBackward"],label:"cycle",labelFirst:!0}];function TG(t){let e=[];for(let n of t){let i=ke().getKeys(n)[0];i!==void 0&&e.push(i)}return e.length===0?"":Yr(CG(e)).replace(/\bpageUp\b/g,"pgup").replace(/\bpageDown\b/g,"pgdn").replace(/\bup\b/g,"\u2191").replace(/\bdown\b/g,"\u2193").replace(/\bleft\b/g,"\u2190").replace(/\bright\b/g,"\u2192")}function CG(t){if(t.length===1)return t[0];let e=t.map(i=>{let o=i.lastIndexOf("+");return o===-1?{prefix:"",suffix:i}:{prefix:i.slice(0,o+1),suffix:i.slice(o+1)}}),n=e[0].prefix;return n&&e.every(i=>i.prefix===n)?`${n}${e.map(i=>i.suffix).join("/")}`:t.join("/")}var yb=class{constructor(e,n){this._focused=!1;this.entryId=e,this.input=new Xe,n&&this.input.setValue(n)}get focused(){return this._focused}set focused(e){this._focused=e,this.input.focused=e}invalidate(){}render(e){let n=[],o=e-2;return n.push(te(` ${v.fg("muted","Label (empty to remove):")}`,e)),n.push(...this.input.render(o).map(r=>te(` ${r}`,e))),n.push(te(` ${le("tui.select.confirm","save")} ${le("tui.select.cancel","cancel")}`,e)),n}handleInput(e){let n=ke();if(n.matches(e,"tui.select.confirm")){let i=this.input.getValue().trim();this.onSubmit?.(this.entryId,i||void 0)}else n.matches(e,"tui.select.cancel")?this.onCancel?.():this.input.handleInput(e)}},El=class extends z{constructor(n,i,o,r,s,a,l,c){super();this.labelInput=null;this._focused=!1;this.onLabelChangeCallback=a;let u=Math.max(5,Math.floor(o/2));this.treeList=new vb(n,i,u,l,c),this.treeList.onSelect=r,this.treeList.onCancel=s,this.treeList.onCopy=d=>this.onCopy?.(d),this.treeList.onLabelEdit=(d,p)=>this.showLabelInput(d,p),this.treeContainer=new z,this.treeContainer.addChild(this.treeList),this.labelInputContainer=new z,this.addChild(new L(1)),this.addChild(new H),this.addChild(new A(v.bold(" Session Tree"),1,0)),this.addChild(new xb),this.addChild(new bb(this.treeList)),this.addChild(new H),this.addChild(new L(1)),this.addChild(this.treeContainer),this.addChild(this.labelInputContainer),this.addChild(new L(1)),this.addChild(new H),n.length===0&&setTimeout(()=>s(),100)}get focused(){return this._focused}set focused(n){this._focused=n,this.labelInput&&(this.labelInput.focused=n)}showLabelInput(n,i){this.labelInput=new yb(n,i),this.labelInput.onSubmit=(o,r)=>{this.treeList.updateNodeLabel(o,r),this.onLabelChangeCallback?.(o,r),this.hideLabelInput()},this.labelInput.onCancel=()=>this.hideLabelInput(),this.labelInput.focused=this._focused,this.treeContainer.clear(),this.labelInputContainer.clear(),this.labelInputContainer.addChild(this.labelInput)}hideLabelInput(){this.labelInput=null,this.labelInputContainer.clear(),this.treeContainer.clear(),this.treeContainer.addChild(this.treeList)}handleInput(n){this.labelInput?this.labelInput.handleInput(n):this.treeList.handleInput(n)}getTreeList(){return this.treeList}};function MG(t,e){if(e===null)return"none";let n=e.decision?"trusted":"untrusted";return t!==void 0&&e.path!==t?`${n} (inherited from ${e.path})`:`${n} (${e.path})`}var Pu=class extends z{constructor(e){super(),this.savedDecision=e.savedDecision,this.trustOptions=X0(e.cwd),this.selectedIndex=Math.max(0,this.trustOptions.findIndex(n=>this.isSavedOption(n))),this.onSelectCallback=e.onSelect,this.onCancelCallback=e.onCancel,this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",v.bold("Project trust")),1,0)),this.addChild(new A(v.fg("muted",e.cwd),1,0)),this.addChild(new L(1)),this.addChild(new A(v.fg("muted",`Saved decision: ${MG(this.trustOptions[0]?.savedPath,e.savedDecision)}`),1,0)),this.addChild(new A(v.fg("muted",`Current session: ${e.projectTrusted?"trusted":"untrusted"}`),1,0)),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new A(lt("\u2191\u2193","navigate")+" "+le("tui.select.confirm","save")+" "+le("tui.select.cancel","cancel"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.updateList()}isSavedOption(e){return e.savedPath!==void 0&&this.savedDecision?.decision===e.trusted&&this.savedDecision.path===e.savedPath}updateList(){this.listContainer.clear();for(let e=0;e<this.trustOptions.length;e++){let n=this.trustOptions[e];if(!n)continue;let i=e===this.selectedIndex,r=this.isSavedOption(n)?v.fg("success"," \u2713"):"",s=i?v.fg("accent","\u2192 "):" ",a=i?v.fg("accent",n.label):v.fg("text",n.label);this.listContainer.addChild(new A(`${s}${a}${r}`,1,0))}}handleInput(e){let n=ke();if(n.matches(e,"tui.select.up")||e==="k")this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList();else if(n.matches(e,"tui.select.down")||e==="j")this.selectedIndex=Math.min(this.trustOptions.length-1,this.selectedIndex+1),this.updateList();else if(n.matches(e,"tui.select.confirm")||e===`
261
- `){let i=this.trustOptions[this.selectedIndex];i&&this.onSelectCallback({trusted:i.trusted,updates:i.updates})}else n.matches(e,"tui.select.cancel")&&this.onCancelCallback()}};var RG="\x1B]133;A\x07",PG="\x1B]133;B\x07",IG="\x1B]133;C\x07",nr=class extends z{constructor(e,n=Ft(),i=1){super(),this.text=e,this.markdownTheme=n,this.outputPad=i,this.rebuild()}setOutputPad(e){this.outputPad=e,this.rebuild()}rebuild(){this.clear();let e=new pt(this.outputPad,1,n=>v.bg("userMessageBg",n));e.addChild(new Ze(this.text,0,0,this.markdownTheme,{color:n=>v.fg("userMessageText",n)},{preserveOrderedListMarkers:!0,preserveBackslashEscapes:!0})),this.addChild(e)}render(e){let n=super.render(e);return n.length===0||(n[0]=RG+n[0],n[n.length-1]=PG+IG+n[n.length-1]),n}};var wb=class{constructor(e,n){this.messages=[];this.selectedIndex=0;this.maxVisible=10;this.messages=e;let i=n?e.findIndex(o=>o.id===n):-1;this.selectedIndex=i>=0?i:Math.max(0,e.length-1)}invalidate(){}render(e){let n=[];if(this.messages.length===0)return n.push(v.fg("muted"," No user messages found")),n;let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.messages.length-this.maxVisible)),o=Math.min(i+this.maxVisible,this.messages.length);for(let r=i;r<o;r++){let s=this.messages[r],a=r===this.selectedIndex,l=s.text.replace(/\n/g," ").trim(),c=a?v.fg("accent","\u203A "):" ",u=e-2,d=te(l,u),p=c+(a?v.bold(d):d);n.push(p);let g=` Message ${r+1} of ${this.messages.length}`,h=v.fg("muted",g);n.push(h),n.push("")}if(i>0||o<this.messages.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.messages.length})`);n.push(r)}return n}handleInput(e){let n=ke();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.messages.length-1:this.selectedIndex-1;else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.messages.length-1?0:this.selectedIndex+1;else if(n.matches(e,"tui.select.confirm")){let i=this.messages[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.id)}else n.matches(e,"tui.select.cancel")&&this.onCancel&&this.onCancel()}},Al=class extends z{constructor(e,n,i,o){super(),this.addChild(new L(1)),this.addChild(new A(v.bold("Fork from Message"),1,0)),this.addChild(new A(v.fg("muted","Select a user message to copy the active path up to that point into a new session"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.addChild(new L(1)),this.messageList=new wb(e,o),this.messageList.onSelect=n,this.messageList.onCancel=i,this.addChild(this.messageList),this.addChild(new L(1)),this.addChild(new H),e.length===0&&setTimeout(()=>i(),100)}getMessageList(){return this.messageList}};var zm=class{constructor(e,n,i,o){this.terminalTheme=jc().theme;this.autoSyncEnabled=!1;this.ui=e,this.settingsManager=n,this.showError=i,this.onChanged=o,this.activeThemeName=jp(this.settingsManager.getThemeSetting(),this.terminalTheme),Qa(this.activeThemeName,!0),this.ui.onTerminalColorSchemeChange(r=>this.applyTerminalTheme(r))}async applyFromSettings(){let e=this.settingsManager.getThemeSetting(),n=Ko(e);if(n){this.terminalTheme=await Uv({ui:this.ui,timeoutMs:100}),this.setAutoSync(!0),this.applyThemeName(this.terminalTheme==="light"?n.lightTheme:n.darkTheme,!0);return}if(this.setAutoSync(!1),e!==void 0){this.applyThemeName(e,!0);return}let i=await Dv({ui:this.ui,timeoutMs:100});this.terminalTheme=i.theme,this.applyThemeName(i.theme).success&&i.confidence==="high"&&(this.settingsManager.setTheme(i.theme),await this.settingsManager.flush())}setThemeName(e,n=!1){return this.setAutoSync(!1),this.applyThemeName(e,n)}setThemeInstance(e){return this.setAutoSync(!1),FR(e),this.activeThemeName="<in-memory>",this.notifyChanged(),{success:!0}}preview(e){let n=jp(e,this.terminalTheme)??this.activeThemeName;n&&qp(n,!0).success&&(this.ui.invalidate(),this.ui.requestRender())}disableAutoSync(){this.setAutoSync(!1)}getTerminalTheme(){return this.terminalTheme}applyThemeName(e,n=!1){let i=qp(e,!0);return this.activeThemeName=i.success?e:"dark",this.notifyChanged(),!i.success&&n&&this.showError(`Failed to load theme "${e}": ${i.error}
260
+ ${o}`),n}};var vG=2,bG=4,xG=20,yG=2,wG=12;function kG(t,e){let n=Math.max(0,e-vG),i=t.reduce((a,l)=>Math.max(a,l.bodyWidth),0),o=Math.max(0,i-n),r=t.find(a=>a.isSelected),s=0;if(r&&o>0){let a=Math.min(xG,Math.max(bG,Math.floor(n/3)));if(r.anchorCol>n-a){let l=Math.min(wG,Math.max(yG,Math.floor(n/4)));s=Math.min(o,r.anchorCol-l)}}return t.map(a=>{let l=s>0?`${a.gutter}${no(a.body,s,n,!0)}\x1B[0m`:a.gutter+a.body;return te(l,e,"")})}var vb=class{constructor(e,n,i,o,r){this.flatNodes=[];this.filteredNodes=[];this.selectedIndex=0;this.filterMode="default";this.searchQuery="";this.toolCallMap=new Map;this.multipleRoots=!1;this.showLabelTimestamps=!1;this.activePathIds=new Set;this.visibleParentMap=new Map;this.visibleChildrenMap=new Map;this.lastSelectedId=null;this.foldedNodes=new Set;this.currentLeafId=n,this.maxVisibleLines=i,this.filterMode=r??"default",this.multipleRoots=e.length>1,this.flatNodes=this.flattenTree(e),this.buildActivePath(),this.applyFilter();let s=o??n;this.selectedIndex=this.findNearestVisibleIndex(s),this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??null}findNearestVisibleIndex(e){if(this.filteredNodes.length===0)return 0;let n=new Map;for(let r of this.flatNodes)n.set(r.node.entry.id,r);let i=new Map(this.filteredNodes.map((r,s)=>[r.node.entry.id,s])),o=e;for(;o!==null;){let r=i.get(o);if(r!==void 0)return r;let s=n.get(o);if(!s)break;o=s.node.entry.parentId??null}return this.filteredNodes.length-1}buildActivePath(){if(this.activePathIds.clear(),!this.currentLeafId)return;let e=new Map;for(let i of this.flatNodes)e.set(i.node.entry.id,i);let n=this.currentLeafId;for(;n;){this.activePathIds.add(n);let i=e.get(n);if(!i)break;n=i.node.entry.parentId??null}}flattenTree(e){let n=[];this.toolCallMap.clear();let i=[],o=new Map,r=this.currentLeafId;{let l=[],c=[...e];for(;c.length>0;){let u=c.pop();l.push(u);for(let d=u.children.length-1;d>=0;d--)c.push(u.children[d])}for(let u=l.length-1;u>=0;u--){let d=l[u],p=r!==null&&d.entry.id===r;for(let m of d.children)o.get(m)&&(p=!0);o.set(d,p)}}let s=e.length>1,a=[...e].sort((l,c)=>Number(o.get(c))-Number(o.get(l)));for(let l=a.length-1;l>=0;l--){let c=l===a.length-1;i.push([a[l],s?1:0,s,s,c,[],s])}for(;i.length>0;){let[l,c,u,d,p,m,g]=i.pop(),h=l.entry;if(h.type==="message"&&h.message.role==="assistant"){let D=h.message.content;if(Array.isArray(D)){for(let _ of D)if(typeof _=="object"&&_!==null&&"type"in _&&_.type==="toolCall"){let F=_;this.toolCallMap.set(F.id,{name:F.name,arguments:F.arguments})}}}n.push({node:l,indent:c,showConnector:d,isLast:p,gutters:m,isVirtualRootChild:g});let f=l.children,b=f.length>1,x=(()=>{let D=[],_=[];for(let F of f)o.get(F)?D.push(F):_.push(F);return[...D,..._]})(),y;b||u&&c>0?y=c+1:y=c;let T=d&&!g,P=this.multipleRoots?Math.max(0,c-1):c,I=Math.max(0,P-1),W=T?[...m,{position:I,show:!p}]:m;for(let D=x.length-1;D>=0;D--){let _=D===x.length-1;i.push([x[D],y,b,b,_,W,!1])}}return n}applyFilter(){this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId);let e=this.searchQuery.toLowerCase().split(/\s+/).filter(Boolean);if(this.filteredNodes=this.flatNodes.filter(n=>{let i=n.node.entry,o=i.id===this.currentLeafId;if(i.type==="message"&&i.message.role==="assistant"&&!o){let a=i.message,l=this.hasTextContent(a.content),c=a.stopReason&&a.stopReason!=="stop"&&a.stopReason!=="toolUse";if(!l&&!c)return!1}let r=!0,s=i.type==="label"||i.type==="custom"||i.type==="model_change"||i.type==="thinking_level_change"||i.type==="session_info";switch(this.filterMode){case"user-only":r=i.type==="message"&&i.message.role==="user";break;case"no-tools":r=!s&&!(i.type==="message"&&i.message.role==="toolResult");break;case"labeled-only":r=n.node.label!==void 0;break;case"all":r=!0;break;default:r=!s;break}if(!r)return!1;if(e.length>0){let a=this.getSearchableText(n.node).toLowerCase();return e.every(l=>a.includes(l))}return!0}),this.foldedNodes.size>0){let n=new Set;for(let i of this.flatNodes){let{id:o,parentId:r}=i.node.entry;r!=null&&(this.foldedNodes.has(r)||n.has(r))&&n.add(o)}this.filteredNodes=this.filteredNodes.filter(i=>!n.has(i.node.entry.id))}this.recalculateVisualStructure(),this.lastSelectedId?this.selectedIndex=this.findNearestVisibleIndex(this.lastSelectedId):this.selectedIndex>=this.filteredNodes.length&&(this.selectedIndex=Math.max(0,this.filteredNodes.length-1)),this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId)}recalculateVisualStructure(){if(this.filteredNodes.length===0)return;let e=new Set(this.filteredNodes.map(c=>c.node.entry.id)),n=new Map;for(let c of this.flatNodes)n.set(c.node.entry.id,c);let i=c=>{let u=n.get(c)?.node.entry.parentId??null;for(;u!==null;){if(e.has(u))return u;u=n.get(u)?.node.entry.parentId??null}return null},o=new Map,r=new Map;r.set(null,[]);for(let c of this.filteredNodes){let u=c.node.entry.id,d=i(u);o.set(u,d),r.has(d)||r.set(d,[]),r.get(d).push(u)}let s=r.get(null);this.multipleRoots=s.length>1;let a=new Map;for(let c of this.filteredNodes)a.set(c.node.entry.id,c);let l=[];for(let c=s.length-1;c>=0;c--){let u=c===s.length-1;l.push([s[c],this.multipleRoots?1:0,this.multipleRoots,this.multipleRoots,u,[],this.multipleRoots])}for(;l.length>0;){let[c,u,d,p,m,g,h]=l.pop(),f=a.get(c);if(!f)continue;f.indent=u,f.showConnector=p,f.isLast=m,f.gutters=g,f.isVirtualRootChild=h;let b=r.get(c)||[],x=b.length>1,y;x||d&&u>0?y=u+1:y=u;let T=p&&!h,P=this.multipleRoots?Math.max(0,u-1):u,I=Math.max(0,P-1),W=T?[...g,{position:I,show:!m}]:g;for(let D=b.length-1;D>=0;D--){let _=D===b.length-1;l.push([b[D],y,x,x,_,W,!1])}}this.visibleParentMap=o,this.visibleChildrenMap=r}getSearchableText(e){let n=e.entry,i=[];switch(e.label&&i.push(e.label),n.type){case"message":{let o=n.message;if(i.push(o.role),"content"in o&&o.content&&i.push(this.extractContent(o.content)),o.role==="bashExecution"){let r=o;r.command&&i.push(r.command)}break}case"custom_message":{i.push(n.customType),typeof n.content=="string"?i.push(n.content):i.push(this.extractContent(n.content));break}case"compaction":i.push("compaction");break;case"branch_summary":i.push("branch summary",n.summary);break;case"session_info":i.push("title"),n.name&&i.push(n.name);break;case"model_change":i.push("model",n.modelId);break;case"thinking_level_change":i.push("thinking",n.thinkingLevel);break;case"custom":i.push("custom",n.customType);break;case"label":i.push("label",n.label??"");break}return i.join(" ")}invalidate(){}getSearchQuery(){return this.searchQuery}getSelectedNode(){return this.filteredNodes[this.selectedIndex]?.node}copySelected(){let e=this.getSelectedNode();this.onCopy?.(e?this.getEntryCopyText(e):void 0)}updateNodeLabel(e,n,i){for(let o of this.flatNodes)if(o.node.entry.id===e){o.node.label=n,o.node.labelTimestamp=n?i??new Date().toISOString():void 0;break}}getStatusLabels(){let e="";switch(this.filterMode){case"no-tools":e+=" [no-tools]";break;case"user-only":e+=" [user]";break;case"labeled-only":e+=" [labeled]";break;case"all":e+=" [all]";break}return this.showLabelTimestamps&&(e+=" [+label time]"),e}render(e){let n=[];if(this.filteredNodes.length===0)return n.push(te(v.fg("muted"," No entries found"),e)),n.push(te(v.fg("muted",` (0/0)${this.getStatusLabels()}`),e)),n;let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisibleLines/2),this.filteredNodes.length-this.maxVisibleLines)),o=Math.min(i+this.maxVisibleLines,this.filteredNodes.length),r=[];for(let s=i;s<o;s++){let a=this.filteredNodes[s],l=a.node.entry,c=s===this.selectedIndex,u=c?v.fg("accent","\u203A "):" ",d=this.multipleRoots?Math.max(0,a.indent-1):a.indent,p=a.showConnector&&!a.isVirtualRootChild?a.isLast?"\u2514\u2500 ":"\u251C\u2500 ":"",m=p?d-1:-1,g=d*3,h=[],f=this.foldedNodes.has(l.id);for(let E=0;E<g;E++){let U=Math.floor(E/3),G=E%3,q=a.gutters.find(Z=>Z.position===U);if(q)G===0?h.push(q.show?"\u2502":" "):h.push(" ");else if(p&&U===m)if(G===0)h.push(a.isLast?"\u2514":"\u251C");else if(G===1){let Z=this.isFoldable(l.id);h.push(f?"\u229E":Z?"\u229F":"\u2500")}else h.push(" ");else h.push(" ")}let b=h.join(""),x=a.showConnector&&!a.isVirtualRootChild,y=f&&!x?v.fg("accent","\u229E "):"",P=this.activePathIds.has(l.id)?v.fg("accent","\u2022 "):"",I=a.node.label?v.fg("warning",`[${a.node.label}] `):"",W=this.showLabelTimestamps&&a.node.label&&a.node.labelTimestamp?v.fg("muted",`${this.formatLabelTimestamp(a.node.labelTimestamp)} `):"",D=this.getEntryDisplayText(a.node,c),_=v.fg("dim",b)+y+P,F=j(_),O=u,R=_+I+W+D;c&&(O=v.bg("selectedBg",O),R=v.bg("selectedBg",R)),r.push({gutter:O,body:R,anchorCol:F,bodyWidth:j(R),isSelected:c})}return n.push(...kG(r,e)),n.push(te(v.fg("muted",` (${this.selectedIndex+1}/${this.filteredNodes.length})${this.getStatusLabels()}`),e)),n}getEntryDisplayText(e,n){let i=e.entry,o,r=s=>s.replace(/[\n\t]/g," ").trim();switch(i.type){case"message":{let s=i.message,a=s.role;if(a==="user"){let l=s,c=r(this.extractContent(l.content));o=v.fg("accent","user: ")+c}else if(a==="assistant"){let l=s,c=r(this.extractContent(l.content));if(c)o=v.fg("success","assistant: ")+c;else if(l.stopReason==="aborted")o=v.fg("success","assistant: ")+v.fg("muted","(aborted)");else if(l.errorMessage){let u=r(l.errorMessage).slice(0,80);o=v.fg("success","assistant: ")+v.fg("error",u)}else o=v.fg("success","assistant: ")+v.fg("muted","(no content)")}else if(a==="toolResult"){let l=s,c=l.toolCallId?this.toolCallMap.get(l.toolCallId):void 0;c?o=v.fg("muted",this.formatToolCall(c.name,c.arguments)):o=v.fg("muted",`[${l.toolName??"tool"}]`)}else if(a==="bashExecution"){let l=s;o=v.fg("dim",`[bash]: ${r(l.command??"")}`)}else o=v.fg("dim",`[${a}]`);break}case"custom_message":{let s=typeof i.content=="string"?i.content:i.content.filter(a=>a.type==="text").map(a=>a.text).join("");o=v.fg("customMessageLabel",`[${i.customType}]: `)+r(s);break}case"compaction":{let s=Math.round(i.tokensBefore/1e3);o=v.fg("borderAccent",`[compaction: ${s}k tokens]`);break}case"branch_summary":o=v.fg("warning","[branch summary]: ")+r(i.summary);break;case"model_change":o=v.fg("dim",`[model: ${i.modelId}]`);break;case"thinking_level_change":o=v.fg("dim",`[thinking: ${i.thinkingLevel}]`);break;case"custom":o=v.fg("dim",`[custom: ${i.customType}]`);break;case"label":o=v.fg("dim",`[label: ${i.label??"(cleared)"}]`);break;case"session_info":o=i.name?[v.fg("dim","[title: "),v.fg("dim",i.name),v.fg("dim","]")].join(""):[v.fg("dim","[title: "),v.italic(v.fg("dim","empty")),v.fg("dim","]")].join("");break;default:o=""}return n?v.bold(o):o}formatLabelTimestamp(e){let n=new Date(e),i=new Date,o=n.getHours().toString().padStart(2,"0"),r=n.getMinutes().toString().padStart(2,"0"),s=`${o}:${r}`;if(n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())return s;let a=n.getMonth()+1,l=n.getDate();return n.getFullYear()===i.getFullYear()?`${a}/${l} ${s}`:`${n.getFullYear().toString().slice(-2)}/${a}/${l} ${s}`}extractContent(e){return this.extractFullContent(e).slice(0,200)}extractFullContent(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";let n="";for(let i of e)typeof i=="object"&&i!==null&&"type"in i&&i.type==="text"&&(n+=i.text);return n}getEntryCopyText(e){let n=e.entry,i;switch(n.type){case"message":n.message.role==="bashExecution"?i=n.message.command:"content"in n.message&&(i=this.extractFullContent(n.message.content),!i&&n.message.role==="assistant"&&(i=n.message.errorMessage));break;case"custom_message":i=this.extractFullContent(n.content);break;case"compaction":i=n.summary;break;case"branch_summary":i=n.summary;break}return i?.trim()?i:void 0}hasTextContent(e){if(typeof e=="string")return e.trim().length>0;if(Array.isArray(e)){for(let n of e)if(typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"){let i=n.text;if(i&&i.trim().length>0)return!0}}return!1}formatToolCall(e,n){let i=o=>{let r=process.env.HOME||process.env.USERPROFILE||"";return r&&o.startsWith(r)?`~${o.slice(r.length)}`:o};switch(e){case"read":{let o=i(String(n.path||n.file_path||"")),r=n.offset,s=n.limit,a=o;if(r!==void 0||s!==void 0){let l=r??1,c=s!==void 0?l+s-1:"";a+=`:${l}${c?`-${c}`:""}`}return`[read: ${a}]`}case"write":return`[write: ${i(String(n.path||n.file_path||""))}]`;case"edit":return`[edit: ${i(String(n.path||n.file_path||""))}]`;case"bash":{let o=String(n.command||"");return`[bash: ${o.replace(/[\n\t]/g," ").trim().slice(0,50)}${o.length>50?"...":""}]`}case"grep":{let o=String(n.pattern||""),r=i(String(n.path||"."));return`[grep: /${o}/ in ${r}]`}case"find":{let o=String(n.pattern||""),r=i(String(n.path||"."));return`[find: ${o} in ${r}]`}case"ls":return`[ls: ${i(String(n.path||"."))}]`;default:{let o=JSON.stringify(n).slice(0,40);return`[${e}: ${o}${JSON.stringify(n).length>40?"...":""}]`}}}handleInput(e){let n=we();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.filteredNodes.length-1:this.selectedIndex-1;else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.filteredNodes.length-1?0:this.selectedIndex+1;else if(n.matches(e,"app.tree.foldOrUp")){let i=this.filteredNodes[this.selectedIndex]?.node.entry.id;i&&this.isFoldable(i)&&!this.foldedNodes.has(i)?(this.foldedNodes.add(i),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("up")}else if(n.matches(e,"app.tree.unfoldOrDown")){let i=this.filteredNodes[this.selectedIndex]?.node.entry.id;i&&this.foldedNodes.has(i)?(this.foldedNodes.delete(i),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("down")}else if(n.matches(e,"tui.editor.cursorLeft")||n.matches(e,"tui.select.pageUp"))this.selectedIndex=Math.max(0,this.selectedIndex-this.maxVisibleLines);else if(n.matches(e,"tui.editor.cursorRight")||n.matches(e,"tui.select.pageDown"))this.selectedIndex=Math.min(this.filteredNodes.length-1,this.selectedIndex+this.maxVisibleLines);else if(n.matches(e,"tui.select.confirm")){let i=this.filteredNodes[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.node.entry.id)}else if(n.matches(e,"app.message.copy"))this.copySelected();else if(n.matches(e,"tui.select.cancel"))this.searchQuery?(this.searchQuery="",this.foldedNodes.clear(),this.applyFilter()):this.onCancel?.();else if(n.matches(e,"app.tree.filter.default"))this.filterMode="default",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.noTools"))this.filterMode=this.filterMode==="no-tools"?"default":"no-tools",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.userOnly"))this.filterMode=this.filterMode==="user-only"?"default":"user-only",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.labeledOnly"))this.filterMode=this.filterMode==="labeled-only"?"default":"labeled-only",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.all"))this.filterMode=this.filterMode==="all"?"default":"all",this.foldedNodes.clear(),this.applyFilter();else if(n.matches(e,"app.tree.filter.cycleBackward")){let i=["default","no-tools","user-only","labeled-only","all"],o=i.indexOf(this.filterMode);this.filterMode=i[(o-1+i.length)%i.length],this.foldedNodes.clear(),this.applyFilter()}else if(n.matches(e,"app.tree.filter.cycleForward")){let i=["default","no-tools","user-only","labeled-only","all"],o=i.indexOf(this.filterMode);this.filterMode=i[(o+1)%i.length],this.foldedNodes.clear(),this.applyFilter()}else if(n.matches(e,"tui.editor.deleteCharBackward"))this.searchQuery.length>0&&(this.searchQuery=this.searchQuery.slice(0,-1),this.foldedNodes.clear(),this.applyFilter());else if(n.matches(e,"app.tree.editLabel")){let i=this.filteredNodes[this.selectedIndex];i&&this.onLabelEdit&&this.onLabelEdit(i.node.entry.id,i.node.label)}else n.matches(e,"app.tree.toggleLabelTimestamp")?this.showLabelTimestamps=!this.showLabelTimestamps:![...e].some(o=>{let r=o.charCodeAt(0);return r<32||r===127||r>=128&&r<=159})&&e.length>0&&(this.searchQuery+=e,this.foldedNodes.clear(),this.applyFilter())}isFoldable(e){let n=this.visibleChildrenMap.get(e);if(!n||n.length===0)return!1;let i=this.visibleParentMap.get(e);if(i==null)return!0;let o=this.visibleChildrenMap.get(i);return o!==void 0&&o.length>1}findBranchSegmentStart(e){let n=this.filteredNodes[this.selectedIndex]?.node.entry.id;if(!n)return this.selectedIndex;let i=new Map(this.filteredNodes.map((r,s)=>[r.node.entry.id,s])),o=n;if(e==="down")for(;;){let r=this.visibleChildrenMap.get(o)??[];if(r.length===0)return i.get(o);if(r.length>1)return i.get(r[0]);o=r[0]}for(;;){let r=this.visibleParentMap.get(o)??null;if(r===null)return i.get(o);if((this.visibleChildrenMap.get(r)??[]).length>1){let a=i.get(o);if(a<this.selectedIndex)return a}o=r}}},bb=class{constructor(e){this.treeList=e}invalidate(){}render(e){let n=this.treeList.getSearchQuery();return n?[te(` ${v.fg("muted","Type to search:")} ${v.fg("accent",n)}`,e)]:[te(` ${v.fg("muted","Type to search:")}`,e)]}handleInput(e){}},xb=class{invalidate(){}render(e){let n=SG.map(({keys:l,label:c,labelFirst:u})=>{let d=TG(l);return d?u?`${c} ${d}`:`${d} ${c}`:c}),i=Math.max(1,e),o=" ",r=" \xB7 ",s=[],a="";for(let l of n){let c=a?`${a}${r}${l}`:j(`${o}${l}`)<=i?`${o}${l}`:l;if(!a||j(c)<=i){a=c;continue}s.push(...rn(a.trimEnd(),i)),a=j(`${o}${l}`)<=i?`${o}${l}`:l}return a&&s.push(...rn(a.trimEnd(),i)),s.map(l=>v.fg("muted",l))}},SG=[{keys:["tui.select.up","tui.select.down"],label:"move"},{keys:["tui.editor.cursorLeft","tui.editor.cursorRight"],label:"page"},{keys:["app.tree.foldOrUp","app.tree.unfoldOrDown"],label:"branch"},{keys:["app.message.copy"],label:"copy"},{keys:["app.tree.editLabel"],label:"label"},{keys:["app.tree.toggleLabelTimestamp"],label:"label time"},{keys:["app.tree.filter.default","app.tree.filter.noTools","app.tree.filter.userOnly","app.tree.filter.labeledOnly","app.tree.filter.all"],label:"filters",labelFirst:!0},{keys:["app.tree.filter.cycleForward","app.tree.filter.cycleBackward"],label:"cycle",labelFirst:!0}];function TG(t){let e=[];for(let n of t){let i=we().getKeys(n)[0];i!==void 0&&e.push(i)}return e.length===0?"":Yr(CG(e)).replace(/\bpageUp\b/g,"pgup").replace(/\bpageDown\b/g,"pgdn").replace(/\bup\b/g,"\u2191").replace(/\bdown\b/g,"\u2193").replace(/\bleft\b/g,"\u2190").replace(/\bright\b/g,"\u2192")}function CG(t){if(t.length===1)return t[0];let e=t.map(i=>{let o=i.lastIndexOf("+");return o===-1?{prefix:"",suffix:i}:{prefix:i.slice(0,o+1),suffix:i.slice(o+1)}}),n=e[0].prefix;return n&&e.every(i=>i.prefix===n)?`${n}${e.map(i=>i.suffix).join("/")}`:t.join("/")}var yb=class{constructor(e,n){this._focused=!1;this.entryId=e,this.input=new Xe,n&&this.input.setValue(n)}get focused(){return this._focused}set focused(e){this._focused=e,this.input.focused=e}invalidate(){}render(e){let n=[],o=e-2;return n.push(te(` ${v.fg("muted","Label (empty to remove):")}`,e)),n.push(...this.input.render(o).map(r=>te(` ${r}`,e))),n.push(te(` ${le("tui.select.confirm","save")} ${le("tui.select.cancel","cancel")}`,e)),n}handleInput(e){let n=we();if(n.matches(e,"tui.select.confirm")){let i=this.input.getValue().trim();this.onSubmit?.(this.entryId,i||void 0)}else n.matches(e,"tui.select.cancel")?this.onCancel?.():this.input.handleInput(e)}},El=class extends z{constructor(n,i,o,r,s,a,l,c){super();this.labelInput=null;this._focused=!1;this.onLabelChangeCallback=a;let u=Math.max(5,Math.floor(o/2));this.treeList=new vb(n,i,u,l,c),this.treeList.onSelect=r,this.treeList.onCancel=s,this.treeList.onCopy=d=>this.onCopy?.(d),this.treeList.onLabelEdit=(d,p)=>this.showLabelInput(d,p),this.treeContainer=new z,this.treeContainer.addChild(this.treeList),this.labelInputContainer=new z,this.addChild(new L(1)),this.addChild(new H),this.addChild(new A(v.bold(" Session Tree"),1,0)),this.addChild(new xb),this.addChild(new bb(this.treeList)),this.addChild(new H),this.addChild(new L(1)),this.addChild(this.treeContainer),this.addChild(this.labelInputContainer),this.addChild(new L(1)),this.addChild(new H),n.length===0&&setTimeout(()=>s(),100)}get focused(){return this._focused}set focused(n){this._focused=n,this.labelInput&&(this.labelInput.focused=n)}showLabelInput(n,i){this.labelInput=new yb(n,i),this.labelInput.onSubmit=(o,r)=>{this.treeList.updateNodeLabel(o,r),this.onLabelChangeCallback?.(o,r),this.hideLabelInput()},this.labelInput.onCancel=()=>this.hideLabelInput(),this.labelInput.focused=this._focused,this.treeContainer.clear(),this.labelInputContainer.clear(),this.labelInputContainer.addChild(this.labelInput)}hideLabelInput(){this.labelInput=null,this.labelInputContainer.clear(),this.treeContainer.clear(),this.treeContainer.addChild(this.treeList)}handleInput(n){this.labelInput?this.labelInput.handleInput(n):this.treeList.handleInput(n)}getTreeList(){return this.treeList}};function MG(t,e){if(e===null)return"none";let n=e.decision?"trusted":"untrusted";return t!==void 0&&e.path!==t?`${n} (inherited from ${e.path})`:`${n} (${e.path})`}var Pu=class extends z{constructor(e){super(),this.savedDecision=e.savedDecision,this.trustOptions=X0(e.cwd),this.selectedIndex=Math.max(0,this.trustOptions.findIndex(n=>this.isSavedOption(n))),this.onSelectCallback=e.onSelect,this.onCancelCallback=e.onCancel,this.addChild(new H),this.addChild(new L(1)),this.addChild(new A(v.fg("accent",v.bold("Project trust")),1,0)),this.addChild(new A(v.fg("muted",e.cwd),1,0)),this.addChild(new L(1)),this.addChild(new A(v.fg("muted",`Saved decision: ${MG(this.trustOptions[0]?.savedPath,e.savedDecision)}`),1,0)),this.addChild(new A(v.fg("muted",`Current session: ${e.projectTrusted?"trusted":"untrusted"}`),1,0)),this.addChild(new L(1)),this.listContainer=new z,this.addChild(this.listContainer),this.addChild(new L(1)),this.addChild(new A(lt("\u2191\u2193","navigate")+" "+le("tui.select.confirm","save")+" "+le("tui.select.cancel","cancel"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.updateList()}isSavedOption(e){return e.savedPath!==void 0&&this.savedDecision?.decision===e.trusted&&this.savedDecision.path===e.savedPath}updateList(){this.listContainer.clear();for(let e=0;e<this.trustOptions.length;e++){let n=this.trustOptions[e];if(!n)continue;let i=e===this.selectedIndex,r=this.isSavedOption(n)?v.fg("success"," \u2713"):"",s=i?v.fg("accent","\u2192 "):" ",a=i?v.fg("accent",n.label):v.fg("text",n.label);this.listContainer.addChild(new A(`${s}${a}${r}`,1,0))}}handleInput(e){let n=we();if(n.matches(e,"tui.select.up")||e==="k")this.selectedIndex=Math.max(0,this.selectedIndex-1),this.updateList();else if(n.matches(e,"tui.select.down")||e==="j")this.selectedIndex=Math.min(this.trustOptions.length-1,this.selectedIndex+1),this.updateList();else if(n.matches(e,"tui.select.confirm")||e===`
261
+ `){let i=this.trustOptions[this.selectedIndex];i&&this.onSelectCallback({trusted:i.trusted,updates:i.updates})}else n.matches(e,"tui.select.cancel")&&this.onCancelCallback()}};var RG="\x1B]133;A\x07",PG="\x1B]133;B\x07",IG="\x1B]133;C\x07",nr=class extends z{constructor(e,n=Ft(),i=1){super(),this.text=e,this.markdownTheme=n,this.outputPad=i,this.rebuild()}setOutputPad(e){this.outputPad=e,this.rebuild()}rebuild(){this.clear();let e=new pt(this.outputPad,1,n=>v.bg("userMessageBg",n));e.addChild(new Ze(this.text,0,0,this.markdownTheme,{color:n=>v.fg("userMessageText",n)},{preserveOrderedListMarkers:!0,preserveBackslashEscapes:!0})),this.addChild(e)}render(e){let n=super.render(e);return n.length===0||(n[0]=RG+n[0],n[n.length-1]=PG+IG+n[n.length-1]),n}};var wb=class{constructor(e,n){this.messages=[];this.selectedIndex=0;this.maxVisible=10;this.messages=e;let i=n?e.findIndex(o=>o.id===n):-1;this.selectedIndex=i>=0?i:Math.max(0,e.length-1)}invalidate(){}render(e){let n=[];if(this.messages.length===0)return n.push(v.fg("muted"," No user messages found")),n;let i=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.messages.length-this.maxVisible)),o=Math.min(i+this.maxVisible,this.messages.length);for(let r=i;r<o;r++){let s=this.messages[r],a=r===this.selectedIndex,l=s.text.replace(/\n/g," ").trim(),c=a?v.fg("accent","\u203A "):" ",u=e-2,d=te(l,u),p=c+(a?v.bold(d):d);n.push(p);let g=` Message ${r+1} of ${this.messages.length}`,h=v.fg("muted",g);n.push(h),n.push("")}if(i>0||o<this.messages.length){let r=v.fg("muted",` (${this.selectedIndex+1}/${this.messages.length})`);n.push(r)}return n}handleInput(e){let n=we();if(n.matches(e,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.messages.length-1:this.selectedIndex-1;else if(n.matches(e,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.messages.length-1?0:this.selectedIndex+1;else if(n.matches(e,"tui.select.confirm")){let i=this.messages[this.selectedIndex];i&&this.onSelect&&this.onSelect(i.id)}else n.matches(e,"tui.select.cancel")&&this.onCancel&&this.onCancel()}},Al=class extends z{constructor(e,n,i,o){super(),this.addChild(new L(1)),this.addChild(new A(v.bold("Fork from Message"),1,0)),this.addChild(new A(v.fg("muted","Select a user message to copy the active path up to that point into a new session"),1,0)),this.addChild(new L(1)),this.addChild(new H),this.addChild(new L(1)),this.messageList=new wb(e,o),this.messageList.onSelect=n,this.messageList.onCancel=i,this.addChild(this.messageList),this.addChild(new L(1)),this.addChild(new H),e.length===0&&setTimeout(()=>i(),100)}getMessageList(){return this.messageList}};var zm=class{constructor(e,n,i,o){this.terminalTheme=jc().theme;this.autoSyncEnabled=!1;this.ui=e,this.settingsManager=n,this.showError=i,this.onChanged=o,this.activeThemeName=jp(this.settingsManager.getThemeSetting(),this.terminalTheme),Qa(this.activeThemeName,!0),this.ui.onTerminalColorSchemeChange(r=>this.applyTerminalTheme(r))}async applyFromSettings(){let e=this.settingsManager.getThemeSetting(),n=Ko(e);if(n){this.terminalTheme=await Uv({ui:this.ui,timeoutMs:100}),this.setAutoSync(!0),this.applyThemeName(this.terminalTheme==="light"?n.lightTheme:n.darkTheme,!0);return}if(this.setAutoSync(!1),e!==void 0){this.applyThemeName(e,!0);return}let i=await Dv({ui:this.ui,timeoutMs:100});this.terminalTheme=i.theme,this.applyThemeName(i.theme).success&&i.confidence==="high"&&(this.settingsManager.setTheme(i.theme),await this.settingsManager.flush())}setThemeName(e,n=!1){return this.setAutoSync(!1),this.applyThemeName(e,n)}setThemeInstance(e){return this.setAutoSync(!1),FR(e),this.activeThemeName="<in-memory>",this.notifyChanged(),{success:!0}}preview(e){let n=jp(e,this.terminalTheme)??this.activeThemeName;n&&qp(n,!0).success&&(this.ui.invalidate(),this.ui.requestRender())}disableAutoSync(){this.setAutoSync(!1)}getTerminalTheme(){return this.terminalTheme}applyThemeName(e,n=!1){let i=qp(e,!0);return this.activeThemeName=i.success?e:"dark",this.notifyChanged(),!i.success&&n&&this.showError(`Failed to load theme "${e}": ${i.error}
262
262
  Fell back to dark theme.`),i}notifyChanged(){this.ui.invalidate(),this.onChanged()}setAutoSync(e){this.autoSyncEnabled!==e&&(this.autoSyncEnabled=e,this.ui.setTerminalColorSchemeNotifications(e))}applyTerminalTheme(e){if(!this.autoSyncEnabled)return;this.terminalTheme=e;let n=Ko(this.settingsManager.getThemeSetting());if(!n){this.setAutoSync(!1);return}let i=e==="light"?n.lightTheme:n.darkTheme;i!==this.activeThemeName&&this.applyThemeName(i)}};function Iu(t){return typeof t=="object"&&t!==null&&"setExpanded"in t&&typeof t.setExpanded=="function"}var Hm=class extends A{constructor(e,n,i=!1,o=0,r=0){super(i?n():e(),o,r),this.getCollapsedText=e,this.getExpandedText=n}setExpanded(e){this.setText(e?this.getExpandedText():this.getCollapsedText())}};function OG(t){return"type"in t&&t.type==="custom"}var LG=new Set(["EIO","EPIPE","ENOTCONN"]);function WG(t){if(!t||typeof t!="object"||!("code"in t))return!1;let e=t.code;return e!==void 0&&LG.has(e)}var kE="Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage. Disable this warning in /settings.";function FG(t){return typeof t=="string"&&t.startsWith("sk-ant-oat")}function DG(t){return!!t&&t.provider==="unknown"&&t.id==="unknown"&&t.api==="unknown"}function UG(t){return t.length>0&&!/[^a-zA-Z0-9_\-./~:@]/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function $G(t){if(!process.stdout.isTTY||!t.isPersisted())return;let e=t.getSessionFile();if(!e||!En.existsSync(e))return;let n=[wt];return t.usesDefaultSessionDir()||n.push("--session-dir",UG(t.getSessionDir())),n.push("--session",t.getSessionId()),n.join(" ")}function NG(t){return t in _0}var SE={oauth:0,api_key:1};function TE(t,e,n,i){let o=Gt(t,e,n);return o.length===0?null:o.map(i)}function BG(t){let e=new Map;for(let n of t){let i=e.get(n.id);if(i){i.authTypes.includes(n.authType)||(i.authTypes.push(n.authType),i.authTypes.sort((o,r)=>SE[o]-SE[r]));continue}e.set(n.id,{id:n.id,name:n.name,authTypes:[n.authType]})}return Array.from(e.values()).sort((n,i)=>n.name.localeCompare(i.name))}function jG(t){let e=t.authTypes.map(n=>`${n} ${Km(n)}`).join(" ");return`${t.id} ${t.name} ${e}`}function qG(t){let e=t.authTypes.map(Km).join("/");return t.name===t.id?e:`${t.name} \xB7 ${e}`}var Eu=class t{constructor(e,n={}){this.autocompleteProviderWrappers=[];this.isInitialized=!1;this.pendingUserInputs=[];this.activeStatusIndicator=void 0;this.idleStatus=new Gm;this.workingMessage=void 0;this.workingVisible=!0;this.workingIndicatorOptions=void 0;this.defaultWorkingMessage="Working...";this.defaultHiddenThinkingLabel="Thinking...";this.hiddenThinkingLabel=this.defaultHiddenThinkingLabel;this.lastSigintTime=0;this.lastEscapeTime=0;this.changelogMarkdown=void 0;this.startupNoticesShown=!1;this.anthropicSubscriptionWarningShown=!1;this.lastStatusSpacer=void 0;this.lastStatusText=void 0;this.streamingComponent=void 0;this.streamingMessage=void 0;this.pendingTools=new Map;this.toolOutputExpanded=!1;this.hideThinkingBlock=!1;this.outputPad=1;this.skillCommands=new Map;this.signalCleanupHandlers=[];this.isBashMode=!1;this.bashComponent=void 0;this.pendingBashComponents=[];this.compactionQueuedMessages=[];this.shutdownRequested=!1;this.extensionSelector=void 0;this.extensionInput=void 0;this.extensionEditor=void 0;this.extensionTerminalInputUnsubscribers=new Set;this.extensionWidgetsAbove=new Map;this.extensionWidgetsBelow=new Map;this.customFooter=void 0;this.builtInHeader=void 0;this.customHeader=void 0;this.isShuttingDown=!1;this.runtimeHost=e,this.options=n,this.autoTrustOnReloadCwd=n.autoTrustOnReloadCwd,this.runtimeHost.setBeforeSessionInvalidate(()=>{this.resetExtensionUI()}),this.runtimeHost.setRebindSession(async()=>{await this.rebindCurrentSession({renderBeforeBind:!0})}),this.version=wi,this.ui=new Fr(new Nr,this.settingsManager.getShowHardwareCursor()),this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink()),this.headerContainer=new z,this.loadedResourcesContainer=new z,this.chatContainer=new z,this.pendingMessagesContainer=new z,this.statusContainer=new z,this.widgetContainerAbove=new z,this.widgetContainerBelow=new z,this.keybindings=Jo.create(),Lc(this.keybindings);let i=this.settingsManager.getEditorPaddingX(),o=this.settingsManager.getAutocompleteMaxVisible();this.defaultEditor=new er(this.ui,Kc(),this.keybindings,{paddingX:i,autocompleteMaxVisible:o}),this.editor=this.defaultEditor,this.editorContainer=new z,this.editorContainer.addChild(this.editor),this.footerDataProvider=new Dm(this.sessionManager.getCwd()),this.footer=new Cl(this.session,this.footerDataProvider),this.footer.setAutoCompactEnabled(this.session.autoCompactionEnabled),this.hideThinkingBlock=this.settingsManager.getHideThinkingBlock(),this.outputPad=this.settingsManager.getOutputPad(),qc(this.session.resourceLoader.getThemes().themes),this.themeController=new zm(this.ui,this.settingsManager,r=>this.showError(r),()=>this.updateEditorBorderColor())}get session(){return this.runtimeHost.session}get agent(){return this.session.agent}get sessionManager(){return this.session.sessionManager}get settingsManager(){return this.session.settingsManager}getAutocompleteSourceTag(e){if(!e)return;let n=e.scope==="user"?"u":e.scope==="project"?"p":"t",i=e.source.trim();if(i==="auto"||i==="local"||i==="cli")return n;if(i.startsWith("npm:"))return`${n}:${i}`;let o=uu(i);if(o){let r=o.ref?`@${o.ref}`:"";return`${n}:git:${o.host}/${o.path}${r}`}return n}prefixAutocompleteDescription(e,n){let i=this.getAutocompleteSourceTag(n);return i?e?`[${i}] ${e}`:`[${i}]`:e}getBuiltInCommandConflictDiagnostics(e){let n=new Set(ob.map(i=>i.name));return e.getRegisteredCommands().filter(i=>n.has(i.name)).map(i=>({type:"warning",message:i.invocationName===i.name?`Extension command '/${i.name}' conflicts with built-in interactive command. Skipping in autocomplete.`:`Extension command '/${i.name}' conflicts with built-in interactive command. Available as '/${i.invocationName}'.`,path:i.sourceInfo.path}))}createBaseAutocompleteProvider(){let e=ob.map(l=>({name:l.name,description:l.description,...l.argumentHint&&{argumentHint:l.argumentHint}})),n=e.find(l=>l.name==="model");n&&(n.getArgumentCompletions=async l=>{let c=this.session.scopedModels.length>0?this.session.scopedModels.map(d=>d.model):await this.session.modelRuntime.getAvailable();if(c.length===0)return null;let u=c.map(d=>({id:d.id,provider:d.provider,name:d.name,label:`${d.provider}/${d.id}`}));return TE(u,l,qm,d=>({value:d.label,label:d.id,description:d.provider}))});let i=e.find(l=>l.name==="login");i&&(i.getArgumentCompletions=l=>{let c=BG(this.getLoginProviderOptions().filter(u=>u.id==="slingshot"||u.id==="ollama"));return TE(c,l,jG,u=>({value:u.id,label:u.id,description:qG(u)}))});let o=this.session.promptTemplates.map(l=>({name:l.name,description:this.prefixAutocompleteDescription(l.description,l.sourceInfo),...l.argumentHint&&{argumentHint:l.argumentHint}})),r=new Set(e.map(l=>l.name)),s=this.session.extensionRunner.getRegisteredCommands().filter(l=>!r.has(l.name)).map(l=>({name:l.invocationName,description:this.prefixAutocompleteDescription(l.description,l.sourceInfo),getArgumentCompletions:l.getArgumentCompletions}));this.skillCommands.clear();let a=[];if(this.settingsManager.getEnableSkillCommands())for(let l of this.session.resourceLoader.getSkills().skills){let c=`skill:${l.name}`;this.skillCommands.set(c,l.filePath),a.push({name:c,description:this.prefixAutocompleteDescription(l.description,l.sourceInfo)})}return new Ic([...e,...o,...s,...a],this.sessionManager.getCwd(),this.fdPath)}setupAutocompleteProvider(){let e=this.createBaseAutocompleteProvider(),n=[];for(let i of this.autocompleteProviderWrappers)e=i(e),n.push(...e.triggerCharacters??[]);n.length>0&&(e.triggerCharacters=[...new Set(n)]),this.autocompleteProvider=e,this.defaultEditor.setAutocompleteProvider(e),this.editor!==this.defaultEditor&&this.editor.setAutocompleteProvider?.(e)}showStartupNoticesIfNeeded(){if(!this.startupNoticesShown&&(this.startupNoticesShown=!0,!!this.changelogMarkdown)){if(this.chatContainer.children.length>0&&this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new H),this.settingsManager.getCollapseChangelog()){let e=this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/),i=`Updated to v${e?e[1]:this.version}. Use ${v.bold("/changelog")} to view full changelog.`;this.chatContainer.addChild(new A(i,1,0))}else this.chatContainer.addChild(new A(v.bold(v.fg("accent","What's New")),1,0)),this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new Ze(this.changelogMarkdown.trim(),1,0,this.getMarkdownThemeWithSettings())),this.chatContainer.addChild(new L(1));this.chatContainer.addChild(new H)}}async init(){if(this.isInitialized)return;this.registerSignalHandlers();let[e]=await Promise.all([Zr("fd"),Zr("rg")]);if(this.fdPath=e,this.session.scopedModels.length>0&&(this.options.verbose||!this.settingsManager.getQuietStartup())){let n=this.session.scopedModels.map(r=>{let s=r.thinkingLevel?`:${r.thinkingLevel}`:"";return`${r.model.id}${s}`}).join(", "),i=this.keybindings.getKeys("app.model.cycleForward"),o=i.length>0?v.fg("muted",` (${Yr(i.join("/"),{capitalize:!0})} to cycle)`):"";console.log(v.fg("dim",`Model scope: ${n}${o}`))}if(this.ui.addChild(this.headerContainer),this.ui.addChild(this.loadedResourcesContainer),this.ui.addChild(this.chatContainer),this.ui.addChild(this.pendingMessagesContainer),this.ui.addChild(this.statusContainer),this.renderWidgets(),this.ui.addChild(this.widgetContainerAbove),this.ui.addChild(this.editorContainer),this.ui.addChild(this.widgetContainerBelow),this.ui.addChild(this.footer),this.ui.setFocus(this.editor),this.setupKeyHandlers(),this.setupEditorSubmitHandler(),this.ui.start(),this.isInitialized=!0,await this.themeController.applyFromSettings(),this.options.verbose||!this.settingsManager.getQuietStartup()){let n=v.bold(v.fg("accent",wt))+v.fg("dim",` v${process.env.SLING_VERSION??this.version}`),i=(l,c)=>le(l,c),o=[i("app.interrupt","to interrupt"),i("app.clear","to clear"),lt(`${Re("app.clear")} twice`,"to exit"),i("app.exit","to exit (empty)"),i("app.suspend","to suspend"),le("tui.editor.deleteToLineEnd","to delete to end"),i("app.thinking.cycle","to cycle thinking level"),lt(`${Re("app.model.cycleForward")}/${Re("app.model.cycleBackward")}`,"to cycle models"),i("app.model.select","to select model"),i("app.tools.expand","to expand tools"),i("app.thinking.toggle","to expand thinking"),i("app.editor.external","for external editor"),lt("/","for commands"),lt("!","to run bash"),lt("!!","to run bash (no context)"),i("app.message.followUp","to queue follow-up"),i("app.message.dequeue","to edit all queued messages"),i("app.clipboard.pasteImage","to paste image (with text fallback)"),lt("drop files","to attach")].join(`
263
263
  `),r=[i("app.interrupt","interrupt"),lt(`${Re("app.clear")}/${Re("app.exit")}`,"clear/exit"),lt("/","commands"),lt("!","bash"),i("app.tools.expand","more")].join(v.fg("muted"," \xB7 ")),s=v.fg("dim",`Press ${Re("app.tools.expand")} to show full startup help and loaded resources.`),a=v.fg("dim","Sling can explain its own features and look up its docs. Ask it how to use or extend Sling.");this.builtInHeader=new Hm(()=>`${n}
264
264
  ${r}
@@ -369,7 +369,7 @@ ${v.fg("dim","Cache Re-billed:")} ${p}`}}this.chatContainer.addChild(new L(1)),t
369
369
  **Extensions**
370
370
  | Key | Action |
371
371
  |-----|--------|
372
- `;for(let[kn,oe]of _t){let we=oe.description??oe.extensionPath,Ce=Yr(kn,{capitalize:!0});Qe+=`| \`${Ce}\` | ${we} |
372
+ `;for(let[kn,oe]of _t){let ye=oe.description??oe.extensionPath,Ce=Yr(kn,{capitalize:!0});Qe+=`| \`${Ce}\` | ${ye} |
373
373
  `}}this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new H),this.chatContainer.addChild(new A(v.bold(v.fg("accent","Keyboard Shortcuts")),1,0)),this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new Ze(Qe.trim(),1,1,this.getMarkdownThemeWithSettings())),this.chatContainer.addChild(new H),this.ui.requestRender()}async handleClearCommand(){this.clearStatusIndicator();try{if((await this.runtimeHost.newSession()).cancelled)return;this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new A(`${v.fg("accent","\u2713 New session started")}`,1,1)),this.ui.requestRender()}catch(e){await this.handleFatalRuntimeError("Failed to create session",e)}}handleDebugCommand(){let e=this.ui.terminal.columns,n=this.ui.terminal.rows,i=this.ui.render(e),o=uS(),r=[`Debug output at ${new Date().toISOString()}`,`Terminal: ${e}x${n}`,`Total lines: ${i.length}`,"","=== All rendered lines with visible widths ===",...i.map((s,a)=>{let l=j(s),c=JSON.stringify(s);return`[${a}] (w=${l}) ${c}`}),"","=== Agent messages (JSONL) ===",...this.session.messages.map(s=>JSON.stringify(s)),""].join(`
374
374
  `);En.mkdirSync(et.dirname(o),{recursive:!0}),En.writeFileSync(o,r),this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new A(`${v.fg("accent","\u2713 Debug log written")}
375
375
  ${v.fg("muted",o)}`,1,1)),this.ui.requestRender()}handleArminSaysHi(){this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new bl(this.ui)),this.ui.requestRender()}handleDementedDelves(){this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new jm),this.ui.requestRender()}handleDaxnuts(){this.chatContainer.addChild(new L(1)),this.chatContainer.addChild(new wu(this.ui)),this.ui.requestRender()}checkDaxnutsEasterEgg(e){e.provider==="opencode"&&e.id.toLowerCase().includes("kimi-k2.5")&&this.handleDaxnuts()}async handleBashCommand(e,n=!1){let o=await this.session.extensionRunner.emitUserBash({type:"user_bash",command:e,excludeFromContext:n,cwd:this.sessionManager.getCwd()});if(o?.result){let s=o.result;this.bashComponent=new Zo(e,this.ui,n),this.session.isStreaming?(this.pendingMessagesContainer.addChild(this.bashComponent),this.pendingBashComponents.push(this.bashComponent)):this.chatContainer.addChild(this.bashComponent),s.output&&this.bashComponent.appendOutput(s.output),this.bashComponent.setComplete(s.exitCode,s.cancelled,s.truncated?{truncated:!0,content:s.output}:void 0,s.fullOutputPath),this.session.recordBashResult(e,s,{excludeFromContext:n}),this.bashComponent=void 0,this.ui.requestRender();return}let r=this.session.isStreaming;this.bashComponent=new Zo(e,this.ui,n),r?(this.pendingMessagesContainer.addChild(this.bashComponent),this.pendingBashComponents.push(this.bashComponent)):this.chatContainer.addChild(this.bashComponent),this.ui.requestRender();try{let s=await this.session.executeBash(e,a=>{this.bashComponent&&(this.bashComponent.appendOutput(a),this.ui.requestRender())},{excludeFromContext:n,operations:o?.operations});this.bashComponent&&this.bashComponent.setComplete(s.exitCode,s.cancelled,s.truncated?{truncated:!0,content:s.output}:void 0,s.fullOutputPath)}catch(s){this.bashComponent&&this.bashComponent.setComplete(void 0,!1),this.showError(`Bash command failed: ${s instanceof Error?s.message:"Unknown error"}`)}this.bashComponent=void 0,this.ui.requestRender()}async handleCompactCommand(e){this.clearStatusIndicator();try{await this.session.compact(e)}catch{}}stop(){this.settingsManager.getShowTerminalProgress()&&this.ui.terminal.setProgress(!1),this.clearStatusIndicator(),this.themeController.disableAutoSync(),this.clearExtensionTerminalInputListeners(),this.footer.dispose(),this.footerDataProvider.dispose(),this.unsubscribe&&this.unsubscribe(),this.isInitialized&&(this.ui.stop(),this.isInitialized=!1),this.unregisterSignalHandlers()}};import V4e from"chalk";var aDe=`${wt} config [-l] [--approve|--no-approve]`;import{randomBytes as mz}from"node:crypto";import Vm from"node:path";import pi from"node:fs";var po=null,ir=null,Au=process.env.SLINGSHOT_DEBUG==="true";function _u(){return Au}function PE(t){Au=t,t?Sb():po=null}function IE(){return po}function Sb(){if(Au)try{if(typeof process<"u"&&process.versions?.node){ir=Dd("fs");let t=Dd("path"),e=Dd("os"),n=process.env.SLINGSHOT_LOG_DIR||t.join(e.homedir(),".sling"),i=t.join(n,"logs","analytics");ir.existsSync(i)||ir.mkdirSync(i,{recursive:!0});let o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);po=t.join(i,`${o}.log`);let r=`
@@ -384,7 +384,7 @@ Log file: ${po}
384
384
  `;ir.appendFileSync(po,n)}catch{}}function ct(t,e){if(!(!po||!ir||!Au))try{let i=`[${new Date().toISOString()}] ${t}:
385
385
  ${JSON.stringify(e,null,2)}
386
386
 
387
- `;ir.appendFileSync(po,i)}catch{}}var or=null;function EE(t){if(!t)return;let e=t.trim();if(e)return e.replace(/\/+$/,"")}var ye=class t{static{this.BASE_URL="base_url"}static{this.ANALYTICS_DOMAIN="analytics_domain"}static{this.CLIENT_ID="client_id"}static{this.PROJECT_ID="project_id"}static{this.WORKSPACE_ID="workspace_id"}static{this.defaultValues={[t.BASE_URL]:"https://sapientaiproducts.com",[t.ANALYTICS_DOMAIN]:"https://slingshot.sapientaiproducts.com",[t.CLIENT_ID]:"b97fbef7-cad9-4e56-9850-39e86c8fdf61",[t.PROJECT_ID]:"fa8121c4-e2fc-48f1-9478-8949c04e13cc",[t.WORKSPACE_ID]:"6e5756eb-d7e2-4d80-ad07-9d7a51600d85"}}static{this.LOGIN_PATH="/web/v1/studio-auth/login"}static{this.EXCHANGE_PATH="/api/v1/studio-auth/auth/desktop/exchange"}static{this.REFRESH_PATH="/api/v3/auth/refreshtoken"}static{this.REFRESH_CLIENT_NAME="machine"}static{this.API_BASE_PATH="/api/v1/llm"}static{this.SAGE_EVENTS_PATH="/api/v1/ai-portal/sage_events"}static{this.APP_TOKEN_PATH="/api/v3/auth/app-token"}static{this.CONFIG_SERVICE_PATH="/api/v2/configservice/client"}static{this.APP_TOKEN_REFRESH_BUFFER_MS=60*1e3}static{this.SLINGSHOT_APP_TOKEN_ENV="SLINGSHOT_APP_TOKEN_HEADER"}static{this.TOKEN_EXPIRY_BUFFER_MS=300*1e3}static{this.SAPI="/save/api/v1"}static{this.CLIENT_NAME="desktop"}static defaults(e){return this.defaultValues[e]}static getLocalSettingsPath(){return Vm.resolve(process.cwd(),".sling","sling.settings.json")}static getGlobalSettingsPath(){return Vm.resolve(_e(),"sling.settings.json")}static getSettingsPath(e){if(e==="local")return this.getLocalSettingsPath();if(e==="global")return this.getGlobalSettingsPath();let n=this.getLocalSettingsPath();return pi.existsSync(n)?n:this.getGlobalSettingsPath()}static getSettings(){if(!or){let i=this.getSettingsPath();try{if(pi.existsSync(i)){let o=pi.readFileSync(i,"utf-8"),r=JSON.parse(o)||{};or={...this.defaultValues,...r}}else{let o=Vm.dirname(i);pi.existsSync(o)||pi.mkdirSync(o,{recursive:!0}),pi.writeFileSync(i,JSON.stringify(this.defaultValues,null,2),"utf-8"),or={...this.defaultValues}}}catch(o){ct("Error reading/writing sling.settings.json: ",o),or={...this.defaultValues}}}let e=EE(process.env.SLINGSHOT_API_DOMAIN),n=EE(process.env.SLINGSHOT_ANALYTICS_DOMAIN);return{...or,[t.BASE_URL]:e||or[t.BASE_URL],[t.ANALYTICS_DOMAIN]:n||or[t.ANALYTICS_DOMAIN]}}static updateSettings(e,n){let i=n?.scope??"global",o=this.getSettingsPath(i);try{let r={};if(pi.existsSync(o)){let l=pi.readFileSync(o,"utf-8");r=JSON.parse(l)||{}}let s={...this.defaultValues,...r,...e},a=Vm.dirname(o);pi.existsSync(a)||pi.mkdirSync(a,{recursive:!0}),pi.writeFileSync(o,JSON.stringify(s,null,2),"utf-8"),or=null}catch(r){ct("Error updating sling.settings.json: ",r)}}static getLoginUrl(e){let n=this.getSettings(),i=new URLSearchParams({client:this.CLIENT_NAME,port:String(e.port),localState:e.localState});return e.clientId&&i.set("clientId",e.clientId),`${n[t.BASE_URL]}${this.LOGIN_PATH}?${i.toString()}`}static getExchangeUrl(){return`${this.getSettings()[t.BASE_URL]}${this.EXCHANGE_PATH}`}static getRefreshUrl(){let e=this.getSettings(),n=new URLSearchParams({client:this.REFRESH_CLIENT_NAME});return`${e[t.BASE_URL]}${this.REFRESH_PATH}?${n.toString()}`}static getApiBaseUrl(){return`${this.getSettings()[t.BASE_URL]}${this.API_BASE_PATH}`}static getSageEventsUrl(){return`${this.getSettings()[t.ANALYTICS_DOMAIN]}${this.SAGE_EVENTS_PATH}`}static getTokenExpiryBuffer(){return this.TOKEN_EXPIRY_BUFFER_MS}static getDefaultProjectId(){let e=this.getSettings();return process.env.SLINGSHOT_PROJECT_ID||e[t.PROJECT_ID]}static getDefaultWorkspaceId(){let e=this.getSettings();return process.env.SLINGSHOT_WORKSPACE_ID||e[t.WORKSPACE_ID]}static getDefaultClientId(){let e=this.getSettings();return process.env.CLIENT_ID||e[t.CLIENT_ID]}static getUserActivityUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users/activity`}static getUserUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users`}static getAppTokenUrl(){return`${this.getSettings()[t.BASE_URL]}${this.APP_TOKEN_PATH}`}static getConfigServiceUrl(e){let n=this.getSettings(),i=this.getDefaultClientId(),o=new URLSearchParams({keys:e});return`${n[t.BASE_URL]}${this.CONFIG_SERVICE_PATH}/${i}?${o.toString()}`}static getAppTokenRefreshBuffer(){return this.APP_TOKEN_REFRESH_BUFFER_MS}};function Ou(t){try{let e=t.split(".");if(e.length!==3)return 0;let n=JSON.parse(atob(e[1]));return n.exp?n.exp*1e3:0}catch{return 0}}function AE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}var Tb="Xq7Wm2zR9pLkVbN4cD8fH3jT6yG1sA5",rz=BigInt(Tb.length);function sz(t){if(t.length===0)return"";let e=0n;for(let i of t){let o=Tb.indexOf(i);if(o===-1)throw new Error(`Cannot decode app_key: character "${i}" is not in the expected alphabet`);e=e*rz+BigInt(o)}let n=[];for(;e>0n;)n.unshift(Number(e&0xffn)),e>>=8n;for(let i of t)if(i===Tb[0])n.unshift(0);else break;return new TextDecoder().decode(new Uint8Array(n))}var Cb=new Map,Qm=new Map;async function az(t,e){let n=ye.getConfigServiceUrl(t);qe(`sling-config: fetching ${n}`);let i;try{i=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`}})}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Cannot reach config service: ${a}`)}if(!i.ok){let s=`${i.status} ${i.statusText}`;try{let a=await i.json();a.message?s=String(a.message):a.error&&(s=String(a.error))}catch{}throw new Error(`Config service request failed: ${s}`)}let r=(await i.json())?.data?.config;if(!r||typeof r!="object")throw new Error("Config service response missing data.config");return r}async function _E(t,e){let n=Cb.get(t);if(n)return n;let i=Qm.get(t);if(i)return i;if(!e)throw new Error("Cannot reach config service: no Slingshot user token provided");let o=az(t,e).then(r=>(Cb.set(t,r),r)).finally(()=>{Qm.delete(t)});return Qm.set(t,o),o}var Ol=class{static async getSlingcliConfig(e){let n=await _E("slingcli",e),i=n.slingcli;if(!i||typeof i.app_id!="string"||typeof i.app_key!="string"||!i.app_id||!i.app_key)throw ct("sling-config: missing slingcli block",n),new Error("Config service did not return slingcli.app_id / slingcli.app_key for this client");return{app_id:i.app_id,app_key:sz(i.app_key)}}static async getRemoteConfig(e,n){return _E(e,n)}static clearCache(){Cb.clear(),Qm=new Map}};import OE from"node:path";import rr from"node:fs";var lz="sling.app-creds.json";function Mb(){return OE.resolve(_e(),lz)}function LE(){let t=Mb();if(!rr.existsSync(t))return null;try{let e=rr.readFileSync(t,"utf-8"),n=JSON.parse(e);return typeof n.app_id!="string"||typeof n.app_key!="string"||!n.app_id||!n.app_key?(ct("app-creds-store: invalid creds file, ignoring",n),null):{app_id:n.app_id,app_key:n.app_key}}catch(e){return ct("app-creds-store: failed to read creds file",e),null}}function Rb(t){let e=Mb(),n=OE.dirname(e);try{rr.existsSync(n)||rr.mkdirSync(n,{recursive:!0});let i={...t,savedAt:Date.now()};rr.writeFileSync(e,JSON.stringify(i,null,2),{encoding:"utf-8",mode:384});try{rr.chmodSync(e,384)}catch{}qe(`app-creds-store: persisted to ${e}`)}catch(i){ct("app-creds-store: failed to persist creds",i)}}function WE(){let t=Mb();try{rr.existsSync(t)&&(rr.unlinkSync(t),qe(`app-creds-store: cleared ${t}`))}catch(e){ct("app-creds-store: failed to clear creds file",e)}}var Jm=class extends Error{constructor(n,i){super(i);this.status=n;this.name="AppTokenHttpError"}},Lu=null,Wu=null,Ym=null,Ll=null;function FE(t){process.env[ye.SLINGSHOT_APP_TOKEN_ENV]=`Bearer ${t}`}function cz(t){Ll&&(clearTimeout(Ll),Ll=null);let e=t.expiresAt-Date.now();e<=0||(Ll=setTimeout(()=>{Ll=null,Yn().catch(n=>{ct("app-token: scheduled refresh failed",n)})},e),Ll.unref?.())}async function DE(t){let e=Buffer.from(`${t.app_id}:${t.app_key}`).toString("base64"),n=ye.getAppTokenUrl();qe(`app-token: minting from ${n}`);let i;try{i=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${e}`}})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach app-token service: ${l}`)}if(!i.ok){let a=`${i.status} ${i.statusText}`;try{let l=await i.text()||"";l&&(a=l)}catch{}throw new Jm(i.status,`App token request failed: ${a}`)}let o=await i.json();if(!o.app_token||typeof o.expires_in!="number")throw new Error("App token response missing app_token or expires_in");let r=ye.getAppTokenRefreshBuffer(),s=Date.now()+o.expires_in*1e3-r;return qe(`app-token: minted, expires at ${new Date(s).toISOString()}`),{token:o.app_token,expiresAt:s}}async function uz(){let t=LE();if(t)return{creds:t,fromDisk:!0};if(!Wu)throw new Error("Cannot mint app token: no on-disk app credentials and no Slingshot user token available (please /login slingshot first)");let e=await Ol.getSlingcliConfig(Wu);return Rb(e),{creds:e,fromDisk:!1}}async function dz(){let{creds:t,fromDisk:e}=await uz();try{return await DE(t)}catch(n){let i=n instanceof Jm&&(n.status===401||n.status===403);if(!e||!i)throw n;if(ct("app-token: disk creds rejected (likely rotated), refetching from config service",{status:n.status}),WE(),!Wu)throw new Error("Cannot rotate app credentials: on-disk creds rejected and no Slingshot user token available (please /login slingshot)");let o=await Ol.getSlingcliConfig(Wu);return Rb(o),await DE(o)}}async function Yn(t){if(t&&(Wu=t),Lu&&Lu.expiresAt>Date.now())return FE(Lu.token),Lu.token;if(Ym)return(await Ym).token;let e=dz().then(i=>(Lu=i,FE(i.token),cz(i),i)).finally(()=>{Ym=null});return Ym=e,(await e).token}var Fu=null,Pb=null;typeof process<"u"&&process.versions?.node&&(Pb=import("node:http").then(t=>{Fu=t.createServer}));async function pz(){if(Fu||(Pb&&await Pb,Fu))return Fu;throw new Error("Slingshot OAuth requires Node.js")}async function Ib(t){let e=await pz(),n,i,o,r=!1,s=new Promise((u,d)=>{i=u,o=d}),a=u=>{if(!r){r=!0;try{n.close()}catch{}u()}};n=e((u,d)=>{let p=new URL(u.url||"","http://127.0.0.1"),m=p.searchParams.get("code"),g=p.searchParams.get("state"),h=p.searchParams.get("clientId"),f=p.searchParams.get("error"),b=p.searchParams.get("error_description");if(f){d.writeHead(400,{"Content-Type":"text/html"}),d.end(`<html><body><h1>Login Failed</h1><p>${b||f}</p><p>You can close this window.</p></body></html>`),a(()=>o(new Error(`Login failed: ${b||f}`)));return}if(!m||!g){d.writeHead(400,{"Content-Type":"text/html"}),d.end("<html><body><h1>Login Failed</h1><p>Missing code or state in callback.</p><p>You can close this window.</p></body></html>"),a(()=>o(new Error("Missing code or state in callback")));return}d.writeHead(200,{"Content-Type":"text/html"}),d.end("<html><body><h1>Login Successful</h1><p>You can close this window and return to your terminal.</p><script>setTimeout(()=>window.close(),3000)</script></body></html>"),a(()=>i({code:m,state:g,clientId:h||""}))}),n.on("error",u=>{a(()=>o(u))});let l=setTimeout(()=>{a(()=>o(new Error("Login timeout - no callback received within 5 minutes")))},300*1e3);return n.on("close",()=>clearTimeout(l)),t&&t.addEventListener("abort",()=>{a(()=>o(new Error("Login cancelled")))}),{port:await new Promise((u,d)=>{n.once("error",d),n.listen(0,"127.0.0.1",()=>{let p=n.address();p&&typeof p=="object"?u(p.port):d(new Error("Failed to obtain loopback server port"))})}),result:s}}async function Eb(t,e){if(!t)throw new Error("Missing exchange code");if(!e)throw new Error("Missing clientId for exchange");let n=ye.getExchangeUrl(),i;try{i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify({code:t,clientId:e})})}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`Cannot reach Studio Auth: ${s}`)}if(!i.ok){let r,s=`${i.status} ${i.statusText}`;try{let a=await i.json();r=a.error?.code,a.error?.message?s=a.error.message:a.message?s=a.message:r&&(s=r)}catch{}throw r==="INVALID_CALLBACK"?new Error("Login failed: exchange code is expired, already used, or bound to a different tenant. Please log in again."):new Error(`Code exchange failed: ${s}`)}let o=await i.json();if(!o.accessToken||!o.refreshToken)throw new Error("Exchange response missing accessToken or refreshToken");return o}function hz(){return mz(16).toString("hex")}function gz(t){let e=new URL(t),n=e.searchParams.get("code"),i=e.searchParams.get("state"),o=e.searchParams.get("clientId");if(!n||!i)throw new Error("Pasted URL is missing code or state");return{code:n,state:i,clientId:o||""}}async function Ab(t){let e=process.env.SLINGSHOT_TOKEN;if(e){let u=Ou(e);return qe("Using Slingshot token from SLINGSHOT_TOKEN environment variable"),await Yn(e),{refresh:"",access:e,expires:u>0?u-ye.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:ye.getDefaultProjectId(),workspaceId:ye.getDefaultWorkspaceId()}}let{port:n,result:i}=await Ib(t.signal),o=hz(),r=ye.getDefaultClientId(),s=ye.getLoginUrl({port:n,localState:o,clientId:r||void 0});t.onAuth({url:s});let a;if(t.onManualCodeInput){let u=t.onManualCodeInput().then(gz);a=await Promise.race([i,u])}else a=await i;if(a.state!==o)throw new Error("CSRF check failed - state does not match localState");if(!a.clientId)throw new Error("Login callback did not include clientId");let l=await Eb(a.code,a.clientId),c=Ou(l.accessToken);return await Yn(l.accessToken),{refresh:l.refreshToken,access:l.accessToken,expires:c>0?c-ye.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:ye.getDefaultProjectId(),workspaceId:ye.getDefaultWorkspaceId()}}import{randomUUID as fz}from"node:crypto";async function Xm(t){if(!t.refresh)throw new Error("No refresh token available. Please login again.");let e;try{e=await Yn()}catch(a){throw ct("auth/refresh: app token unavailable for refresh call",a),new Error(`Cannot refresh Slingshot token: app token unavailable (${a instanceof Error?a.message:String(a)}). Please /login slingshot.`)}let n=fz(),i={accept:"application/json",rt:t.refresh,"trace-id":n,Authorization:`Bearer ${e}`},o;try{let a=ye.getRefreshUrl();o=await fetch(a,{headers:i})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach Slingshot server: ${l}`)}if(!o.ok){let a=`${o.status} ${o.statusText}`;try{let l=await o.json();l.message?a=String(l.message):l.error&&(a=String(l.error))}catch{}throw new Error(`Token refresh failed: ${a}`)}let r=await o.json();if(!r.accessToken)throw new Error("No access token in refresh response");let s=Ou(r.accessToken);try{await Yn(r.accessToken)}catch(a){throw ct("auth/refresh: app token refresh failed",a),a}return{refresh:r.refreshToken||t.refresh,access:r.accessToken,expires:s>0?s-ye.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:t.projectId,workspaceId:t.workspaceId}}var UE=[{id:"gpt-5.4-nano",name:"GPT-5.4 nano",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-4.1",name:"GPT-4.1",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,provider:"slingshot",api:"openai-completions"},{id:"gpt-5",name:"GPT-5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-mini",name:"GPT-5 Mini",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-nano",name:"GPT-5 Nano",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.1",name:"GPT-5.1",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.2",name:"GPT-5.2",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.4",name:"GPT-5.4",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.5",name:"GPT-5.5",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"claude-opus-4@20250514",name:"Claude Opus 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4@20250514",name:"Claude Sonnet 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-5@20250929",name:"Claude Sonnet 4.5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-opus-4-6",name:"Claude Opus 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,provider:"slingshot",api:"openai-completions"},{id:"o3",name:"O3",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o3-mini",name:"o3-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o4-mini",name:"o4-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536,provider:"slingshot",api:"openai-completions"}];var Zm={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build","build:offline":"cd packages/tui && npm run build && cd ../ai && npm run build:offline && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build",dev:'concurrently --names "ai,agent,coding-agent,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/server && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","test:models":"node scripts/test-models.mjs","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{"@anthropic-ai/sandbox-runtime":"0.0.57","@biomejs/biome":"2.3.15","@types/better-sqlite3":"^7.6.13","@types/lodash.mergewith":"^4.6.9","@types/node":"24.13.2","@types/turndown":"^5.0.6","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.3",esbuild:"0.28.1","fast-xml-parser":"^5.9.3",husky:"9.1.7",jiti:"2.7.0",psadk:"^1.5.1",shx:"0.4.0",tsx:"4.22.4",turbo:"^2.9.18",typescript:"5.9.3",vitest:"^4.1.9"},engines:{node:">=20.0.0"},slingVersion:"2.5.20260722-3",overrides:{postcss:"8.5.14",next:{postcss:"8.5.14"},"ip-address":"^10.1.1","@modelcontextprotocol/sdk":"^1.29.0",ai:">=5.0.52","fast-xml-parser":"^5.9.3","@aws-sdk/xml-builder":{"fast-xml-parser":"^5.9.3"},"adaptivecards-templating":{"adaptive-expressions":{"fast-xml-parser":"^5.5.8"}},picomatch:"^4.0.4","path-to-regexp":"8.4.1",router:{"path-to-regexp":"8.4.1"},minimatch:"^10.2.3",tar:"7.5.11",react:"19.1.1","react-dom":"19.1.1","@types/react":"19","@types/react-dom":"19",tailwindcss:"4.1.12",lightningcss:"1.30.2",glob:{".":"11.1.0",minimatch:"10.2.3"},prismjs:"^1.30.0",qs:"^6.15.0","@hono/node-server":"1.19.14",protobufjs:"^8.2.0","@opentelemetry/otlp-transformer":{protobufjs:"^8.2.0"},langchain:{langsmith:">=0.7.0"},hono:"4.12.18",fsevents:"^2.3.3",swiper:"^12.1.2",lodash:"^4.18.0","lodash-es":"^4.18.1",axios:"^1.15.0","ibm-cloud-sdk-core":"^5.4.11",dompurify:">=3.4.0","react-markdown-mermaid":{mermaid:"10.9.6"}},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0","@mozilla/readability":"^0.6.0","better-sqlite3":"^12.11.1","compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0",linkedom:"^0.18.12",turndown:"^7.2.4",unpdf:"^1.6.2"}};import Du from"chalk";function $E(t,e){return{render(n){let i=` \u26AC _______. __ __ .__ __. _______
387
+ `;ir.appendFileSync(po,i)}catch{}}var or=null;function EE(t){if(!t)return;let e=t.trim();if(e)return e.replace(/\/+$/,"")}var ke=class t{static{this.BASE_URL="base_url"}static{this.ANALYTICS_DOMAIN="analytics_domain"}static{this.CLIENT_ID="client_id"}static{this.PROJECT_ID="project_id"}static{this.WORKSPACE_ID="workspace_id"}static{this.defaultValues={[t.BASE_URL]:"https://sapientaiproducts.com",[t.ANALYTICS_DOMAIN]:"https://slingshot.sapientaiproducts.com",[t.CLIENT_ID]:"b97fbef7-cad9-4e56-9850-39e86c8fdf61",[t.PROJECT_ID]:"fa8121c4-e2fc-48f1-9478-8949c04e13cc",[t.WORKSPACE_ID]:"6e5756eb-d7e2-4d80-ad07-9d7a51600d85"}}static{this.LOGIN_PATH="/web/v1/studio-auth/login"}static{this.EXCHANGE_PATH="/api/v1/studio-auth/auth/desktop/exchange"}static{this.REFRESH_PATH="/api/v3/auth/refreshtoken"}static{this.REFRESH_CLIENT_NAME="machine"}static{this.API_BASE_PATH="/api/v1/llm"}static{this.SAGE_EVENTS_PATH="/api/v1/ai-portal/sage_events"}static{this.APP_TOKEN_PATH="/api/v3/auth/app-token"}static{this.CONFIG_SERVICE_PATH="/api/v2/configservice/client"}static{this.APP_TOKEN_REFRESH_BUFFER_MS=60*1e3}static{this.SLINGSHOT_APP_TOKEN_ENV="SLINGSHOT_APP_TOKEN_HEADER"}static{this.TOKEN_EXPIRY_BUFFER_MS=300*1e3}static{this.SAPI="/save/api/v1"}static{this.CLIENT_NAME="desktop"}static defaults(e){return this.defaultValues[e]}static getLocalSettingsPath(){return Vm.resolve(process.cwd(),".sling","sling.settings.json")}static getGlobalSettingsPath(){return Vm.resolve(_e(),"sling.settings.json")}static getSettingsPath(e){if(e==="local")return this.getLocalSettingsPath();if(e==="global")return this.getGlobalSettingsPath();let n=this.getLocalSettingsPath();return pi.existsSync(n)?n:this.getGlobalSettingsPath()}static getSettings(){if(!or){let i=this.getSettingsPath();try{if(pi.existsSync(i)){let o=pi.readFileSync(i,"utf-8"),r=JSON.parse(o)||{};or={...this.defaultValues,...r}}else{let o=Vm.dirname(i);pi.existsSync(o)||pi.mkdirSync(o,{recursive:!0}),pi.writeFileSync(i,JSON.stringify(this.defaultValues,null,2),"utf-8"),or={...this.defaultValues}}}catch(o){ct("Error reading/writing sling.settings.json: ",o),or={...this.defaultValues}}}let e=EE(process.env.SLINGSHOT_API_DOMAIN),n=EE(process.env.SLINGSHOT_ANALYTICS_DOMAIN);return{...or,[t.BASE_URL]:e||or[t.BASE_URL],[t.ANALYTICS_DOMAIN]:n||or[t.ANALYTICS_DOMAIN]}}static updateSettings(e,n){let i=n?.scope??"global",o=this.getSettingsPath(i);try{let r={};if(pi.existsSync(o)){let l=pi.readFileSync(o,"utf-8");r=JSON.parse(l)||{}}let s={...this.defaultValues,...r,...e},a=Vm.dirname(o);pi.existsSync(a)||pi.mkdirSync(a,{recursive:!0}),pi.writeFileSync(o,JSON.stringify(s,null,2),"utf-8"),or=null}catch(r){ct("Error updating sling.settings.json: ",r)}}static getLoginUrl(e){let n=this.getSettings(),i=new URLSearchParams({client:this.CLIENT_NAME,port:String(e.port),localState:e.localState});return e.clientId&&i.set("clientId",e.clientId),`${n[t.BASE_URL]}${this.LOGIN_PATH}?${i.toString()}`}static getExchangeUrl(){return`${this.getSettings()[t.BASE_URL]}${this.EXCHANGE_PATH}`}static getRefreshUrl(){let e=this.getSettings(),n=new URLSearchParams({client:this.REFRESH_CLIENT_NAME});return`${e[t.BASE_URL]}${this.REFRESH_PATH}?${n.toString()}`}static getApiBaseUrl(){return`${this.getSettings()[t.BASE_URL]}${this.API_BASE_PATH}`}static getSageEventsUrl(){return`${this.getSettings()[t.ANALYTICS_DOMAIN]}${this.SAGE_EVENTS_PATH}`}static getTokenExpiryBuffer(){return this.TOKEN_EXPIRY_BUFFER_MS}static getDefaultProjectId(){let e=this.getSettings();return process.env.SLINGSHOT_PROJECT_ID||e[t.PROJECT_ID]}static getDefaultWorkspaceId(){let e=this.getSettings();return process.env.SLINGSHOT_WORKSPACE_ID||e[t.WORKSPACE_ID]}static getDefaultClientId(){let e=this.getSettings();return process.env.CLIENT_ID||e[t.CLIENT_ID]}static getUserActivityUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users/activity`}static getUserUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users`}static getAppTokenUrl(){return`${this.getSettings()[t.BASE_URL]}${this.APP_TOKEN_PATH}`}static getConfigServiceUrl(e){let n=this.getSettings(),i=this.getDefaultClientId(),o=new URLSearchParams({keys:e});return`${n[t.BASE_URL]}${this.CONFIG_SERVICE_PATH}/${i}?${o.toString()}`}static getAppTokenRefreshBuffer(){return this.APP_TOKEN_REFRESH_BUFFER_MS}};function Ou(t){try{let e=t.split(".");if(e.length!==3)return 0;let n=JSON.parse(atob(e[1]));return n.exp?n.exp*1e3:0}catch{return 0}}function AE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}var Tb="Xq7Wm2zR9pLkVbN4cD8fH3jT6yG1sA5",rz=BigInt(Tb.length);function sz(t){if(t.length===0)return"";let e=0n;for(let i of t){let o=Tb.indexOf(i);if(o===-1)throw new Error(`Cannot decode app_key: character "${i}" is not in the expected alphabet`);e=e*rz+BigInt(o)}let n=[];for(;e>0n;)n.unshift(Number(e&0xffn)),e>>=8n;for(let i of t)if(i===Tb[0])n.unshift(0);else break;return new TextDecoder().decode(new Uint8Array(n))}var Cb=new Map,Qm=new Map;async function az(t,e){let n=ke.getConfigServiceUrl(t);qe(`sling-config: fetching ${n}`);let i;try{i=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`}})}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Cannot reach config service: ${a}`)}if(!i.ok){let s=`${i.status} ${i.statusText}`;try{let a=await i.json();a.message?s=String(a.message):a.error&&(s=String(a.error))}catch{}throw new Error(`Config service request failed: ${s}`)}let r=(await i.json())?.data?.config;if(!r||typeof r!="object")throw new Error("Config service response missing data.config");return r}async function _E(t,e){let n=Cb.get(t);if(n)return n;let i=Qm.get(t);if(i)return i;if(!e)throw new Error("Cannot reach config service: no Slingshot user token provided");let o=az(t,e).then(r=>(Cb.set(t,r),r)).finally(()=>{Qm.delete(t)});return Qm.set(t,o),o}var Ol=class{static async getSlingcliConfig(e){let n=await _E("slingcli",e),i=n.slingcli;if(!i||typeof i.app_id!="string"||typeof i.app_key!="string"||!i.app_id||!i.app_key)throw ct("sling-config: missing slingcli block",n),new Error("Config service did not return slingcli.app_id / slingcli.app_key for this client");return{app_id:i.app_id,app_key:sz(i.app_key)}}static async getRemoteConfig(e,n){return _E(e,n)}static clearCache(){Cb.clear(),Qm=new Map}};import OE from"node:path";import rr from"node:fs";var lz="sling.app-creds.json";function Mb(){return OE.resolve(_e(),lz)}function LE(){let t=Mb();if(!rr.existsSync(t))return null;try{let e=rr.readFileSync(t,"utf-8"),n=JSON.parse(e);return typeof n.app_id!="string"||typeof n.app_key!="string"||!n.app_id||!n.app_key?(ct("app-creds-store: invalid creds file, ignoring",n),null):{app_id:n.app_id,app_key:n.app_key}}catch(e){return ct("app-creds-store: failed to read creds file",e),null}}function Rb(t){let e=Mb(),n=OE.dirname(e);try{rr.existsSync(n)||rr.mkdirSync(n,{recursive:!0});let i={...t,savedAt:Date.now()};rr.writeFileSync(e,JSON.stringify(i,null,2),{encoding:"utf-8",mode:384});try{rr.chmodSync(e,384)}catch{}qe(`app-creds-store: persisted to ${e}`)}catch(i){ct("app-creds-store: failed to persist creds",i)}}function WE(){let t=Mb();try{rr.existsSync(t)&&(rr.unlinkSync(t),qe(`app-creds-store: cleared ${t}`))}catch(e){ct("app-creds-store: failed to clear creds file",e)}}var Jm=class extends Error{constructor(n,i){super(i);this.status=n;this.name="AppTokenHttpError"}},Lu=null,Wu=null,Ym=null,Ll=null;function FE(t){process.env[ke.SLINGSHOT_APP_TOKEN_ENV]=`Bearer ${t}`}function cz(t){Ll&&(clearTimeout(Ll),Ll=null);let e=t.expiresAt-Date.now();e<=0||(Ll=setTimeout(()=>{Ll=null,Yn().catch(n=>{ct("app-token: scheduled refresh failed",n)})},e),Ll.unref?.())}async function DE(t){let e=Buffer.from(`${t.app_id}:${t.app_key}`).toString("base64"),n=ke.getAppTokenUrl();qe(`app-token: minting from ${n}`);let i;try{i=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${e}`}})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach app-token service: ${l}`)}if(!i.ok){let a=`${i.status} ${i.statusText}`;try{let l=await i.text()||"";l&&(a=l)}catch{}throw new Jm(i.status,`App token request failed: ${a}`)}let o=await i.json();if(!o.app_token||typeof o.expires_in!="number")throw new Error("App token response missing app_token or expires_in");let r=ke.getAppTokenRefreshBuffer(),s=Date.now()+o.expires_in*1e3-r;return qe(`app-token: minted, expires at ${new Date(s).toISOString()}`),{token:o.app_token,expiresAt:s}}async function uz(){let t=LE();if(t)return{creds:t,fromDisk:!0};if(!Wu)throw new Error("Cannot mint app token: no on-disk app credentials and no Slingshot user token available (please /login slingshot first)");let e=await Ol.getSlingcliConfig(Wu);return Rb(e),{creds:e,fromDisk:!1}}async function dz(){let{creds:t,fromDisk:e}=await uz();try{return await DE(t)}catch(n){let i=n instanceof Jm&&(n.status===401||n.status===403);if(!e||!i)throw n;if(ct("app-token: disk creds rejected (likely rotated), refetching from config service",{status:n.status}),WE(),!Wu)throw new Error("Cannot rotate app credentials: on-disk creds rejected and no Slingshot user token available (please /login slingshot)");let o=await Ol.getSlingcliConfig(Wu);return Rb(o),await DE(o)}}async function Yn(t){if(t&&(Wu=t),Lu&&Lu.expiresAt>Date.now())return FE(Lu.token),Lu.token;if(Ym)return(await Ym).token;let e=dz().then(i=>(Lu=i,FE(i.token),cz(i),i)).finally(()=>{Ym=null});return Ym=e,(await e).token}var Fu=null,Pb=null;typeof process<"u"&&process.versions?.node&&(Pb=import("node:http").then(t=>{Fu=t.createServer}));async function pz(){if(Fu||(Pb&&await Pb,Fu))return Fu;throw new Error("Slingshot OAuth requires Node.js")}async function Ib(t){let e=await pz(),n,i,o,r=!1,s=new Promise((u,d)=>{i=u,o=d}),a=u=>{if(!r){r=!0;try{n.close()}catch{}u()}};n=e((u,d)=>{let p=new URL(u.url||"","http://127.0.0.1"),m=p.searchParams.get("code"),g=p.searchParams.get("state"),h=p.searchParams.get("clientId"),f=p.searchParams.get("error"),b=p.searchParams.get("error_description");if(f){d.writeHead(400,{"Content-Type":"text/html"}),d.end(`<html><body><h1>Login Failed</h1><p>${b||f}</p><p>You can close this window.</p></body></html>`),a(()=>o(new Error(`Login failed: ${b||f}`)));return}if(!m||!g){d.writeHead(400,{"Content-Type":"text/html"}),d.end("<html><body><h1>Login Failed</h1><p>Missing code or state in callback.</p><p>You can close this window.</p></body></html>"),a(()=>o(new Error("Missing code or state in callback")));return}d.writeHead(200,{"Content-Type":"text/html"}),d.end("<html><body><h1>Login Successful</h1><p>You can close this window and return to your terminal.</p><script>setTimeout(()=>window.close(),3000)</script></body></html>"),a(()=>i({code:m,state:g,clientId:h||""}))}),n.on("error",u=>{a(()=>o(u))});let l=setTimeout(()=>{a(()=>o(new Error("Login timeout - no callback received within 5 minutes")))},300*1e3);return n.on("close",()=>clearTimeout(l)),t&&t.addEventListener("abort",()=>{a(()=>o(new Error("Login cancelled")))}),{port:await new Promise((u,d)=>{n.once("error",d),n.listen(0,"127.0.0.1",()=>{let p=n.address();p&&typeof p=="object"?u(p.port):d(new Error("Failed to obtain loopback server port"))})}),result:s}}async function Eb(t,e){if(!t)throw new Error("Missing exchange code");if(!e)throw new Error("Missing clientId for exchange");let n=ke.getExchangeUrl(),i;try{i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify({code:t,clientId:e})})}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`Cannot reach Studio Auth: ${s}`)}if(!i.ok){let r,s=`${i.status} ${i.statusText}`;try{let a=await i.json();r=a.error?.code,a.error?.message?s=a.error.message:a.message?s=a.message:r&&(s=r)}catch{}throw r==="INVALID_CALLBACK"?new Error("Login failed: exchange code is expired, already used, or bound to a different tenant. Please log in again."):new Error(`Code exchange failed: ${s}`)}let o=await i.json();if(!o.accessToken||!o.refreshToken)throw new Error("Exchange response missing accessToken or refreshToken");return o}function hz(){return mz(16).toString("hex")}function gz(t){let e=new URL(t),n=e.searchParams.get("code"),i=e.searchParams.get("state"),o=e.searchParams.get("clientId");if(!n||!i)throw new Error("Pasted URL is missing code or state");return{code:n,state:i,clientId:o||""}}async function Ab(t){let e=process.env.SLINGSHOT_TOKEN;if(e){let u=Ou(e);return qe("Using Slingshot token from SLINGSHOT_TOKEN environment variable"),await Yn(e),{refresh:"",access:e,expires:u>0?u-ke.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:ke.getDefaultProjectId(),workspaceId:ke.getDefaultWorkspaceId()}}let{port:n,result:i}=await Ib(t.signal),o=hz(),r=ke.getDefaultClientId(),s=ke.getLoginUrl({port:n,localState:o,clientId:r||void 0});t.onAuth({url:s});let a;if(t.onManualCodeInput){let u=t.onManualCodeInput().then(gz);a=await Promise.race([i,u])}else a=await i;if(a.state!==o)throw new Error("CSRF check failed - state does not match localState");if(!a.clientId)throw new Error("Login callback did not include clientId");let l=await Eb(a.code,a.clientId),c=Ou(l.accessToken);return await Yn(l.accessToken),{refresh:l.refreshToken,access:l.accessToken,expires:c>0?c-ke.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:ke.getDefaultProjectId(),workspaceId:ke.getDefaultWorkspaceId()}}import{randomUUID as fz}from"node:crypto";async function Xm(t){if(!t.refresh)throw new Error("No refresh token available. Please login again.");let e;try{e=await Yn()}catch(a){throw ct("auth/refresh: app token unavailable for refresh call",a),new Error(`Cannot refresh Slingshot token: app token unavailable (${a instanceof Error?a.message:String(a)}). Please /login slingshot.`)}let n=fz(),i={accept:"application/json",rt:t.refresh,"trace-id":n,Authorization:`Bearer ${e}`},o;try{let a=ke.getRefreshUrl();o=await fetch(a,{headers:i})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach Slingshot server: ${l}`)}if(!o.ok){let a=`${o.status} ${o.statusText}`;try{let l=await o.json();l.message?a=String(l.message):l.error&&(a=String(l.error))}catch{}throw new Error(`Token refresh failed: ${a}`)}let r=await o.json();if(!r.accessToken)throw new Error("No access token in refresh response");let s=Ou(r.accessToken);try{await Yn(r.accessToken)}catch(a){throw ct("auth/refresh: app token refresh failed",a),a}return{refresh:r.refreshToken||t.refresh,access:r.accessToken,expires:s>0?s-ke.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:t.projectId,workspaceId:t.workspaceId}}var UE=[{id:"gpt-5.4-nano",name:"GPT-5.4 nano",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-4.1",name:"GPT-4.1",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,provider:"slingshot",api:"openai-completions"},{id:"gpt-5",name:"GPT-5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-mini",name:"GPT-5 Mini",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-nano",name:"GPT-5 Nano",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.1",name:"GPT-5.1",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.2",name:"GPT-5.2",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.4",name:"GPT-5.4",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.5",name:"GPT-5.5",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"claude-opus-4@20250514",name:"Claude Opus 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4@20250514",name:"Claude Sonnet 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-5@20250929",name:"Claude Sonnet 4.5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-opus-4-6",name:"Claude Opus 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,provider:"slingshot",api:"openai-completions"},{id:"o3",name:"O3",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o3-mini",name:"o3-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o4-mini",name:"o4-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536,provider:"slingshot",api:"openai-completions"}];var Zm={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build","build:offline":"cd packages/tui && npm run build && cd ../ai && npm run build:offline && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build",dev:'concurrently --names "ai,agent,coding-agent,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/server && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","test:models":"node scripts/test-models.mjs","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{"@anthropic-ai/sandbox-runtime":"0.0.57","@biomejs/biome":"2.3.15","@types/better-sqlite3":"^7.6.13","@types/lodash.mergewith":"^4.6.9","@types/node":"24.13.2","@types/turndown":"^5.0.6","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.3",esbuild:"0.28.1","fast-xml-parser":"^5.9.3",husky:"9.1.7",jiti:"2.7.0",psadk:"^1.5.1",shx:"0.4.0",tsx:"4.22.4",turbo:"^2.9.18",typescript:"5.9.3",vitest:"^4.1.9"},engines:{node:">=20.0.0"},slingVersion:"2.5.20260723-1",overrides:{postcss:"8.5.14",next:{postcss:"8.5.14"},"ip-address":"^10.1.1","@modelcontextprotocol/sdk":"^1.29.0",ai:">=5.0.52","fast-xml-parser":"^5.9.3","@aws-sdk/xml-builder":{"fast-xml-parser":"^5.9.3"},"adaptivecards-templating":{"adaptive-expressions":{"fast-xml-parser":"^5.5.8"}},picomatch:"^4.0.4","path-to-regexp":"8.4.1",router:{"path-to-regexp":"8.4.1"},minimatch:"^10.2.3",tar:"7.5.11",react:"19.1.1","react-dom":"19.1.1","@types/react":"19","@types/react-dom":"19",tailwindcss:"4.1.12",lightningcss:"1.30.2",glob:{".":"11.1.0",minimatch:"10.2.3"},prismjs:"^1.30.0",qs:"^6.15.0","@hono/node-server":"1.19.14",protobufjs:"^8.2.0","@opentelemetry/otlp-transformer":{protobufjs:"^8.2.0"},langchain:{langsmith:">=0.7.0"},hono:"4.12.18",fsevents:"^2.3.3",swiper:"^12.1.2",lodash:"^4.18.0","lodash-es":"^4.18.1",axios:"^1.15.0","ibm-cloud-sdk-core":"^5.4.11",dompurify:">=3.4.0","react-markdown-mermaid":{mermaid:"10.9.6"}},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0","@mozilla/readability":"^0.6.0","better-sqlite3":"^12.11.1","compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0",linkedom:"^0.18.12",turndown:"^7.2.4",unpdf:"^1.6.2"}};import Du from"chalk";function $E(t,e){return{render(n){let i=` \u26AC _______. __ __ .__ __. _______
388
388
  \u274D \xB7 \u274D / || | | | | \\ | | / _____|
389
389
  \u2726 \u26AC \u2726 | (----\`| | | | | \\| | | | __
390
390
  \u26AC \xB7 \u26AC \u26AC \xB7 \u26AC \\ \\ | | | | | . \` | | | |_ |
@@ -459,22 +459,22 @@ Output only the message, nothing else.`;var ZV="You generate short themed loadin
459
459
  `).replace(/\s+/g," ").trim()}function N9(t,e){let n=U9(t);if(!ql(n))return[];let i=[],o=v9(n).filter(a=>a.endsWith(".jsonl"));for(let a of o){let l=ho(n,a),c=Yu(l,"utf-8").split(`
460
460
  `);for(let u=c.length-1;u>=0;u--){let d=c[u];if(!d||!d.includes('"type":"message"')||!d.includes('"role":"user"'))continue;let p;try{p=JSON.parse(d)}catch(h){let f=h instanceof Error?h.message:String(h);throw new Error(`Failed to parse session file ${l}: ${f}`,{cause:h})}if(!Rt(p)||p.type!=="message"||!Rt(p.message)||p.message.role!=="user")continue;let m=$9(p.message.content);if(!cr(m))continue;let g=typeof p.message.timestamp=="number"?p.message.timestamp:typeof p.timestamp=="string"?Date.parse(p.timestamp):0;i.push({text:m,timestamp:Number.isFinite(g)?g:0})}}i.sort((a,l)=>l.timestamp-a.timestamp);let r=[],s=new Set;for(let a of i)if(!s.has(a.text)&&(s.add(a.text),r.push(a.text),r.length>=e))return r;return r}function B9(t){if(!Array.isArray(t))return[];let e=[];for(let n of t)if(typeof n=="string"&&cr(n)&&e[e.length-1]!==n&&(e.push(n),e.length>=Ih))break;return e}function v_(){let t=O_();try{if(!ql(t))return[];let e=JSON.parse(Yu(t,"utf-8"));return Rt(e)?B9(e.history):(console.debug(`[sling-footer] Ignoring invalid stash history at ${t}`),[])}catch(e){return console.debug(`[sling-footer] Failed to read stash history from ${t}:`,e),[]}}function j9(t){let e=O_(),n={version:1,history:t.slice(0,Ih)};try{M_(R_(e),{recursive:!0}),C_(e,JSON.stringify(n,null,2)+`
461
461
  `)}catch(i){console.debug(`[sling-footer] Failed to persist stash history to ${e}:`,i)}}function b_(t=process.cwd()){return __(h_(E_()),h_(A_(t)))}function L_(t,e){let n=E_(),i=A_(t),o=g_(n),r=g_(i);if(o===null||r===null)return!1;let s=Object.prototype.hasOwnProperty.call(r,"powerline"),a=s?i:n,l=s?r:o;l.powerline=e(l.powerline);try{return M_(R_(a),{recursive:!0}),C_(a,JSON.stringify(l,null,2)+`
462
- `),!0}catch(c){return console.debug(`[sling-footer] Failed to persist powerline setting to ${a}:`,c),!1}}function q9(t,e=process.cwd()){return L_(e,n=>vA(n,t))}function x_(t,e,n){return L_(t,i=>bA(i,e,n))}var y_=Object.keys(Ul);function K9(t){return typeof t=="string"&&Object.prototype.hasOwnProperty.call(Ul,t)}function G9(t){if(typeof t!="string")return null;let e=t.trim().toLowerCase();return K9(e)?e:null}function cr(t){return t.trim().length>0}function Vu(t,e){return e?.getExpandedText?.()??t.ui.getEditorText()}function w_(t,e){let n=t.replace(/\s+/g," ").trim();return n?te(n,e,"\u2026"):"(empty)"}function z9(t,e){return!cr(e)||t[0]===e?!1:(t.unshift(e),t.length>Ih&&(t.length=Ih),!0)}function Eh(t){let e=t.trim().toLowerCase().split("+");if(e.length<=1)return e[0]??"";let n=new Map(P_.map((o,r)=>[o,r]));return[...e.slice(0,-1).sort((o,r)=>(n.get(o)??99)-(n.get(r)??99)),e[e.length-1]].join("+")}function W_(){let t=new Set([...w9,...y9].map(Eh));for(let e of Object.values(Da)){let n=e.defaultKeys,i=n===void 0?[]:Array.isArray(n)?n:[n];for(let o of i)t.add(Eh(o))}return t}function H9(t){let e=t.toLowerCase();return/^[a-z0-9]$/i.test(t)||/^f([1-9]|1[0-2])$/i.test(t)||S9.has(e)?!0:I_.has(t)}function F_(t){if(typeof t!="string")return null;let e=t.trim();if(!e||/\s/.test(e))return null;let n=e.split("+");if(n.some(a=>a.length===0))return null;let i=n.slice(0,-1).map(a=>{let l=a.toLowerCase();return l==="cmd"||l==="command"?"super":l});if(new Set(i).size!==i.length)return null;for(let a of i)if(!k9.has(a))return null;let o=n[n.length-1];if(!H9(o))return null;let r=I_.has(o)?o:o.toLowerCase(),s=Eh([...i,r].join("+"));return $b(s)&&!nA(s)?null:s}function jl(t){return iA(Eh(t))}function V9(t,e){let n=vx[t];if(!e.has(jl(n)))return n;for(let i of bx){let o=vx[i];if(!e.has(jl(o)))return o}return null}function k_(t){let e={...vx},n=t.powerlineShortcuts;if(Rt(n))for(let o of bx){let r=F_(n[o]);r&&(e[o]=r)}let i=new Set(Array.from(W_(),jl));for(let o of bx){let r=e[o],s=jl(r);if(!i.has(s)){i.add(s);continue}let a=V9(o,i);if(!a){console.debug(`[sling-footer] Shortcut conflict for ${o}: "${r}" is already in use`);continue}console.debug(`[sling-footer] Shortcut conflict for ${o}: "${r}" replaced with "${a}"`),e[o]=a,i.add(jl(a))}return e}function S_(t){let e=Rt(t.bashMode)?t.bashMode:{},n=F_(e.toggleShortcut),i=n&&!W_().has(jl(n))?n:gx.toggleShortcut;n&&i!==n&&console.debug(`[sling-footer] Bash mode shortcut conflict: "${n}" replaced with "${i}"`);let o=typeof e.transcriptMaxLines=="number"&&Number.isFinite(e.transcriptMaxLines)?Math.max(100,Math.floor(e.transcriptMaxLines)):gx.transcriptMaxLines,r=typeof e.transcriptMaxBytes=="number"&&Number.isFinite(e.transcriptMaxBytes)?Math.max(16*1024,Math.floor(e.transcriptMaxBytes)):gx.transcriptMaxBytes;return{toggleShortcut:i,transcriptMaxLines:o,transcriptMaxBytes:r}}function Q9(t,e){let n=MA(t,e);return!n.visible||!n.content?{content:"",width:0,visible:!1}:{content:n.content,width:j(n.content),visible:!0}}function T_(t,e){if(t.length===0)return"";let n=ph(e.separator),i=ds("sep"),o=n.left;return" "+t.join(` ${i}${o}${An.reset} `)+An.reset+" "}function Y9(t,e,n){let i=ph(e.separator),o=j(i.left)+2,r=fA(e,Ge.customItems),s=[...r.leftSegments,...r.rightSegments],a=r.secondarySegments,l=[...s,...a],c=[];for(let b of l){let{content:x,width:y,visible:T}=Q9(b,t);T&&c.push({content:x,width:y})}if(c.length===0)return{topContent:"",secondaryContent:""};let u=2,d=u,p=[],m=[],g=!1;for(let b of c){let x=b.width+(p.length>0?o:0);!g&&d+x<=n?(p.push(b.content),d+=x):(g=!0,m.push(b))}let h=u,f=[];for(let b of m){let x=b.width+(f.length>0?o:0);if(h+x<=n)f.push(b.content),h+=x;else break}return{topContent:T_(p,e),secondaryContent:T_(f,e)}}function yx(t){let e=b_();Ge=Kb(e.powerline,y_);let n=k_(e),i=S_(e),o=!0,r=Date.now(),s=0,a=null,l=null,c=null,u=null,d=null,p=!1,m=null,g=null,h=null,f=null,b=null,x=null,y=null,T=null,P=null,I=!1,W=!1,D="",_=!0,F=null,O=v_(),R=null,E=!1,U=new Uu(i),G=new qu,q=null,Z=0,Y=null,se=0,xe=!0,rt=!1,Qe=0,At=()=>process.env.SHELL||"/bin/sh",_t=()=>q?.state.cwd??a?.cwd??process.cwd(),kn=_A({dismiss:w=>_d(w),getGeneration:()=>s,isEnabled:()=>o}),oe=OA(()=>{let w=Date.now()-Qe;if(xe&&!rt&&w<Rh){oe.schedule(Math.max(0,Rh-w));return}m?.requestRender()},R9),we=()=>{Y=null,xe=!0},Ce=w=>{xe=!0,oe.schedule(w)},dt=(w={})=>{if(xe=!0,w.deferDuringTyping!==!1&&Date.now()-Qe<Rh){oe.schedule();return}rt=!0,oe.cancel(),oe.schedule(0)},jt=w=>{g?.(),g=null;let S=w;if(typeof S.setExtensionStatus!="function")return;let $=S.setExtensionStatus,K=S.clearExtensionStatuses,re=function(Ye,De){$.call(this,Ye,De),dt()};S.setExtensionStatus=re;let J=null;typeof K=="function"&&(J=function(){K.call(this),dt()},S.clearExtensionStatuses=J),g=()=>{S.setExtensionStatus===re&&(S.setExtensionStatus=$),J&&S.clearExtensionStatuses===J&&(S.clearExtensionStatuses=K)}},Ki=w=>{let S=ls(Nu(a?.cwd??process.cwd()).map(K=>K.command),w,50),$=ls(Bu(At()),w,50);return[...new Set([...S,...$])]},nn=async()=>(q||(q=new lh(At(),a?.cwd??process.cwd(),U,Ce,(w,S)=>HE(a?.cwd??process.cwd(),w,S))),await q.ensureReady(),q),Ln=async(w,S)=>{try{await(await nn()).runCommand(w),Ce()}catch($){let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to run shell command: ${K}`,"error")}},Gi=async(w,S)=>{if(w!==E){if(!w&&q?.state.running){S.ui.notify("Wait for the current shell command to finish before leaving bash mode","warning");return}if(w){try{let $=await nn();E=!0,R?.dismissBashModeUi?.(),R?.refreshGhostSuggestion?.(),Ce(),S.ui.notify(`Bash mode enabled (${$.state.shellName})`,"info")}catch($){q?.dispose(),q=null,E=!1,Ce();let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to start shell session: ${K}`,"error")}return}E=w,R?.dismissBashModeUi?.(),Ce(),S.ui.notify("Bash mode disabled","info")}};function pc(w){return{selectedPrefix:S=>w.fg("accent",S),selectedText:S=>w.fg("accent",S),description:S=>w.fg("muted",S),scrollInfo:S=>w.fg("dim",S),noMatch:S=>w.fg("warning",S)}}async function Tr(w,S,$,K,re){return w.ui.custom((J,ee,Ye,De)=>{let yt=new Ht(K,re,pc(ee)),ht=he=>ee.fg("dim",he),Wn=(he,We)=>`${ht("\u2502")}${te(he,We,"\u2026",!0)}${ht("\u2502")}`;return yt.onSelect=he=>De(he),yt.onCancel=()=>De(null),{render:he=>{let We=Math.max(1,he-2),Ve=[];Ve.push(ht(`\u256D${"\u2500".repeat(We)}\u256E`)),Ve.push(Wn(ee.fg("accent",ee.bold(S)),We)),Ve.push(ht(`\u251C${"\u2500".repeat(We)}\u2524`));for(let $t of yt.render(We))Ve.push(Wn($t,We));return Ve.push(ht(`\u251C${"\u2500".repeat(We)}\u2524`)),Ve.push(Wn(ee.fg("dim",$),We)),Ve.push(ht(`\u2570${"\u2500".repeat(We)}\u256F`)),Ve},invalidate:()=>yt.invalidate(),handleInput:he=>{yt.handleInput(he),J.requestRender()}}},{overlay:!0,overlayOptions:()=>({verticalAlign:"center",horizontalAlign:"center"})})}t.on("session_start",async(w,S)=>{q?.dispose(),q=null,s++,r=Date.now(),a=S,c_=F9(S.cwd),D="",p=!1,d=null,F=null;let $=b_(S.cwd);i=S_($),n=k_($),_=$.showLastPrompt!==!1,Ge=Kb($.powerline,y_),O=v_(),E=!1,U=new Uu(i),G=new qu,c=typeof S.getThinkingLevel=="function"?()=>S.getThinkingLevel():null,u=c?.()??null,S.hasUI&&S.ui.setStatus("stash",void 0),o_(S),o&&S.hasUI&&(Wd(S),w.reason==="startup"&&Ge.welcome?$.quietStartup===!0?p3(S):m3(S):_d(S))}),t.on("session_shutdown",async(w,S)=>{s++,P?.(),P=null,I=!1,W=!1,kn.cancel(),oe.cancel(),g?.(),g=null,Ld({resetExtendedKeyboardModes:S.hasUI}),T?.(),T=null,q?.dispose(),q=null,E=!1,a=null,l=null,c=null,u=null,d=null,m=null,R=null,we()});let mc=w=>[/\bgit\s+(checkout|switch|branch\s+-[dDmM]|merge|rebase|pull|reset|worktree)/,/\bgit\s+stash\s+(pop|apply)/].some($=>$.test(w));t.on("tool_result",async w=>{if((w.toolName==="write"||w.toolName==="edit")&&mh(),w.toolName==="bash"&&w.input?.command){let S=String(w.input.command);mc(S)&&(mh(),Zb(),setTimeout(()=>Ce(),100))}}),t.on("user_bash",async w=>{mc(w.command)&&(mh(),Zb(),setTimeout(()=>Ce(),100),setTimeout(()=>Ce(),300),setTimeout(()=>Ce(),500))}),t.on("model_select",async(w,S)=>{a=S,Ce()}),t.on("thinking_level_select",async(w,S)=>{a=S,u=c?.()??(typeof w.level=="string"?w.level:null),dt({deferDuringTyping:!1})}),t.on("session_tree",async(w,S)=>{a=S,u=null,d=null,dt({deferDuringTyping:!1})}),t.on("before_agent_start",async(w,S)=>{D=w.prompt,S.hasUI&&r_(w.prompt,S.ui.setWorkingMessage)}),t.on("agent_start",async(w,S)=>{p=!0,d=null,s_(),_d(S),a=S}),t.on("message_update",async(w,S)=>{fx(w.message)&&w.message.stopReason!=="error"&&w.message.stopReason!=="aborted"&&Ph(w.message.usage)>0&&(d=w.message.usage,a=S,xe=!0,oe.schedule(P9))}),t.on("message_end",async(w,S)=>{a=S,fx(w.message)&&(w.message.stopReason==="error"||w.message.stopReason==="aborted"?d=null:Ph(w.message.usage)>0&&(d=w.message.usage)),dt({deferDuringTyping:!1})}),t.on("turn_end",async(w,S)=>{a=S,dt({deferDuringTyping:!1})}),t.on("tool_call",async(w,S)=>{if(_d(S),S.hasUI){let $=Zg(S);a_(w.toolName,w.input,S.ui.setWorkingMessage,$)}});function Zg(w){let S=w.sessionManager?.getBranch?.()??[];for(let $=S.length-1;$>=0;$--){let K=S[$];if(K.type==="message"&&K.message?.role==="assistant"){let re=K.message.content;if(!Array.isArray(re))continue;for(let J of re)if(J.type==="text"&&J.text){let ee=J.text.trim();if(ee.length>0)return ee.slice(0,200)}}}}function _d(w){kn.cancel(),P?(P(),P=null):W=!0,I&&(I=!1,w.ui.setHeader(void 0))}function hc(w){!P&&W&&!I||kn.schedule(w)}function JW(w){z9(O,w)&&j9(O)}function Od(w,S,$){vl(S),$&&w.ui.notify($,"info")}function ef(w){let S=Vu(w,R);return cr(S)?S:(w.ui.notify("Editor is empty","info"),null)}async function XW(w){let S=[...O],$=S.map((J,ee)=>({value:String(ee),label:`#${ee+1} ${w_(J,u_)}`})),K=await Tr(w,"Stash history","\u2191\u2193 navigate \u2022 enter insert \u2022 esc cancel",$,Math.min($.length,10));if(!K)return null;let re=Number.parseInt(K.value,10);return S[re]??null}async function ZW(w,S){let $=S.map((J,ee)=>({value:String(ee),label:`#${ee+1} ${w_(J,u_)}`})),K=await Tr(w,"Recent project prompts","\u2191\u2193 navigate \u2022 enter insert \u2022 esc cancel",$,Math.min($.length,10));if(!K)return null;let re=Number.parseInt(K.value,10);return S[re]??null}async function e3(w,S,$){let K=[];if(S>0&&K.push({value:"stash",label:"Stashed prompts",description:`${S} saved`}),$>0&&K.push({value:"project",label:"Recent project prompts",description:`${$} recent`}),K.length===0)return null;if(K.length===1)return K[0]?.value==="project"?"project":"stash";let re=await Tr(w,"Prompt history","\u2191\u2193 navigate \u2022 enter open \u2022 esc cancel",K,K.length);return re?re.value==="project"?"project":"stash":null}async function t3(w,S){let $=Vu(w,R);if(!cr($)){w.ui.setEditorText(S),w.ui.notify("Inserted prompt","info");return}let K=await w.ui.select("Insert prompt",["Replace","Append","Cancel"]);if(K==="Replace"){w.ui.setEditorText(S),w.ui.notify("Replaced editor with prompt","info");return}if(K==="Append"){let re=$.endsWith(`
462
+ `),!0}catch(c){return console.debug(`[sling-footer] Failed to persist powerline setting to ${a}:`,c),!1}}function q9(t,e=process.cwd()){return L_(e,n=>vA(n,t))}function x_(t,e,n){return L_(t,i=>bA(i,e,n))}var y_=Object.keys(Ul);function K9(t){return typeof t=="string"&&Object.prototype.hasOwnProperty.call(Ul,t)}function G9(t){if(typeof t!="string")return null;let e=t.trim().toLowerCase();return K9(e)?e:null}function cr(t){return t.trim().length>0}function Vu(t,e){return e?.getExpandedText?.()??t.ui.getEditorText()}function w_(t,e){let n=t.replace(/\s+/g," ").trim();return n?te(n,e,"\u2026"):"(empty)"}function z9(t,e){return!cr(e)||t[0]===e?!1:(t.unshift(e),t.length>Ih&&(t.length=Ih),!0)}function Eh(t){let e=t.trim().toLowerCase().split("+");if(e.length<=1)return e[0]??"";let n=new Map(P_.map((o,r)=>[o,r]));return[...e.slice(0,-1).sort((o,r)=>(n.get(o)??99)-(n.get(r)??99)),e[e.length-1]].join("+")}function W_(){let t=new Set([...w9,...y9].map(Eh));for(let e of Object.values(Da)){let n=e.defaultKeys,i=n===void 0?[]:Array.isArray(n)?n:[n];for(let o of i)t.add(Eh(o))}return t}function H9(t){let e=t.toLowerCase();return/^[a-z0-9]$/i.test(t)||/^f([1-9]|1[0-2])$/i.test(t)||S9.has(e)?!0:I_.has(t)}function F_(t){if(typeof t!="string")return null;let e=t.trim();if(!e||/\s/.test(e))return null;let n=e.split("+");if(n.some(a=>a.length===0))return null;let i=n.slice(0,-1).map(a=>{let l=a.toLowerCase();return l==="cmd"||l==="command"?"super":l});if(new Set(i).size!==i.length)return null;for(let a of i)if(!k9.has(a))return null;let o=n[n.length-1];if(!H9(o))return null;let r=I_.has(o)?o:o.toLowerCase(),s=Eh([...i,r].join("+"));return $b(s)&&!nA(s)?null:s}function jl(t){return iA(Eh(t))}function V9(t,e){let n=vx[t];if(!e.has(jl(n)))return n;for(let i of bx){let o=vx[i];if(!e.has(jl(o)))return o}return null}function k_(t){let e={...vx},n=t.powerlineShortcuts;if(Rt(n))for(let o of bx){let r=F_(n[o]);r&&(e[o]=r)}let i=new Set(Array.from(W_(),jl));for(let o of bx){let r=e[o],s=jl(r);if(!i.has(s)){i.add(s);continue}let a=V9(o,i);if(!a){console.debug(`[sling-footer] Shortcut conflict for ${o}: "${r}" is already in use`);continue}console.debug(`[sling-footer] Shortcut conflict for ${o}: "${r}" replaced with "${a}"`),e[o]=a,i.add(jl(a))}return e}function S_(t){let e=Rt(t.bashMode)?t.bashMode:{},n=F_(e.toggleShortcut),i=n&&!W_().has(jl(n))?n:gx.toggleShortcut;n&&i!==n&&console.debug(`[sling-footer] Bash mode shortcut conflict: "${n}" replaced with "${i}"`);let o=typeof e.transcriptMaxLines=="number"&&Number.isFinite(e.transcriptMaxLines)?Math.max(100,Math.floor(e.transcriptMaxLines)):gx.transcriptMaxLines,r=typeof e.transcriptMaxBytes=="number"&&Number.isFinite(e.transcriptMaxBytes)?Math.max(16*1024,Math.floor(e.transcriptMaxBytes)):gx.transcriptMaxBytes;return{toggleShortcut:i,transcriptMaxLines:o,transcriptMaxBytes:r}}function Q9(t,e){let n=MA(t,e);return!n.visible||!n.content?{content:"",width:0,visible:!1}:{content:n.content,width:j(n.content),visible:!0}}function T_(t,e){if(t.length===0)return"";let n=ph(e.separator),i=ds("sep"),o=n.left;return" "+t.join(` ${i}${o}${An.reset} `)+An.reset+" "}function Y9(t,e,n){let i=ph(e.separator),o=j(i.left)+2,r=fA(e,Ge.customItems),s=[...r.leftSegments,...r.rightSegments],a=r.secondarySegments,l=[...s,...a],c=[];for(let b of l){let{content:x,width:y,visible:T}=Q9(b,t);T&&c.push({content:x,width:y})}if(c.length===0)return{topContent:"",secondaryContent:""};let u=2,d=u,p=[],m=[],g=!1;for(let b of c){let x=b.width+(p.length>0?o:0);!g&&d+x<=n?(p.push(b.content),d+=x):(g=!0,m.push(b))}let h=u,f=[];for(let b of m){let x=b.width+(f.length>0?o:0);if(h+x<=n)f.push(b.content),h+=x;else break}return{topContent:T_(p,e),secondaryContent:T_(f,e)}}function yx(t){let e=b_();Ge=Kb(e.powerline,y_);let n=k_(e),i=S_(e),o=!0,r=Date.now(),s=0,a=null,l=null,c=null,u=null,d=null,p=!1,m=null,g=null,h=null,f=null,b=null,x=null,y=null,T=null,P=null,I=!1,W=!1,D="",_=!0,F=null,O=v_(),R=null,E=!1,U=new Uu(i),G=new qu,q=null,Z=0,Y=null,se=0,xe=!0,rt=!1,Qe=0,At=()=>process.env.SHELL||"/bin/sh",_t=()=>q?.state.cwd??a?.cwd??process.cwd(),kn=_A({dismiss:w=>_d(w),getGeneration:()=>s,isEnabled:()=>o}),oe=OA(()=>{let w=Date.now()-Qe;if(xe&&!rt&&w<Rh){oe.schedule(Math.max(0,Rh-w));return}m?.requestRender()},R9),ye=()=>{Y=null,xe=!0},Ce=w=>{xe=!0,oe.schedule(w)},dt=(w={})=>{if(xe=!0,w.deferDuringTyping!==!1&&Date.now()-Qe<Rh){oe.schedule();return}rt=!0,oe.cancel(),oe.schedule(0)},jt=w=>{g?.(),g=null;let S=w;if(typeof S.setExtensionStatus!="function")return;let $=S.setExtensionStatus,K=S.clearExtensionStatuses,re=function(Ye,De){$.call(this,Ye,De),dt()};S.setExtensionStatus=re;let J=null;typeof K=="function"&&(J=function(){K.call(this),dt()},S.clearExtensionStatuses=J),g=()=>{S.setExtensionStatus===re&&(S.setExtensionStatus=$),J&&S.clearExtensionStatuses===J&&(S.clearExtensionStatuses=K)}},Ki=w=>{let S=ls(Nu(a?.cwd??process.cwd()).map(K=>K.command),w,50),$=ls(Bu(At()),w,50);return[...new Set([...S,...$])]},nn=async()=>(q||(q=new lh(At(),a?.cwd??process.cwd(),U,Ce,(w,S)=>HE(a?.cwd??process.cwd(),w,S))),await q.ensureReady(),q),Ln=async(w,S)=>{try{await(await nn()).runCommand(w),Ce()}catch($){let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to run shell command: ${K}`,"error")}},Gi=async(w,S)=>{if(w!==E){if(!w&&q?.state.running){S.ui.notify("Wait for the current shell command to finish before leaving bash mode","warning");return}if(w){try{let $=await nn();E=!0,R?.dismissBashModeUi?.(),R?.refreshGhostSuggestion?.(),Ce(),S.ui.notify(`Bash mode enabled (${$.state.shellName})`,"info")}catch($){q?.dispose(),q=null,E=!1,Ce();let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to start shell session: ${K}`,"error")}return}E=w,R?.dismissBashModeUi?.(),Ce(),S.ui.notify("Bash mode disabled","info")}};function pc(w){return{selectedPrefix:S=>w.fg("accent",S),selectedText:S=>w.fg("accent",S),description:S=>w.fg("muted",S),scrollInfo:S=>w.fg("dim",S),noMatch:S=>w.fg("warning",S)}}async function Tr(w,S,$,K,re){return w.ui.custom((J,ee,Ye,De)=>{let yt=new Ht(K,re,pc(ee)),ht=he=>ee.fg("dim",he),Wn=(he,We)=>`${ht("\u2502")}${te(he,We,"\u2026",!0)}${ht("\u2502")}`;return yt.onSelect=he=>De(he),yt.onCancel=()=>De(null),{render:he=>{let We=Math.max(1,he-2),Ve=[];Ve.push(ht(`\u256D${"\u2500".repeat(We)}\u256E`)),Ve.push(Wn(ee.fg("accent",ee.bold(S)),We)),Ve.push(ht(`\u251C${"\u2500".repeat(We)}\u2524`));for(let $t of yt.render(We))Ve.push(Wn($t,We));return Ve.push(ht(`\u251C${"\u2500".repeat(We)}\u2524`)),Ve.push(Wn(ee.fg("dim",$),We)),Ve.push(ht(`\u2570${"\u2500".repeat(We)}\u256F`)),Ve},invalidate:()=>yt.invalidate(),handleInput:he=>{yt.handleInput(he),J.requestRender()}}},{overlay:!0,overlayOptions:()=>({verticalAlign:"center",horizontalAlign:"center"})})}t.on("session_start",async(w,S)=>{q?.dispose(),q=null,s++,r=Date.now(),a=S,c_=F9(S.cwd),D="",p=!1,d=null,F=null;let $=b_(S.cwd);i=S_($),n=k_($),_=$.showLastPrompt!==!1,Ge=Kb($.powerline,y_),O=v_(),E=!1,U=new Uu(i),G=new qu,c=typeof S.getThinkingLevel=="function"?()=>S.getThinkingLevel():null,u=c?.()??null,S.hasUI&&S.ui.setStatus("stash",void 0),o_(S),o&&S.hasUI&&(Wd(S),w.reason==="startup"&&Ge.welcome?$.quietStartup===!0?p3(S):m3(S):_d(S))}),t.on("session_shutdown",async(w,S)=>{s++,P?.(),P=null,I=!1,W=!1,kn.cancel(),oe.cancel(),g?.(),g=null,Ld({resetExtendedKeyboardModes:S.hasUI}),T?.(),T=null,q?.dispose(),q=null,E=!1,a=null,l=null,c=null,u=null,d=null,m=null,R=null,ye()});let mc=w=>[/\bgit\s+(checkout|switch|branch\s+-[dDmM]|merge|rebase|pull|reset|worktree)/,/\bgit\s+stash\s+(pop|apply)/].some($=>$.test(w));t.on("tool_result",async w=>{if((w.toolName==="write"||w.toolName==="edit")&&mh(),w.toolName==="bash"&&w.input?.command){let S=String(w.input.command);mc(S)&&(mh(),Zb(),setTimeout(()=>Ce(),100))}}),t.on("user_bash",async w=>{mc(w.command)&&(mh(),Zb(),setTimeout(()=>Ce(),100),setTimeout(()=>Ce(),300),setTimeout(()=>Ce(),500))}),t.on("model_select",async(w,S)=>{a=S,Ce()}),t.on("thinking_level_select",async(w,S)=>{a=S,u=c?.()??(typeof w.level=="string"?w.level:null),dt({deferDuringTyping:!1})}),t.on("session_tree",async(w,S)=>{a=S,u=null,d=null,dt({deferDuringTyping:!1})}),t.on("before_agent_start",async(w,S)=>{D=w.prompt,S.hasUI&&r_(w.prompt,S.ui.setWorkingMessage)}),t.on("agent_start",async(w,S)=>{p=!0,d=null,s_(),_d(S),a=S}),t.on("message_update",async(w,S)=>{fx(w.message)&&w.message.stopReason!=="error"&&w.message.stopReason!=="aborted"&&Ph(w.message.usage)>0&&(d=w.message.usage,a=S,xe=!0,oe.schedule(P9))}),t.on("message_end",async(w,S)=>{a=S,fx(w.message)&&(w.message.stopReason==="error"||w.message.stopReason==="aborted"?d=null:Ph(w.message.usage)>0&&(d=w.message.usage)),dt({deferDuringTyping:!1})}),t.on("turn_end",async(w,S)=>{a=S,dt({deferDuringTyping:!1})}),t.on("tool_call",async(w,S)=>{if(_d(S),S.hasUI){let $=Zg(S);a_(w.toolName,w.input,S.ui.setWorkingMessage,$)}});function Zg(w){let S=w.sessionManager?.getBranch?.()??[];for(let $=S.length-1;$>=0;$--){let K=S[$];if(K.type==="message"&&K.message?.role==="assistant"){let re=K.message.content;if(!Array.isArray(re))continue;for(let J of re)if(J.type==="text"&&J.text){let ee=J.text.trim();if(ee.length>0)return ee.slice(0,200)}}}}function _d(w){kn.cancel(),P?(P(),P=null):W=!0,I&&(I=!1,w.ui.setHeader(void 0))}function hc(w){!P&&W&&!I||kn.schedule(w)}function JW(w){z9(O,w)&&j9(O)}function Od(w,S,$){vl(S),$&&w.ui.notify($,"info")}function ef(w){let S=Vu(w,R);return cr(S)?S:(w.ui.notify("Editor is empty","info"),null)}async function XW(w){let S=[...O],$=S.map((J,ee)=>({value:String(ee),label:`#${ee+1} ${w_(J,u_)}`})),K=await Tr(w,"Stash history","\u2191\u2193 navigate \u2022 enter insert \u2022 esc cancel",$,Math.min($.length,10));if(!K)return null;let re=Number.parseInt(K.value,10);return S[re]??null}async function ZW(w,S){let $=S.map((J,ee)=>({value:String(ee),label:`#${ee+1} ${w_(J,u_)}`})),K=await Tr(w,"Recent project prompts","\u2191\u2193 navigate \u2022 enter insert \u2022 esc cancel",$,Math.min($.length,10));if(!K)return null;let re=Number.parseInt(K.value,10);return S[re]??null}async function e3(w,S,$){let K=[];if(S>0&&K.push({value:"stash",label:"Stashed prompts",description:`${S} saved`}),$>0&&K.push({value:"project",label:"Recent project prompts",description:`${$} recent`}),K.length===0)return null;if(K.length===1)return K[0]?.value==="project"?"project":"stash";let re=await Tr(w,"Prompt history","\u2191\u2193 navigate \u2022 enter open \u2022 esc cancel",K,K.length);return re?re.value==="project"?"project":"stash":null}async function t3(w,S){let $=Vu(w,R);if(!cr($)){w.ui.setEditorText(S),w.ui.notify("Inserted prompt","info");return}let K=await w.ui.select("Insert prompt",["Replace","Append","Cancel"]);if(K==="Replace"){w.ui.setEditorText(S),w.ui.notify("Replaced editor with prompt","info");return}if(K==="Append"){let re=$.endsWith(`
463
463
  `)||S.startsWith(`
464
464
  `)?"":`
465
- `;w.ui.setEditorText(`${$}${re}${S}`),w.ui.notify("Appended prompt","info")}}function Bk(w){return ai(w)?!1:w==="\xDF"||w==="\x1Bs"||w==="\x1BS"||/^\x1b\[(?:83|115)(?::\d*)?(?::\d*)?;3(?::\d+)?u$/.test(w)||w==="\x1B[27;3;115~"||w==="\x1B[27;3;83~"||Fe(w,"alt+s")}function n3(w){return d_.find(({shortcutKey:S})=>Jn(w,n[S]))?.action??null}function i3(w){return Jn(w,n.stashHistory)||n.stashHistory==="ctrl+alt+h"&&(/^\x1b\[104(?::\d*)?(?::\d*)?;7(?::\d+)?u$/.test(w)||w==="\x1B[27;7;104~"||w==="\x1B[27;7;72~")}function jk(w){if(ai(w))return null;if(i3(w))return{kind:"stashHistory"};if(Jn(w,n.copyEditor))return{kind:"copyEditor"};if(Jn(w,n.cutEditor))return{kind:"cutEditor"};if(Jn(w,i.toggleShortcut))return{kind:"bashMode"};let S=n3(w);return S?{kind:"chat",action:S}:null}function tf(w,S){if(S.kind==="stashHistory"){of(w);return}if(S.kind==="copyEditor"||S.kind==="cutEditor"){let $=ef(w);if(!$)return;Od(w,$,S.kind==="copyEditor"?"Copied editor text":void 0),S.kind==="cutEditor"&&(w.ui.setEditorText(""),w.ui.notify("Cut editor text","info"));return}if(S.kind==="bashMode"){Gi(!E,w);return}if(S.action.kind==="bottom"){u3(w);return}c3(w,S.action.role,S.action.direction)}function nf(w){let S=Vu(w,R),$=F!==null;if(!cr(S)){if(!$){w.ui.notify("Nothing to stash","info");return}w.ui.setEditorText(F),F=null,w.ui.setStatus("stash",void 0),w.ui.notify("Stash restored","info");return}F=S,JW(S),w.ui.setEditorText(""),w.ui.setStatus("stash","stash"),w.ui.notify($?"Stash updated":"Text stashed","info")}async function of(w){let S=[];try{S=N9(w.cwd,x9)}catch(re){let J=re instanceof Error?re.message:String(re);w.ui.notify(`Failed to load project prompts: ${J}`,"warning")}if(O.length===0&&S.length===0){w.ui.notify("No prompt history yet","info");return}let $=await e3(w,O.length,S.length);if(!$)return;let K=$==="project"?await ZW(w,S):await XW(w);K&&await t3(w,K)}t.on("agent_end",async(w,S)=>{p=!1,d=null,a=S,S.hasUI&&(l_(S.ui.setWorkingMessage),F!==null&&(S.ui.getEditorText().trim()===""?(S.ui.setEditorText(F),F=null,S.ui.setStatus("stash",void 0),S.ui.notify("Stash restored","info")):S.ui.notify("Stash preserved \u2014 clear editor then Alt+S to restore","info"))),Ce()}),t.registerCommand("s:footer",{description:"Configure sling footer status (toggle, preset)",handler:async(w,S)=>{if(a=S,!w?.trim()){o=!o,o?(Wd(S),S.ui.notify("sling footer enabled","info")):(q?.dispose(),q=null,U.clear(),E=!1,P?.(),P=null,I=!1,W=!1,kn.cancel(),xx().savedPromptHistory=[],F=null,S.ui.setStatus("stash",void 0),g?.(),g=null,Ld(),T?.(),T=null,S.ui.setEditorComponent(void 0),S.ui.setFooter(void 0),S.ui.setHeader(void 0),S.ui.setWidget("powerline-top",void 0),S.ui.setWidget("powerline-secondary",void 0),S.ui.setWidget("powerline-bash-transcript",void 0),S.ui.setWidget("powerline-status",void 0),S.ui.setWidget("powerline-last-prompt",void 0),l=null,m=null,R=null,oe.cancel(),we(),S.ui.notify("sling footer disabled","info"));return}let $=w.trim().toLowerCase(),K=/^mouse-scroll(?:\s+(on|off|toggle))?$/.exec($);if(K){let Ye=K[1]??"toggle";Ge.mouseScroll=Ye==="toggle"?!Ge.mouseScroll:Ye==="on",o&&S.hasUI&&Ge.fixedEditor&&m&&R&&rf(S,m),x_(S.cwd,{mouseScroll:Ge.mouseScroll},Ge.preset)?S.ui.notify(`sling mouse scroll ${Ge.mouseScroll?"enabled":"disabled"}`,"info"):S.ui.notify(`sling mouse scroll ${Ge.mouseScroll?"enabled":"disabled"} (not persisted; check settings.json)`,"warning");return}let re=/^fixed-editor(?:\s+(on|off|toggle))?$/.exec($);if(re){let Ye=re[1]??"toggle";Ge.fixedEditor=Ye==="toggle"?!Ge.fixedEditor:Ye==="on",o&&S.hasUI&&Wd(S),x_(S.cwd,{fixedEditor:Ge.fixedEditor},Ge.preset)?S.ui.notify(`sling fixed editor ${Ge.fixedEditor?"enabled":"disabled"}`,"info"):S.ui.notify(`sling fixed editor ${Ge.fixedEditor?"enabled":"disabled"} (not persisted; check settings.json)`,"warning");return}let J=G9(w);if(J){Ge.preset=J,we(),o&&Wd(S),q9(J,S.cwd)?S.ui.notify(`Preset set to: ${J}`,"info"):S.ui.notify(`Preset set to: ${J} (not persisted; check settings.json)`,"warning");return}let ee=Object.keys(Ul).join(", ");S.ui.notify(`Available presets: ${ee}`,"info")}}),t.registerCommand("s:stash-history",{description:"Open prompt history picker",handler:async(w,S)=>{if(S.hasUI){if(!o){S.ui.notify("sling footer is disabled","info");return}await of(S)}}}),t.registerCommand("s:bash-mode",{description:"Toggle sticky bash mode (on, off, toggle)",handler:async(w,S)=>{let $=w?.trim().toLowerCase()||"toggle";if($==="on"){await Gi(!0,S);return}if($==="off"){await Gi(!1,S);return}if($==="toggle"){await Gi(!E,S);return}S.ui.notify("Usage: /bash-mode [on|off|toggle]","warning")}}),t.registerCommand("s:bash-reset",{description:"Reset the managed bash session",handler:async(w,S)=>{if(q?.dispose(),q=null,U.clear(),E)try{await nn()}catch($){E=!1;let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to restart shell session: ${K}`,"error"),Ce();return}Ce(),S.ui.notify("Bash session reset","info")}}),t.registerShortcut(i.toggleShortcut,{description:"Toggle bash mode",handler:async w=>{!o||!w.hasUI||await Gi(!E,w)}}),t.registerShortcut("alt+s",{description:"Stash/restore editor text",handler:async w=>{!o||!w.hasUI||nf(w)}}),t.registerShortcut(n.stashHistory,{description:"Open prompt history picker",handler:async w=>{!o||!w.hasUI||await of(w)}}),t.registerShortcut(n.copyEditor,{description:"Copy full editor text",handler:async w=>{if(!o||!w.hasUI)return;let S=ef(w);S&&Od(w,S,"Copied editor text")}}),t.registerShortcut(n.cutEditor,{description:"Cut full editor text",handler:async w=>{if(!o||!w.hasUI)return;let S=ef(w);S&&(Od(w,S),w.ui.setEditorText(""),w.ui.notify("Cut editor text","info"))}});for(let{shortcutKey:w,description:S,action:$}of d_)t.registerShortcut(n[w],{description:S,handler:async K=>{!o||!K.hasUI||tf(K,{kind:"chat",action:$})}});function o3(w,S){let $=qb(Ge.preset),K=$.colors??dh(),re=0,J=0,ee=0,Ye=0,De=0,yt,ht=null,Wn=w.sessionManager?.getBranch?.()??[];for(let yi of Wn){if(!Rt(yi)||(yi.type==="thinking_level_change"&&typeof yi.thinkingLevel=="string"&&(ht=yi.thinkingLevel),yi.type!=="message"||!fx(yi.message)))continue;let Hi=yi.message;Hi.stopReason==="error"||Hi.stopReason==="aborted"||(re+=Hi.usage.input,J+=Hi.usage.output,ee+=Hi.usage.cacheRead,Ye+=Hi.usage.cacheWrite,De+=Hi.usage.cost.total,Ph(Hi.usage)>0&&(yt=Hi))}let he=p?d??yt?.usage:yt?.usage,We=p&&d?null:WA(w),Ve=We?.contextTokens??(he?Ph(he):0),$t=We?.contextWindow??w.model?.contextWindow??0,zi=We?.contextPercent??($t>0?Ve/$t*100:0),gc=l?.getGitBranch()??null,Fd=RA(gc),oi=l?.getExtensionStatuses()??new Map,wa=new Map(Ge.customItems.map(yi=>[yi.id,yi])),Do=Gb(Ge.customItems),Ot=w.model?w.modelRegistry?.isUsingOAuth?.(w.model)??!1:!1,ka=u??ht??c?.()??"off";return{model:w.model,thinkingLevel:ka,sessionId:w.sessionManager?.getSessionId?.(),cwd:w.cwd,usageStats:{input:re,output:J,cacheRead:ee,cacheWrite:Ye,cost:De},contextPercent:zi,contextWindow:$t,autoCompactEnabled:w.settingsManager?.getCompactionSettings?.()?.enabled??!0,customCompactionEnabled:c_||oi.has(b9),usingSubscription:Ot,sessionStartTime:r,shellModeActive:E,shellRunning:q?.state.running??!1,shellName:q?.state.shellName??null,shellCwd:q?.state.cwd??null,git:Fd,extensionStatuses:oi,hiddenExtensionStatusKeys:Do,customItemsById:wa,options:$.segmentOptions??{},theme:S,colors:K}}function qk(w,S){let $=Date.now(),K=p?M9:C9;if(Y&&Z===w){let Ye=$-Qe<Rh;if(!rt&&Ye&&(xe||$-se>=K)||!xe&&$-se<K)return Y}let re=qb(Ge.preset),J=o3(a,S);return Z=w,Y=Y9(J,re,w),se=$,xe=!1,rt=!1,Y}function Kk(w){if(!a||!l)return[];let S=l.getExtensionStatuses();if(!S||S.size===0)return[];let $=Gb(Ge.customItems),K=[];for(let re of yA(S,$)){let J=` ${re}`;j(J)<=w&&K.push(J)}return K}function Gk(w,S){if(!a)return[];let $=qk(w,S);return $.topContent?[$.topContent]:[]}function zk(w,S){if(!a)return[];let $=qk(w,S);return $.secondaryContent?[$.secondaryContent]:[]}function Hk(w,S){if(!E)return[];let $=U.getSnapshot();if($.commands.length===0)return[];let K=[];$.truncatedCommands>0&&K.push(` ${S.fg("dim",`\u2026 ${$.truncatedCommands} earlier command${$.truncatedCommands===1?"":"s"} truncated`)}`);let re=$.commands.slice(-4);for(let J of re){let ee=(q?.state.shellName??"shell")==="fish"?">":"$",Ye=J.exitCode===null?S.fg("accent","running"):J.exitCode===0?S.fg("success","ok"):S.fg("error",`exit ${J.exitCode}`),De=te(J.command.replace(/\s+/g," ").trim(),Math.max(8,w-8),"\u2026");K.push(` ${S.fg("accent",ee)} ${De} ${S.fg("dim","(")}${Ye}${S.fg("dim",")")}`);let yt=J.output.slice(-6);for(let ht of yt)K.push(` ${te(ht,Math.max(1,w-3),"\u2026")}`)}return K.slice(-16)}function Vk(w){if(E||!_||!D)return[];let S=` ${ds("sep")}\u21B3${An.reset} `,$=w-j(S);if($<10)return[];let K=D.replace(/\s+/g," ").trim();if(!K)return[];K=te(K,$,"\u2026");let re=`${ds("sep")}${K}${An.reset}`,J=`${S}${re}`;return[te(J,w,"\u2026")]}function Ld(w){let S=h!==null;if(h?.dispose(w),!S&&w?.resetExtendedKeyboardModes)try{process.stdout.write(QA())}catch{}h=null,f=null,b=null,x=null,y=null}function r3(w,S){let $=Array.isArray(w?.children)?w.children:[],K=$.findIndex(re=>Array.isArray(re?.children)&&re.children.includes(S));return K===-1?null:{container:$[K],index:K}}function rf(w,S){if(Ld(),!w.hasUI||!Ge.fixedEditor)return;if(!S?.terminal||typeof S.terminal.write!="function")throw new Error("[sling-footer] Fixed editor compositor could not find tui.terminal.write()");if(!R)throw new Error("[sling-footer] Fixed editor compositor expected the custom editor to be installed first");let $=r3(S,R);if(!$)throw new Error("[sling-footer] Fixed editor compositor could not find the editor container in TUI children");let K=Array.isArray(S.children)?S.children:[];b=$.container;let re=K[$.index-2]??null;f=re&&typeof re.render=="function"?re:null,x=K[$.index-1]??null,y=K[$.index+1]??null;let J;J=new Sh({tui:S,terminal:S.terminal,mouseScroll:Ge.mouseScroll,keyboardScrollShortcuts:{up:n.scrollChatUp,down:n.scrollChatDown},onCopySelection:ee=>Od(w,ee),getShowHardwareCursor:()=>typeof S.getShowHardwareCursor=="function"&&S.getShowHardwareCursor(),renderCluster:(ee,Ye)=>{let De=a?.ui?.theme??w.ui.theme,yt=f?J.renderHidden(f,ee).filter(he=>j(he)>0):[],ht=x?J.renderHidden(x,ee):[],Wn=y?J.renderHidden(y,ee):[];return FA({width:ee,terminalRows:Ye,statusLines:[...ht,...Kk(ee),...yt],topLines:Gk(ee,De),editorLines:b?J.renderHidden(b,ee):[],secondaryLines:[...zk(ee,De),...Wn],transcriptLines:Hk(ee,De),lastPromptLines:Vk(ee)})}}),h=J,f?.render&&J.hideRenderable(f),x?.render&&J.hideRenderable(x),J.hideRenderable(b),y?.render&&J.hideRenderable(y),J.install(),S.requestRender(!0)}function s3(w,S){let $=typeof w=="object"&&w!==null?w.constructor?.name:void 0;return S==="assistant"?$==="AssistantMessageComponent":$==="UserMessageComponent"||$==="SkillInvocationMessageComponent"}function a3(w,S){if(typeof w!="object"||w===null)return 0;let $=Reflect.get(w,"render");if(typeof $!="function")return 0;let K=$.call(w,S);return Array.isArray(K)?K.length:0}function Qk(w,S,$,K){let re=a3(w,S);if(s3(w,$))return{targets:[K],lineCount:re};let J=typeof w=="object"&&w!==null?Reflect.get(w,"children"):null;if(!Array.isArray(J)||J.length===0)return{targets:[],lineCount:re};let ee=[],Ye=K,De=0;for(let yt of J){let ht=Qk(yt,S,$,Ye);ee.push(...ht.targets),Ye+=ht.lineCount,De+=ht.lineCount}return{targets:ee,lineCount:Math.max(re,De)}}function l3(w){let S=Array.isArray(m?.children)?m.children:[],$=Math.max(1,m?.terminal?.columns??80),K=[],re=0;for(let J of S){let ee=Qk(J,$,w,re);K.push(...ee.targets),re+=ee.lineCount}return[...new Set(K)].sort((J,ee)=>J-ee)}function c3(w,S,$){if(!h){w.ui.notify("Chat message jumps require /s:footer fixed-editor on","warning");return}let K=l3(S),re=S==="assistant"?"LLM":"user";if(K.length===0){w.ui.notify(`No ${re} messages found`,"info");return}($==="previous"?h.jumpToPreviousRootTarget(K):h.jumpToNextRootTarget(K))||w.ui.notify(`No ${$} ${re} message`,"info")}function u3(w){if(!h){w.ui.notify("Chat bottom jump requires /s:footer fixed-editor on","warning");return}h.jumpToRootBottom()}function sf(){h?.jumpToRootBottom()}function d3(w){w.ui.setWidget("powerline-status",()=>({dispose(){},invalidate(){Ce()},render(S){return Kk(S)}}),{placement:"aboveEditor"}),w.ui.setWidget("powerline-top",(S,$)=>({dispose(){},invalidate(){we()},render(K){return Gk(K,$)}}),{placement:"aboveEditor"}),w.ui.setWidget("powerline-secondary",(S,$)=>({dispose(){},invalidate(){we()},render(K){return zk(K,$)}}),{placement:"belowEditor"}),w.ui.setWidget("powerline-bash-transcript",(S,$)=>({dispose(){},invalidate(){},render(K){return Hk(K,$)}}),{placement:"belowEditor"}),w.ui.setWidget("powerline-last-prompt",()=>({dispose(){},invalidate(){},render(S){return Vk(S)}}),{placement:"belowEditor"})}function Wd(w){if(Qu(R),!o)return;T?.(),T=typeof w.ui.onTerminalInput=="function"?w.ui.onTerminalInput(K=>{if(!o||!w.hasUI||m?.hasOverlay?.())return;if(Bk(K))return nf(w),hc(w),m?.requestRender(),{consume:!0};let re=jk(K);if(re)return tf(w,re),hc(w),m?.requestRender(),{consume:!0}}):null,Ld(),w.ui.setWidget("powerline-top",void 0),w.ui.setWidget("powerline-secondary",void 0),w.ui.setWidget("powerline-bash-transcript",void 0),w.ui.setWidget("powerline-status",void 0),w.ui.setWidget("powerline-last-prompt",void 0);let S=!1,$=(K,re,J)=>{let ee=new rh(K,re,J,{keybindings:J,isBashModeActive:()=>E,isShellRunning:()=>q?.state.running??!1,onExitBashMode:()=>{Gi(!1,w)},onSubmitCommand:he=>{Ln(he,w)},onEditorSubmit:()=>sf(),editorBoundaryShortcuts:{start:n.editorStart,end:n.editorEnd},onInterrupt:()=>{q?.interrupt(),w.ui.notify("Sent interrupt to shell","info")},onNotify:(he,We="info")=>w.ui.notify(he,We),getHistoryEntries:he=>Ki(he),resolveGhostSuggestion:async(he,We)=>{let Ve=Ku(he);if(Ve){let $t=await G.getGhostSuggestion(Ve.command,_t(),At(),We);return $t?{...$t,value:`${Ve.prefix}${$t.value}`}:null}return G.getGhostSuggestion(he,_t(),At(),We)}}),Ye=()=>{let he=Reflect.get(ee,"autocompleteProvider");if(!(!he||typeof he!="object")&&typeof Reflect.get(he,"getSuggestions")=="function"&&typeof Reflect.get(he,"applyCompletion")=="function")return he},De=()=>{if(ee.hasWrappedProvider())return!0;let he=Ye();if(!he)return!1;let We=new nh,Ve=new ih;return ee.installAutocompleteProvider(new oh(he,We,Ve,()=>E)),!0},yt;Object.defineProperty(ee,"onSubmit",{configurable:!0,get:()=>yt,set(he){yt=typeof he=="function"?We=>{sf(),he(We)}:he}}),R=ee,O9(ee),_9(ee),De();let ht=ee.handleInput.bind(ee);ee.handleInput=he=>{if(Qe=Date.now(),Bk(he)){nf(w),hc(w);return}let We=jk(he);if(We){tf(w,We),hc(w);return}if(!S&&!Ye()){S=!0,Qu(ee),w.ui.setEditorComponent($),Ge.fixedEditor&&rf(w,K),R?.handleInput(he);return}De();let Ve=J.matches(he,"app.message.followUp")?Vu(w,ee):"";hc(w),ht(he),cr(Ve)&&!cr(Vu(w,ee))&&sf()};let Wn=ee.render.bind(ee);return ee.render=he=>{if(he<10)return Wn(he);let We=Ot=>`${ds("sep")}${Ot}${An.reset}`,Ve=E?"$":">",zi=` ${`${An.getFgAnsi(200,200,200)}${Ve}${An.reset}`} `,gc=" ",Fd=Math.max(1,he-3),oi=Wn(Fd);if(oi.length===0)return oi;let wa=oi.length-1;for(let Ot=oi.length-1;Ot>=1;Ot--){let ka=oi[Ot]?.replace(/\x1b\[[0-9;]*m/g,"")||"";if(ka.length>0&&/^─{3,}/.test(ka)){wa=Ot;break}}let Do=[];Do.push(" "+We("\u2500".repeat(he-2)));for(let Ot=1;Ot<wa;Ot++){let ka=Ot===1?zi:gc;Do.push(`${ka}${oi[Ot]||""}`)}wa===1&&Do.push(`${zi}${" ".repeat(Fd)}`),Do.push(" "+We("\u2500".repeat(he-2)));for(let Ot=wa+1;Ot<oi.length;Ot++)Do.push(oi[Ot]||"");return Do},ee};w.ui.setEditorComponent($),w.ui.setFooter((K,re,J)=>{l=J,m=K,jt(J);let ee=J.onBranchChange(()=>Ce());return{dispose(){ee(),g?.(),g=null},invalidate(){Ce()},render(){return[]}}}),Ge.fixedEditor?m&&rf(w,m):d3(w)}function p3(w){let S=w.model?.name||w.model?.id||"No model",$=w.model?.provider||"Unknown",K=nx(),re=ix(3),J=new yh(S,$,re,K);I=!0,w.ui.setHeader(()=>({render(ee){return J.render(ee)},invalidate(){J.invalidate()}}))}function m3(w){let S=w.model?.name||w.model?.id||"No model",$=w.model?.provider||"Unknown",K=nx(),re=ix(3),J=s;setTimeout(()=>{if(!o||W||p||J!==s){W=!1;return}(w.sessionManager?.getBranch?.()??[]).some(De=>Rt(De)?De.type==="tool_call"||De.type==="tool_result"?!0:De.type==="message"&&Rt(De.message)&&De.message.role==="assistant":!1)||w.ui.custom((De,yt,ht,Wn)=>{let he=new xh(S,$,re,K),We=10,Ve=!1,$t=null,zi=()=>{Ve||(Ve=!0,$t&&clearInterval($t),P=null,Wn())};return $t=setInterval(()=>{Ve||(We--,he.setCountdown(We),De.requestRender(),We<=0&&zi())},1e3),P=zi,W&&(W=!1,zi()),{focused:!1,invalidate:()=>he.invalidate(),render:gc=>he.render(gc),handleInput:()=>zi(),dispose:()=>{Ve=!0,$t&&clearInterval($t)}}},{overlay:!0,overlayOptions:()=>({verticalAlign:"center",horizontalAlign:"center"})}).catch(De=>{console.debug("[sling-footer] Welcome overlay failed:",De)})},100)}}var D_=async t=>{try{if(t.model?.provider!=="slingshot")return qe("Skipping credits refresh for non-slingshot provider: "+t.model?.provider),100;let e=await t.modelRegistry.getApiKeyForProvider(t.model?.provider||"slingshot"),o=(await(await fetch(ye.getUserUrl(),{headers:{Authorization:`Bearer ${e||""}`,Accept:"application/json"}})).json()).remainingCredits||0;return qe("Fetched user data for credits: "+o),o}catch(e){ct("Error fetching user data for credits",e)}return 0};function Ah(t){return t<1e3?t.toString():t<1e4?`${(t/1e3).toFixed(1)}k`:t<1e6?`${Math.round(t/1e3)}k`:t<1e7?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e6)}M`}function U_(t){if(!t||typeof t!="object")return null;let e=t;if(e.role!=="assistant"||!e.usage||typeof e.usage!="object")return null;let n=e.usage;return typeof n.input!="number"||typeof n.output!="number"||typeof n.cacheRead!="number"||typeof n.cacheWrite!="number"||typeof n.cost?.total!="number"?null:{input:n.input,output:n.output,cacheRead:n.cacheRead,cacheWrite:n.cacheWrite,cost:{total:n.cost.total}}}var _h=class{constructor(e,n,i="ss-credit"){this.refreshCredits=e;this.log=n;this.statusKey=i;this.latestKnownCredits=0;this.creditRefreshInFlight=!1;this.lastCreditRefreshAt=0;this.liveAssistantUsage=null;this.isAssistantStreaming=!1;this.lastStatusUpdateAt=0}initialize(e){this.setStatus(e,this.latestKnownCredits,{force:!0})}startStreaming(e){this.isAssistantStreaming=!0,this.liveAssistantUsage=null,this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0,force:!0})}stopStreaming(e){this.isAssistantStreaming=!1,this.liveAssistantUsage=null,this.setStatus(e,this.latestKnownCredits,{force:!0})}onProgress(e){this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0})}onMessageUpdate(e,n){let i=U_(n);i&&(this.liveAssistantUsage=i,this.isAssistantStreaming=!0),this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0})}onMessageEnd(e,n){U_(n)&&(this.liveAssistantUsage=null,this.isAssistantStreaming=!1),this.setStatus(e,this.latestKnownCredits,{force:!0})}setCreditsFromServer(e,n){this.latestKnownCredits=n,this.setStatus(e,n,{force:!0})}async refreshAndUpdate(e,n={}){this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0});let i=Date.now();if(!n.force&&i-this.lastCreditRefreshAt<5e3)return this.latestKnownCredits;if(this.creditRefreshInFlight)return this.latestKnownCredits;this.creditRefreshInFlight=!0;try{return this.latestKnownCredits=await this.refreshCredits(e),this.lastCreditRefreshAt=Date.now(),this.setStatus(e,this.latestKnownCredits,{force:!0}),this.latestKnownCredits}catch(o){return n.logErrors&&this.log(`credits refresh failed: ${o instanceof Error?o.message:String(o)}`),this.latestKnownCredits}finally{this.creditRefreshInFlight=!1}}getUsageTotals(e,n){let i=0,o=0,r=0,s=0,a=0;for(let l of e.sessionManager.getEntries())l.type==="message"&&l.message.role==="assistant"&&(i+=l.message.usage.input,o+=l.message.usage.output,r+=l.message.usage.cacheRead,s+=l.message.usage.cacheWrite,a+=l.message.usage.cost.total);return n&&this.isAssistantStreaming&&this.liveAssistantUsage&&(i+=this.liveAssistantUsage.input,o+=this.liveAssistantUsage.output,r+=this.liveAssistantUsage.cacheRead,s+=this.liveAssistantUsage.cacheWrite,a+=this.liveAssistantUsage.cost.total),{input:i,output:o,cacheRead:r,cacheWrite:s,cost:a}}setStatus(e,n,i={}){if(!e.hasUI)return;let o=Date.now();if(!i.force&&o-this.lastStatusUpdateAt<120)return;this.lastStatusUpdateAt=o;let r=this.getUsageTotals(e,i.includeLiveUsage===!0),s=[`Credits: ${n.toFixed(4)}`,`\u2191${Ah(r.input)} \u2193${Ah(r.output)}`,`$${r.cost.toFixed(3)}`];(r.cacheRead>0||r.cacheWrite>0)&&s.push(`R${Ah(r.cacheRead)} W${Ah(r.cacheWrite)}`),e.ui.setStatus(this.statusKey,s.join(" \u2022 "))}};var tn=y3(AW(),1);var dc=t=>t==null?"N/A":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?Math.round(t/1e3)+"k":t.toString();var Lme=["context_tag","context_log","context_checkout"],Qg=null,yn=null,Yg=t=>Lme.includes(t),_W=(t,e)=>{if(e.toLowerCase()==="root"){let i=t.getTree();return i.length>0?i[0].entry.id:e}if(/^[0-9a-f]{8,}$/i.test(e))return e;let n=[...t.getTree()];for(;n.length>0;){let i=n.pop();if(t.getLabel(i.entry.id)===e)return i.entry.id;i.children?.length&&n.push(...i.children)}return e},Wme=tn.Type.Object({limit:tn.Type.Optional(tn.Type.Number({description:"History limit for visible entries (default: 50)."})),verbose:tn.Type.Optional(tn.Type.Boolean({description:"If true, show ALL messages. If false (default), collapses intermediate AI steps and only shows 'milestones': User messages, Tags, Branch Points, and Summaries."}))}),Fme=tn.Type.Object({target:tn.Type.String({description:"Where to jump/squash to. Can be a tag name (e.g., 'task-start'), a commit ID, or 'root'. This is the base for your new branch."}),message:tn.Type.String({description:"The 'Carryover Message' for the new branch. A summary of your *current* progress/lessons that you want to bring with you to the new state. This ensures you don't lose key information when switching contexts. Good summary message: '[Status] + [Reason] + [Important Changes] + [Carryover Data]'"}),backupTag:tn.Type.Optional(tn.Type.String({description:"Optional tag name to apply to the CURRENT state before checking out. Use this to create an automatic backup of the history you are about to leave/squash."}))}),Dme=tn.Type.Object({name:tn.Type.String({description:"The tag/milestone name. Use meaningful names."}),target:tn.Type.Optional(tn.Type.String({description:"The commit ID to tag. Defaults to HEAD (current state)."}))});function OW(t){t.registerCommand("s:acm",{description:"Enable agentic context management for the current session",handler:async(n,i)=>{Qg=i,i.ui.notify("Agentic Context Management enabled.","info"),t.sendMessage({customType:"ss-context",content:"use context-management skill",display:!1},{deliverAs:"followUp"}),n&&t.sendUserMessage(n)}});let e=(n,i,o)=>{let r=[...i].reverse();for(;r.length>0;){let s=r.pop();if(n.getLabel(s.entry.id)===o)return s.entry.id;if(s.children?.length)for(let a=s.children.length-1;a>=0;a--)r.push(s.children[a])}return null};t.registerTool({name:"context_tag",label:"Context Tag",description:"Creates a 'Save Point' (Bookmark) in the history. Use this before trying risky changes or when a feature is stable. 'Untagged progress is risky'.",parameters:Dme,async execute(n,i,o,r,s){let a=s.sessionManager,l=e(a,a.getTree(),i.name);if(l)return{content:[{type:"text",text:`Error: Tag '${i.name}' already exists at ${l}. Tag names must be unique. Use a different name or delete the existing tag first.`}],details:{}};let c=i.target?_W(a,i.target):void 0;if(!c){let u=a.getBranch();for(let d=u.length-1;d>=0;d--){let p=u[d];if(p.type==="message"&&p.message.role==="toolResult"){let m=p.message;if(Yg(m.toolName))continue;c=p.id;break}if(p.type==="message"&&p.message.role==="assistant"&&!p.message.content.some(h=>h.type==="toolCall"&&Yg(h.name))){c=p.id;break}c=p.id;break}c||(c=a.getLeafId()??"")}return t.setLabel(c,i.name),{content:[{type:"text",text:`Created tag '${i.name}' at ${c}`}],details:{}}}}),t.registerTool({name:"context_log",label:"Context Log",description:"Show the entire history structure (status, message, tags, milestones). Analogous to 'git log --graph --oneline --decorate'",parameters:Wme,async execute(n,i,o,r,s){let a=s.sessionManager,l=a.getBranch(),c=a.getLeafId(),u=i.verbose??!1,d=i.limit??50,p=new Set(l.map(_=>_.id)),m=[];l.forEach(_=>{m.push(_),a.getChildren(_.id).forEach(O=>{(O.type==="branch_summary"||O.type==="compaction")&&!p.has(O.id)&&m.push(O)})});let g=_=>{if(_.type==="branch_summary"||_.type==="compaction")return _.summary||"[No summary provided]";if(_.type==="label")return`tag: ${_.label}`;if(_.type==="message"){let F=_.message;if(F.role==="toolResult"){let O=F;if(!u&&Yg(O.toolName))return"";let E=(G=>G.map(q=>q.type==="text"?q.text:"").join(" ").trim())(O.content),U=O.details;return(O.toolName==="read"||O.toolName==="edit")&&U&&"path"in U&&typeof U.path=="string"&&(E=`${U.path}: ${E}`),`(${O.toolName}) ${E}`}if(F.role==="bashExecution")return`[Bash] ${F.command}`;if(F.role==="user"||F.role==="assistant"){let O="";typeof F.content=="string"?O=F.content:Array.isArray(F.content)&&(O=F.content.map(E=>typeof E=="object"&&E!==null&&"text"in E?E.text:"").join(" ").trim());let R="";return F.role==="assistant"&&(R=F.content.filter(U=>U.type==="toolCall").filter(U=>u||!Yg(U.name)).map(U=>`call: ${U.name}(${JSON.stringify(U.arguments)})`).join("; ")),[O,R].filter(Boolean).join(" ")}}return""},h=_=>_.id===c||l.length>0&&_.id===l[0].id||a.getLabel(_.id)?!0:_.type==="label"?!1:_.type==="branch_summary"||_.type==="compaction"||a.getChildren(_.id).length>1||_.type==="message"&&_.message.role==="user",f=new Set;m.forEach(_=>{(u||h(_))&&f.add(_.id)});let b=m.filter(_=>f.has(_.id));if(b.length>d){let _=new Set(b.slice(-d).map(F=>F.id));f.clear(),_.forEach(F=>f.add(F))}let x=[],y=0;m.forEach(_=>{if(!f.has(_.id)){y++;return}y>0&&(x.push(` : ... (${y} hidden messages) ...`),y=0);let F=_.id===c,O=a.getLabel(_.id),R=g(_).replace(/\s+/g," "),E=_.type.toUpperCase();if(_.type==="message"){let se=_.message;E=se.role==="assistant"?"AI":se.role==="user"?"USER":se.role==="bashExecution"?"BASH":"TOOL"}else(_.type==="branch_summary"||_.type==="compaction")&&(E="SUMMARY");if(E==="CUSTOM_MESSAGE")return;let U=_.id,q=[l.length>0&&_.id===l[0].id?"ROOT":null,F?"HEAD":null,O?`tag: ${O}`:null].filter(Boolean).join(", "),Z=R.length>100?R.slice(0,100)+"...":R,Y=F?"*":E==="USER"?"\u2022":"|";x.push(`${Y} ${U}${q?` (${q})`:""} [${E}] ${Z}`)}),y>0&&x.push(` : ... (${y} hidden messages) ...`);let T=await s.getContextUsage(),P="Unknown";T&&(P=`${T.percent.toFixed(1)}% (${dc(T.tokens)}/${dc(T.contextWindow)})`);let I=0,W="None";for(let _=l.length-1;_>=0;_--){let F=l[_].id,O=a.getLabel(F);if(O){W=O;break}I++}return{content:[{type:"text",text:["[Context Dashboard]",`\u2022 Context Usage: ${P}`,`\u2022 Segment Size: ${I} steps since last tag '${W}'`,"---------------------------------------------------"].join(`
465
+ `;w.ui.setEditorText(`${$}${re}${S}`),w.ui.notify("Appended prompt","info")}}function Bk(w){return ai(w)?!1:w==="\xDF"||w==="\x1Bs"||w==="\x1BS"||/^\x1b\[(?:83|115)(?::\d*)?(?::\d*)?;3(?::\d+)?u$/.test(w)||w==="\x1B[27;3;115~"||w==="\x1B[27;3;83~"||Fe(w,"alt+s")}function n3(w){return d_.find(({shortcutKey:S})=>Jn(w,n[S]))?.action??null}function i3(w){return Jn(w,n.stashHistory)||n.stashHistory==="ctrl+alt+h"&&(/^\x1b\[104(?::\d*)?(?::\d*)?;7(?::\d+)?u$/.test(w)||w==="\x1B[27;7;104~"||w==="\x1B[27;7;72~")}function jk(w){if(ai(w))return null;if(i3(w))return{kind:"stashHistory"};if(Jn(w,n.copyEditor))return{kind:"copyEditor"};if(Jn(w,n.cutEditor))return{kind:"cutEditor"};if(Jn(w,i.toggleShortcut))return{kind:"bashMode"};let S=n3(w);return S?{kind:"chat",action:S}:null}function tf(w,S){if(S.kind==="stashHistory"){of(w);return}if(S.kind==="copyEditor"||S.kind==="cutEditor"){let $=ef(w);if(!$)return;Od(w,$,S.kind==="copyEditor"?"Copied editor text":void 0),S.kind==="cutEditor"&&(w.ui.setEditorText(""),w.ui.notify("Cut editor text","info"));return}if(S.kind==="bashMode"){Gi(!E,w);return}if(S.action.kind==="bottom"){u3(w);return}c3(w,S.action.role,S.action.direction)}function nf(w){let S=Vu(w,R),$=F!==null;if(!cr(S)){if(!$){w.ui.notify("Nothing to stash","info");return}w.ui.setEditorText(F),F=null,w.ui.setStatus("stash",void 0),w.ui.notify("Stash restored","info");return}F=S,JW(S),w.ui.setEditorText(""),w.ui.setStatus("stash","stash"),w.ui.notify($?"Stash updated":"Text stashed","info")}async function of(w){let S=[];try{S=N9(w.cwd,x9)}catch(re){let J=re instanceof Error?re.message:String(re);w.ui.notify(`Failed to load project prompts: ${J}`,"warning")}if(O.length===0&&S.length===0){w.ui.notify("No prompt history yet","info");return}let $=await e3(w,O.length,S.length);if(!$)return;let K=$==="project"?await ZW(w,S):await XW(w);K&&await t3(w,K)}t.on("agent_end",async(w,S)=>{p=!1,d=null,a=S,S.hasUI&&(l_(S.ui.setWorkingMessage),F!==null&&(S.ui.getEditorText().trim()===""?(S.ui.setEditorText(F),F=null,S.ui.setStatus("stash",void 0),S.ui.notify("Stash restored","info")):S.ui.notify("Stash preserved \u2014 clear editor then Alt+S to restore","info"))),Ce()}),t.registerCommand("s:footer",{description:"Configure sling footer status (toggle, preset)",handler:async(w,S)=>{if(a=S,!w?.trim()){o=!o,o?(Wd(S),S.ui.notify("sling footer enabled","info")):(q?.dispose(),q=null,U.clear(),E=!1,P?.(),P=null,I=!1,W=!1,kn.cancel(),xx().savedPromptHistory=[],F=null,S.ui.setStatus("stash",void 0),g?.(),g=null,Ld(),T?.(),T=null,S.ui.setEditorComponent(void 0),S.ui.setFooter(void 0),S.ui.setHeader(void 0),S.ui.setWidget("powerline-top",void 0),S.ui.setWidget("powerline-secondary",void 0),S.ui.setWidget("powerline-bash-transcript",void 0),S.ui.setWidget("powerline-status",void 0),S.ui.setWidget("powerline-last-prompt",void 0),l=null,m=null,R=null,oe.cancel(),ye(),S.ui.notify("sling footer disabled","info"));return}let $=w.trim().toLowerCase(),K=/^mouse-scroll(?:\s+(on|off|toggle))?$/.exec($);if(K){let Ye=K[1]??"toggle";Ge.mouseScroll=Ye==="toggle"?!Ge.mouseScroll:Ye==="on",o&&S.hasUI&&Ge.fixedEditor&&m&&R&&rf(S,m),x_(S.cwd,{mouseScroll:Ge.mouseScroll},Ge.preset)?S.ui.notify(`sling mouse scroll ${Ge.mouseScroll?"enabled":"disabled"}`,"info"):S.ui.notify(`sling mouse scroll ${Ge.mouseScroll?"enabled":"disabled"} (not persisted; check settings.json)`,"warning");return}let re=/^fixed-editor(?:\s+(on|off|toggle))?$/.exec($);if(re){let Ye=re[1]??"toggle";Ge.fixedEditor=Ye==="toggle"?!Ge.fixedEditor:Ye==="on",o&&S.hasUI&&Wd(S),x_(S.cwd,{fixedEditor:Ge.fixedEditor},Ge.preset)?S.ui.notify(`sling fixed editor ${Ge.fixedEditor?"enabled":"disabled"}`,"info"):S.ui.notify(`sling fixed editor ${Ge.fixedEditor?"enabled":"disabled"} (not persisted; check settings.json)`,"warning");return}let J=G9(w);if(J){Ge.preset=J,ye(),o&&Wd(S),q9(J,S.cwd)?S.ui.notify(`Preset set to: ${J}`,"info"):S.ui.notify(`Preset set to: ${J} (not persisted; check settings.json)`,"warning");return}let ee=Object.keys(Ul).join(", ");S.ui.notify(`Available presets: ${ee}`,"info")}}),t.registerCommand("s:stash-history",{description:"Open prompt history picker",handler:async(w,S)=>{if(S.hasUI){if(!o){S.ui.notify("sling footer is disabled","info");return}await of(S)}}}),t.registerCommand("s:bash-mode",{description:"Toggle sticky bash mode (on, off, toggle)",handler:async(w,S)=>{let $=w?.trim().toLowerCase()||"toggle";if($==="on"){await Gi(!0,S);return}if($==="off"){await Gi(!1,S);return}if($==="toggle"){await Gi(!E,S);return}S.ui.notify("Usage: /bash-mode [on|off|toggle]","warning")}}),t.registerCommand("s:bash-reset",{description:"Reset the managed bash session",handler:async(w,S)=>{if(q?.dispose(),q=null,U.clear(),E)try{await nn()}catch($){E=!1;let K=$ instanceof Error?$.message:String($);S.ui.notify(`Failed to restart shell session: ${K}`,"error"),Ce();return}Ce(),S.ui.notify("Bash session reset","info")}}),t.registerShortcut(i.toggleShortcut,{description:"Toggle bash mode",handler:async w=>{!o||!w.hasUI||await Gi(!E,w)}}),t.registerShortcut("alt+s",{description:"Stash/restore editor text",handler:async w=>{!o||!w.hasUI||nf(w)}}),t.registerShortcut(n.stashHistory,{description:"Open prompt history picker",handler:async w=>{!o||!w.hasUI||await of(w)}}),t.registerShortcut(n.copyEditor,{description:"Copy full editor text",handler:async w=>{if(!o||!w.hasUI)return;let S=ef(w);S&&Od(w,S,"Copied editor text")}}),t.registerShortcut(n.cutEditor,{description:"Cut full editor text",handler:async w=>{if(!o||!w.hasUI)return;let S=ef(w);S&&(Od(w,S),w.ui.setEditorText(""),w.ui.notify("Cut editor text","info"))}});for(let{shortcutKey:w,description:S,action:$}of d_)t.registerShortcut(n[w],{description:S,handler:async K=>{!o||!K.hasUI||tf(K,{kind:"chat",action:$})}});function o3(w,S){let $=qb(Ge.preset),K=$.colors??dh(),re=0,J=0,ee=0,Ye=0,De=0,yt,ht=null,Wn=w.sessionManager?.getBranch?.()??[];for(let yi of Wn){if(!Rt(yi)||(yi.type==="thinking_level_change"&&typeof yi.thinkingLevel=="string"&&(ht=yi.thinkingLevel),yi.type!=="message"||!fx(yi.message)))continue;let Hi=yi.message;Hi.stopReason==="error"||Hi.stopReason==="aborted"||(re+=Hi.usage.input,J+=Hi.usage.output,ee+=Hi.usage.cacheRead,Ye+=Hi.usage.cacheWrite,De+=Hi.usage.cost.total,Ph(Hi.usage)>0&&(yt=Hi))}let he=p?d??yt?.usage:yt?.usage,We=p&&d?null:WA(w),Ve=We?.contextTokens??(he?Ph(he):0),$t=We?.contextWindow??w.model?.contextWindow??0,zi=We?.contextPercent??($t>0?Ve/$t*100:0),gc=l?.getGitBranch()??null,Fd=RA(gc),oi=l?.getExtensionStatuses()??new Map,wa=new Map(Ge.customItems.map(yi=>[yi.id,yi])),Do=Gb(Ge.customItems),Ot=w.model?w.modelRegistry?.isUsingOAuth?.(w.model)??!1:!1,ka=u??ht??c?.()??"off";return{model:w.model,thinkingLevel:ka,sessionId:w.sessionManager?.getSessionId?.(),cwd:w.cwd,usageStats:{input:re,output:J,cacheRead:ee,cacheWrite:Ye,cost:De},contextPercent:zi,contextWindow:$t,autoCompactEnabled:w.settingsManager?.getCompactionSettings?.()?.enabled??!0,customCompactionEnabled:c_||oi.has(b9),usingSubscription:Ot,sessionStartTime:r,shellModeActive:E,shellRunning:q?.state.running??!1,shellName:q?.state.shellName??null,shellCwd:q?.state.cwd??null,git:Fd,extensionStatuses:oi,hiddenExtensionStatusKeys:Do,customItemsById:wa,options:$.segmentOptions??{},theme:S,colors:K}}function qk(w,S){let $=Date.now(),K=p?M9:C9;if(Y&&Z===w){let Ye=$-Qe<Rh;if(!rt&&Ye&&(xe||$-se>=K)||!xe&&$-se<K)return Y}let re=qb(Ge.preset),J=o3(a,S);return Z=w,Y=Y9(J,re,w),se=$,xe=!1,rt=!1,Y}function Kk(w){if(!a||!l)return[];let S=l.getExtensionStatuses();if(!S||S.size===0)return[];let $=Gb(Ge.customItems),K=[];for(let re of yA(S,$)){let J=` ${re}`;j(J)<=w&&K.push(J)}return K}function Gk(w,S){if(!a)return[];let $=qk(w,S);return $.topContent?[$.topContent]:[]}function zk(w,S){if(!a)return[];let $=qk(w,S);return $.secondaryContent?[$.secondaryContent]:[]}function Hk(w,S){if(!E)return[];let $=U.getSnapshot();if($.commands.length===0)return[];let K=[];$.truncatedCommands>0&&K.push(` ${S.fg("dim",`\u2026 ${$.truncatedCommands} earlier command${$.truncatedCommands===1?"":"s"} truncated`)}`);let re=$.commands.slice(-4);for(let J of re){let ee=(q?.state.shellName??"shell")==="fish"?">":"$",Ye=J.exitCode===null?S.fg("accent","running"):J.exitCode===0?S.fg("success","ok"):S.fg("error",`exit ${J.exitCode}`),De=te(J.command.replace(/\s+/g," ").trim(),Math.max(8,w-8),"\u2026");K.push(` ${S.fg("accent",ee)} ${De} ${S.fg("dim","(")}${Ye}${S.fg("dim",")")}`);let yt=J.output.slice(-6);for(let ht of yt)K.push(` ${te(ht,Math.max(1,w-3),"\u2026")}`)}return K.slice(-16)}function Vk(w){if(E||!_||!D)return[];let S=` ${ds("sep")}\u21B3${An.reset} `,$=w-j(S);if($<10)return[];let K=D.replace(/\s+/g," ").trim();if(!K)return[];K=te(K,$,"\u2026");let re=`${ds("sep")}${K}${An.reset}`,J=`${S}${re}`;return[te(J,w,"\u2026")]}function Ld(w){let S=h!==null;if(h?.dispose(w),!S&&w?.resetExtendedKeyboardModes)try{process.stdout.write(QA())}catch{}h=null,f=null,b=null,x=null,y=null}function r3(w,S){let $=Array.isArray(w?.children)?w.children:[],K=$.findIndex(re=>Array.isArray(re?.children)&&re.children.includes(S));return K===-1?null:{container:$[K],index:K}}function rf(w,S){if(Ld(),!w.hasUI||!Ge.fixedEditor)return;if(!S?.terminal||typeof S.terminal.write!="function")throw new Error("[sling-footer] Fixed editor compositor could not find tui.terminal.write()");if(!R)throw new Error("[sling-footer] Fixed editor compositor expected the custom editor to be installed first");let $=r3(S,R);if(!$)throw new Error("[sling-footer] Fixed editor compositor could not find the editor container in TUI children");let K=Array.isArray(S.children)?S.children:[];b=$.container;let re=K[$.index-2]??null;f=re&&typeof re.render=="function"?re:null,x=K[$.index-1]??null,y=K[$.index+1]??null;let J;J=new Sh({tui:S,terminal:S.terminal,mouseScroll:Ge.mouseScroll,keyboardScrollShortcuts:{up:n.scrollChatUp,down:n.scrollChatDown},onCopySelection:ee=>Od(w,ee),getShowHardwareCursor:()=>typeof S.getShowHardwareCursor=="function"&&S.getShowHardwareCursor(),renderCluster:(ee,Ye)=>{let De=a?.ui?.theme??w.ui.theme,yt=f?J.renderHidden(f,ee).filter(he=>j(he)>0):[],ht=x?J.renderHidden(x,ee):[],Wn=y?J.renderHidden(y,ee):[];return FA({width:ee,terminalRows:Ye,statusLines:[...ht,...Kk(ee),...yt],topLines:Gk(ee,De),editorLines:b?J.renderHidden(b,ee):[],secondaryLines:[...zk(ee,De),...Wn],transcriptLines:Hk(ee,De),lastPromptLines:Vk(ee)})}}),h=J,f?.render&&J.hideRenderable(f),x?.render&&J.hideRenderable(x),J.hideRenderable(b),y?.render&&J.hideRenderable(y),J.install(),S.requestRender(!0)}function s3(w,S){let $=typeof w=="object"&&w!==null?w.constructor?.name:void 0;return S==="assistant"?$==="AssistantMessageComponent":$==="UserMessageComponent"||$==="SkillInvocationMessageComponent"}function a3(w,S){if(typeof w!="object"||w===null)return 0;let $=Reflect.get(w,"render");if(typeof $!="function")return 0;let K=$.call(w,S);return Array.isArray(K)?K.length:0}function Qk(w,S,$,K){let re=a3(w,S);if(s3(w,$))return{targets:[K],lineCount:re};let J=typeof w=="object"&&w!==null?Reflect.get(w,"children"):null;if(!Array.isArray(J)||J.length===0)return{targets:[],lineCount:re};let ee=[],Ye=K,De=0;for(let yt of J){let ht=Qk(yt,S,$,Ye);ee.push(...ht.targets),Ye+=ht.lineCount,De+=ht.lineCount}return{targets:ee,lineCount:Math.max(re,De)}}function l3(w){let S=Array.isArray(m?.children)?m.children:[],$=Math.max(1,m?.terminal?.columns??80),K=[],re=0;for(let J of S){let ee=Qk(J,$,w,re);K.push(...ee.targets),re+=ee.lineCount}return[...new Set(K)].sort((J,ee)=>J-ee)}function c3(w,S,$){if(!h){w.ui.notify("Chat message jumps require /s:footer fixed-editor on","warning");return}let K=l3(S),re=S==="assistant"?"LLM":"user";if(K.length===0){w.ui.notify(`No ${re} messages found`,"info");return}($==="previous"?h.jumpToPreviousRootTarget(K):h.jumpToNextRootTarget(K))||w.ui.notify(`No ${$} ${re} message`,"info")}function u3(w){if(!h){w.ui.notify("Chat bottom jump requires /s:footer fixed-editor on","warning");return}h.jumpToRootBottom()}function sf(){h?.jumpToRootBottom()}function d3(w){w.ui.setWidget("powerline-status",()=>({dispose(){},invalidate(){Ce()},render(S){return Kk(S)}}),{placement:"aboveEditor"}),w.ui.setWidget("powerline-top",(S,$)=>({dispose(){},invalidate(){ye()},render(K){return Gk(K,$)}}),{placement:"aboveEditor"}),w.ui.setWidget("powerline-secondary",(S,$)=>({dispose(){},invalidate(){ye()},render(K){return zk(K,$)}}),{placement:"belowEditor"}),w.ui.setWidget("powerline-bash-transcript",(S,$)=>({dispose(){},invalidate(){},render(K){return Hk(K,$)}}),{placement:"belowEditor"}),w.ui.setWidget("powerline-last-prompt",()=>({dispose(){},invalidate(){},render(S){return Vk(S)}}),{placement:"belowEditor"})}function Wd(w){if(Qu(R),!o)return;T?.(),T=typeof w.ui.onTerminalInput=="function"?w.ui.onTerminalInput(K=>{if(!o||!w.hasUI||m?.hasOverlay?.())return;if(Bk(K))return nf(w),hc(w),m?.requestRender(),{consume:!0};let re=jk(K);if(re)return tf(w,re),hc(w),m?.requestRender(),{consume:!0}}):null,Ld(),w.ui.setWidget("powerline-top",void 0),w.ui.setWidget("powerline-secondary",void 0),w.ui.setWidget("powerline-bash-transcript",void 0),w.ui.setWidget("powerline-status",void 0),w.ui.setWidget("powerline-last-prompt",void 0);let S=!1,$=(K,re,J)=>{let ee=new rh(K,re,J,{keybindings:J,isBashModeActive:()=>E,isShellRunning:()=>q?.state.running??!1,onExitBashMode:()=>{Gi(!1,w)},onSubmitCommand:he=>{Ln(he,w)},onEditorSubmit:()=>sf(),editorBoundaryShortcuts:{start:n.editorStart,end:n.editorEnd},onInterrupt:()=>{q?.interrupt(),w.ui.notify("Sent interrupt to shell","info")},onNotify:(he,We="info")=>w.ui.notify(he,We),getHistoryEntries:he=>Ki(he),resolveGhostSuggestion:async(he,We)=>{let Ve=Ku(he);if(Ve){let $t=await G.getGhostSuggestion(Ve.command,_t(),At(),We);return $t?{...$t,value:`${Ve.prefix}${$t.value}`}:null}return G.getGhostSuggestion(he,_t(),At(),We)}}),Ye=()=>{let he=Reflect.get(ee,"autocompleteProvider");if(!(!he||typeof he!="object")&&typeof Reflect.get(he,"getSuggestions")=="function"&&typeof Reflect.get(he,"applyCompletion")=="function")return he},De=()=>{if(ee.hasWrappedProvider())return!0;let he=Ye();if(!he)return!1;let We=new nh,Ve=new ih;return ee.installAutocompleteProvider(new oh(he,We,Ve,()=>E)),!0},yt;Object.defineProperty(ee,"onSubmit",{configurable:!0,get:()=>yt,set(he){yt=typeof he=="function"?We=>{sf(),he(We)}:he}}),R=ee,O9(ee),_9(ee),De();let ht=ee.handleInput.bind(ee);ee.handleInput=he=>{if(Qe=Date.now(),Bk(he)){nf(w),hc(w);return}let We=jk(he);if(We){tf(w,We),hc(w);return}if(!S&&!Ye()){S=!0,Qu(ee),w.ui.setEditorComponent($),Ge.fixedEditor&&rf(w,K),R?.handleInput(he);return}De();let Ve=J.matches(he,"app.message.followUp")?Vu(w,ee):"";hc(w),ht(he),cr(Ve)&&!cr(Vu(w,ee))&&sf()};let Wn=ee.render.bind(ee);return ee.render=he=>{if(he<10)return Wn(he);let We=Ot=>`${ds("sep")}${Ot}${An.reset}`,Ve=E?"$":">",zi=` ${`${An.getFgAnsi(200,200,200)}${Ve}${An.reset}`} `,gc=" ",Fd=Math.max(1,he-3),oi=Wn(Fd);if(oi.length===0)return oi;let wa=oi.length-1;for(let Ot=oi.length-1;Ot>=1;Ot--){let ka=oi[Ot]?.replace(/\x1b\[[0-9;]*m/g,"")||"";if(ka.length>0&&/^─{3,}/.test(ka)){wa=Ot;break}}let Do=[];Do.push(" "+We("\u2500".repeat(he-2)));for(let Ot=1;Ot<wa;Ot++){let ka=Ot===1?zi:gc;Do.push(`${ka}${oi[Ot]||""}`)}wa===1&&Do.push(`${zi}${" ".repeat(Fd)}`),Do.push(" "+We("\u2500".repeat(he-2)));for(let Ot=wa+1;Ot<oi.length;Ot++)Do.push(oi[Ot]||"");return Do},ee};w.ui.setEditorComponent($),w.ui.setFooter((K,re,J)=>{l=J,m=K,jt(J);let ee=J.onBranchChange(()=>Ce());return{dispose(){ee(),g?.(),g=null},invalidate(){Ce()},render(){return[]}}}),Ge.fixedEditor?m&&rf(w,m):d3(w)}function p3(w){let S=w.model?.name||w.model?.id||"No model",$=w.model?.provider||"Unknown",K=nx(),re=ix(3),J=new yh(S,$,re,K);I=!0,w.ui.setHeader(()=>({render(ee){return J.render(ee)},invalidate(){J.invalidate()}}))}function m3(w){let S=w.model?.name||w.model?.id||"No model",$=w.model?.provider||"Unknown",K=nx(),re=ix(3),J=s;setTimeout(()=>{if(!o||W||p||J!==s){W=!1;return}(w.sessionManager?.getBranch?.()??[]).some(De=>Rt(De)?De.type==="tool_call"||De.type==="tool_result"?!0:De.type==="message"&&Rt(De.message)&&De.message.role==="assistant":!1)||w.ui.custom((De,yt,ht,Wn)=>{let he=new xh(S,$,re,K),We=10,Ve=!1,$t=null,zi=()=>{Ve||(Ve=!0,$t&&clearInterval($t),P=null,Wn())};return $t=setInterval(()=>{Ve||(We--,he.setCountdown(We),De.requestRender(),We<=0&&zi())},1e3),P=zi,W&&(W=!1,zi()),{focused:!1,invalidate:()=>he.invalidate(),render:gc=>he.render(gc),handleInput:()=>zi(),dispose:()=>{Ve=!0,$t&&clearInterval($t)}}},{overlay:!0,overlayOptions:()=>({verticalAlign:"center",horizontalAlign:"center"})}).catch(De=>{console.debug("[sling-footer] Welcome overlay failed:",De)})},100)}}var D_=async t=>{try{if(t.model?.provider!=="slingshot")return qe("Skipping credits refresh for non-slingshot provider: "+t.model?.provider),100;let e=await t.modelRegistry.getApiKeyForProvider(t.model?.provider||"slingshot"),o=(await(await fetch(ke.getUserUrl(),{headers:{Authorization:`Bearer ${e||""}`,Accept:"application/json"}})).json()).remainingCredits||0;return qe("Fetched user data for credits: "+o),o}catch(e){ct("Error fetching user data for credits",e)}return 0};function Ah(t){return t<1e3?t.toString():t<1e4?`${(t/1e3).toFixed(1)}k`:t<1e6?`${Math.round(t/1e3)}k`:t<1e7?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e6)}M`}function U_(t){if(!t||typeof t!="object")return null;let e=t;if(e.role!=="assistant"||!e.usage||typeof e.usage!="object")return null;let n=e.usage;return typeof n.input!="number"||typeof n.output!="number"||typeof n.cacheRead!="number"||typeof n.cacheWrite!="number"||typeof n.cost?.total!="number"?null:{input:n.input,output:n.output,cacheRead:n.cacheRead,cacheWrite:n.cacheWrite,cost:{total:n.cost.total}}}var _h=class{constructor(e,n,i="ss-credit"){this.refreshCredits=e;this.log=n;this.statusKey=i;this.latestKnownCredits=0;this.creditRefreshInFlight=!1;this.lastCreditRefreshAt=0;this.liveAssistantUsage=null;this.isAssistantStreaming=!1;this.lastStatusUpdateAt=0}initialize(e){this.setStatus(e,this.latestKnownCredits,{force:!0})}startStreaming(e){this.isAssistantStreaming=!0,this.liveAssistantUsage=null,this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0,force:!0})}stopStreaming(e){this.isAssistantStreaming=!1,this.liveAssistantUsage=null,this.setStatus(e,this.latestKnownCredits,{force:!0})}onProgress(e){this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0})}onMessageUpdate(e,n){let i=U_(n);i&&(this.liveAssistantUsage=i,this.isAssistantStreaming=!0),this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0})}onMessageEnd(e,n){U_(n)&&(this.liveAssistantUsage=null,this.isAssistantStreaming=!1),this.setStatus(e,this.latestKnownCredits,{force:!0})}setCreditsFromServer(e,n){this.latestKnownCredits=n,this.setStatus(e,n,{force:!0})}async refreshAndUpdate(e,n={}){this.setStatus(e,this.latestKnownCredits,{includeLiveUsage:!0});let i=Date.now();if(!n.force&&i-this.lastCreditRefreshAt<5e3)return this.latestKnownCredits;if(this.creditRefreshInFlight)return this.latestKnownCredits;this.creditRefreshInFlight=!0;try{return this.latestKnownCredits=await this.refreshCredits(e),this.lastCreditRefreshAt=Date.now(),this.setStatus(e,this.latestKnownCredits,{force:!0}),this.latestKnownCredits}catch(o){return n.logErrors&&this.log(`credits refresh failed: ${o instanceof Error?o.message:String(o)}`),this.latestKnownCredits}finally{this.creditRefreshInFlight=!1}}getUsageTotals(e,n){let i=0,o=0,r=0,s=0,a=0;for(let l of e.sessionManager.getEntries())l.type==="message"&&l.message.role==="assistant"&&(i+=l.message.usage.input,o+=l.message.usage.output,r+=l.message.usage.cacheRead,s+=l.message.usage.cacheWrite,a+=l.message.usage.cost.total);return n&&this.isAssistantStreaming&&this.liveAssistantUsage&&(i+=this.liveAssistantUsage.input,o+=this.liveAssistantUsage.output,r+=this.liveAssistantUsage.cacheRead,s+=this.liveAssistantUsage.cacheWrite,a+=this.liveAssistantUsage.cost.total),{input:i,output:o,cacheRead:r,cacheWrite:s,cost:a}}setStatus(e,n,i={}){if(!e.hasUI)return;let o=Date.now();if(!i.force&&o-this.lastStatusUpdateAt<120)return;this.lastStatusUpdateAt=o;let r=this.getUsageTotals(e,i.includeLiveUsage===!0),s=[`Credits: ${n.toFixed(4)}`,`\u2191${Ah(r.input)} \u2193${Ah(r.output)}`,`$${r.cost.toFixed(3)}`];(r.cacheRead>0||r.cacheWrite>0)&&s.push(`R${Ah(r.cacheRead)} W${Ah(r.cacheWrite)}`),e.ui.setStatus(this.statusKey,s.join(" \u2022 "))}};var tn=y3(AW(),1);var dc=t=>t==null?"N/A":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?Math.round(t/1e3)+"k":t.toString();var Lme=["context_tag","context_log","context_checkout"],Qg=null,yn=null,Yg=t=>Lme.includes(t),_W=(t,e)=>{if(e.toLowerCase()==="root"){let i=t.getTree();return i.length>0?i[0].entry.id:e}if(/^[0-9a-f]{8,}$/i.test(e))return e;let n=[...t.getTree()];for(;n.length>0;){let i=n.pop();if(t.getLabel(i.entry.id)===e)return i.entry.id;i.children?.length&&n.push(...i.children)}return e},Wme=tn.Type.Object({limit:tn.Type.Optional(tn.Type.Number({description:"History limit for visible entries (default: 50)."})),verbose:tn.Type.Optional(tn.Type.Boolean({description:"If true, show ALL messages. If false (default), collapses intermediate AI steps and only shows 'milestones': User messages, Tags, Branch Points, and Summaries."}))}),Fme=tn.Type.Object({target:tn.Type.String({description:"Where to jump/squash to. Can be a tag name (e.g., 'task-start'), a commit ID, or 'root'. This is the base for your new branch."}),message:tn.Type.String({description:"The 'Carryover Message' for the new branch. A summary of your *current* progress/lessons that you want to bring with you to the new state. This ensures you don't lose key information when switching contexts. Good summary message: '[Status] + [Reason] + [Important Changes] + [Carryover Data]'"}),backupTag:tn.Type.Optional(tn.Type.String({description:"Optional tag name to apply to the CURRENT state before checking out. Use this to create an automatic backup of the history you are about to leave/squash."}))}),Dme=tn.Type.Object({name:tn.Type.String({description:"The tag/milestone name. Use meaningful names."}),target:tn.Type.Optional(tn.Type.String({description:"The commit ID to tag. Defaults to HEAD (current state)."}))});function OW(t){t.registerCommand("s:acm",{description:"Enable agentic context management for the current session",handler:async(n,i)=>{Qg=i,i.ui.notify("Agentic Context Management enabled.","info"),t.sendMessage({customType:"ss-context",content:"use context-management skill",display:!1},{deliverAs:"followUp"}),n&&t.sendUserMessage(n)}});let e=(n,i,o)=>{let r=[...i].reverse();for(;r.length>0;){let s=r.pop();if(n.getLabel(s.entry.id)===o)return s.entry.id;if(s.children?.length)for(let a=s.children.length-1;a>=0;a--)r.push(s.children[a])}return null};t.registerTool({name:"context_tag",label:"Context Tag",description:"Creates a 'Save Point' (Bookmark) in the history. Use this before trying risky changes or when a feature is stable. 'Untagged progress is risky'.",parameters:Dme,async execute(n,i,o,r,s){let a=s.sessionManager,l=e(a,a.getTree(),i.name);if(l)return{content:[{type:"text",text:`Error: Tag '${i.name}' already exists at ${l}. Tag names must be unique. Use a different name or delete the existing tag first.`}],details:{}};let c=i.target?_W(a,i.target):void 0;if(!c){let u=a.getBranch();for(let d=u.length-1;d>=0;d--){let p=u[d];if(p.type==="message"&&p.message.role==="toolResult"){let m=p.message;if(Yg(m.toolName))continue;c=p.id;break}if(p.type==="message"&&p.message.role==="assistant"&&!p.message.content.some(h=>h.type==="toolCall"&&Yg(h.name))){c=p.id;break}c=p.id;break}c||(c=a.getLeafId()??"")}return t.setLabel(c,i.name),{content:[{type:"text",text:`Created tag '${i.name}' at ${c}`}],details:{}}}}),t.registerTool({name:"context_log",label:"Context Log",description:"Show the entire history structure (status, message, tags, milestones). Analogous to 'git log --graph --oneline --decorate'",parameters:Wme,async execute(n,i,o,r,s){let a=s.sessionManager,l=a.getBranch(),c=a.getLeafId(),u=i.verbose??!1,d=i.limit??50,p=new Set(l.map(_=>_.id)),m=[];l.forEach(_=>{m.push(_),a.getChildren(_.id).forEach(O=>{(O.type==="branch_summary"||O.type==="compaction")&&!p.has(O.id)&&m.push(O)})});let g=_=>{if(_.type==="branch_summary"||_.type==="compaction")return _.summary||"[No summary provided]";if(_.type==="label")return`tag: ${_.label}`;if(_.type==="message"){let F=_.message;if(F.role==="toolResult"){let O=F;if(!u&&Yg(O.toolName))return"";let E=(G=>G.map(q=>q.type==="text"?q.text:"").join(" ").trim())(O.content),U=O.details;return(O.toolName==="read"||O.toolName==="edit")&&U&&"path"in U&&typeof U.path=="string"&&(E=`${U.path}: ${E}`),`(${O.toolName}) ${E}`}if(F.role==="bashExecution")return`[Bash] ${F.command}`;if(F.role==="user"||F.role==="assistant"){let O="";typeof F.content=="string"?O=F.content:Array.isArray(F.content)&&(O=F.content.map(E=>typeof E=="object"&&E!==null&&"text"in E?E.text:"").join(" ").trim());let R="";return F.role==="assistant"&&(R=F.content.filter(U=>U.type==="toolCall").filter(U=>u||!Yg(U.name)).map(U=>`call: ${U.name}(${JSON.stringify(U.arguments)})`).join("; ")),[O,R].filter(Boolean).join(" ")}}return""},h=_=>_.id===c||l.length>0&&_.id===l[0].id||a.getLabel(_.id)?!0:_.type==="label"?!1:_.type==="branch_summary"||_.type==="compaction"||a.getChildren(_.id).length>1||_.type==="message"&&_.message.role==="user",f=new Set;m.forEach(_=>{(u||h(_))&&f.add(_.id)});let b=m.filter(_=>f.has(_.id));if(b.length>d){let _=new Set(b.slice(-d).map(F=>F.id));f.clear(),_.forEach(F=>f.add(F))}let x=[],y=0;m.forEach(_=>{if(!f.has(_.id)){y++;return}y>0&&(x.push(` : ... (${y} hidden messages) ...`),y=0);let F=_.id===c,O=a.getLabel(_.id),R=g(_).replace(/\s+/g," "),E=_.type.toUpperCase();if(_.type==="message"){let se=_.message;E=se.role==="assistant"?"AI":se.role==="user"?"USER":se.role==="bashExecution"?"BASH":"TOOL"}else(_.type==="branch_summary"||_.type==="compaction")&&(E="SUMMARY");if(E==="CUSTOM_MESSAGE")return;let U=_.id,q=[l.length>0&&_.id===l[0].id?"ROOT":null,F?"HEAD":null,O?`tag: ${O}`:null].filter(Boolean).join(", "),Z=R.length>100?R.slice(0,100)+"...":R,Y=F?"*":E==="USER"?"\u2022":"|";x.push(`${Y} ${U}${q?` (${q})`:""} [${E}] ${Z}`)}),y>0&&x.push(` : ... (${y} hidden messages) ...`);let T=await s.getContextUsage(),P="Unknown";T&&(P=`${T.percent.toFixed(1)}% (${dc(T.tokens)}/${dc(T.contextWindow)})`);let I=0,W="None";for(let _=l.length-1;_>=0;_--){let F=l[_].id,O=a.getLabel(F);if(O){W=O;break}I++}return{content:[{type:"text",text:["[Context Dashboard]",`\u2022 Context Usage: ${P}`,`\u2022 Segment Size: ${I} steps since last tag '${W}'`,"---------------------------------------------------"].join(`
466
466
  `)+`
467
467
  `+(x.join(`
468
468
  `)||"(Root Path Only)")}],details:{}}}}),t.registerTool({name:"context_checkout",label:"Context Checkout",description:"Navigate to ANY point in the conversation history. This checkout only resets *conversation history*, NOT disk files. ALWAYS provide a detailed 'message' to bridge context.",parameters:Fme,async execute(n,i,o,r,s){if(!Qg)return s.ui.setEditorText(`/acm ${s.ui.getEditorText()||"continue"}`),{content:[{type:"text",text:"Agentic context management is not enabled. Ask the user to run `/acm` in the pi to enable it, then retry."}],details:{}};let a=s.sessionManager,l=_W(a,i.target),c=a.getLeafId();if(c===l)return{content:[{type:"text",text:`Already at target ${l}`}],details:{}};i.backupTag&&c&&t.setLabel(c,i.backupTag);let u=c?a.getLabel(c):void 0,p=`(summary from ${u?`tag: ${u}`:c||"unknown"})
469
469
  ${i.message}`,m=await a.branchWithSummary(l,p);return yn=i,yn.nid=m,yn.tid=l,yn.enrichedMessage=p,{content:[{type:"text",text:"checkout start"}],details:{}}}}),t.on("turn_end",async(n,i)=>{yn&&i.abort()}),t.on("agent_end",async(n,i)=>{yn&&Qg&&(await Qg.navigateTree(yn.nid,{summarize:!1}),i.ui.notify(`Checked out ${yn.target}${yn.target===yn.tid?"":`(${yn.tid})`}
470
470
  Backup tag created: ${yn.backupTag||"none"}
471
- message: ${yn.enrichedMessage}`,"info"),yn=null,t.sendMessage({customType:"ss-context",content:"context_checkout complete. A summary of your previous branch was injected above. Read it to understand your new state. Execute the 'Next Step' from the summary",display:!1},{triggerTurn:!0}))})}function LW(t){t.registerCommand("s:context",{description:"Show context usage visualization",handler:async(e,n)=>{let i=await n.getContextUsage();if(!i){n.ui.notify("Context usage info not available.","warning");return}let r=n.sessionManager.getBranch(),s=n.getSystemPrompt(),a=t.getActiveTools(),c=t.getAllTools().filter(_=>a.includes(_.name)),u=_=>Math.ceil(_.length/4),d=0,p=0,m=0;for(let _ of r)if(_.type==="message"){let F=_.message;if(F.role==="user"){if(typeof F.content=="string")d+=u(F.content);else if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(d+=u(O.text))}else if(F.role==="assistant"){if(typeof F.content=="string")d+=u(F.content);else if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(d+=u(O.text)),O.type==="toolCall"&&(p+=u(JSON.stringify(O)))}else if(F.role==="toolResult"){if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(m+=u(O.text))}else F.role==="bashExecution"&&(p+=u(F.command||""))}else(_.type==="branch_summary"||_.type==="compaction")&&(d+=u(_.summary||""));let g=u(s),h=u(JSON.stringify(c)),f=i.tokens,b=i.contextWindow;if(f==null||b==null||i.percent==null){n.ui.notify("Context usage info not available.","warning");return}let x=g+h+d+p+m,y=x>0?f/x:1,T=Math.round(g*y),P=Math.round(h*y),I=Math.round(d*y),W=Math.round(p*y),D=Math.round(m*y);await n.ui.custom((_,F,O,R)=>{let E=new z;E.addChild(new H(oe=>F.fg("accent",oe))),E.addChild(new A(F.fg("accent",F.bold(" Context Usage")),1,0)),E.addChild(new L(1));let U=[{label:"System Prompt",value:T,color:"muted"},{label:"System Tools",value:P,color:"dim"},{label:"Tool Call",value:W+D,color:"success"},{label:"Messages",value:I,color:"accent"}],G=Math.max(0,f-(T+P+I+W+D));G>10&&U.push({label:"Other",value:G,color:"dim"}),U.push({label:"Available",value:Math.max(0,b-f),color:"borderMuted"});let q=10,Z=5,Y=q*Z,se=[];for(U.forEach(oe=>{if(oe.label==="Available")return;let we=Math.round(oe.value/b*Y);we===0&&oe.value>0&&(we=1);for(let Ce=0;Ce<we&&se.length<Y;Ce++)se.push({color:oe.color,filled:!0})});se.length<Y;)se.push({color:"borderMuted",filled:!1});let xe=[];for(let oe=0;oe<Z;oe++){let we="";for(let Ce=0;Ce<q;Ce++){let dt=se[oe*q+Ce];we+=F.fg(dt.color,dt.filled?"\u25A0 ":"\u25A1 ")}xe.push(we.trimEnd())}let rt=`${F.fg("text",F.bold("Total Usage".padEnd(16)))} ${F.fg("text",F.bold(dc(f).padStart(7)))} ${F.fg("text",F.bold(`(${i.percent.toFixed(1).padStart(5)}%)`))}`,Qe=U.map(oe=>{let we=oe.label.padEnd(14),Ce=dc(oe.value).padStart(7),dt=(oe.value/b*100).toFixed(1).padStart(5),jt=oe.label==="Available"?"\u25A1":"\u25A0";return`${F.fg(oe.color,jt)} ${F.fg("text",we)} ${F.fg("accent",Ce)} (${dt}%)`}),At=[rt,"",...Qe],_t=20,kn=Math.max(xe.length,At.length);for(let oe=0;oe<kn;oe++){let we=(xe[oe]||"").padEnd(_t),Ce=At[oe]||"";E.addChild(new A(` ${we} ${Ce}`,1,0))}return E.addChild(new L(1)),E.addChild(new A(F.fg("dim"," Press any key to close"),1,0)),E.addChild(new H(oe=>F.fg("accent",oe))),{render:oe=>E.render(oe),invalidate:()=>E.invalidate(),handleInput:oe=>R(void 0)}},{overlay:!0})}})}import{basename as WW,dirname as DW,join as Ume,relative as UW}from"node:path";var Ok=["by-source","a-z","active-first"],$me={"by-source":"By source","a-z":"A\u2013Z","active-first":"Active first"};function Nme(t){let e=Ok.indexOf(t);return Ok[(e+1)%Ok.length]??"by-source"}function Bme(t){return t.origin==="package"?`${t.source} (${t.scope})`:t.source==="auto"?t.scope==="user"?"User (~/.sling/agent/)":"Project (.sling/)":t.scope==="user"?"User settings":"Project settings"}function jme(t){let e=new Map;for(let i of t){let{path:o,enabled:r,metadata:s}=i,a=`${s.origin}:${s.scope}:${s.source}`;e.has(a)||e.set(a,{key:a,label:Bme(s),scope:s.scope,origin:s.origin,source:s.source,items:[]});let l=WW(o),c=WW(DW(o)),u=l==="SKILL.md"?c:l.endsWith(".md")?l.replace(/\.md$/,""):l;e.get(a)?.items.push({path:o,enabled:r,metadata:s,displayName:u,groupKey:a})}let n=Array.from(e.values());n.sort((i,o)=>i.origin!==o.origin?i.origin==="package"?-1:1:i.scope!==o.scope?i.scope==="user"?-1:1:i.source.localeCompare(o.source));for(let i of n)i.items.sort((o,r)=>o.displayName.localeCompare(r.displayName));return n}function qme(t){let e=[];for(let n of t){e.push({type:"group",group:n});for(let i of n.items)e.push({type:"item",item:i})}return e}function Kme(t){let e=t.flatMap(n=>n.items);return e.sort((n,i)=>n.displayName.localeCompare(i.displayName)),e.map(n=>({type:"item",item:n}))}function Gme(t){let e=t.flatMap(n=>n.items);return e.sort((n,i)=>n.enabled!==i.enabled?n.enabled?-1:1:n.displayName.localeCompare(i.displayName)),e.map(n=>({type:"item",item:n}))}function FW(t,e){switch(e){case"by-source":return qme(t);case"a-z":return Kme(t);case"active-first":return Gme(t)}}function zme(t){let e=t.trim();if(e.length===0)return;if(e.startsWith("/")){let i=e.slice(1).toLowerCase();return i.length===0?void 0:o=>o.path.toLowerCase().includes(i)}if(e.startsWith("@")){let i=e.slice(1).toLowerCase();return i.length===0?void 0:o=>o.metadata.source.toLowerCase().includes(i)}let n=e.toLowerCase();return i=>i.displayName.toLowerCase().includes(n)}function Hme(t,e){let n=_e(),i=Ume(e,".sling"),o=t.metadata.scope==="project"?i:n;return UW(o,t.path)}function Vme(t){let e=t.metadata.baseDir??DW(t.path);return UW(e,t.path)}function $W(t){return t.startsWith("!")||t.startsWith("+")||t.startsWith("-")?t.slice(1):t}function Qme(t,e,n,i){let o=t.metadata.scope,s=[...(o==="project"?n.getProjectSettings():n.getGlobalSettings()).skills??[]],a=Hme(t,i),l=s.filter(c=>$W(c)!==a);l.push(e?`+${a}`:`-${a}`),o==="project"?n.setProjectSkillPaths(l):n.setSkillPaths(l)}function Yme(t,e,n){let i=t.metadata.scope,r=[...(i==="project"?n.getProjectSettings():n.getGlobalSettings()).packages??[]],s=r.findIndex(p=>(typeof p=="string"?p:p.source)===t.metadata.source);if(s===-1)return;let a=r[s];if(a===void 0)return;typeof a=="string"&&(a={source:a},r[s]=a);let l=[...a.skills??[]],c=Vme(t),u=l.filter(p=>$W(p)!==c);u.push(e?`+${c}`:`-${c}`),u.length>0?a.skills=u:delete a.skills,a.extensions!==void 0||a.skills!==void 0||a.prompts!==void 0||a.themes!==void 0||(r[s]=a.source),i==="project"?n.setProjectPackages(r):n.setPackages(r)}function Jme(t,e,n,i){t.metadata.origin==="top-level"?Qme(t,e,n,i):Yme(t,e,n)}function Lk(t){t.registerCommand("s:skills-manager",{description:"Enable/disable skills",getArgumentCompletions:e=>{let n=[{value:"list",description:"List skills with enabled/disabled state"}],i=(e??"").toLowerCase(),o=n.filter(r=>r.value.startsWith(i)||r.description.toLowerCase().includes(i));return o.length>0?o.map(r=>({value:r.value,label:`${r.value} - ${r.description}`})):null},handler:async(e,n)=>{let i=n.cwd,o=_e(),r=di.create(i,o),l=(await new Ei({cwd:i,agentDir:o,settingsManager:r}).resolve()).skills;if(l.length===0){n.ui.notify("No skills found.","info");return}let c=jme(l);if(e.trim().toLowerCase()==="list"||!n.hasUI){let p=[];for(let m of c){p.push(`${m.label}`);for(let g of m.items){let h=g.enabled?"[x]":"[ ]";p.push(` ${h} ${g.displayName}`)}}n.ui.notify(p.join(`
472
- `),"info");return}let d=0;if(await n.ui.custom((p,m,g,h)=>{let f="by-source",b=FW(c,f),x=[...b],y=x.findIndex(E=>E.type==="item");y<0&&(y=0);let T=new Xe;function P(E,U){let G=E+U;for(;G>=0&&G<x.length;){if(x[G]?.type==="item")return G;G+=U}return E}function I(E){let U=zme(E);if(!U){x=[...b],D();return}let G=new Set,q=new Set;for(let Z of b)Z.type==="item"&&U(Z.item)&&G.add(Z.item);for(let Z of c)for(let Y of Z.items)G.has(Y)&&q.add(Z);x=[];for(let Z of b)(Z.type==="group"&&q.has(Z.group)||Z.type==="item"&&G.has(Z.item))&&x.push(Z);D()}function W(){b=FW(c,f),I(T.getValue())}function D(){let E=x.findIndex(U=>U.type==="item");y=E>=0?E:0}let _={invalidate(){},render(E){let U=m.bold("Skill Configuration"),G=m.fg("muted"," \xB7 "),q=lt("space","toggle")+G+lt("tab","view")+G+lt("esc","close"),Z=j(q),Y=j(U),se=Math.max(1,E-Y-Z);return[te(`${U}${" ".repeat(se)}${q}`,E,""),m.fg("muted","Filter: name \xB7 /path \xB7 @source")]}},F=15,O={invalidate(){},render(E){let U=[];if(U.push(...T.render(E)),U.push(""),x.length===0)return U.push(m.fg("muted"," No skills found")),U;let G=Math.max(0,Math.min(y-Math.floor(F/2),x.length-F)),q=Math.min(G+F,x.length);for(let xe=G;xe<q;xe++){let rt=x[xe];if(!rt)continue;let Qe=xe===y;if(rt.type==="group"){let At=m.fg("accent",m.bold(rt.group.label));U.push(te(` ${At}`,E,""))}else{let At=Qe?"> ":" ",_t=rt.item.enabled?m.fg("success","[x]"):m.fg("dim","[ ]"),kn=Qe?m.bold(rt.item.displayName):rt.item.displayName;U.push(te(`${At} ${_t} ${kn}`,E,"..."))}}let Z=x.filter(xe=>xe.type==="item").length,Y=x[y]?.type==="item"?x.slice(0,y+1).filter(xe=>xe.type==="item").length:0,se=$me[f];return G>0||q<x.length?U.push(m.fg("dim",` ${Y}/${Z} ${se}`)):U.push(m.fg("dim",` ${se}`)),U}},R=new z;return R.addChild(new L(1)),R.addChild(new H),R.addChild(new L(1)),R.addChild(_),R.addChild(new L(1)),R.addChild(O),R.addChild(new L(1)),R.addChild(new H),{render(E){return R.render(E)},invalidate(){R.invalidate()},handleInput(E){let U=ke();if(U.matches(E,"tui.select.up")){y=P(y,-1),p.requestRender();return}if(U.matches(E,"tui.select.down")){y=P(y,1),p.requestRender();return}if(U.matches(E,"tui.select.pageUp")){let G=Math.max(0,y-F);for(;G<x.length&&x[G]?.type!=="item";)G++;G<x.length&&(y=G),p.requestRender();return}if(U.matches(E,"tui.select.pageDown")){let G=Math.min(x.length-1,y+F);for(;G>=0&&x[G]?.type!=="item";)G--;G>=0&&(y=G),p.requestRender();return}if(U.matches(E,"tui.select.cancel")){h(void 0);return}if(Fe(E,"ctrl+c")){h(void 0);return}if(Fe(E,"tab")){f=Nme(f),W(),p.requestRender();return}if(E===" "||U.matches(E,"tui.select.confirm")){let G=x[y];if(G?.type==="item"){let q=!G.item.enabled;Jme(G.item,q,r,i),G.item.enabled=q;for(let Z of c){let Y=Z.items.find(se=>se.path===G.item.path);Y&&(Y.enabled=q)}d++,f==="active-first"&&W()}p.requestRender();return}T.handleInput(E),I(T.getValue()),p.requestRender()}}}),d>0){if(await n.ui.confirm("Reload Required",`${d} skill change(s) saved. Reload pi now?`)){await n.reload();return}n.ui.notify("Changes saved to settings. Use /reload to apply.","info")}}})}async function Wk(t,e){let n=await e.modelRegistry.getApiKeyForProvider(e.model?.provider||"slingshot"),i=new Date;return fetch(`${ye.getUserActivityUrl()}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n||""}`,Accept:"application/json"},body:JSON.stringify({...t,activity_entity_type:"slingcli",activity_entity_id:Zm.slingVersion||"dev",activity_startdate:t.activity_startdate?.toISOString()||i.toISOString(),activity_enddate:t.activity_enddate?.toISOString()||i.toISOString(),metadata:t.metadata||{}})}).then(o=>o.json()).then(o=>{qe("User activity posted successfully, credits used: "+o.credits_used+"/"+o.remainingCredits)}).catch(o=>{ct("Error posting user activity:",o)}),{}}import BW from"node:path";var Jg=null,Fk=0,NW=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Dk(t){let e=BW.basename(process.cwd());return t?`\u2B55\uFE0F - ${t} - ${e}`:`\u2B55\uFE0F - ${e}`}function Uk(t){Jg&&(clearInterval(Jg),Jg=null),Fk=0;let e=t.sessionManager.getSessionName();t.ui.setTitle(Dk(e))}function jW(t){Uk(t),Jg=setInterval(()=>{let e=NW[Fk%NW.length],n=BW.basename(process.cwd()),i=t.sessionManager.getSessionName(),o=i?`${e} ${Dk(i)}`:`${e} ${Dk()}`;t.ui.setTitle(o),Fk++},80)}var qW=2e3,Xme=23;function Zme(t){let e=t.trim().match(/(\d+)\.(\d+)\.(\d+)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)]:null}async function ehe(t,e,n){let i=await t.exec("rtk",["rewrite",e],{timeout:qW,signal:n});return i.killed||i.code!==0&&i.code!==3?null:i.stdout.trim()||null}async function KW(t){let e=await t.exec("rtk",["--version"],{timeout:qW});if(e.code!==0){console.warn("[rtk] rtk binary not found in PATH \u2014 extension disabled");return}let n=Zme(e.stdout.replace(/^rtk\s+/,""));if(n){let[i,o]=n;if(i===0&&o<Xme){console.warn(`[rtk] rtk ${e.stdout.trim()} is too old (need >= 0.23.0) \u2014 extension disabled`);return}}t.on("tool_call",async(i,o)=>{try{if(!Vr("bash",i))return;let r=i.input.command;if(typeof r!="string"||r.trim()===""||r.startsWith("rtk ")||process.env.RTK_DISABLED==="1")return;let s=await ehe(t,r,o.signal);s&&s!==r&&(i.input.command=s)}catch(r){console.warn("[rtk] unexpected error in tool_call handler; passing through command",r);return}})}function ya(t){return typeof t=="object"&&t!==null}var the="/api/v2/projects/getAllProjects",nhe="/api/v2/projects/workspaces/getAllWorkspaces",GW=100;function ihe(t){return ya(t)&&typeof t.status=="string"&&typeof t.message=="string"&&typeof t.errorCode=="number"&&typeof t.details=="string"}function ohe(t){return ya(t)?typeof t.id=="string"&&typeof t.name=="string":!1}function rhe(t){return ya(t)?typeof t.id=="string"&&typeof t.name=="string":!1}function zW(){let e=ye.getSettings()[ye.BASE_URL];return String(e)}function she(t,e){let n=new URL(the,`${zW()}/`);return n.searchParams.set("limit",String(e)),n.searchParams.set("page",String(t)),n.searchParams.set("sort","name"),n.searchParams.set("sortOrder","ASC"),n.searchParams.set("metaData","true"),n}function ahe(t,e,n){let i=new URL(nhe,`${zW()}/`);return i.searchParams.set("limit",String(n)),i.searchParams.set("page",String(e)),i.searchParams.set("sort","name"),i.searchParams.set("sortOrder","ASC"),i.searchParams.set("projectId",t),i}function lhe(t){if(ihe(t)){let e=t.details.trim();return e.length>0?`${t.message} (${e})`:t.message}if(typeof t=="string"&&t.trim().length>0)return t;if(ya(t)){if(typeof t.message=="string"&&t.message.trim().length>0)return t.message;if(typeof t.error=="string"&&t.error.trim().length>0)return t.error}return"Unknown upstream response"}function che(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}async function HW(t,e){let n=await Yn(e),i=await fetch(t.toString(),{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"X-App-Authorization":`Bearer ${n}`}}),o=await i.text(),r=che(o);if(!i.ok){let s=lhe(r);throw new Error(`Request failed for ${t.pathname}: ${s}`)}return r}function VW(t,e,n){if(!ya(t)||!Array.isArray(t.data))throw new Error(`Unexpected ${n} response shape.`);let i=t.data.filter(e);if(i.length!==t.data.length)throw new Error(`Unexpected ${n} item shape in response data.`);let o=typeof t.currentPage=="number"?t.currentPage:1,r=typeof t.limit=="number"?t.limit:i.length,s=typeof t.total=="number"?t.total:i.length;return{data:i,currentPage:o,limit:r,total:s}}async function uhe(t,e,n){let i=await HW(she(e,n),t);return VW(i,ohe,"getAllProjects")}async function dhe(t,e,n,i){let o=await HW(ahe(e,n,i),t);return VW(o,rhe,"getAllWorkspaces")}async function QW(t,e,n){let i=[],o=new Set,r=1,s=Number.POSITIVE_INFINITY;for(;i.length<s;){let a=await t(r,GW);s=a.total>=0?a.total:s;for(let l of a.data){let c=e(l);if(!c)continue;let u=n(c);o.has(u)||(o.add(u),i.push(c))}if(a.data.length===0||Number.isFinite(s)&&i.length>=s||a.data.length<GW)break;r=a.currentPage+1}return i}function phe(t){let e=t.id.trim(),n=t.name.trim();if(!e||!n)return null;let i=ya(t.client)&&typeof t.client.name=="string"&&t.client.name.trim()||void 0;return{id:e,name:n,clientName:i}}function mhe(t){let e=t.id.trim(),n=t.name.trim();return e&&n?{id:e,name:n}:null}function hhe(t){return QW((e,n)=>uhe(t,e,n),phe,e=>e.id)}function ghe(t,e){return QW((n,i)=>dhe(t,e,n,i),mhe,n=>n.id)}function fhe(t){let e=t.clientName?` \xB7 ${t.clientName}`:"";return`${t.name}${e} (${t.id})`}function vhe(t){return`${t.name} (${t.id})`}function bhe(){return{project_id:ye.getDefaultProjectId(),workspace_id:ye.getDefaultWorkspaceId()}}async function xhe(t){let e=await t.modelRegistry.getApiKeyForProvider("slingshot");if(!e)return t.ui.notify("No Slingshot token found. Please run /login slingshot first.","error"),null;t.ui.setStatus("project-selection","Fetching projects...");let n=await hhe(e);if(t.ui.setStatus("project-selection",void 0),n.length===0)return t.ui.notify("No projects available for this user.","warning"),null;let i=n.map(p=>({label:fhe(p),value:p})),o=await t.ui.select("Select project",i.map(p=>p.label));if(!o)return t.ui.notify("Project selection cancelled.","info"),null;let r=i.find(p=>p.label===o)?.value;if(!r)return t.ui.notify("Unable to resolve selected project.","error"),null;t.ui.setStatus("project-selection","Fetching workspaces...");let s=await ghe(e,r.id);if(t.ui.setStatus("project-selection",void 0),s.length===0)return t.ui.notify("No workspaces found for the selected project.","warning"),null;let a=s.map(p=>({label:vhe(p),value:p})),l=await t.ui.select("Select workspace",a.map(p=>p.label));if(!l)return t.ui.notify("Workspace selection cancelled.","info"),null;let c=a.find(p=>p.label===l)?.value;if(!c)return t.ui.notify("Unable to resolve selected workspace.","error"),null;let u=`Confirm selection?
471
+ message: ${yn.enrichedMessage}`,"info"),yn=null,t.sendMessage({customType:"ss-context",content:"context_checkout complete. A summary of your previous branch was injected above. Read it to understand your new state. Execute the 'Next Step' from the summary",display:!1},{triggerTurn:!0}))})}function LW(t){t.registerCommand("s:context",{description:"Show context usage visualization",handler:async(e,n)=>{let i=await n.getContextUsage();if(!i){n.ui.notify("Context usage info not available.","warning");return}let r=n.sessionManager.getBranch(),s=n.getSystemPrompt(),a=t.getActiveTools(),c=t.getAllTools().filter(_=>a.includes(_.name)),u=_=>Math.ceil(_.length/4),d=0,p=0,m=0;for(let _ of r)if(_.type==="message"){let F=_.message;if(F.role==="user"){if(typeof F.content=="string")d+=u(F.content);else if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(d+=u(O.text))}else if(F.role==="assistant"){if(typeof F.content=="string")d+=u(F.content);else if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(d+=u(O.text)),O.type==="toolCall"&&(p+=u(JSON.stringify(O)))}else if(F.role==="toolResult"){if(Array.isArray(F.content))for(let O of F.content)O.type==="text"&&(m+=u(O.text))}else F.role==="bashExecution"&&(p+=u(F.command||""))}else(_.type==="branch_summary"||_.type==="compaction")&&(d+=u(_.summary||""));let g=u(s),h=u(JSON.stringify(c)),f=i.tokens,b=i.contextWindow;if(f==null||b==null||i.percent==null){n.ui.notify("Context usage info not available.","warning");return}let x=g+h+d+p+m,y=x>0?f/x:1,T=Math.round(g*y),P=Math.round(h*y),I=Math.round(d*y),W=Math.round(p*y),D=Math.round(m*y);await n.ui.custom((_,F,O,R)=>{let E=new z;E.addChild(new H(oe=>F.fg("accent",oe))),E.addChild(new A(F.fg("accent",F.bold(" Context Usage")),1,0)),E.addChild(new L(1));let U=[{label:"System Prompt",value:T,color:"muted"},{label:"System Tools",value:P,color:"dim"},{label:"Tool Call",value:W+D,color:"success"},{label:"Messages",value:I,color:"accent"}],G=Math.max(0,f-(T+P+I+W+D));G>10&&U.push({label:"Other",value:G,color:"dim"}),U.push({label:"Available",value:Math.max(0,b-f),color:"borderMuted"});let q=10,Z=5,Y=q*Z,se=[];for(U.forEach(oe=>{if(oe.label==="Available")return;let ye=Math.round(oe.value/b*Y);ye===0&&oe.value>0&&(ye=1);for(let Ce=0;Ce<ye&&se.length<Y;Ce++)se.push({color:oe.color,filled:!0})});se.length<Y;)se.push({color:"borderMuted",filled:!1});let xe=[];for(let oe=0;oe<Z;oe++){let ye="";for(let Ce=0;Ce<q;Ce++){let dt=se[oe*q+Ce];ye+=F.fg(dt.color,dt.filled?"\u25A0 ":"\u25A1 ")}xe.push(ye.trimEnd())}let rt=`${F.fg("text",F.bold("Total Usage".padEnd(16)))} ${F.fg("text",F.bold(dc(f).padStart(7)))} ${F.fg("text",F.bold(`(${i.percent.toFixed(1).padStart(5)}%)`))}`,Qe=U.map(oe=>{let ye=oe.label.padEnd(14),Ce=dc(oe.value).padStart(7),dt=(oe.value/b*100).toFixed(1).padStart(5),jt=oe.label==="Available"?"\u25A1":"\u25A0";return`${F.fg(oe.color,jt)} ${F.fg("text",ye)} ${F.fg("accent",Ce)} (${dt}%)`}),At=[rt,"",...Qe],_t=20,kn=Math.max(xe.length,At.length);for(let oe=0;oe<kn;oe++){let ye=(xe[oe]||"").padEnd(_t),Ce=At[oe]||"";E.addChild(new A(` ${ye} ${Ce}`,1,0))}return E.addChild(new L(1)),E.addChild(new A(F.fg("dim"," Press any key to close"),1,0)),E.addChild(new H(oe=>F.fg("accent",oe))),{render:oe=>E.render(oe),invalidate:()=>E.invalidate(),handleInput:oe=>R(void 0)}},{overlay:!0})}})}import{basename as WW,dirname as DW,join as Ume,relative as UW}from"node:path";var Ok=["by-source","a-z","active-first"],$me={"by-source":"By source","a-z":"A\u2013Z","active-first":"Active first"};function Nme(t){let e=Ok.indexOf(t);return Ok[(e+1)%Ok.length]??"by-source"}function Bme(t){return t.origin==="package"?`${t.source} (${t.scope})`:t.source==="auto"?t.scope==="user"?"User (~/.sling/agent/)":"Project (.sling/)":t.scope==="user"?"User settings":"Project settings"}function jme(t){let e=new Map;for(let i of t){let{path:o,enabled:r,metadata:s}=i,a=`${s.origin}:${s.scope}:${s.source}`;e.has(a)||e.set(a,{key:a,label:Bme(s),scope:s.scope,origin:s.origin,source:s.source,items:[]});let l=WW(o),c=WW(DW(o)),u=l==="SKILL.md"?c:l.endsWith(".md")?l.replace(/\.md$/,""):l;e.get(a)?.items.push({path:o,enabled:r,metadata:s,displayName:u,groupKey:a})}let n=Array.from(e.values());n.sort((i,o)=>i.origin!==o.origin?i.origin==="package"?-1:1:i.scope!==o.scope?i.scope==="user"?-1:1:i.source.localeCompare(o.source));for(let i of n)i.items.sort((o,r)=>o.displayName.localeCompare(r.displayName));return n}function qme(t){let e=[];for(let n of t){e.push({type:"group",group:n});for(let i of n.items)e.push({type:"item",item:i})}return e}function Kme(t){let e=t.flatMap(n=>n.items);return e.sort((n,i)=>n.displayName.localeCompare(i.displayName)),e.map(n=>({type:"item",item:n}))}function Gme(t){let e=t.flatMap(n=>n.items);return e.sort((n,i)=>n.enabled!==i.enabled?n.enabled?-1:1:n.displayName.localeCompare(i.displayName)),e.map(n=>({type:"item",item:n}))}function FW(t,e){switch(e){case"by-source":return qme(t);case"a-z":return Kme(t);case"active-first":return Gme(t)}}function zme(t){let e=t.trim();if(e.length===0)return;if(e.startsWith("/")){let i=e.slice(1).toLowerCase();return i.length===0?void 0:o=>o.path.toLowerCase().includes(i)}if(e.startsWith("@")){let i=e.slice(1).toLowerCase();return i.length===0?void 0:o=>o.metadata.source.toLowerCase().includes(i)}let n=e.toLowerCase();return i=>i.displayName.toLowerCase().includes(n)}function Hme(t,e){let n=_e(),i=Ume(e,".sling"),o=t.metadata.scope==="project"?i:n;return UW(o,t.path)}function Vme(t){let e=t.metadata.baseDir??DW(t.path);return UW(e,t.path)}function $W(t){return t.startsWith("!")||t.startsWith("+")||t.startsWith("-")?t.slice(1):t}function Qme(t,e,n,i){let o=t.metadata.scope,s=[...(o==="project"?n.getProjectSettings():n.getGlobalSettings()).skills??[]],a=Hme(t,i),l=s.filter(c=>$W(c)!==a);l.push(e?`+${a}`:`-${a}`),o==="project"?n.setProjectSkillPaths(l):n.setSkillPaths(l)}function Yme(t,e,n){let i=t.metadata.scope,r=[...(i==="project"?n.getProjectSettings():n.getGlobalSettings()).packages??[]],s=r.findIndex(p=>(typeof p=="string"?p:p.source)===t.metadata.source);if(s===-1)return;let a=r[s];if(a===void 0)return;typeof a=="string"&&(a={source:a},r[s]=a);let l=[...a.skills??[]],c=Vme(t),u=l.filter(p=>$W(p)!==c);u.push(e?`+${c}`:`-${c}`),u.length>0?a.skills=u:delete a.skills,a.extensions!==void 0||a.skills!==void 0||a.prompts!==void 0||a.themes!==void 0||(r[s]=a.source),i==="project"?n.setProjectPackages(r):n.setPackages(r)}function Jme(t,e,n,i){t.metadata.origin==="top-level"?Qme(t,e,n,i):Yme(t,e,n)}function Lk(t){t.registerCommand("s:skills-manager",{description:"Enable/disable skills",getArgumentCompletions:e=>{let n=[{value:"list",description:"List skills with enabled/disabled state"}],i=(e??"").toLowerCase(),o=n.filter(r=>r.value.startsWith(i)||r.description.toLowerCase().includes(i));return o.length>0?o.map(r=>({value:r.value,label:`${r.value} - ${r.description}`})):null},handler:async(e,n)=>{let i=n.cwd,o=_e(),r=di.create(i,o),l=(await new Ei({cwd:i,agentDir:o,settingsManager:r}).resolve()).skills;if(l.length===0){n.ui.notify("No skills found.","info");return}let c=jme(l);if(e.trim().toLowerCase()==="list"||!n.hasUI){let p=[];for(let m of c){p.push(`${m.label}`);for(let g of m.items){let h=g.enabled?"[x]":"[ ]";p.push(` ${h} ${g.displayName}`)}}n.ui.notify(p.join(`
472
+ `),"info");return}let d=0;if(await n.ui.custom((p,m,g,h)=>{let f="by-source",b=FW(c,f),x=[...b],y=x.findIndex(E=>E.type==="item");y<0&&(y=0);let T=new Xe;function P(E,U){let G=E+U;for(;G>=0&&G<x.length;){if(x[G]?.type==="item")return G;G+=U}return E}function I(E){let U=zme(E);if(!U){x=[...b],D();return}let G=new Set,q=new Set;for(let Z of b)Z.type==="item"&&U(Z.item)&&G.add(Z.item);for(let Z of c)for(let Y of Z.items)G.has(Y)&&q.add(Z);x=[];for(let Z of b)(Z.type==="group"&&q.has(Z.group)||Z.type==="item"&&G.has(Z.item))&&x.push(Z);D()}function W(){b=FW(c,f),I(T.getValue())}function D(){let E=x.findIndex(U=>U.type==="item");y=E>=0?E:0}let _={invalidate(){},render(E){let U=m.bold("Skill Configuration"),G=m.fg("muted"," \xB7 "),q=lt("space","toggle")+G+lt("tab","view")+G+lt("esc","close"),Z=j(q),Y=j(U),se=Math.max(1,E-Y-Z);return[te(`${U}${" ".repeat(se)}${q}`,E,""),m.fg("muted","Filter: name \xB7 /path \xB7 @source")]}},F=15,O={invalidate(){},render(E){let U=[];if(U.push(...T.render(E)),U.push(""),x.length===0)return U.push(m.fg("muted"," No skills found")),U;let G=Math.max(0,Math.min(y-Math.floor(F/2),x.length-F)),q=Math.min(G+F,x.length);for(let xe=G;xe<q;xe++){let rt=x[xe];if(!rt)continue;let Qe=xe===y;if(rt.type==="group"){let At=m.fg("accent",m.bold(rt.group.label));U.push(te(` ${At}`,E,""))}else{let At=Qe?"> ":" ",_t=rt.item.enabled?m.fg("success","[x]"):m.fg("dim","[ ]"),kn=Qe?m.bold(rt.item.displayName):rt.item.displayName;U.push(te(`${At} ${_t} ${kn}`,E,"..."))}}let Z=x.filter(xe=>xe.type==="item").length,Y=x[y]?.type==="item"?x.slice(0,y+1).filter(xe=>xe.type==="item").length:0,se=$me[f];return G>0||q<x.length?U.push(m.fg("dim",` ${Y}/${Z} ${se}`)):U.push(m.fg("dim",` ${se}`)),U}},R=new z;return R.addChild(new L(1)),R.addChild(new H),R.addChild(new L(1)),R.addChild(_),R.addChild(new L(1)),R.addChild(O),R.addChild(new L(1)),R.addChild(new H),{render(E){return R.render(E)},invalidate(){R.invalidate()},handleInput(E){let U=we();if(U.matches(E,"tui.select.up")){y=P(y,-1),p.requestRender();return}if(U.matches(E,"tui.select.down")){y=P(y,1),p.requestRender();return}if(U.matches(E,"tui.select.pageUp")){let G=Math.max(0,y-F);for(;G<x.length&&x[G]?.type!=="item";)G++;G<x.length&&(y=G),p.requestRender();return}if(U.matches(E,"tui.select.pageDown")){let G=Math.min(x.length-1,y+F);for(;G>=0&&x[G]?.type!=="item";)G--;G>=0&&(y=G),p.requestRender();return}if(U.matches(E,"tui.select.cancel")){h(void 0);return}if(Fe(E,"ctrl+c")){h(void 0);return}if(Fe(E,"tab")){f=Nme(f),W(),p.requestRender();return}if(E===" "||U.matches(E,"tui.select.confirm")){let G=x[y];if(G?.type==="item"){let q=!G.item.enabled;Jme(G.item,q,r,i),G.item.enabled=q;for(let Z of c){let Y=Z.items.find(se=>se.path===G.item.path);Y&&(Y.enabled=q)}d++,f==="active-first"&&W()}p.requestRender();return}T.handleInput(E),I(T.getValue()),p.requestRender()}}}),d>0){if(await n.ui.confirm("Reload Required",`${d} skill change(s) saved. Reload pi now?`)){await n.reload();return}n.ui.notify("Changes saved to settings. Use /reload to apply.","info")}}})}async function Wk(t,e){let n=await e.modelRegistry.getApiKeyForProvider(e.model?.provider||"slingshot"),i=new Date;return fetch(`${ke.getUserActivityUrl()}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n||""}`,Accept:"application/json"},body:JSON.stringify({...t,activity_entity_type:"slingcli",activity_entity_id:Zm.slingVersion||"dev",activity_startdate:t.activity_startdate?.toISOString()||i.toISOString(),activity_enddate:t.activity_enddate?.toISOString()||i.toISOString(),metadata:t.metadata||{}})}).then(o=>o.json()).then(o=>{qe("User activity posted successfully, credits used: "+o.credits_used+"/"+o.remainingCredits)}).catch(o=>{ct("Error posting user activity:",o)}),{}}import BW from"node:path";var Jg=null,Fk=0,NW=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Dk(t){let e=BW.basename(process.cwd());return t?`\u2B55\uFE0F - ${t} - ${e}`:`\u2B55\uFE0F - ${e}`}function Uk(t){Jg&&(clearInterval(Jg),Jg=null),Fk=0;let e=t.sessionManager.getSessionName();t.ui.setTitle(Dk(e))}function jW(t){Uk(t),Jg=setInterval(()=>{let e=NW[Fk%NW.length],n=BW.basename(process.cwd()),i=t.sessionManager.getSessionName(),o=i?`${e} ${Dk(i)}`:`${e} ${Dk()}`;t.ui.setTitle(o),Fk++},80)}var qW=2e3,Xme=23;function Zme(t){let e=t.trim().match(/(\d+)\.(\d+)\.(\d+)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)]:null}async function ehe(t,e,n){let i=await t.exec("rtk",["rewrite",e],{timeout:qW,signal:n});return i.killed||i.code!==0&&i.code!==3?null:i.stdout.trim()||null}async function KW(t){let e=await t.exec("rtk",["--version"],{timeout:qW});if(e.code!==0){console.warn("[rtk] rtk binary not found in PATH \u2014 extension disabled");return}let n=Zme(e.stdout.replace(/^rtk\s+/,""));if(n){let[i,o]=n;if(i===0&&o<Xme){console.warn(`[rtk] rtk ${e.stdout.trim()} is too old (need >= 0.23.0) \u2014 extension disabled`);return}}t.on("tool_call",async(i,o)=>{try{if(!Vr("bash",i))return;let r=i.input.command;if(typeof r!="string"||r.trim()===""||r.startsWith("rtk ")||process.env.RTK_DISABLED==="1")return;let s=await ehe(t,r,o.signal);s&&s!==r&&(i.input.command=s)}catch(r){console.warn("[rtk] unexpected error in tool_call handler; passing through command",r);return}})}function ya(t){return typeof t=="object"&&t!==null}var the="/api/v2/projects/getAllProjects",nhe="/api/v2/projects/workspaces/getAllWorkspaces",GW=100;function ihe(t){return ya(t)&&typeof t.status=="string"&&typeof t.message=="string"&&typeof t.errorCode=="number"&&typeof t.details=="string"}function ohe(t){return ya(t)?typeof t.id=="string"&&typeof t.name=="string":!1}function rhe(t){return ya(t)?typeof t.id=="string"&&typeof t.name=="string":!1}function zW(){let e=ke.getSettings()[ke.BASE_URL];return String(e)}function she(t,e){let n=new URL(the,`${zW()}/`);return n.searchParams.set("limit",String(e)),n.searchParams.set("page",String(t)),n.searchParams.set("sort","name"),n.searchParams.set("sortOrder","ASC"),n.searchParams.set("metaData","true"),n}function ahe(t,e,n){let i=new URL(nhe,`${zW()}/`);return i.searchParams.set("limit",String(n)),i.searchParams.set("page",String(e)),i.searchParams.set("sort","name"),i.searchParams.set("sortOrder","ASC"),i.searchParams.set("projectId",t),i}function lhe(t){if(ihe(t)){let e=t.details.trim();return e.length>0?`${t.message} (${e})`:t.message}if(typeof t=="string"&&t.trim().length>0)return t;if(ya(t)){if(typeof t.message=="string"&&t.message.trim().length>0)return t.message;if(typeof t.error=="string"&&t.error.trim().length>0)return t.error}return"Unknown upstream response"}function che(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}async function HW(t,e){let n=await Yn(e),i=await fetch(t.toString(),{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"X-App-Authorization":`Bearer ${n}`}}),o=await i.text(),r=che(o);if(!i.ok){let s=lhe(r);throw new Error(`Request failed for ${t.pathname}: ${s}`)}return r}function VW(t,e,n){if(!ya(t)||!Array.isArray(t.data))throw new Error(`Unexpected ${n} response shape.`);let i=t.data.filter(e);if(i.length!==t.data.length)throw new Error(`Unexpected ${n} item shape in response data.`);let o=typeof t.currentPage=="number"?t.currentPage:1,r=typeof t.limit=="number"?t.limit:i.length,s=typeof t.total=="number"?t.total:i.length;return{data:i,currentPage:o,limit:r,total:s}}async function uhe(t,e,n){let i=await HW(she(e,n),t);return VW(i,ohe,"getAllProjects")}async function dhe(t,e,n,i){let o=await HW(ahe(e,n,i),t);return VW(o,rhe,"getAllWorkspaces")}async function QW(t,e,n){let i=[],o=new Set,r=1,s=Number.POSITIVE_INFINITY;for(;i.length<s;){let a=await t(r,GW);s=a.total>=0?a.total:s;for(let l of a.data){let c=e(l);if(!c)continue;let u=n(c);o.has(u)||(o.add(u),i.push(c))}if(a.data.length===0||Number.isFinite(s)&&i.length>=s||a.data.length<GW)break;r=a.currentPage+1}return i}function phe(t){let e=t.id.trim(),n=t.name.trim();if(!e||!n)return null;let i=ya(t.client)&&typeof t.client.name=="string"&&t.client.name.trim()||void 0;return{id:e,name:n,clientName:i}}function mhe(t){let e=t.id.trim(),n=t.name.trim();return e&&n?{id:e,name:n}:null}function hhe(t){return QW((e,n)=>uhe(t,e,n),phe,e=>e.id)}function ghe(t,e){return QW((n,i)=>dhe(t,e,n,i),mhe,n=>n.id)}function fhe(t){let e=t.clientName?` \xB7 ${t.clientName}`:"";return`${t.name}${e} (${t.id})`}function vhe(t){return`${t.name} (${t.id})`}function bhe(){return{project_id:ke.getDefaultProjectId(),workspace_id:ke.getDefaultWorkspaceId()}}async function xhe(t){let e=await t.modelRegistry.getApiKeyForProvider("slingshot");if(!e)return t.ui.notify("No Slingshot token found. Please run /login slingshot first.","error"),null;t.ui.setStatus("project-selection","Fetching projects...");let n=await hhe(e);if(t.ui.setStatus("project-selection",void 0),n.length===0)return t.ui.notify("No projects available for this user.","warning"),null;let i=n.map(p=>({label:fhe(p),value:p})),o=await t.ui.select("Select project",i.map(p=>p.label));if(!o)return t.ui.notify("Project selection cancelled.","info"),null;let r=i.find(p=>p.label===o)?.value;if(!r)return t.ui.notify("Unable to resolve selected project.","error"),null;t.ui.setStatus("project-selection","Fetching workspaces...");let s=await ghe(e,r.id);if(t.ui.setStatus("project-selection",void 0),s.length===0)return t.ui.notify("No workspaces found for the selected project.","warning"),null;let a=s.map(p=>({label:vhe(p),value:p})),l=await t.ui.select("Select workspace",a.map(p=>p.label));if(!l)return t.ui.notify("Workspace selection cancelled.","info"),null;let c=a.find(p=>p.label===l)?.value;if(!c)return t.ui.notify("Unable to resolve selected workspace.","error"),null;let u=`Confirm selection?
473
473
  Project: ${r.name}
474
- Workspace: ${c.name}`;return await t.ui.select(u,["Confirm","Cancel"])!=="Confirm"?(t.ui.notify("Project/workspace update cancelled.","info"),null):(ye.updateSettings({[ye.PROJECT_ID]:r.id,[ye.WORKSPACE_ID]:c.id},{scope:"global"}),t.ui.notify(`Saved project '${r.name}' and workspace '${c.name}' to global settings.`,"info"),{project_id:r.id,workspace_id:c.id})}function $k(t){t.registerCommand("s:project",{description:"Select and save Slingshot project/workspace",handler:async(e,n)=>{if(!n.hasUI){t.sendMessage({customType:"slingshot-project-selection",content:JSON.stringify(bhe(),null,2),display:!0});return}try{let i=await xhe(n);if(!i)return;t.sendMessage({customType:"slingshot-project-selection",content:JSON.stringify(i,null,2),display:!0})}catch(i){n.ui.setStatus("project-selection",void 0),ct("/s:project command failed",i),n.ui.notify(`Failed to update project/workspace: ${i instanceof Error?i.message:String(i)}`,"error")}}})}var YW=null,wn=new _h(D_,qe);function yhe(t){let e=new WeakSet,n="",i={},o=AE(),r=new Date,s="";t.unregisterProvider("Anthropic"),t.unregisterProvider("GitHub Copilot"),t.unregisterProvider("OpenAI"),t.unregisterProvider("OpenAI Codex"),t.unregisterProvider("XAI"),Sb(),KE(t),Lk(t),yx(t),OW(t),LW(t),KW(t),$k(t);function a(){let l=t.getFlag("profile")||"default",c="";if(l.endsWith(".md")){n=Ad.readFileSync(l,"utf-8"),t.sendMessage({customType:"slingshot-profile",content:`Loaded Profile: ${l}`,display:!0});return}if(c=xi.resolve(".sling","profiles",`./${l}.md`),Ad.existsSync(c)||(c=xi.resolve(_e(),"profiles",`./${l}.md`)),Ad.existsSync(c))try{n=Ad.readFileSync(c,"utf-8"),t.sendMessage({customType:"slingshot-profile",content:`Loaded Profile: ${l}`,display:!0});return}catch{}t.sendMessage({customType:"slingshot-profile",content:`Profile Not found: ${l}`,display:!0})}t.registerFlag("profile",{type:"string",description:"Set a profile to use for this session (the profiles are stored in .sling/profiles/*). Usage: --profile=work or --profile=personal. This is useful to switch between different personas in the system prompts for different contexts (e.g. work vs personal).",default:"default"}),t.on("resources_discover",async l=>{let c=xi.join(Nk(),".pi","agent"),u=xi.join(Nk(),".agents"),d=xi.join(Nk(),".slingshot"),m=[xi.join(l.cwd,".sling","agent"),u,c],g=[],h=[],f=[];for(let b of m){let x=xi.join(b,"skills");Xg(x)&&g.push(x);let y=xi.join(b,"prompts");Xg(y)&&h.push(y);let T=xi.join(b,"themes");Xg(T)&&f.push(T)}return{skillPaths:g,promptPaths:h,themePaths:f}}),t.on("session_start",async(l,c)=>{wn.initialize(c),c.hasUI&&c.ui.setHeader($E);try{let u=await Yn();u||qe("session_start: no Slingshot token found in modelRegistry"),c.hasUI&&(u?c.ui.notify("Slingshot initialized successfully.","info"):c.ui.notify("Slingshot not authorized. Please use /login slingshot to authenticate.","warning")),await wn.refreshAndUpdate(c,{force:!0,logErrors:!0})}catch(u){qe(`session_start: app-token fetch failed: ${u instanceof Error?u.message:String(u)}`)}}),t.registerProvider("slingshot",{baseUrl:ye.getApiBaseUrl(),api:"openai-completions",apiKey:"$SLINGSHOT_API_KEY",models:UE.map(l=>({...l,baseUrl:ye.getApiBaseUrl()})),headers:{"X-App-Authorization":`$${ye.SLINGSHOT_APP_TOKEN_ENV}`},oauth:{name:"Slingshot",login:Ab,refreshToken:Xm,getApiKey:l=>(YW=l,l.access)}}),t.registerCommand("s:settings",{description:"Edit Slingshot settings (base URL, analytics domain, and IDs)",handler:async(l,c)=>{let u=ye.getSettings();if(!c.hasUI){t.sendMessage({customType:"slingshot-settings",content:JSON.stringify(u,null,2),display:!0});return}let d=ye.getLocalSettingsPath(),p=ye.getGlobalSettingsPath(),m=await c.ui.editor("Slingshot settings (JSON)",JSON.stringify(u,null,2));if(!m){c.ui.notify("Cancelled","info");return}let g;try{let y=JSON.parse(m);if(!y||typeof y!="object"||Array.isArray(y))throw new Error("Expected a JSON object");g=y}catch(y){c.ui.notify(`Invalid JSON: ${y instanceof Error?y.message:String(y)}`,"error");return}let h=await c.ui.select("Save location",[`Local (${d})`,`Global (${p})`]);if(!h){c.ui.notify("Cancelled","info");return}let f=h.startsWith("Local")?"local":"global";ye.updateSettings(g,{scope:f});let b=f==="local"?d:p;c.ui.notify(`Settings saved to ${b}`,"info");let x=ye.getSettings();t.sendMessage({customType:"slingshot-settings",content:JSON.stringify(x,null,2),display:!0})}}),t.registerCommand("s:debug",{description:"Toggle Slingshot debug logging",handler:async(l,c)=>{let u=!_u();if(PE(u),u){let d="Slingshot Debug: ENABLED \u2705",p=IE();p&&(d+=`
474
+ Workspace: ${c.name}`;return await t.ui.select(u,["Confirm","Cancel"])!=="Confirm"?(t.ui.notify("Project/workspace update cancelled.","info"),null):(ke.updateSettings({[ke.PROJECT_ID]:r.id,[ke.WORKSPACE_ID]:c.id},{scope:"global"}),t.ui.notify(`Saved project '${r.name}' and workspace '${c.name}' to global settings.`,"info"),{project_id:r.id,workspace_id:c.id})}function $k(t){t.registerCommand("s:project",{description:"Select and save Slingshot project/workspace",handler:async(e,n)=>{if(!n.hasUI){t.sendMessage({customType:"slingshot-project-selection",content:JSON.stringify(bhe(),null,2),display:!0});return}try{let i=await xhe(n);if(!i)return;t.sendMessage({customType:"slingshot-project-selection",content:JSON.stringify(i,null,2),display:!0})}catch(i){n.ui.setStatus("project-selection",void 0),ct("/s:project command failed",i),n.ui.notify(`Failed to update project/workspace: ${i instanceof Error?i.message:String(i)}`,"error")}}})}var YW=null,wn=new _h(D_,qe);function yhe(t){let e=new WeakSet,n="",i={},o=AE(),r=new Date,s="";t.unregisterProvider("Anthropic"),t.unregisterProvider("GitHub Copilot"),t.unregisterProvider("OpenAI"),t.unregisterProvider("OpenAI Codex"),t.unregisterProvider("XAI"),Sb(),KE(t),Lk(t),yx(t),OW(t),LW(t),KW(t),$k(t);function a(){let l=t.getFlag("profile")||"default",c="";if(l.endsWith(".md")){n=Ad.readFileSync(l,"utf-8"),t.sendMessage({customType:"slingshot-profile",content:`Loaded Profile: ${l}`,display:!0});return}if(c=xi.resolve(".sling","profiles",`./${l}.md`),Ad.existsSync(c)||(c=xi.resolve(_e(),"profiles",`./${l}.md`)),Ad.existsSync(c))try{n=Ad.readFileSync(c,"utf-8"),t.sendMessage({customType:"slingshot-profile",content:`Loaded Profile: ${l}`,display:!0});return}catch{}t.sendMessage({customType:"slingshot-profile",content:`Profile Not found: ${l}`,display:!0})}t.registerFlag("profile",{type:"string",description:"Set a profile to use for this session (the profiles are stored in .sling/profiles/*). Usage: --profile=work or --profile=personal. This is useful to switch between different personas in the system prompts for different contexts (e.g. work vs personal).",default:"default"}),t.on("resources_discover",async l=>{let c=xi.join(Nk(),".pi","agent"),u=xi.join(Nk(),".agents"),d=xi.join(Nk(),".slingshot"),m=[xi.join(l.cwd,".sling","agent"),u,c],g=[],h=[],f=[];for(let b of m){let x=xi.join(b,"skills");Xg(x)&&g.push(x);let y=xi.join(b,"prompts");Xg(y)&&h.push(y);let T=xi.join(b,"themes");Xg(T)&&f.push(T)}return{skillPaths:g,promptPaths:h,themePaths:f}}),t.on("session_start",async(l,c)=>{wn.initialize(c),c.hasUI&&c.ui.setHeader($E);try{let u=await c.modelRegistry.getApiKeyForProvider("slingshot"),d=u?await Yn(u):void 0;d||qe("session_start: no Slingshot token found in modelRegistry"),c.hasUI&&(d?c.ui.notify("Slingshot initialized successfully.","info"):c.ui.notify("Slingshot not authorized. Please use /login slingshot to authenticate.","warning")),await wn.refreshAndUpdate(c,{force:!0,logErrors:!0})}catch(u){qe(`session_start: app-token fetch failed: ${u instanceof Error?u.message:String(u)}`)}}),t.registerProvider("slingshot",{baseUrl:ke.getApiBaseUrl(),api:"openai-completions",apiKey:"$SLINGSHOT_API_KEY",models:UE.map(l=>({...l,baseUrl:ke.getApiBaseUrl()})),oauth:{name:"Slingshot",login:Ab,refreshToken:Xm,getApiKey:l=>(YW=l,l.access)}}),t.on("before_provider_headers",async(l,c)=>{if(c.model?.provider!=="slingshot")return;let u=await c.modelRegistry.getApiKeyForProvider("slingshot");if(!u)throw new Error("Slingshot user token unavailable while preparing request headers");let d=await Yn(u);l.headers["X-App-Authorization"]=`Bearer ${d}`}),t.registerCommand("s:settings",{description:"Edit Slingshot settings (base URL, analytics domain, and IDs)",handler:async(l,c)=>{let u=ke.getSettings();if(!c.hasUI){t.sendMessage({customType:"slingshot-settings",content:JSON.stringify(u,null,2),display:!0});return}let d=ke.getLocalSettingsPath(),p=ke.getGlobalSettingsPath(),m=await c.ui.editor("Slingshot settings (JSON)",JSON.stringify(u,null,2));if(!m){c.ui.notify("Cancelled","info");return}let g;try{let y=JSON.parse(m);if(!y||typeof y!="object"||Array.isArray(y))throw new Error("Expected a JSON object");g=y}catch(y){c.ui.notify(`Invalid JSON: ${y instanceof Error?y.message:String(y)}`,"error");return}let h=await c.ui.select("Save location",[`Local (${d})`,`Global (${p})`]);if(!h){c.ui.notify("Cancelled","info");return}let f=h.startsWith("Local")?"local":"global";ke.updateSettings(g,{scope:f});let b=f==="local"?d:p;c.ui.notify(`Settings saved to ${b}`,"info");let x=ke.getSettings();t.sendMessage({customType:"slingshot-settings",content:JSON.stringify(x,null,2),display:!0})}}),t.registerCommand("s:debug",{description:"Toggle Slingshot debug logging",handler:async(l,c)=>{let u=!_u();if(PE(u),u){let d="Slingshot Debug: ENABLED \u2705",p=IE();p&&(d+=`
475
475
 
476
476
  Log file:
477
- ${p}`),t.sendMessage({customType:"slingshot-debug-status",content:d,display:!0})}else t.sendMessage({customType:"slingshot-debug-status",content:"Slingshot Debug: DISABLED \u274C",display:!0})}}),t.registerCommand("refresh-token",{description:"Manually refresh Slingshot OAuth token",handler:async(l,c)=>{try{let u=c.modelRegistry.authStorage,d=u.get("slingshot");if(!d||d.type!=="oauth"){c.hasUI&&c.ui.notify("No Slingshot OAuth credentials found. Please use /login slingshot first.","error");return}c.hasUI&&c.ui.setStatus("refresh","Refreshing Slingshot token...");let p=await Xm(d);u.set("slingshot",{type:"oauth",...p}),YW=p,c.hasUI&&(c.ui.setStatus("refresh",void 0),c.ui.notify("Slingshot token refreshed successfully!","info"))}catch(u){if(c.hasUI){c.ui.setStatus("refresh",void 0);let d=u instanceof Error?u.message:String(u);c.ui.notify(`Failed to refresh token: ${d}`,"error")}}}}),t.on("before_agent_start",async(l,c)=>{try{if(Yn(),wn.startStreaming(c),await wn.refreshAndUpdate(c,{force:!0,logErrors:!0})<=0){c.hasUI&&(c.ui.notify("You do not have enough credits remaining. Please recharge to continue using the slingcli.","warning"),c.ui.notify("For more information on credits, visit: https://sapientaiproducts.com/help/credits","info")),c.abort();return}i={},r=new Date,jW(c),sr(c),Lb(c,"random");let d=l.systemPrompt;return d.includes("<pi-intercom>")||(d=l.systemPrompt+`
477
+ ${p}`),t.sendMessage({customType:"slingshot-debug-status",content:d,display:!0})}else t.sendMessage({customType:"slingshot-debug-status",content:"Slingshot Debug: DISABLED \u274C",display:!0})}}),t.registerCommand("refresh-token",{description:"Manually refresh Slingshot OAuth token",handler:async(l,c)=>{try{let u=c.modelRegistry.authStorage,d=u.get("slingshot");if(!d||d.type!=="oauth"){c.hasUI&&c.ui.notify("No Slingshot OAuth credentials found. Please use /login slingshot first.","error");return}c.hasUI&&c.ui.setStatus("refresh","Refreshing Slingshot token...");let p=await Xm(d);u.set("slingshot",{type:"oauth",...p}),YW=p,c.hasUI&&(c.ui.setStatus("refresh",void 0),c.ui.notify("Slingshot token refreshed successfully!","info"))}catch(u){if(c.hasUI){c.ui.setStatus("refresh",void 0);let d=u instanceof Error?u.message:String(u);c.ui.notify(`Failed to refresh token: ${d}`,"error")}}}}),t.on("before_agent_start",async(l,c)=>{try{if(wn.startStreaming(c),await wn.refreshAndUpdate(c,{force:!0,logErrors:!0})<=0){c.hasUI&&(c.ui.notify("You do not have enough credits remaining. Please recharge to continue using the slingcli.","warning"),c.ui.notify("For more information on credits, visit: https://sapientaiproducts.com/help/credits","info")),c.abort();return}i={},r=new Date,jW(c),sr(c),Lb(c,"random");let d=l.systemPrompt;return d.includes("<pi-intercom>")||(d=l.systemPrompt+`
478
478
 
479
479
  <pi-intercom>
480
480
  Coordinate with other local sling sessions on related codebases. Use \`/skill:pi-intercom\` for patterns.