@agi-cli/web-ui 0.1.141 → 0.1.142

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.
@@ -12,16 +12,16 @@ Error generating stack: `+g.message+`
12
12
  transition-all duration-150 ease-out cursor-pointer
13
13
  hover:bg-accent/50
14
14
  ${t?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}
15
- `,onClick:s,role:"alert",children:[PF[e.type],y.jsx("span",{className:"text-sm text-foreground",children:e.message}),e.action&&y.jsxs("a",{href:e.action.href,target:"_blank",rel:"noopener noreferrer",onClick:l=>l.stopPropagation(),className:"ml-auto flex items-center gap-1 text-xs text-primary hover:underline",children:[e.action.label,y.jsx(wr,{className:"h-3 w-3"})]})]})}function HF(){const e=Cr(t=>t.toasts);return e.length===0?null:y.jsx("div",{className:"fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 max-w-sm",children:e.map(t=>y.jsx(UF,{toast:t},t.id))})}const $v=$n(e=>({pendingApprovals:[],addPendingApproval:t=>e(n=>({pendingApprovals:[...n.pendingApprovals,t]})),removePendingApproval:t=>e(n=>({pendingApprovals:n.pendingApprovals.filter(i=>i.callId!==t)})),updatePendingApproval:(t,n)=>e(i=>({pendingApprovals:i.pendingApprovals.map(s=>s.callId===t?{...s,args:n}:s)})),clearPendingApprovals:()=>e({pendingApprovals:[]}),setPendingApprovals:t=>e({pendingApprovals:t})}));function Xr(e){return Array.isArray?Array.isArray(e):zO(e)==="[object Array]"}function zF(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function qF(e){return e==null?"":zF(e)}function xr(e){return typeof e=="string"}function UO(e){return typeof e=="number"}function $F(e){return e===!0||e===!1||GF(e)&&zO(e)=="[object Boolean]"}function HO(e){return typeof e=="object"}function GF(e){return HO(e)&&e!==null}function Fn(e){return e!=null}function Tp(e){return!e.trim().length}function zO(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const WF="Incorrect 'index' type",VF=e=>`Invalid value for key ${e}`,KF=e=>`Pattern length exceeds max of ${e}.`,YF=e=>`Missing ${e} property in key`,XF=e=>`Property 'weight' in key '${e}' must be a positive integer`,xE=Object.prototype.hasOwnProperty;class ZF{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(i=>{let s=qO(i);this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(i=>{i.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function qO(e){let t=null,n=null,i=null,s=1,l=null;if(xr(e)||Xr(e))i=e,t=EE(e),n=Vy(e);else{if(!xE.call(e,"name"))throw new Error(YF("name"));const c=e.name;if(i=c,xE.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(XF(c));t=EE(c),n=Vy(c),l=e.getFn}return{path:t,id:n,weight:s,src:i,getFn:l}}function EE(e){return Xr(e)?e:e.split(".")}function Vy(e){return Xr(e)?e.join("."):e}function QF(e,t){let n=[],i=!1;const s=(l,c,o)=>{if(Fn(l))if(!c[o])n.push(l);else{let u=c[o];const d=l[u];if(!Fn(d))return;if(o===c.length-1&&(xr(d)||UO(d)||$F(d)))n.push(qF(d));else if(Xr(d)){i=!0;for(let p=0,f=d.length;p<f;p+=1)s(d[p],c,o+1)}else c.length&&s(d,c,o+1)}};return s(e,xr(t)?t.split("."):t,0),i?n:n[0]}const JF={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},e8={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},t8={location:0,threshold:.6,distance:100},n8={useExtendedSearch:!1,getFn:QF,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var De={...e8,...JF,...t8,...n8};const r8=/[^ ]+/g;function i8(e=1,t=3){const n=new Map,i=Math.pow(10,t);return{get(s){const l=s.match(r8).length;if(n.has(l))return n.get(l);const c=1/Math.pow(l,.5*e),o=parseFloat(Math.round(c*i)/i);return n.set(l,o),o},clear(){n.clear()}}}class Gv{constructor({getFn:t=De.getFn,fieldNormWeight:n=De.fieldNormWeight}={}){this.norm=i8(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,i)=>{this._keysMap[n.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,xr(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();xr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,i=this.size();n<i;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Fn(t)||Tp(t))return;let i={v:t,i:n,n:this.norm.get(t)};this.records.push(i)}_addObject(t,n){let i={i:n,$:{}};this.keys.forEach((s,l)=>{let c=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Fn(c)){if(Xr(c)){let o=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:d,value:p}=u.pop();if(Fn(p))if(xr(p)&&!Tp(p)){let f={v:p,i:d,n:this.norm.get(p)};o.push(f)}else Xr(p)&&p.forEach((f,m)=>{u.push({nestedArrIndex:m,value:f})})}i.$[l]=o}else if(xr(c)&&!Tp(c)){let o={v:c,n:this.norm.get(c)};i.$[l]=o}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function $O(e,t,{getFn:n=De.getFn,fieldNormWeight:i=De.fieldNormWeight}={}){const s=new Gv({getFn:n,fieldNormWeight:i});return s.setKeys(e.map(qO)),s.setSources(t),s.create(),s}function a8(e,{getFn:t=De.getFn,fieldNormWeight:n=De.fieldNormWeight}={}){const{keys:i,records:s}=e,l=new Gv({getFn:t,fieldNormWeight:n});return l.setKeys(i),l.setIndexRecords(s),l}function Ru(e,{errors:t=0,currentLocation:n=0,expectedLocation:i=0,distance:s=De.distance,ignoreLocation:l=De.ignoreLocation}={}){const c=t/e.length;if(l)return c;const o=Math.abs(i-n);return s?c+o/s:o?1:c}function s8(e=[],t=De.minMatchCharLength){let n=[],i=-1,s=-1,l=0;for(let c=e.length;l<c;l+=1){let o=e[l];o&&i===-1?i=l:!o&&i!==-1&&(s=l-1,s-i+1>=t&&n.push([i,s]),i=-1)}return e[l-1]&&l-i>=t&&n.push([i,l-1]),n}const ia=32;function o8(e,t,n,{location:i=De.location,distance:s=De.distance,threshold:l=De.threshold,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,includeMatches:u=De.includeMatches,ignoreLocation:d=De.ignoreLocation}={}){if(t.length>ia)throw new Error(KF(ia));const p=t.length,f=e.length,m=Math.max(0,Math.min(i,f));let v=l,w=m;const E=o>1||u,b=E?Array(f):[];let _;for(;(_=e.indexOf(t,w))>-1;){let A=Ru(t,{currentLocation:_,expectedLocation:m,distance:s,ignoreLocation:d});if(v=Math.min(A,v),w=_+p,E){let R=0;for(;R<p;)b[_+R]=1,R+=1}}w=-1;let x=[],S=1,k=p+f;const O=1<<p-1;for(let A=0;A<p;A+=1){let R=0,D=k;for(;R<D;)Ru(t,{errors:A,currentLocation:m+D,expectedLocation:m,distance:s,ignoreLocation:d})<=v?R=D:k=D,D=Math.floor((k-R)/2+R);k=D;let L=Math.max(1,m-D+1),I=c?f:Math.min(m+D,f)+p,H=Array(I+2);H[I+1]=(1<<A)-1;for(let W=I;W>=L;W-=1){let K=W-1,V=n[e.charAt(K)];if(E&&(b[K]=+!!V),H[W]=(H[W+1]<<1|1)&V,A&&(H[W]|=(x[W+1]|x[W])<<1|1|x[W+1]),H[W]&O&&(S=Ru(t,{errors:A,currentLocation:K,expectedLocation:m,distance:s,ignoreLocation:d}),S<=v)){if(v=S,w=K,w<=m)break;L=Math.max(1,2*m-w)}}if(Ru(t,{errors:A+1,currentLocation:m,expectedLocation:m,distance:s,ignoreLocation:d})>v)break;x=H}const T={isMatch:w>=0,score:Math.max(.001,S)};if(E){const A=s8(b,o);A.length?u&&(T.indices=A):T.isMatch=!1}return T}function l8(e){let t={};for(let n=0,i=e.length;n<i;n+=1){const s=e.charAt(n);t[s]=(t[s]||0)|1<<i-n-1}return t}const cc=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class GO{constructor(t,{location:n=De.location,threshold:i=De.threshold,distance:s=De.distance,includeMatches:l=De.includeMatches,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,isCaseSensitive:u=De.isCaseSensitive,ignoreDiacritics:d=De.ignoreDiacritics,ignoreLocation:p=De.ignoreLocation}={}){if(this.options={location:n,threshold:i,distance:s,includeMatches:l,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:p},t=u?t:t.toLowerCase(),t=d?cc(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const f=(v,w)=>{this.chunks.push({pattern:v,alphabet:l8(v),startIndex:w})},m=this.pattern.length;if(m>ia){let v=0;const w=m%ia,E=m-w;for(;v<E;)f(this.pattern.substr(v,ia),v),v+=ia;if(w){const b=m-ia;f(this.pattern.substr(b),b)}}else f(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:i,includeMatches:s}=this.options;if(t=n?t:t.toLowerCase(),t=i?cc(t):t,this.pattern===t){let E={isMatch:!0,score:0};return s&&(E.indices=[[0,t.length-1]]),E}const{location:l,distance:c,threshold:o,findAllMatches:u,minMatchCharLength:d,ignoreLocation:p}=this.options;let f=[],m=0,v=!1;this.chunks.forEach(({pattern:E,alphabet:b,startIndex:_})=>{const{isMatch:x,score:S,indices:k}=o8(t,E,b,{location:l+_,distance:c,threshold:o,findAllMatches:u,minMatchCharLength:d,includeMatches:s,ignoreLocation:p});x&&(v=!0),m+=S,x&&k&&(f=[...f,...k])});let w={isMatch:v,score:v?m/this.chunks.length:1};return v&&s&&(w.indices=f),w}}class Bi{constructor(t){this.pattern=t}static isMultiMatch(t){return wE(t,this.multiRegex)}static isSingleMatch(t){return wE(t,this.singleRegex)}search(){}}function wE(e,t){const n=e.match(t);return n?n[1]:null}class u8 extends Bi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class c8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class d8 extends Bi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class h8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class p8 extends Bi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class f8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class WO extends Bi{constructor(t,{location:n=De.location,threshold:i=De.threshold,distance:s=De.distance,includeMatches:l=De.includeMatches,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,isCaseSensitive:u=De.isCaseSensitive,ignoreDiacritics:d=De.ignoreDiacritics,ignoreLocation:p=De.ignoreLocation}={}){super(t),this._bitapSearch=new GO(t,{location:n,threshold:i,distance:s,includeMatches:l,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class VO extends Bi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,i;const s=[],l=this.pattern.length;for(;(i=t.indexOf(this.pattern,n))>-1;)n=i+l,s.push([i,n-1]);const c=!!s.length;return{isMatch:c,score:c?0:1,indices:s}}}const Ky=[u8,VO,d8,h8,f8,p8,c8,WO],CE=Ky.length,m8=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,g8="|";function b8(e,t={}){return e.split(g8).map(n=>{let i=n.trim().split(m8).filter(l=>l&&!!l.trim()),s=[];for(let l=0,c=i.length;l<c;l+=1){const o=i[l];let u=!1,d=-1;for(;!u&&++d<CE;){const p=Ky[d];let f=p.isMultiMatch(o);f&&(s.push(new p(f,t)),u=!0)}if(!u)for(d=-1;++d<CE;){const p=Ky[d];let f=p.isSingleMatch(o);if(f){s.push(new p(f,t));break}}}return s})}const y8=new Set([WO.type,VO.type]);class v8{constructor(t,{isCaseSensitive:n=De.isCaseSensitive,ignoreDiacritics:i=De.ignoreDiacritics,includeMatches:s=De.includeMatches,minMatchCharLength:l=De.minMatchCharLength,ignoreLocation:c=De.ignoreLocation,findAllMatches:o=De.findAllMatches,location:u=De.location,threshold:d=De.threshold,distance:p=De.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:i,includeMatches:s,minMatchCharLength:l,findAllMatches:o,ignoreLocation:c,location:u,threshold:d,distance:p},t=n?t:t.toLowerCase(),t=i?cc(t):t,this.pattern=t,this.query=b8(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s,ignoreDiacritics:l}=this.options;t=s?t:t.toLowerCase(),t=l?cc(t):t;let c=0,o=[],u=0;for(let d=0,p=n.length;d<p;d+=1){const f=n[d];o.length=0,c=0;for(let m=0,v=f.length;m<v;m+=1){const w=f[m],{isMatch:E,indices:b,score:_}=w.search(t);if(E){if(c+=1,u+=_,i){const x=w.constructor.type;y8.has(x)?o=[...o,...b]:o.push(b)}}else{u=0,c=0,o.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return i&&(m.indices=o),m}}return{isMatch:!1,score:1}}}const Yy=[];function _8(...e){Yy.push(...e)}function Xy(e,t){for(let n=0,i=Yy.length;n<i;n+=1){let s=Yy[n];if(s.condition(e,t))return new s(e,t)}return new GO(e,t)}const dc={AND:"$and",OR:"$or"},Zy={PATH:"$path",PATTERN:"$val"},Qy=e=>!!(e[dc.AND]||e[dc.OR]),S8=e=>!!e[Zy.PATH],x8=e=>!Xr(e)&&HO(e)&&!Qy(e),kE=e=>({[dc.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function KO(e,t,{auto:n=!0}={}){const i=s=>{let l=Object.keys(s);const c=S8(s);if(!c&&l.length>1&&!Qy(s))return i(kE(s));if(x8(s)){const u=c?s[Zy.PATH]:l[0],d=c?s[Zy.PATTERN]:s[u];if(!xr(d))throw new Error(VF(u));const p={keyId:Vy(u),pattern:d};return n&&(p.searcher=Xy(d,t)),p}let o={children:[],operator:l[0]};return l.forEach(u=>{const d=s[u];Xr(d)&&d.forEach(p=>{o.children.push(i(p))})}),o};return Qy(e)||(e=kE(e)),i(e)}function E8(e,{ignoreFieldNorm:t=De.ignoreFieldNorm}){e.forEach(n=>{let i=1;n.matches.forEach(({key:s,norm:l,score:c})=>{const o=s?s.weight:null;i*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(t?1:l))}),n.score=i})}function w8(e,t){const n=e.matches;t.matches=[],Fn(n)&&n.forEach(i=>{if(!Fn(i.indices)||!i.indices.length)return;const{indices:s,value:l}=i;let c={indices:s,value:l};i.key&&(c.key=i.key.src),i.idx>-1&&(c.refIndex=i.idx),t.matches.push(c)})}function C8(e,t){t.score=e.score}function k8(e,t,{includeMatches:n=De.includeMatches,includeScore:i=De.includeScore}={}){const s=[];return n&&s.push(w8),i&&s.push(C8),e.map(l=>{const{idx:c}=l,o={item:t[c],refIndex:c};return s.length&&s.forEach(u=>{u(l,o)}),o})}class Fi{constructor(t,n={},i){this.options={...De,...n},this.options.useExtendedSearch,this._keyStore=new ZF(this.options.keys),this.setCollection(t,i)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof Gv))throw new Error(WF);this._myIndex=n||$O(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Fn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let i=0,s=this._docs.length;i<s;i+=1){const l=this._docs[i];t(l,i)&&(this.removeAt(i),i-=1,s-=1,n.push(l))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:l,sortFn:c,ignoreFieldNorm:o}=this.options;let u=xr(t)?xr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return E8(u,{ignoreFieldNorm:o}),l&&u.sort(c),UO(n)&&n>-1&&(u=u.slice(0,n)),k8(u,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const n=Xy(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:l,i:c,n:o})=>{if(!Fn(l))return;const{isMatch:u,score:d,indices:p}=n.searchIn(l);u&&s.push({item:l,idx:c,matches:[{score:d,value:l,norm:o,indices:p}]})}),s}_searchLogical(t){const n=KO(t,this.options),i=(o,u,d)=>{if(!o.children){const{keyId:f,searcher:m}=o,v=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(u,f),searcher:m});return v&&v.length?[{idx:d,item:u,matches:v}]:[]}const p=[];for(let f=0,m=o.children.length;f<m;f+=1){const v=o.children[f],w=i(v,u,d);if(w.length)p.push(...w);else if(o.operator===dc.AND)return[]}return p},s=this._myIndex.records,l={},c=[];return s.forEach(({$:o,i:u})=>{if(Fn(o)){let d=i(n,o,u);d.length&&(l[u]||(l[u]={idx:u,item:o,matches:[]},c.push(l[u])),d.forEach(({matches:p})=>{l[u].matches.push(...p)}))}}),c}_searchObjectList(t){const n=Xy(t,this.options),{keys:i,records:s}=this._myIndex,l=[];return s.forEach(({$:c,i:o})=>{if(!Fn(c))return;let u=[];i.forEach((d,p)=>{u.push(...this._findMatches({key:d,value:c[p],searcher:n}))}),u.length&&l.push({idx:o,item:c,matches:u})}),l}_findMatches({key:t,value:n,searcher:i}){if(!Fn(n))return[];let s=[];if(Xr(n))n.forEach(({v:l,i:c,n:o})=>{if(!Fn(l))return;const{isMatch:u,score:d,indices:p}=i.searchIn(l);u&&s.push({score:d,key:t,value:l,idx:c,norm:o,indices:p})});else{const{v:l,n:c}=n,{isMatch:o,score:u,indices:d}=i.searchIn(l);o&&s.push({score:u,key:t,value:l,norm:c,indices:d})}return s}}Fi.version="7.1.0";Fi.createIndex=$O;Fi.parseIndex=a8;Fi.config=De;Fi.parseQuery=KO;_8(v8);function T8(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":case"js":case"jsx":case"mjs":case"cjs":case"py":case"rb":case"go":case"rs":case"java":case"c":case"cpp":case"h":case"hpp":return OO;case"json":case"yaml":case"yml":case"toml":return OB;case"md":case"txt":case"log":return kc;case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return LO;case"css":case"scss":case"sass":case"less":return Y6;case"html":case"xml":return BB;default:return Li}}function R8(e,t){const n=t.get(e);return n?{added:{icon:Wo,label:"Added",className:"text-green-500"},modified:{icon:SE,label:"Modified",className:"text-yellow-500"},untracked:{icon:Wo,label:"Untracked",className:"text-blue-500"}}[n]||{icon:SE,label:"Modified",className:"text-yellow-500"}:null}function A8({files:e,changedFiles:t=[],query:n,selectedIndex:i,onSelect:s,onEnterSelect:l,onClose:c}){const o=q.useMemo(()=>new Map(t?.map(p=>[p.path,p.status])||[]),[t]),u=q.useMemo(()=>new Fi(e,{threshold:.4,distance:100,ignoreLocation:!0,includeMatches:!0}),[e]),d=q.useMemo(()=>{if(!n)return e.slice(0,20);const p=u.search(n).map(f=>f.item);return p.sort((f,m)=>{const v=o.has(f),w=o.has(m);return v&&!w?-1:!v&&w?1:0}),p.slice(0,20)},[u,n,e,o]);return q.useEffect(()=>{document.getElementById(`file-item-${i}`)?.scrollIntoView({block:"nearest"})},[i]),q.useEffect(()=>{l(d[i])},[d,i,l]),q.useEffect(()=>{const p=f=>{f.target.closest("[data-file-mention-popup]")||c()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[c]),d.length===0?y.jsx("div",{"data-file-mention-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg z-50 p-3",children:y.jsx("span",{className:"text-muted-foreground text-sm",children:"No files found"})}):y.jsx("div",{"data-file-mention-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg max-h-[300px] overflow-y-auto z-50",children:d.map((p,f)=>y.jsx("button",{type:"button",id:`file-item-${f}`,onMouseDown:m=>{m.preventDefault(),s(p)},className:`w-full text-left px-3 py-2 hover:bg-accent ${f===i?"bg-accent":""}`,children:y.jsxs("div",{className:"flex items-center gap-2 w-full",children:[(()=>{const m=T8(p);return y.jsx(m,{className:"w-4 h-4 flex-shrink-0 text-muted-foreground"})})(),y.jsx("span",{className:"font-mono text-sm flex-1 truncate",children:p}),(()=>{const m=R8(p,o);return m&&y.jsx(m.icon,{className:`w-3.5 h-3.5 flex-shrink-0 ${m.className}`,title:m.label})})()]})},p))})}const YO="agi-preferences",zu={vimMode:!1,reasoningEnabled:!0};function N8(){if(typeof window>"u")return zu;try{const e=window.localStorage.getItem(YO);if(e){const t=JSON.parse(e);return{...zu,...t}}}catch(e){console.warn("Failed to load preferences",e)}return zu}let qu=N8();const Jy=new Set;function O8(){return qu}function D8(){return zu}function I8(e){return Jy.add(e),()=>Jy.delete(e)}function L8(){for(const e of Jy)e()}function M8(e){if(qu={...qu,...e},typeof window<"u")try{window.localStorage.setItem(YO,JSON.stringify(qu))}catch(t){console.warn("Failed to persist preferences",t)}L8()}function Jo(){const e=q.useSyncExternalStore(I8,O8,D8),t=q.useCallback(n=>{M8(n)},[]);return q.useMemo(()=>({preferences:e,updatePreferences:t}),[e,t])}var TE;(function(e){e.OPENAI="openai",e.ANTHROPIC="anthropic",e.GOOGLE="google",e.OPENROUTER="openrouter",e.OPENCODE="opencode",e.ZAI="zai",e.ZAI_CODING="zai-coding",e.MOONSHOT="moonshot",e.SOLFORGE="solforge"})(TE||(TE={}));function XO(e,t){return function(){return e.apply(t,arguments)}}const{toString:B8}=Object.prototype,{getPrototypeOf:Wv}=Object,{iterator:Tc,toStringTag:ZO}=Symbol,Rc=(e=>t=>{const n=B8.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),pr=e=>(e=e.toLowerCase(),t=>Rc(t)===e),Ac=e=>t=>typeof t===e,{isArray:ks}=Array,xs=Ac("undefined");function el(e){return e!==null&&!xs(e)&&e.constructor!==null&&!xs(e.constructor)&&En(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const QO=pr("ArrayBuffer");function F8(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&QO(e.buffer),t}const j8=Ac("string"),En=Ac("function"),JO=Ac("number"),tl=e=>e!==null&&typeof e=="object",P8=e=>e===!0||e===!1,$u=e=>{if(Rc(e)!=="object")return!1;const t=Wv(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ZO in e)&&!(Tc in e)},U8=e=>{if(!tl(e)||el(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},H8=pr("Date"),z8=pr("File"),q8=pr("Blob"),$8=pr("FileList"),G8=e=>tl(e)&&En(e.pipe),W8=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||En(e.append)&&((t=Rc(e))==="formdata"||t==="object"&&En(e.toString)&&e.toString()==="[object FormData]"))},V8=pr("URLSearchParams"),[K8,Y8,X8,Z8]=["ReadableStream","Request","Response","Headers"].map(pr),Q8=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nl(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let i,s;if(typeof e!="object"&&(e=[e]),ks(e))for(i=0,s=e.length;i<s;i++)t.call(null,e[i],i,e);else{if(el(e))return;const l=n?Object.getOwnPropertyNames(e):Object.keys(e),c=l.length;let o;for(i=0;i<c;i++)o=l[i],t.call(null,e[o],o,e)}}function eD(e,t){if(el(e))return null;t=t.toLowerCase();const n=Object.keys(e);let i=n.length,s;for(;i-- >0;)if(s=n[i],t===s.toLowerCase())return s;return null}const la=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tD=e=>!xs(e)&&e!==la;function ev(){const{caseless:e,skipUndefined:t}=tD(this)&&this||{},n={},i=(s,l)=>{const c=e&&eD(n,l)||l;$u(n[c])&&$u(s)?n[c]=ev(n[c],s):$u(s)?n[c]=ev({},s):ks(s)?n[c]=s.slice():(!t||!xs(s))&&(n[c]=s)};for(let s=0,l=arguments.length;s<l;s++)arguments[s]&&nl(arguments[s],i);return n}const J8=(e,t,n,{allOwnKeys:i}={})=>(nl(t,(s,l)=>{n&&En(s)?Object.defineProperty(e,l,{value:XO(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,l,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),e),ej=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),tj=(e,t,n,i)=>{e.prototype=Object.create(t.prototype,i),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},nj=(e,t,n,i)=>{let s,l,c;const o={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),l=s.length;l-- >0;)c=s[l],(!i||i(c,e,t))&&!o[c]&&(t[c]=e[c],o[c]=!0);e=n!==!1&&Wv(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},rj=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const i=e.indexOf(t,n);return i!==-1&&i===n},ij=e=>{if(!e)return null;if(ks(e))return e;let t=e.length;if(!JO(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},aj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Wv(Uint8Array)),sj=(e,t)=>{const i=(e&&e[Tc]).call(e);let s;for(;(s=i.next())&&!s.done;){const l=s.value;t.call(e,l[0],l[1])}},oj=(e,t)=>{let n;const i=[];for(;(n=e.exec(t))!==null;)i.push(n);return i},lj=pr("HTMLFormElement"),uj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,i,s){return i.toUpperCase()+s}),RE=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cj=pr("RegExp"),nD=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),i={};nl(n,(s,l)=>{let c;(c=t(s,l,e))!==!1&&(i[l]=c||s)}),Object.defineProperties(e,i)},dj=e=>{nD(e,(t,n)=>{if(En(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const i=e[n];if(En(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},hj=(e,t)=>{const n={},i=s=>{s.forEach(l=>{n[l]=!0})};return ks(e)?i(e):i(String(e).split(t)),n},pj=()=>{},fj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function mj(e){return!!(e&&En(e.append)&&e[ZO]==="FormData"&&e[Tc])}const gj=e=>{const t=new Array(10),n=(i,s)=>{if(tl(i)){if(t.indexOf(i)>=0)return;if(el(i))return i;if(!("toJSON"in i)){t[s]=i;const l=ks(i)?[]:{};return nl(i,(c,o)=>{const u=n(c,s+1);!xs(u)&&(l[o]=u)}),t[s]=void 0,l}}return i};return n(e,0)},bj=pr("AsyncFunction"),yj=e=>e&&(tl(e)||En(e))&&En(e.then)&&En(e.catch),rD=((e,t)=>e?setImmediate:t?((n,i)=>(la.addEventListener("message",({source:s,data:l})=>{s===la&&l===n&&i.length&&i.shift()()},!1),s=>{i.push(s),la.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",En(la.postMessage)),vj=typeof queueMicrotask<"u"?queueMicrotask.bind(la):typeof process<"u"&&process.nextTick||rD,_j=e=>e!=null&&En(e[Tc]),ue={isArray:ks,isArrayBuffer:QO,isBuffer:el,isFormData:W8,isArrayBufferView:F8,isString:j8,isNumber:JO,isBoolean:P8,isObject:tl,isPlainObject:$u,isEmptyObject:U8,isReadableStream:K8,isRequest:Y8,isResponse:X8,isHeaders:Z8,isUndefined:xs,isDate:H8,isFile:z8,isBlob:q8,isRegExp:cj,isFunction:En,isStream:G8,isURLSearchParams:V8,isTypedArray:aj,isFileList:$8,forEach:nl,merge:ev,extend:J8,trim:Q8,stripBOM:ej,inherits:tj,toFlatObject:nj,kindOf:Rc,kindOfTest:pr,endsWith:rj,toArray:ij,forEachEntry:sj,matchAll:oj,isHTMLForm:lj,hasOwnProperty:RE,hasOwnProp:RE,reduceDescriptors:nD,freezeMethods:dj,toObjectSet:hj,toCamelCase:uj,noop:pj,toFiniteNumber:fj,findKey:eD,global:la,isContextDefined:tD,isSpecCompliantForm:mj,toJSONObject:gj,isAsyncFn:bj,isThenable:yj,setImmediate:rD,asap:vj,isIterable:_j};let Ie=class iD extends Error{static from(t,n,i,s,l,c){const o=new iD(t.message,n||t.code,i,s,l);return o.cause=t,o.name=t.name,c&&Object.assign(o,c),o}constructor(t,n,i,s,l){super(t),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),i&&(this.config=i),s&&(this.request=s),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ue.toJSONObject(this.config),code:this.code,status:this.status}}};Ie.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ie.ERR_BAD_OPTION="ERR_BAD_OPTION";Ie.ECONNABORTED="ECONNABORTED";Ie.ETIMEDOUT="ETIMEDOUT";Ie.ERR_NETWORK="ERR_NETWORK";Ie.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ie.ERR_DEPRECATED="ERR_DEPRECATED";Ie.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ie.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ie.ERR_CANCELED="ERR_CANCELED";Ie.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ie.ERR_INVALID_URL="ERR_INVALID_URL";const Sj=null;function tv(e){return ue.isPlainObject(e)||ue.isArray(e)}function aD(e){return ue.endsWith(e,"[]")?e.slice(0,-2):e}function AE(e,t,n){return e?e.concat(t).map(function(s,l){return s=aD(s),!n&&l?"["+s+"]":s}).join(n?".":""):t}function xj(e){return ue.isArray(e)&&!e.some(tv)}const Ej=ue.toFlatObject(ue,{},null,function(t){return/^is[A-Z]/.test(t)});function Nc(e,t,n){if(!ue.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=ue.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,b){return!ue.isUndefined(b[E])});const i=n.metaTokens,s=n.visitor||p,l=n.dots,c=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&ue.isSpecCompliantForm(t);if(!ue.isFunction(s))throw new TypeError("visitor must be a function");function d(w){if(w===null)return"";if(ue.isDate(w))return w.toISOString();if(ue.isBoolean(w))return w.toString();if(!u&&ue.isBlob(w))throw new Ie("Blob is not supported. Use a Buffer instead.");return ue.isArrayBuffer(w)||ue.isTypedArray(w)?u&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function p(w,E,b){let _=w;if(w&&!b&&typeof w=="object"){if(ue.endsWith(E,"{}"))E=i?E:E.slice(0,-2),w=JSON.stringify(w);else if(ue.isArray(w)&&xj(w)||(ue.isFileList(w)||ue.endsWith(E,"[]"))&&(_=ue.toArray(w)))return E=aD(E),_.forEach(function(S,k){!(ue.isUndefined(S)||S===null)&&t.append(c===!0?AE([E],k,l):c===null?E:E+"[]",d(S))}),!1}return tv(w)?!0:(t.append(AE(b,E,l),d(w)),!1)}const f=[],m=Object.assign(Ej,{defaultVisitor:p,convertValue:d,isVisitable:tv});function v(w,E){if(!ue.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(w),ue.forEach(w,function(_,x){(!(ue.isUndefined(_)||_===null)&&s.call(t,_,ue.isString(x)?x.trim():x,E,m))===!0&&v(_,E?E.concat(x):[x])}),f.pop()}}if(!ue.isObject(e))throw new TypeError("data must be an object");return v(e),t}function NE(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Vv(e,t){this._pairs=[],e&&Nc(e,this,t)}const sD=Vv.prototype;sD.append=function(t,n){this._pairs.push([t,n])};sD.toString=function(t){const n=t?function(i){return t.call(this,i,NE)}:NE;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function oD(e,t,n){if(!t)return e;const i=n&&n.encode||wj,s=ue.isFunction(n)?{serialize:n}:n,l=s&&s.serialize;let c;if(l?c=l(t,s):c=ue.isURLSearchParams(t)?t.toString():new Vv(t,s).toString(i),c){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+c}return e}class OE{constructor(){this.handlers=[]}use(t,n,i){return this.handlers.push({fulfilled:t,rejected:n,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ue.forEach(this.handlers,function(i){i!==null&&t(i)})}}const lD={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cj=typeof URLSearchParams<"u"?URLSearchParams:Vv,kj=typeof FormData<"u"?FormData:null,Tj=typeof Blob<"u"?Blob:null,Rj={isBrowser:!0,classes:{URLSearchParams:Cj,FormData:kj,Blob:Tj},protocols:["http","https","file","blob","url","data"]},Kv=typeof window<"u"&&typeof document<"u",nv=typeof navigator=="object"&&navigator||void 0,Aj=Kv&&(!nv||["ReactNative","NativeScript","NS"].indexOf(nv.product)<0),Nj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Oj=Kv&&window.location.href||"http://localhost",Dj=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Kv,hasStandardBrowserEnv:Aj,hasStandardBrowserWebWorkerEnv:Nj,navigator:nv,origin:Oj},Symbol.toStringTag,{value:"Module"})),an={...Dj,...Rj};function Ij(e,t){return Nc(e,new an.classes.URLSearchParams,{visitor:function(n,i,s,l){return an.isNode&&ue.isBuffer(n)?(this.append(i,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...t})}function Lj(e){return ue.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Mj(e){const t={},n=Object.keys(e);let i;const s=n.length;let l;for(i=0;i<s;i++)l=n[i],t[l]=e[l];return t}function uD(e){function t(n,i,s,l){let c=n[l++];if(c==="__proto__")return!0;const o=Number.isFinite(+c),u=l>=n.length;return c=!c&&ue.isArray(s)?s.length:c,u?(ue.hasOwnProp(s,c)?s[c]=[s[c],i]:s[c]=i,!o):((!s[c]||!ue.isObject(s[c]))&&(s[c]=[]),t(n,i,s[c],l)&&ue.isArray(s[c])&&(s[c]=Mj(s[c])),!o)}if(ue.isFormData(e)&&ue.isFunction(e.entries)){const n={};return ue.forEachEntry(e,(i,s)=>{t(Lj(i),s,n,0)}),n}return null}function Bj(e,t,n){if(ue.isString(e))try{return(t||JSON.parse)(e),ue.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(n||JSON.stringify)(e)}const rl={transitional:lD,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const i=n.getContentType()||"",s=i.indexOf("application/json")>-1,l=ue.isObject(t);if(l&&ue.isHTMLForm(t)&&(t=new FormData(t)),ue.isFormData(t))return s?JSON.stringify(uD(t)):t;if(ue.isArrayBuffer(t)||ue.isBuffer(t)||ue.isStream(t)||ue.isFile(t)||ue.isBlob(t)||ue.isReadableStream(t))return t;if(ue.isArrayBufferView(t))return t.buffer;if(ue.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(l){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Ij(t,this.formSerializer).toString();if((o=ue.isFileList(t))||i.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Nc(o?{"files[]":t}:t,u&&new u,this.formSerializer)}}return l||s?(n.setContentType("application/json",!1),Bj(t)):t}],transformResponse:[function(t){const n=this.transitional||rl.transitional,i=n&&n.forcedJSONParsing,s=this.responseType==="json";if(ue.isResponse(t)||ue.isReadableStream(t))return t;if(t&&ue.isString(t)&&(i&&!this.responseType||s)){const c=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(o){if(c)throw o.name==="SyntaxError"?Ie.from(o,Ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:an.classes.FormData,Blob:an.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ue.forEach(["delete","get","head","post","put","patch"],e=>{rl.headers[e]={}});const Fj=ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),jj=e=>{const t={};let n,i,s;return e&&e.split(`
15
+ `,onClick:s,role:"alert",children:[PF[e.type],y.jsx("span",{className:"text-sm text-foreground",children:e.message}),e.action&&y.jsxs("a",{href:e.action.href,target:"_blank",rel:"noopener noreferrer",onClick:l=>l.stopPropagation(),className:"ml-auto flex items-center gap-1 text-xs text-primary hover:underline",children:[e.action.label,y.jsx(wr,{className:"h-3 w-3"})]})]})}function HF(){const e=Cr(t=>t.toasts);return e.length===0?null:y.jsx("div",{className:"fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 max-w-sm",children:e.map(t=>y.jsx(UF,{toast:t},t.id))})}const $v=$n(e=>({pendingApprovals:[],addPendingApproval:t=>e(n=>({pendingApprovals:[...n.pendingApprovals,t]})),removePendingApproval:t=>e(n=>({pendingApprovals:n.pendingApprovals.filter(i=>i.callId!==t)})),updatePendingApproval:(t,n)=>e(i=>({pendingApprovals:i.pendingApprovals.map(s=>s.callId===t?{...s,args:n}:s)})),clearPendingApprovals:()=>e({pendingApprovals:[]}),setPendingApprovals:t=>e({pendingApprovals:t})}));function Xr(e){return Array.isArray?Array.isArray(e):zO(e)==="[object Array]"}function zF(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function qF(e){return e==null?"":zF(e)}function xr(e){return typeof e=="string"}function UO(e){return typeof e=="number"}function $F(e){return e===!0||e===!1||GF(e)&&zO(e)=="[object Boolean]"}function HO(e){return typeof e=="object"}function GF(e){return HO(e)&&e!==null}function Fn(e){return e!=null}function Tp(e){return!e.trim().length}function zO(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const WF="Incorrect 'index' type",VF=e=>`Invalid value for key ${e}`,KF=e=>`Pattern length exceeds max of ${e}.`,YF=e=>`Missing ${e} property in key`,XF=e=>`Property 'weight' in key '${e}' must be a positive integer`,xE=Object.prototype.hasOwnProperty;class ZF{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(i=>{let s=qO(i);this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(i=>{i.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function qO(e){let t=null,n=null,i=null,s=1,l=null;if(xr(e)||Xr(e))i=e,t=EE(e),n=Vy(e);else{if(!xE.call(e,"name"))throw new Error(YF("name"));const c=e.name;if(i=c,xE.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(XF(c));t=EE(c),n=Vy(c),l=e.getFn}return{path:t,id:n,weight:s,src:i,getFn:l}}function EE(e){return Xr(e)?e:e.split(".")}function Vy(e){return Xr(e)?e.join("."):e}function QF(e,t){let n=[],i=!1;const s=(l,c,o)=>{if(Fn(l))if(!c[o])n.push(l);else{let u=c[o];const d=l[u];if(!Fn(d))return;if(o===c.length-1&&(xr(d)||UO(d)||$F(d)))n.push(qF(d));else if(Xr(d)){i=!0;for(let p=0,f=d.length;p<f;p+=1)s(d[p],c,o+1)}else c.length&&s(d,c,o+1)}};return s(e,xr(t)?t.split("."):t,0),i?n:n[0]}const JF={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},e8={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},t8={location:0,threshold:.6,distance:100},n8={useExtendedSearch:!1,getFn:QF,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var De={...e8,...JF,...t8,...n8};const r8=/[^ ]+/g;function i8(e=1,t=3){const n=new Map,i=Math.pow(10,t);return{get(s){const l=s.match(r8).length;if(n.has(l))return n.get(l);const c=1/Math.pow(l,.5*e),o=parseFloat(Math.round(c*i)/i);return n.set(l,o),o},clear(){n.clear()}}}class Gv{constructor({getFn:t=De.getFn,fieldNormWeight:n=De.fieldNormWeight}={}){this.norm=i8(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,i)=>{this._keysMap[n.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,xr(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();xr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,i=this.size();n<i;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Fn(t)||Tp(t))return;let i={v:t,i:n,n:this.norm.get(t)};this.records.push(i)}_addObject(t,n){let i={i:n,$:{}};this.keys.forEach((s,l)=>{let c=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Fn(c)){if(Xr(c)){let o=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:d,value:p}=u.pop();if(Fn(p))if(xr(p)&&!Tp(p)){let f={v:p,i:d,n:this.norm.get(p)};o.push(f)}else Xr(p)&&p.forEach((f,m)=>{u.push({nestedArrIndex:m,value:f})})}i.$[l]=o}else if(xr(c)&&!Tp(c)){let o={v:c,n:this.norm.get(c)};i.$[l]=o}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function $O(e,t,{getFn:n=De.getFn,fieldNormWeight:i=De.fieldNormWeight}={}){const s=new Gv({getFn:n,fieldNormWeight:i});return s.setKeys(e.map(qO)),s.setSources(t),s.create(),s}function a8(e,{getFn:t=De.getFn,fieldNormWeight:n=De.fieldNormWeight}={}){const{keys:i,records:s}=e,l=new Gv({getFn:t,fieldNormWeight:n});return l.setKeys(i),l.setIndexRecords(s),l}function Ru(e,{errors:t=0,currentLocation:n=0,expectedLocation:i=0,distance:s=De.distance,ignoreLocation:l=De.ignoreLocation}={}){const c=t/e.length;if(l)return c;const o=Math.abs(i-n);return s?c+o/s:o?1:c}function s8(e=[],t=De.minMatchCharLength){let n=[],i=-1,s=-1,l=0;for(let c=e.length;l<c;l+=1){let o=e[l];o&&i===-1?i=l:!o&&i!==-1&&(s=l-1,s-i+1>=t&&n.push([i,s]),i=-1)}return e[l-1]&&l-i>=t&&n.push([i,l-1]),n}const ia=32;function o8(e,t,n,{location:i=De.location,distance:s=De.distance,threshold:l=De.threshold,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,includeMatches:u=De.includeMatches,ignoreLocation:d=De.ignoreLocation}={}){if(t.length>ia)throw new Error(KF(ia));const p=t.length,f=e.length,m=Math.max(0,Math.min(i,f));let v=l,w=m;const E=o>1||u,b=E?Array(f):[];let _;for(;(_=e.indexOf(t,w))>-1;){let A=Ru(t,{currentLocation:_,expectedLocation:m,distance:s,ignoreLocation:d});if(v=Math.min(A,v),w=_+p,E){let R=0;for(;R<p;)b[_+R]=1,R+=1}}w=-1;let x=[],S=1,k=p+f;const O=1<<p-1;for(let A=0;A<p;A+=1){let R=0,D=k;for(;R<D;)Ru(t,{errors:A,currentLocation:m+D,expectedLocation:m,distance:s,ignoreLocation:d})<=v?R=D:k=D,D=Math.floor((k-R)/2+R);k=D;let L=Math.max(1,m-D+1),I=c?f:Math.min(m+D,f)+p,H=Array(I+2);H[I+1]=(1<<A)-1;for(let W=I;W>=L;W-=1){let K=W-1,V=n[e.charAt(K)];if(E&&(b[K]=+!!V),H[W]=(H[W+1]<<1|1)&V,A&&(H[W]|=(x[W+1]|x[W])<<1|1|x[W+1]),H[W]&O&&(S=Ru(t,{errors:A,currentLocation:K,expectedLocation:m,distance:s,ignoreLocation:d}),S<=v)){if(v=S,w=K,w<=m)break;L=Math.max(1,2*m-w)}}if(Ru(t,{errors:A+1,currentLocation:m,expectedLocation:m,distance:s,ignoreLocation:d})>v)break;x=H}const T={isMatch:w>=0,score:Math.max(.001,S)};if(E){const A=s8(b,o);A.length?u&&(T.indices=A):T.isMatch=!1}return T}function l8(e){let t={};for(let n=0,i=e.length;n<i;n+=1){const s=e.charAt(n);t[s]=(t[s]||0)|1<<i-n-1}return t}const cc=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class GO{constructor(t,{location:n=De.location,threshold:i=De.threshold,distance:s=De.distance,includeMatches:l=De.includeMatches,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,isCaseSensitive:u=De.isCaseSensitive,ignoreDiacritics:d=De.ignoreDiacritics,ignoreLocation:p=De.ignoreLocation}={}){if(this.options={location:n,threshold:i,distance:s,includeMatches:l,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:p},t=u?t:t.toLowerCase(),t=d?cc(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const f=(v,w)=>{this.chunks.push({pattern:v,alphabet:l8(v),startIndex:w})},m=this.pattern.length;if(m>ia){let v=0;const w=m%ia,E=m-w;for(;v<E;)f(this.pattern.substr(v,ia),v),v+=ia;if(w){const b=m-ia;f(this.pattern.substr(b),b)}}else f(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:i,includeMatches:s}=this.options;if(t=n?t:t.toLowerCase(),t=i?cc(t):t,this.pattern===t){let E={isMatch:!0,score:0};return s&&(E.indices=[[0,t.length-1]]),E}const{location:l,distance:c,threshold:o,findAllMatches:u,minMatchCharLength:d,ignoreLocation:p}=this.options;let f=[],m=0,v=!1;this.chunks.forEach(({pattern:E,alphabet:b,startIndex:_})=>{const{isMatch:x,score:S,indices:k}=o8(t,E,b,{location:l+_,distance:c,threshold:o,findAllMatches:u,minMatchCharLength:d,includeMatches:s,ignoreLocation:p});x&&(v=!0),m+=S,x&&k&&(f=[...f,...k])});let w={isMatch:v,score:v?m/this.chunks.length:1};return v&&s&&(w.indices=f),w}}class Bi{constructor(t){this.pattern=t}static isMultiMatch(t){return wE(t,this.multiRegex)}static isSingleMatch(t){return wE(t,this.singleRegex)}search(){}}function wE(e,t){const n=e.match(t);return n?n[1]:null}class u8 extends Bi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class c8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class d8 extends Bi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class h8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class p8 extends Bi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class f8 extends Bi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class WO extends Bi{constructor(t,{location:n=De.location,threshold:i=De.threshold,distance:s=De.distance,includeMatches:l=De.includeMatches,findAllMatches:c=De.findAllMatches,minMatchCharLength:o=De.minMatchCharLength,isCaseSensitive:u=De.isCaseSensitive,ignoreDiacritics:d=De.ignoreDiacritics,ignoreLocation:p=De.ignoreLocation}={}){super(t),this._bitapSearch=new GO(t,{location:n,threshold:i,distance:s,includeMatches:l,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class VO extends Bi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,i;const s=[],l=this.pattern.length;for(;(i=t.indexOf(this.pattern,n))>-1;)n=i+l,s.push([i,n-1]);const c=!!s.length;return{isMatch:c,score:c?0:1,indices:s}}}const Ky=[u8,VO,d8,h8,f8,p8,c8,WO],CE=Ky.length,m8=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,g8="|";function b8(e,t={}){return e.split(g8).map(n=>{let i=n.trim().split(m8).filter(l=>l&&!!l.trim()),s=[];for(let l=0,c=i.length;l<c;l+=1){const o=i[l];let u=!1,d=-1;for(;!u&&++d<CE;){const p=Ky[d];let f=p.isMultiMatch(o);f&&(s.push(new p(f,t)),u=!0)}if(!u)for(d=-1;++d<CE;){const p=Ky[d];let f=p.isSingleMatch(o);if(f){s.push(new p(f,t));break}}}return s})}const y8=new Set([WO.type,VO.type]);class v8{constructor(t,{isCaseSensitive:n=De.isCaseSensitive,ignoreDiacritics:i=De.ignoreDiacritics,includeMatches:s=De.includeMatches,minMatchCharLength:l=De.minMatchCharLength,ignoreLocation:c=De.ignoreLocation,findAllMatches:o=De.findAllMatches,location:u=De.location,threshold:d=De.threshold,distance:p=De.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:i,includeMatches:s,minMatchCharLength:l,findAllMatches:o,ignoreLocation:c,location:u,threshold:d,distance:p},t=n?t:t.toLowerCase(),t=i?cc(t):t,this.pattern=t,this.query=b8(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s,ignoreDiacritics:l}=this.options;t=s?t:t.toLowerCase(),t=l?cc(t):t;let c=0,o=[],u=0;for(let d=0,p=n.length;d<p;d+=1){const f=n[d];o.length=0,c=0;for(let m=0,v=f.length;m<v;m+=1){const w=f[m],{isMatch:E,indices:b,score:_}=w.search(t);if(E){if(c+=1,u+=_,i){const x=w.constructor.type;y8.has(x)?o=[...o,...b]:o.push(b)}}else{u=0,c=0,o.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return i&&(m.indices=o),m}}return{isMatch:!1,score:1}}}const Yy=[];function _8(...e){Yy.push(...e)}function Xy(e,t){for(let n=0,i=Yy.length;n<i;n+=1){let s=Yy[n];if(s.condition(e,t))return new s(e,t)}return new GO(e,t)}const dc={AND:"$and",OR:"$or"},Zy={PATH:"$path",PATTERN:"$val"},Qy=e=>!!(e[dc.AND]||e[dc.OR]),S8=e=>!!e[Zy.PATH],x8=e=>!Xr(e)&&HO(e)&&!Qy(e),kE=e=>({[dc.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function KO(e,t,{auto:n=!0}={}){const i=s=>{let l=Object.keys(s);const c=S8(s);if(!c&&l.length>1&&!Qy(s))return i(kE(s));if(x8(s)){const u=c?s[Zy.PATH]:l[0],d=c?s[Zy.PATTERN]:s[u];if(!xr(d))throw new Error(VF(u));const p={keyId:Vy(u),pattern:d};return n&&(p.searcher=Xy(d,t)),p}let o={children:[],operator:l[0]};return l.forEach(u=>{const d=s[u];Xr(d)&&d.forEach(p=>{o.children.push(i(p))})}),o};return Qy(e)||(e=kE(e)),i(e)}function E8(e,{ignoreFieldNorm:t=De.ignoreFieldNorm}){e.forEach(n=>{let i=1;n.matches.forEach(({key:s,norm:l,score:c})=>{const o=s?s.weight:null;i*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(t?1:l))}),n.score=i})}function w8(e,t){const n=e.matches;t.matches=[],Fn(n)&&n.forEach(i=>{if(!Fn(i.indices)||!i.indices.length)return;const{indices:s,value:l}=i;let c={indices:s,value:l};i.key&&(c.key=i.key.src),i.idx>-1&&(c.refIndex=i.idx),t.matches.push(c)})}function C8(e,t){t.score=e.score}function k8(e,t,{includeMatches:n=De.includeMatches,includeScore:i=De.includeScore}={}){const s=[];return n&&s.push(w8),i&&s.push(C8),e.map(l=>{const{idx:c}=l,o={item:t[c],refIndex:c};return s.length&&s.forEach(u=>{u(l,o)}),o})}class Fi{constructor(t,n={},i){this.options={...De,...n},this.options.useExtendedSearch,this._keyStore=new ZF(this.options.keys),this.setCollection(t,i)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof Gv))throw new Error(WF);this._myIndex=n||$O(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Fn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let i=0,s=this._docs.length;i<s;i+=1){const l=this._docs[i];t(l,i)&&(this.removeAt(i),i-=1,s-=1,n.push(l))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:l,sortFn:c,ignoreFieldNorm:o}=this.options;let u=xr(t)?xr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return E8(u,{ignoreFieldNorm:o}),l&&u.sort(c),UO(n)&&n>-1&&(u=u.slice(0,n)),k8(u,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const n=Xy(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:l,i:c,n:o})=>{if(!Fn(l))return;const{isMatch:u,score:d,indices:p}=n.searchIn(l);u&&s.push({item:l,idx:c,matches:[{score:d,value:l,norm:o,indices:p}]})}),s}_searchLogical(t){const n=KO(t,this.options),i=(o,u,d)=>{if(!o.children){const{keyId:f,searcher:m}=o,v=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(u,f),searcher:m});return v&&v.length?[{idx:d,item:u,matches:v}]:[]}const p=[];for(let f=0,m=o.children.length;f<m;f+=1){const v=o.children[f],w=i(v,u,d);if(w.length)p.push(...w);else if(o.operator===dc.AND)return[]}return p},s=this._myIndex.records,l={},c=[];return s.forEach(({$:o,i:u})=>{if(Fn(o)){let d=i(n,o,u);d.length&&(l[u]||(l[u]={idx:u,item:o,matches:[]},c.push(l[u])),d.forEach(({matches:p})=>{l[u].matches.push(...p)}))}}),c}_searchObjectList(t){const n=Xy(t,this.options),{keys:i,records:s}=this._myIndex,l=[];return s.forEach(({$:c,i:o})=>{if(!Fn(c))return;let u=[];i.forEach((d,p)=>{u.push(...this._findMatches({key:d,value:c[p],searcher:n}))}),u.length&&l.push({idx:o,item:c,matches:u})}),l}_findMatches({key:t,value:n,searcher:i}){if(!Fn(n))return[];let s=[];if(Xr(n))n.forEach(({v:l,i:c,n:o})=>{if(!Fn(l))return;const{isMatch:u,score:d,indices:p}=i.searchIn(l);u&&s.push({score:d,key:t,value:l,idx:c,norm:o,indices:p})});else{const{v:l,n:c}=n,{isMatch:o,score:u,indices:d}=i.searchIn(l);o&&s.push({score:u,key:t,value:l,norm:c,indices:d})}return s}}Fi.version="7.1.0";Fi.createIndex=$O;Fi.parseIndex=a8;Fi.config=De;Fi.parseQuery=KO;_8(v8);function T8(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":case"js":case"jsx":case"mjs":case"cjs":case"py":case"rb":case"go":case"rs":case"java":case"c":case"cpp":case"h":case"hpp":return OO;case"json":case"yaml":case"yml":case"toml":return OB;case"md":case"txt":case"log":return kc;case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return LO;case"css":case"scss":case"sass":case"less":return Y6;case"html":case"xml":return BB;default:return Li}}function R8(e,t){const n=t.get(e);return n?{added:{icon:Wo,label:"Added",className:"text-green-500"},modified:{icon:SE,label:"Modified",className:"text-yellow-500"},untracked:{icon:Wo,label:"Untracked",className:"text-blue-500"}}[n]||{icon:SE,label:"Modified",className:"text-yellow-500"}:null}function A8({files:e,changedFiles:t=[],query:n,selectedIndex:i,onSelect:s,onEnterSelect:l,onClose:c}){const o=q.useMemo(()=>new Map(t?.map(p=>[p.path,p.status])||[]),[t]),u=q.useMemo(()=>new Fi(e,{threshold:.4,distance:100,ignoreLocation:!0,includeMatches:!0}),[e]),d=q.useMemo(()=>{if(!n)return e.slice(0,20);const p=u.search(n).map(f=>f.item);return p.sort((f,m)=>{const v=o.has(f),w=o.has(m);return v&&!w?-1:!v&&w?1:0}),p.slice(0,20)},[u,n,e,o]);return q.useEffect(()=>{document.getElementById(`file-item-${i}`)?.scrollIntoView({block:"nearest"})},[i]),q.useEffect(()=>{l(d[i])},[d,i,l]),q.useEffect(()=>{const p=f=>{f.target.closest("[data-file-mention-popup]")||c()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[c]),d.length===0?y.jsx("div",{"data-file-mention-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg z-50 p-3",children:y.jsx("span",{className:"text-muted-foreground text-sm",children:"No files found"})}):y.jsx("div",{"data-file-mention-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg max-h-[300px] overflow-y-auto z-50",children:d.map((p,f)=>y.jsx("button",{type:"button",id:`file-item-${f}`,onMouseDown:m=>{m.preventDefault(),s(p)},className:`w-full text-left px-3 py-2 hover:bg-accent ${f===i?"bg-accent":""}`,children:y.jsxs("div",{className:"flex items-center gap-2 w-full",children:[(()=>{const m=T8(p);return y.jsx(m,{className:"w-4 h-4 flex-shrink-0 text-muted-foreground"})})(),y.jsx("span",{className:"font-mono text-sm flex-1 truncate",children:p}),(()=>{const m=R8(p,o);return m&&y.jsx(m.icon,{className:`w-3.5 h-3.5 flex-shrink-0 ${m.className}`,title:m.label})})()]})},p))})}const YO="agi-preferences",zu={vimMode:!1,reasoningEnabled:!0};function N8(){if(typeof window>"u")return zu;try{const e=window.localStorage.getItem(YO);if(e){const t=JSON.parse(e);return{...zu,...t}}}catch(e){console.warn("Failed to load preferences",e)}return zu}let qu=N8();const Jy=new Set;function O8(){return qu}function D8(){return zu}function I8(e){return Jy.add(e),()=>Jy.delete(e)}function L8(){for(const e of Jy)e()}function M8(e){if(qu={...qu,...e},typeof window<"u")try{window.localStorage.setItem(YO,JSON.stringify(qu))}catch(t){console.warn("Failed to persist preferences",t)}L8()}function Jo(){const e=q.useSyncExternalStore(I8,O8,D8),t=q.useCallback(n=>{M8(n)},[]);return q.useMemo(()=>({preferences:e,updatePreferences:t}),[e,t])}var TE;(function(e){e.OPENAI="openai",e.ANTHROPIC="anthropic",e.GOOGLE="google",e.OPENROUTER="openrouter",e.OPENCODE="opencode",e.ZAI="zai",e.ZAI_CODING="zai-coding",e.MOONSHOT="moonshot",e.SETU="setu"})(TE||(TE={}));function XO(e,t){return function(){return e.apply(t,arguments)}}const{toString:B8}=Object.prototype,{getPrototypeOf:Wv}=Object,{iterator:Tc,toStringTag:ZO}=Symbol,Rc=(e=>t=>{const n=B8.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),pr=e=>(e=e.toLowerCase(),t=>Rc(t)===e),Ac=e=>t=>typeof t===e,{isArray:ks}=Array,xs=Ac("undefined");function el(e){return e!==null&&!xs(e)&&e.constructor!==null&&!xs(e.constructor)&&En(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const QO=pr("ArrayBuffer");function F8(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&QO(e.buffer),t}const j8=Ac("string"),En=Ac("function"),JO=Ac("number"),tl=e=>e!==null&&typeof e=="object",P8=e=>e===!0||e===!1,$u=e=>{if(Rc(e)!=="object")return!1;const t=Wv(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ZO in e)&&!(Tc in e)},U8=e=>{if(!tl(e)||el(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},H8=pr("Date"),z8=pr("File"),q8=pr("Blob"),$8=pr("FileList"),G8=e=>tl(e)&&En(e.pipe),W8=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||En(e.append)&&((t=Rc(e))==="formdata"||t==="object"&&En(e.toString)&&e.toString()==="[object FormData]"))},V8=pr("URLSearchParams"),[K8,Y8,X8,Z8]=["ReadableStream","Request","Response","Headers"].map(pr),Q8=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nl(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let i,s;if(typeof e!="object"&&(e=[e]),ks(e))for(i=0,s=e.length;i<s;i++)t.call(null,e[i],i,e);else{if(el(e))return;const l=n?Object.getOwnPropertyNames(e):Object.keys(e),c=l.length;let o;for(i=0;i<c;i++)o=l[i],t.call(null,e[o],o,e)}}function eD(e,t){if(el(e))return null;t=t.toLowerCase();const n=Object.keys(e);let i=n.length,s;for(;i-- >0;)if(s=n[i],t===s.toLowerCase())return s;return null}const la=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tD=e=>!xs(e)&&e!==la;function ev(){const{caseless:e,skipUndefined:t}=tD(this)&&this||{},n={},i=(s,l)=>{const c=e&&eD(n,l)||l;$u(n[c])&&$u(s)?n[c]=ev(n[c],s):$u(s)?n[c]=ev({},s):ks(s)?n[c]=s.slice():(!t||!xs(s))&&(n[c]=s)};for(let s=0,l=arguments.length;s<l;s++)arguments[s]&&nl(arguments[s],i);return n}const J8=(e,t,n,{allOwnKeys:i}={})=>(nl(t,(s,l)=>{n&&En(s)?Object.defineProperty(e,l,{value:XO(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,l,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),e),ej=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),tj=(e,t,n,i)=>{e.prototype=Object.create(t.prototype,i),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},nj=(e,t,n,i)=>{let s,l,c;const o={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),l=s.length;l-- >0;)c=s[l],(!i||i(c,e,t))&&!o[c]&&(t[c]=e[c],o[c]=!0);e=n!==!1&&Wv(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},rj=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const i=e.indexOf(t,n);return i!==-1&&i===n},ij=e=>{if(!e)return null;if(ks(e))return e;let t=e.length;if(!JO(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},aj=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Wv(Uint8Array)),sj=(e,t)=>{const i=(e&&e[Tc]).call(e);let s;for(;(s=i.next())&&!s.done;){const l=s.value;t.call(e,l[0],l[1])}},oj=(e,t)=>{let n;const i=[];for(;(n=e.exec(t))!==null;)i.push(n);return i},lj=pr("HTMLFormElement"),uj=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,i,s){return i.toUpperCase()+s}),RE=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cj=pr("RegExp"),nD=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),i={};nl(n,(s,l)=>{let c;(c=t(s,l,e))!==!1&&(i[l]=c||s)}),Object.defineProperties(e,i)},dj=e=>{nD(e,(t,n)=>{if(En(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const i=e[n];if(En(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},hj=(e,t)=>{const n={},i=s=>{s.forEach(l=>{n[l]=!0})};return ks(e)?i(e):i(String(e).split(t)),n},pj=()=>{},fj=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function mj(e){return!!(e&&En(e.append)&&e[ZO]==="FormData"&&e[Tc])}const gj=e=>{const t=new Array(10),n=(i,s)=>{if(tl(i)){if(t.indexOf(i)>=0)return;if(el(i))return i;if(!("toJSON"in i)){t[s]=i;const l=ks(i)?[]:{};return nl(i,(c,o)=>{const u=n(c,s+1);!xs(u)&&(l[o]=u)}),t[s]=void 0,l}}return i};return n(e,0)},bj=pr("AsyncFunction"),yj=e=>e&&(tl(e)||En(e))&&En(e.then)&&En(e.catch),rD=((e,t)=>e?setImmediate:t?((n,i)=>(la.addEventListener("message",({source:s,data:l})=>{s===la&&l===n&&i.length&&i.shift()()},!1),s=>{i.push(s),la.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",En(la.postMessage)),vj=typeof queueMicrotask<"u"?queueMicrotask.bind(la):typeof process<"u"&&process.nextTick||rD,_j=e=>e!=null&&En(e[Tc]),ue={isArray:ks,isArrayBuffer:QO,isBuffer:el,isFormData:W8,isArrayBufferView:F8,isString:j8,isNumber:JO,isBoolean:P8,isObject:tl,isPlainObject:$u,isEmptyObject:U8,isReadableStream:K8,isRequest:Y8,isResponse:X8,isHeaders:Z8,isUndefined:xs,isDate:H8,isFile:z8,isBlob:q8,isRegExp:cj,isFunction:En,isStream:G8,isURLSearchParams:V8,isTypedArray:aj,isFileList:$8,forEach:nl,merge:ev,extend:J8,trim:Q8,stripBOM:ej,inherits:tj,toFlatObject:nj,kindOf:Rc,kindOfTest:pr,endsWith:rj,toArray:ij,forEachEntry:sj,matchAll:oj,isHTMLForm:lj,hasOwnProperty:RE,hasOwnProp:RE,reduceDescriptors:nD,freezeMethods:dj,toObjectSet:hj,toCamelCase:uj,noop:pj,toFiniteNumber:fj,findKey:eD,global:la,isContextDefined:tD,isSpecCompliantForm:mj,toJSONObject:gj,isAsyncFn:bj,isThenable:yj,setImmediate:rD,asap:vj,isIterable:_j};let Ie=class iD extends Error{static from(t,n,i,s,l,c){const o=new iD(t.message,n||t.code,i,s,l);return o.cause=t,o.name=t.name,c&&Object.assign(o,c),o}constructor(t,n,i,s,l){super(t),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),i&&(this.config=i),s&&(this.request=s),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ue.toJSONObject(this.config),code:this.code,status:this.status}}};Ie.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ie.ERR_BAD_OPTION="ERR_BAD_OPTION";Ie.ECONNABORTED="ECONNABORTED";Ie.ETIMEDOUT="ETIMEDOUT";Ie.ERR_NETWORK="ERR_NETWORK";Ie.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ie.ERR_DEPRECATED="ERR_DEPRECATED";Ie.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ie.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ie.ERR_CANCELED="ERR_CANCELED";Ie.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ie.ERR_INVALID_URL="ERR_INVALID_URL";const Sj=null;function tv(e){return ue.isPlainObject(e)||ue.isArray(e)}function aD(e){return ue.endsWith(e,"[]")?e.slice(0,-2):e}function AE(e,t,n){return e?e.concat(t).map(function(s,l){return s=aD(s),!n&&l?"["+s+"]":s}).join(n?".":""):t}function xj(e){return ue.isArray(e)&&!e.some(tv)}const Ej=ue.toFlatObject(ue,{},null,function(t){return/^is[A-Z]/.test(t)});function Nc(e,t,n){if(!ue.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=ue.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,b){return!ue.isUndefined(b[E])});const i=n.metaTokens,s=n.visitor||p,l=n.dots,c=n.indexes,u=(n.Blob||typeof Blob<"u"&&Blob)&&ue.isSpecCompliantForm(t);if(!ue.isFunction(s))throw new TypeError("visitor must be a function");function d(w){if(w===null)return"";if(ue.isDate(w))return w.toISOString();if(ue.isBoolean(w))return w.toString();if(!u&&ue.isBlob(w))throw new Ie("Blob is not supported. Use a Buffer instead.");return ue.isArrayBuffer(w)||ue.isTypedArray(w)?u&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function p(w,E,b){let _=w;if(w&&!b&&typeof w=="object"){if(ue.endsWith(E,"{}"))E=i?E:E.slice(0,-2),w=JSON.stringify(w);else if(ue.isArray(w)&&xj(w)||(ue.isFileList(w)||ue.endsWith(E,"[]"))&&(_=ue.toArray(w)))return E=aD(E),_.forEach(function(S,k){!(ue.isUndefined(S)||S===null)&&t.append(c===!0?AE([E],k,l):c===null?E:E+"[]",d(S))}),!1}return tv(w)?!0:(t.append(AE(b,E,l),d(w)),!1)}const f=[],m=Object.assign(Ej,{defaultVisitor:p,convertValue:d,isVisitable:tv});function v(w,E){if(!ue.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(w),ue.forEach(w,function(_,x){(!(ue.isUndefined(_)||_===null)&&s.call(t,_,ue.isString(x)?x.trim():x,E,m))===!0&&v(_,E?E.concat(x):[x])}),f.pop()}}if(!ue.isObject(e))throw new TypeError("data must be an object");return v(e),t}function NE(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Vv(e,t){this._pairs=[],e&&Nc(e,this,t)}const sD=Vv.prototype;sD.append=function(t,n){this._pairs.push([t,n])};sD.toString=function(t){const n=t?function(i){return t.call(this,i,NE)}:NE;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wj(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function oD(e,t,n){if(!t)return e;const i=n&&n.encode||wj,s=ue.isFunction(n)?{serialize:n}:n,l=s&&s.serialize;let c;if(l?c=l(t,s):c=ue.isURLSearchParams(t)?t.toString():new Vv(t,s).toString(i),c){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+c}return e}class OE{constructor(){this.handlers=[]}use(t,n,i){return this.handlers.push({fulfilled:t,rejected:n,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ue.forEach(this.handlers,function(i){i!==null&&t(i)})}}const lD={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cj=typeof URLSearchParams<"u"?URLSearchParams:Vv,kj=typeof FormData<"u"?FormData:null,Tj=typeof Blob<"u"?Blob:null,Rj={isBrowser:!0,classes:{URLSearchParams:Cj,FormData:kj,Blob:Tj},protocols:["http","https","file","blob","url","data"]},Kv=typeof window<"u"&&typeof document<"u",nv=typeof navigator=="object"&&navigator||void 0,Aj=Kv&&(!nv||["ReactNative","NativeScript","NS"].indexOf(nv.product)<0),Nj=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Oj=Kv&&window.location.href||"http://localhost",Dj=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Kv,hasStandardBrowserEnv:Aj,hasStandardBrowserWebWorkerEnv:Nj,navigator:nv,origin:Oj},Symbol.toStringTag,{value:"Module"})),an={...Dj,...Rj};function Ij(e,t){return Nc(e,new an.classes.URLSearchParams,{visitor:function(n,i,s,l){return an.isNode&&ue.isBuffer(n)?(this.append(i,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...t})}function Lj(e){return ue.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Mj(e){const t={},n=Object.keys(e);let i;const s=n.length;let l;for(i=0;i<s;i++)l=n[i],t[l]=e[l];return t}function uD(e){function t(n,i,s,l){let c=n[l++];if(c==="__proto__")return!0;const o=Number.isFinite(+c),u=l>=n.length;return c=!c&&ue.isArray(s)?s.length:c,u?(ue.hasOwnProp(s,c)?s[c]=[s[c],i]:s[c]=i,!o):((!s[c]||!ue.isObject(s[c]))&&(s[c]=[]),t(n,i,s[c],l)&&ue.isArray(s[c])&&(s[c]=Mj(s[c])),!o)}if(ue.isFormData(e)&&ue.isFunction(e.entries)){const n={};return ue.forEachEntry(e,(i,s)=>{t(Lj(i),s,n,0)}),n}return null}function Bj(e,t,n){if(ue.isString(e))try{return(t||JSON.parse)(e),ue.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(n||JSON.stringify)(e)}const rl={transitional:lD,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const i=n.getContentType()||"",s=i.indexOf("application/json")>-1,l=ue.isObject(t);if(l&&ue.isHTMLForm(t)&&(t=new FormData(t)),ue.isFormData(t))return s?JSON.stringify(uD(t)):t;if(ue.isArrayBuffer(t)||ue.isBuffer(t)||ue.isStream(t)||ue.isFile(t)||ue.isBlob(t)||ue.isReadableStream(t))return t;if(ue.isArrayBufferView(t))return t.buffer;if(ue.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(l){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Ij(t,this.formSerializer).toString();if((o=ue.isFileList(t))||i.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Nc(o?{"files[]":t}:t,u&&new u,this.formSerializer)}}return l||s?(n.setContentType("application/json",!1),Bj(t)):t}],transformResponse:[function(t){const n=this.transitional||rl.transitional,i=n&&n.forcedJSONParsing,s=this.responseType==="json";if(ue.isResponse(t)||ue.isReadableStream(t))return t;if(t&&ue.isString(t)&&(i&&!this.responseType||s)){const c=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(o){if(c)throw o.name==="SyntaxError"?Ie.from(o,Ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:an.classes.FormData,Blob:an.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ue.forEach(["delete","get","head","post","put","patch"],e=>{rl.headers[e]={}});const Fj=ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),jj=e=>{const t={};let n,i,s;return e&&e.split(`
16
16
  `).forEach(function(c){s=c.indexOf(":"),n=c.substring(0,s).trim().toLowerCase(),i=c.substring(s+1).trim(),!(!n||t[n]&&Fj[n])&&(n==="set-cookie"?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)}),t},DE=Symbol("internals");function No(e){return e&&String(e).trim().toLowerCase()}function Gu(e){return e===!1||e==null?e:ue.isArray(e)?e.map(Gu):String(e)}function Pj(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=n.exec(e);)t[i[1]]=i[2];return t}const Uj=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Rp(e,t,n,i,s){if(ue.isFunction(i))return i.call(this,t,n);if(s&&(t=n),!!ue.isString(t)){if(ue.isString(i))return t.indexOf(i)!==-1;if(ue.isRegExp(i))return i.test(t)}}function Hj(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,i)=>n.toUpperCase()+i)}function zj(e,t){const n=ue.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+n,{value:function(s,l,c){return this[i].call(this,t,s,l,c)},configurable:!0})})}let wn=class{constructor(t){t&&this.set(t)}set(t,n,i){const s=this;function l(o,u,d){const p=No(u);if(!p)throw new Error("header name must be a non-empty string");const f=ue.findKey(s,p);(!f||s[f]===void 0||d===!0||d===void 0&&s[f]!==!1)&&(s[f||u]=Gu(o))}const c=(o,u)=>ue.forEach(o,(d,p)=>l(d,p,u));if(ue.isPlainObject(t)||t instanceof this.constructor)c(t,n);else if(ue.isString(t)&&(t=t.trim())&&!Uj(t))c(jj(t),n);else if(ue.isObject(t)&&ue.isIterable(t)){let o={},u,d;for(const p of t){if(!ue.isArray(p))throw TypeError("Object iterator must return a key-value pair");o[d=p[0]]=(u=o[d])?ue.isArray(u)?[...u,p[1]]:[u,p[1]]:p[1]}c(o,n)}else t!=null&&l(n,t,i);return this}get(t,n){if(t=No(t),t){const i=ue.findKey(this,t);if(i){const s=this[i];if(!n)return s;if(n===!0)return Pj(s);if(ue.isFunction(n))return n.call(this,s,i);if(ue.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=No(t),t){const i=ue.findKey(this,t);return!!(i&&this[i]!==void 0&&(!n||Rp(this,this[i],i,n)))}return!1}delete(t,n){const i=this;let s=!1;function l(c){if(c=No(c),c){const o=ue.findKey(i,c);o&&(!n||Rp(i,i[o],o,n))&&(delete i[o],s=!0)}}return ue.isArray(t)?t.forEach(l):l(t),s}clear(t){const n=Object.keys(this);let i=n.length,s=!1;for(;i--;){const l=n[i];(!t||Rp(this,this[l],l,t,!0))&&(delete this[l],s=!0)}return s}normalize(t){const n=this,i={};return ue.forEach(this,(s,l)=>{const c=ue.findKey(i,l);if(c){n[c]=Gu(s),delete n[l];return}const o=t?Hj(l):String(l).trim();o!==l&&delete n[l],n[o]=Gu(s),i[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return ue.forEach(this,(i,s)=>{i!=null&&i!==!1&&(n[s]=t&&ue.isArray(i)?i.join(", "):i)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
17
17
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const i=new this(t);return n.forEach(s=>i.set(s)),i}static accessor(t){const i=(this[DE]=this[DE]={accessors:{}}).accessors,s=this.prototype;function l(c){const o=No(c);i[o]||(zj(s,c),i[o]=!0)}return ue.isArray(t)?t.forEach(l):l(t),this}};wn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ue.reduceDescriptors(wn.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}});ue.freezeMethods(wn);function Ap(e,t){const n=this||rl,i=t||n,s=wn.from(i.headers);let l=i.data;return ue.forEach(e,function(o){l=o.call(n,l,s.normalize(),t?t.status:void 0)}),s.normalize(),l}function cD(e){return!!(e&&e.__CANCEL__)}let il=class extends Ie{constructor(t,n,i){super(t??"canceled",Ie.ERR_CANCELED,n,i),this.name="CanceledError",this.__CANCEL__=!0}};function dD(e,t,n){const i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):t(new Ie("Request failed with status code "+n.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function qj(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $j(e,t){e=e||10;const n=new Array(e),i=new Array(e);let s=0,l=0,c;return t=t!==void 0?t:1e3,function(u){const d=Date.now(),p=i[l];c||(c=d),n[s]=u,i[s]=d;let f=l,m=0;for(;f!==s;)m+=n[f++],f=f%e;if(s=(s+1)%e,s===l&&(l=(l+1)%e),d-c<t)return;const v=p&&d-p;return v?Math.round(m*1e3/v):void 0}}function Gj(e,t){let n=0,i=1e3/t,s,l;const c=(d,p=Date.now())=>{n=p,s=null,l&&(clearTimeout(l),l=null),e(...d)};return[(...d)=>{const p=Date.now(),f=p-n;f>=i?c(d,p):(s=d,l||(l=setTimeout(()=>{l=null,c(s)},i-f)))},()=>s&&c(s)]}const hc=(e,t,n=3)=>{let i=0;const s=$j(50,250);return Gj(l=>{const c=l.loaded,o=l.lengthComputable?l.total:void 0,u=c-i,d=s(u),p=c<=o;i=c;const f={loaded:c,total:o,progress:o?c/o:void 0,bytes:u,rate:d||void 0,estimated:d&&o&&p?(o-c)/d:void 0,event:l,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(f)},n)},IE=(e,t)=>{const n=e!=null;return[i=>t[0]({lengthComputable:n,total:e,loaded:i}),t[1]]},LE=e=>(...t)=>ue.asap(()=>e(...t)),Wj=an.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,an.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(an.origin),an.navigator&&/(msie|trident)/i.test(an.navigator.userAgent)):()=>!0,Vj=an.hasStandardBrowserEnv?{write(e,t,n,i,s,l,c){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];ue.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),ue.isString(i)&&o.push(`path=${i}`),ue.isString(s)&&o.push(`domain=${s}`),l===!0&&o.push("secure"),ue.isString(c)&&o.push(`SameSite=${c}`),document.cookie=o.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Kj(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Yj(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function hD(e,t,n){let i=!Kj(t);return e&&(i||n==!1)?Yj(e,t):t}const ME=e=>e instanceof wn?{...e}:e;function ya(e,t){t=t||{};const n={};function i(d,p,f,m){return ue.isPlainObject(d)&&ue.isPlainObject(p)?ue.merge.call({caseless:m},d,p):ue.isPlainObject(p)?ue.merge({},p):ue.isArray(p)?p.slice():p}function s(d,p,f,m){if(ue.isUndefined(p)){if(!ue.isUndefined(d))return i(void 0,d,f,m)}else return i(d,p,f,m)}function l(d,p){if(!ue.isUndefined(p))return i(void 0,p)}function c(d,p){if(ue.isUndefined(p)){if(!ue.isUndefined(d))return i(void 0,d)}else return i(void 0,p)}function o(d,p,f){if(f in t)return i(d,p);if(f in e)return i(void 0,d)}const u={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:o,headers:(d,p,f)=>s(ME(d),ME(p),f,!0)};return ue.forEach(Object.keys({...e,...t}),function(p){const f=u[p]||s,m=f(e[p],t[p],p);ue.isUndefined(m)&&f!==o||(n[p]=m)}),n}const pD=e=>{const t=ya({},e);let{data:n,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:l,headers:c,auth:o}=t;if(t.headers=c=wn.from(c),t.url=oD(hD(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&c.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),ue.isFormData(n)){if(an.hasStandardBrowserEnv||an.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(ue.isFunction(n.getHeaders)){const u=n.getHeaders(),d=["content-type","content-length"];Object.entries(u).forEach(([p,f])=>{d.includes(p.toLowerCase())&&c.set(p,f)})}}if(an.hasStandardBrowserEnv&&(i&&ue.isFunction(i)&&(i=i(t)),i||i!==!1&&Wj(t.url))){const u=s&&l&&Vj.read(l);u&&c.set(s,u)}return t},Xj=typeof XMLHttpRequest<"u",Zj=Xj&&function(e){return new Promise(function(n,i){const s=pD(e);let l=s.data;const c=wn.from(s.headers).normalize();let{responseType:o,onUploadProgress:u,onDownloadProgress:d}=s,p,f,m,v,w;function E(){v&&v(),w&&w(),s.cancelToken&&s.cancelToken.unsubscribe(p),s.signal&&s.signal.removeEventListener("abort",p)}let b=new XMLHttpRequest;b.open(s.method.toUpperCase(),s.url,!0),b.timeout=s.timeout;function _(){if(!b)return;const S=wn.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),O={data:!o||o==="text"||o==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:S,config:e,request:b};dD(function(A){n(A),E()},function(A){i(A),E()},O),b=null}"onloadend"in b?b.onloadend=_:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(_)},b.onabort=function(){b&&(i(new Ie("Request aborted",Ie.ECONNABORTED,e,b)),b=null)},b.onerror=function(k){const O=k&&k.message?k.message:"Network Error",T=new Ie(O,Ie.ERR_NETWORK,e,b);T.event=k||null,i(T),b=null},b.ontimeout=function(){let k=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const O=s.transitional||lD;s.timeoutErrorMessage&&(k=s.timeoutErrorMessage),i(new Ie(k,O.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,b)),b=null},l===void 0&&c.setContentType(null),"setRequestHeader"in b&&ue.forEach(c.toJSON(),function(k,O){b.setRequestHeader(O,k)}),ue.isUndefined(s.withCredentials)||(b.withCredentials=!!s.withCredentials),o&&o!=="json"&&(b.responseType=s.responseType),d&&([m,w]=hc(d,!0),b.addEventListener("progress",m)),u&&b.upload&&([f,v]=hc(u),b.upload.addEventListener("progress",f),b.upload.addEventListener("loadend",v)),(s.cancelToken||s.signal)&&(p=S=>{b&&(i(!S||S.type?new il(null,e,b):S),b.abort(),b=null)},s.cancelToken&&s.cancelToken.subscribe(p),s.signal&&(s.signal.aborted?p():s.signal.addEventListener("abort",p)));const x=qj(s.url);if(x&&an.protocols.indexOf(x)===-1){i(new Ie("Unsupported protocol "+x+":",Ie.ERR_BAD_REQUEST,e));return}b.send(l||null)})},Qj=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let i=new AbortController,s;const l=function(d){if(!s){s=!0,o();const p=d instanceof Error?d:this.reason;i.abort(p instanceof Ie?p:new il(p instanceof Error?p.message:p))}};let c=t&&setTimeout(()=>{c=null,l(new Ie(`timeout of ${t}ms exceeded`,Ie.ETIMEDOUT))},t);const o=()=>{e&&(c&&clearTimeout(c),c=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(l):d.removeEventListener("abort",l)}),e=null)};e.forEach(d=>d.addEventListener("abort",l));const{signal:u}=i;return u.unsubscribe=()=>ue.asap(o),u}},Jj=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let i=0,s;for(;i<n;)s=i+t,yield e.slice(i,s),i=s},eP=async function*(e,t){for await(const n of tP(e))yield*Jj(n,t)},tP=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:i}=await t.read();if(n)break;yield i}}finally{await t.cancel()}},BE=(e,t,n,i)=>{const s=eP(e,t);let l=0,c,o=u=>{c||(c=!0,i&&i(u))};return new ReadableStream({async pull(u){try{const{done:d,value:p}=await s.next();if(d){o(),u.close();return}let f=p.byteLength;if(n){let m=l+=f;n(m)}u.enqueue(new Uint8Array(p))}catch(d){throw o(d),d}},cancel(u){return o(u),s.return()}},{highWaterMark:2})},FE=64*1024,{isFunction:Au}=ue,nP=(({Request:e,Response:t})=>({Request:e,Response:t}))(ue.global),{ReadableStream:jE,TextEncoder:PE}=ue.global,UE=(e,...t)=>{try{return!!e(...t)}catch{return!1}},rP=e=>{e=ue.merge.call({skipUndefined:!0},nP,e);const{fetch:t,Request:n,Response:i}=e,s=t?Au(t):typeof fetch=="function",l=Au(n),c=Au(i);if(!s)return!1;const o=s&&Au(jE),u=s&&(typeof PE=="function"?(w=>E=>w.encode(E))(new PE):async w=>new Uint8Array(await new n(w).arrayBuffer())),d=l&&o&&UE(()=>{let w=!1;const E=new n(an.origin,{body:new jE,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!E}),p=c&&o&&UE(()=>ue.isReadableStream(new i("").body)),f={stream:p&&(w=>w.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(E,b)=>{let _=E&&E[w];if(_)return _.call(E);throw new Ie(`Response type '${w}' is not supported`,Ie.ERR_NOT_SUPPORT,b)})});const m=async w=>{if(w==null)return 0;if(ue.isBlob(w))return w.size;if(ue.isSpecCompliantForm(w))return(await new n(an.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(ue.isArrayBufferView(w)||ue.isArrayBuffer(w))return w.byteLength;if(ue.isURLSearchParams(w)&&(w=w+""),ue.isString(w))return(await u(w)).byteLength},v=async(w,E)=>{const b=ue.toFiniteNumber(w.getContentLength());return b??m(E)};return async w=>{let{url:E,method:b,data:_,signal:x,cancelToken:S,timeout:k,onDownloadProgress:O,onUploadProgress:T,responseType:A,headers:R,withCredentials:D="same-origin",fetchOptions:L}=pD(w),I=t||fetch;A=A?(A+"").toLowerCase():"text";let H=Qj([x,S&&S.toAbortSignal()],k),B=null;const W=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let K;try{if(T&&d&&b!=="get"&&b!=="head"&&(K=await v(R,_))!==0){let j=new n(E,{method:"POST",body:_,duplex:"half"}),$;if(ue.isFormData(_)&&($=j.headers.get("content-type"))&&R.setContentType($),j.body){const[U,J]=IE(K,hc(LE(T)));_=BE(j.body,FE,U,J)}}ue.isString(D)||(D=D?"include":"omit");const V=l&&"credentials"in n.prototype,X={...L,signal:H,method:b.toUpperCase(),headers:R.normalize().toJSON(),body:_,duplex:"half",credentials:V?D:void 0};B=l&&new n(E,X);let Y=await(l?I(B,L):I(E,X));const P=p&&(A==="stream"||A==="response");if(p&&(O||P&&W)){const j={};["status","statusText","headers"].forEach(oe=>{j[oe]=Y[oe]});const $=ue.toFiniteNumber(Y.headers.get("content-length")),[U,J]=O&&IE($,hc(LE(O),!0))||[];Y=new i(BE(Y.body,FE,U,()=>{J&&J(),W&&W()}),j)}A=A||"text";let M=await f[ue.findKey(f,A)||"text"](Y,w);return!P&&W&&W(),await new Promise((j,$)=>{dD(j,$,{data:M,headers:wn.from(Y.headers),status:Y.status,statusText:Y.statusText,config:w,request:B})})}catch(V){throw W&&W(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,w,B),{cause:V.cause||V}):Ie.from(V,V&&V.code,w,B)}}},iP=new Map,fD=e=>{let t=e&&e.env||{};const{fetch:n,Request:i,Response:s}=t,l=[i,s,n];let c=l.length,o=c,u,d,p=iP;for(;o--;)u=l[o],d=p.get(u),d===void 0&&p.set(u,d=o?new Map:rP(t)),p=d;return d};fD();const Yv={http:Sj,xhr:Zj,fetch:{get:fD}};ue.forEach(Yv,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const HE=e=>`- ${e}`,aP=e=>ue.isFunction(e)||e===null||e===!1;function sP(e,t){e=ue.isArray(e)?e:[e];const{length:n}=e;let i,s;const l={};for(let c=0;c<n;c++){i=e[c];let o;if(s=i,!aP(i)&&(s=Yv[(o=String(i)).toLowerCase()],s===void 0))throw new Ie(`Unknown adapter '${o}'`);if(s&&(ue.isFunction(s)||(s=s.get(t))))break;l[o||"#"+c]=s}if(!s){const c=Object.entries(l).map(([u,d])=>`adapter ${u} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=n?c.length>1?`since :
18
18
  `+c.map(HE).join(`
19
- `):" "+HE(c[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s}const mD={getAdapter:sP,adapters:Yv};function Np(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new il(null,e)}function zE(e){return Np(e),e.headers=wn.from(e.headers),e.data=Ap.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),mD.getAdapter(e.adapter||rl.adapter,e)(e).then(function(i){return Np(e),i.data=Ap.call(e,e.transformResponse,i),i.headers=wn.from(i.headers),i},function(i){return cD(i)||(Np(e),i&&i.response&&(i.response.data=Ap.call(e,e.transformResponse,i.response),i.response.headers=wn.from(i.response.headers))),Promise.reject(i)})}const gD="1.13.3",Oc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Oc[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}});const qE={};Oc.transitional=function(t,n,i){function s(l,c){return"[Axios v"+gD+"] Transitional option '"+l+"'"+c+(i?". "+i:"")}return(l,c,o)=>{if(t===!1)throw new Ie(s(c," has been removed"+(n?" in "+n:"")),Ie.ERR_DEPRECATED);return n&&!qE[c]&&(qE[c]=!0,console.warn(s(c," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(l,c,o):!0}};Oc.spelling=function(t){return(n,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function oP(e,t,n){if(typeof e!="object")throw new Ie("options must be an object",Ie.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let s=i.length;for(;s-- >0;){const l=i[s],c=t[l];if(c){const o=e[l],u=o===void 0||c(o,l,e);if(u!==!0)throw new Ie("option "+l+" must be "+u,Ie.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ie("Unknown option "+l,Ie.ERR_BAD_OPTION)}}const Wu={assertOptions:oP,validators:Oc},_r=Wu.validators;let da=class{constructor(t){this.defaults=t||{},this.interceptors={request:new OE,response:new OE}}async request(t,n){try{return await this._request(t,n)}catch(i){if(i instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const l=s.stack?s.stack.replace(/^.+\n/,""):"";try{i.stack?l&&!String(i.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(i.stack+=`
20
- `+l):i.stack=l}catch{}}throw i}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ya(this.defaults,n);const{transitional:i,paramsSerializer:s,headers:l}=n;i!==void 0&&Wu.assertOptions(i,{silentJSONParsing:_r.transitional(_r.boolean),forcedJSONParsing:_r.transitional(_r.boolean),clarifyTimeoutError:_r.transitional(_r.boolean)},!1),s!=null&&(ue.isFunction(s)?n.paramsSerializer={serialize:s}:Wu.assertOptions(s,{encode:_r.function,serialize:_r.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wu.assertOptions(n,{baseUrl:_r.spelling("baseURL"),withXsrfToken:_r.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=l&&ue.merge(l.common,l[n.method]);l&&ue.forEach(["delete","get","head","post","put","patch","common"],w=>{delete l[w]}),n.headers=wn.concat(c,l);const o=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(n)===!1||(u=u&&E.synchronous,o.unshift(E.fulfilled,E.rejected))});const d=[];this.interceptors.response.forEach(function(E){d.push(E.fulfilled,E.rejected)});let p,f=0,m;if(!u){const w=[zE.bind(this),void 0];w.unshift(...o),w.push(...d),m=w.length,p=Promise.resolve(n);let E=n;for(;f<m;)p=p.then(w[f++]).then(b=>{E=b!==void 0?b:E}).catch(w[f++]).then(()=>E);return p}m=o.length;let v=n;for(;f<m;){const w=o[f++],E=o[f++];try{v=w(v)}catch(b){E.call(this,b);break}}try{p=zE.call(this,v)}catch(w){return Promise.reject(w)}for(f=0,m=d.length;f<m;)p=p.then(d[f++]).catch(d[f++]);return p}getUri(t){t=ya(this.defaults,t);const n=hD(t.baseURL,t.url,t.allowAbsoluteUrls);return oD(n,t.params,t.paramsSerializer)}};ue.forEach(["delete","get","head","options"],function(t){da.prototype[t]=function(n,i){return this.request(ya(i||{},{method:t,url:n,data:(i||{}).data}))}});ue.forEach(["post","put","patch"],function(t){function n(i){return function(l,c,o){return this.request(ya(o||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}da.prototype[t]=n(),da.prototype[t+"Form"]=n(!0)});let lP=class bD{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(l){n=l});const i=this;this.promise.then(s=>{if(!i._listeners)return;let l=i._listeners.length;for(;l-- >0;)i._listeners[l](s);i._listeners=null}),this.promise.then=s=>{let l;const c=new Promise(o=>{i.subscribe(o),l=o}).then(s);return c.cancel=function(){i.unsubscribe(l)},c},t(function(l,c,o){i.reason||(i.reason=new il(l,c,o),n(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=i=>{t.abort(i)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new bD(function(s){t=s}),cancel:t}}};function uP(e){return function(n){return e.apply(null,n)}}function cP(e){return ue.isObject(e)&&e.isAxiosError===!0}const rv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(rv).forEach(([e,t])=>{rv[t]=e});function yD(e){const t=new da(e),n=XO(da.prototype.request,t);return ue.extend(n,da.prototype,t,{allOwnKeys:!0}),ue.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yD(ya(e,s))},n}const jt=yD(rl);jt.Axios=da;jt.CanceledError=il;jt.CancelToken=lP;jt.isCancel=cD;jt.VERSION=gD;jt.toFormData=Nc;jt.AxiosError=Ie;jt.Cancel=jt.CanceledError;jt.all=function(t){return Promise.all(t)};jt.spread=uP;jt.isAxiosError=cP;jt.mergeConfig=ya;jt.AxiosHeaders=wn;jt.formToJSON=e=>uD(ue.isHTMLForm(e)?new FormData(e):e);jt.getAdapter=mD.getAdapter;jt.HttpStatusCode=rv;jt.default=jt;const{Axios:Hte,AxiosError:zte,CanceledError:qte,isCancel:$te,CancelToken:Gte,VERSION:Wte,all:Vte,Cancel:Kte,isAxiosError:Yte,spread:Xte,toFormData:Zte,AxiosHeaders:Qte,HttpStatusCode:Jte,formToJSON:ene,getAdapter:tne,mergeConfig:nne}=jt,dP=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:l,sseMaxRetryAttempts:c,sseMaxRetryDelay:o,sseSleepFn:u,url:d,...p})=>{let f;const m=u??(E=>new Promise(b=>setTimeout(b,E)));return{stream:async function*(){let E=l??3e3,b=0;const _=p.signal??new AbortController().signal;for(;!_.aborted;){b++;const x=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&x.set("Last-Event-ID",f);try{const S={redirect:"follow",...p,body:p.serializedBody,headers:x,signal:_};let k=new Request(d,S);e&&(k=await e(d,S));const T=await(p.fetch??globalThis.fetch)(k);if(!T.ok)throw new Error(`SSE failed: ${T.status} ${T.statusText}`);if(!T.body)throw new Error("No body in SSE response");const A=T.body.pipeThrough(new TextDecoderStream).getReader();let R="";const D=()=>{try{A.cancel()}catch{}};_.addEventListener("abort",D);try{for(;;){const{done:L,value:I}=await A.read();if(L)break;R+=I;const H=R.split(`
19
+ `):" "+HE(c[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s}const mD={getAdapter:sP,adapters:Yv};function Np(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new il(null,e)}function zE(e){return Np(e),e.headers=wn.from(e.headers),e.data=Ap.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),mD.getAdapter(e.adapter||rl.adapter,e)(e).then(function(i){return Np(e),i.data=Ap.call(e,e.transformResponse,i),i.headers=wn.from(i.headers),i},function(i){return cD(i)||(Np(e),i&&i.response&&(i.response.data=Ap.call(e,e.transformResponse,i.response),i.response.headers=wn.from(i.response.headers))),Promise.reject(i)})}const gD="1.13.4",Oc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Oc[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}});const qE={};Oc.transitional=function(t,n,i){function s(l,c){return"[Axios v"+gD+"] Transitional option '"+l+"'"+c+(i?". "+i:"")}return(l,c,o)=>{if(t===!1)throw new Ie(s(c," has been removed"+(n?" in "+n:"")),Ie.ERR_DEPRECATED);return n&&!qE[c]&&(qE[c]=!0,console.warn(s(c," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(l,c,o):!0}};Oc.spelling=function(t){return(n,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function oP(e,t,n){if(typeof e!="object")throw new Ie("options must be an object",Ie.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let s=i.length;for(;s-- >0;){const l=i[s],c=t[l];if(c){const o=e[l],u=o===void 0||c(o,l,e);if(u!==!0)throw new Ie("option "+l+" must be "+u,Ie.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ie("Unknown option "+l,Ie.ERR_BAD_OPTION)}}const Wu={assertOptions:oP,validators:Oc},_r=Wu.validators;let da=class{constructor(t){this.defaults=t||{},this.interceptors={request:new OE,response:new OE}}async request(t,n){try{return await this._request(t,n)}catch(i){if(i instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const l=s.stack?s.stack.replace(/^.+\n/,""):"";try{i.stack?l&&!String(i.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(i.stack+=`
20
+ `+l):i.stack=l}catch{}}throw i}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ya(this.defaults,n);const{transitional:i,paramsSerializer:s,headers:l}=n;i!==void 0&&Wu.assertOptions(i,{silentJSONParsing:_r.transitional(_r.boolean),forcedJSONParsing:_r.transitional(_r.boolean),clarifyTimeoutError:_r.transitional(_r.boolean)},!1),s!=null&&(ue.isFunction(s)?n.paramsSerializer={serialize:s}:Wu.assertOptions(s,{encode:_r.function,serialize:_r.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wu.assertOptions(n,{baseUrl:_r.spelling("baseURL"),withXsrfToken:_r.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let c=l&&ue.merge(l.common,l[n.method]);l&&ue.forEach(["delete","get","head","post","put","patch","common"],w=>{delete l[w]}),n.headers=wn.concat(c,l);const o=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(n)===!1||(u=u&&E.synchronous,o.unshift(E.fulfilled,E.rejected))});const d=[];this.interceptors.response.forEach(function(E){d.push(E.fulfilled,E.rejected)});let p,f=0,m;if(!u){const w=[zE.bind(this),void 0];for(w.unshift(...o),w.push(...d),m=w.length,p=Promise.resolve(n);f<m;)p=p.then(w[f++],w[f++]);return p}m=o.length;let v=n;for(;f<m;){const w=o[f++],E=o[f++];try{v=w(v)}catch(b){E.call(this,b);break}}try{p=zE.call(this,v)}catch(w){return Promise.reject(w)}for(f=0,m=d.length;f<m;)p=p.then(d[f++],d[f++]);return p}getUri(t){t=ya(this.defaults,t);const n=hD(t.baseURL,t.url,t.allowAbsoluteUrls);return oD(n,t.params,t.paramsSerializer)}};ue.forEach(["delete","get","head","options"],function(t){da.prototype[t]=function(n,i){return this.request(ya(i||{},{method:t,url:n,data:(i||{}).data}))}});ue.forEach(["post","put","patch"],function(t){function n(i){return function(l,c,o){return this.request(ya(o||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}da.prototype[t]=n(),da.prototype[t+"Form"]=n(!0)});let lP=class bD{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(l){n=l});const i=this;this.promise.then(s=>{if(!i._listeners)return;let l=i._listeners.length;for(;l-- >0;)i._listeners[l](s);i._listeners=null}),this.promise.then=s=>{let l;const c=new Promise(o=>{i.subscribe(o),l=o}).then(s);return c.cancel=function(){i.unsubscribe(l)},c},t(function(l,c,o){i.reason||(i.reason=new il(l,c,o),n(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=i=>{t.abort(i)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new bD(function(s){t=s}),cancel:t}}};function uP(e){return function(n){return e.apply(null,n)}}function cP(e){return ue.isObject(e)&&e.isAxiosError===!0}const rv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(rv).forEach(([e,t])=>{rv[t]=e});function yD(e){const t=new da(e),n=XO(da.prototype.request,t);return ue.extend(n,da.prototype,t,{allOwnKeys:!0}),ue.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yD(ya(e,s))},n}const jt=yD(rl);jt.Axios=da;jt.CanceledError=il;jt.CancelToken=lP;jt.isCancel=cD;jt.VERSION=gD;jt.toFormData=Nc;jt.AxiosError=Ie;jt.Cancel=jt.CanceledError;jt.all=function(t){return Promise.all(t)};jt.spread=uP;jt.isAxiosError=cP;jt.mergeConfig=ya;jt.AxiosHeaders=wn;jt.formToJSON=e=>uD(ue.isHTMLForm(e)?new FormData(e):e);jt.getAdapter=mD.getAdapter;jt.HttpStatusCode=rv;jt.default=jt;const{Axios:Hte,AxiosError:zte,CanceledError:qte,isCancel:$te,CancelToken:Gte,VERSION:Wte,all:Vte,Cancel:Kte,isAxiosError:Yte,spread:Xte,toFormData:Zte,AxiosHeaders:Qte,HttpStatusCode:Jte,formToJSON:ene,getAdapter:tne,mergeConfig:nne}=jt,dP=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:i,responseValidator:s,sseDefaultRetryDelay:l,sseMaxRetryAttempts:c,sseMaxRetryDelay:o,sseSleepFn:u,url:d,...p})=>{let f;const m=u??(E=>new Promise(b=>setTimeout(b,E)));return{stream:async function*(){let E=l??3e3,b=0;const _=p.signal??new AbortController().signal;for(;!_.aborted;){b++;const x=p.headers instanceof Headers?p.headers:new Headers(p.headers);f!==void 0&&x.set("Last-Event-ID",f);try{const S={redirect:"follow",...p,body:p.serializedBody,headers:x,signal:_};let k=new Request(d,S);e&&(k=await e(d,S));const T=await(p.fetch??globalThis.fetch)(k);if(!T.ok)throw new Error(`SSE failed: ${T.status} ${T.statusText}`);if(!T.body)throw new Error("No body in SSE response");const A=T.body.pipeThrough(new TextDecoderStream).getReader();let R="";const D=()=>{try{A.cancel()}catch{}};_.addEventListener("abort",D);try{for(;;){const{done:L,value:I}=await A.read();if(L)break;R+=I;const H=R.split(`
21
21
 
22
22
  `);R=H.pop()??"";for(const B of H){const W=B.split(`
23
23
  `),K=[];let V;for(const P of W)if(P.startsWith("data:"))K.push(P.replace(/^data:\s*/,""));else if(P.startsWith("event:"))V=P.replace(/^event:\s*/,"");else if(P.startsWith("id:"))f=P.replace(/^id:\s*/,"");else if(P.startsWith("retry:")){const M=Number.parseInt(P.replace(/^retry:\s*/,""),10);Number.isNaN(M)||(E=M)}let X,Y=!1;if(K.length){const P=K.join(`
24
- `);try{X=JSON.parse(P),Y=!0}catch{X=P}}Y&&(s&&await s(X),i&&(X=await i(X))),n?.({data:X,event:V,id:f,retry:E}),K.length&&(yield X)}}}finally{_.removeEventListener("abort",D),A.releaseLock()}break}catch(S){if(t?.(S),c!==void 0&&b>=c)break;const k=Math.min(E*2**(b-1),o??3e4);await m(k)}}}()}},hP=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},pP=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},fP=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},vD=({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){const o=(e?s:s.map(u=>encodeURIComponent(u))).join(pP(i));switch(i){case"label":return`.${o}`;case"matrix":return`;${n}=${o}`;case"simple":return o;default:return`${n}=${o}`}}const l=hP(i),c=s.map(o=>i==="label"||i==="simple"?e?o:encodeURIComponent(o):Dc({allowReserved:e,name:n,value:o})).join(l);return i==="label"||i==="matrix"?l+c:c},Dc=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},_D=({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:l})=>{if(s instanceof Date)return l?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let u=[];Object.entries(s).forEach(([p,f])=>{u=[...u,p,e?f:encodeURIComponent(f)]});const d=u.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}const c=fP(i),o=Object.entries(s).map(([u,d])=>Dc({allowReserved:e,name:i==="deepObject"?`${n}[${u}]`:u,value:d})).join(c);return i==="label"||i==="matrix"?c+o:o},mP=/\{[^{}]+\}/g,gP=({path:e,url:t})=>{let n=t;const i=t.match(mP);if(i)for(const s of i){let l=!1,c=s.substring(1,s.length-1),o="simple";c.endsWith("*")&&(l=!0,c=c.substring(0,c.length-1)),c.startsWith(".")?(c=c.substring(1),o="label"):c.startsWith(";")&&(c=c.substring(1),o="matrix");const u=e[c];if(u==null)continue;if(Array.isArray(u)){n=n.replace(s,vD({explode:l,name:c,style:o,value:u}));continue}if(typeof u=="object"){n=n.replace(s,_D({explode:l,name:c,style:o,value:u,valueOnly:!0}));continue}if(o==="matrix"){n=n.replace(s,`;${Dc({name:c,value:u})}`);continue}const d=encodeURIComponent(o==="label"?`.${u}`:u);n=n.replace(s,d)}return n},bP=({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{const l=s.startsWith("/")?s:`/${s}`;let c=(e??"")+l;t&&(c=gP({path:t,url:c}));let o=n?i(n):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(c+=`?${o}`),c};function yP(e){const t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}const vP=async(e,t)=>{const n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},_P=({allowReserved:e,array:t,object:n}={})=>s=>{const l=[];if(s&&typeof s=="object")for(const c in s){const o=s[c];if(o!=null)if(Array.isArray(o)){const u=vD({allowReserved:e,explode:!0,name:c,style:"form",value:o,...t});u&&l.push(u)}else if(typeof o=="object"){const u=_D({allowReserved:e,explode:!0,name:c,style:"deepObject",value:o,...n});u&&l.push(u)}else{const u=Dc({allowReserved:e,name:c,value:o});u&&l.push(u)}}return l.join("&")},SP=(e,t)=>t?t in e.headers||e.query?.[t]?!0:"Cookie"in e.headers&&e.headers.Cookie&&typeof e.headers.Cookie=="string"?e.headers.Cookie.includes(`${t}=`):!1:!1,xP=async({security:e,...t})=>{for(const n of e){if(SP(t,n.name))continue;const i=await vP(n,t.auth);if(!i)continue;const s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":{const l=`${s}=${i}`;"Cookie"in t.headers&&t.headers.Cookie?t.headers.Cookie=`${t.headers.Cookie}; ${l}`:t.headers.Cookie=l;break}default:t.headers[s]=i;break}}},$E=e=>{const t=e.axios?.defaults?.baseURL,n=e.baseURL&&typeof e.baseURL=="string"?e.baseURL:t;return bP({baseUrl:n,path:e.path,query:e.paramsSerializer?void 0:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_P(e.querySerializer),url:e.url})},GE=(e,t)=>{const n={...e,...t};return n.headers=iv(e.headers,t.headers),n},EP=["common","delete","get","head","patch","post","put"],iv=(...e)=>{const t={};for(const n of e){if(!n||typeof n!="object")continue;const i=Object.entries(n);for(const[s,l]of i)if(EP.includes(s)&&typeof l=="object")t[s]={...t[s],...l};else if(l===null)delete t[s];else if(Array.isArray(l))for(const c of l)t[s]=[...t[s]??[],c];else l!==void 0&&(t[s]=typeof l=="object"?JSON.stringify(l):l)}return t},SD=(e={})=>({...e}),wP=(e={})=>{let t=GE(SD(),e),n;if(t.axios&&!("Axios"in t.axios))n=t.axios;else{const{auth:d,...p}=t;n=jt.create(p)}const i=()=>({...t}),s=d=>(t=GE(t,d),n.defaults={...n.defaults,...t,headers:iv(n.defaults.headers,t.headers)},i()),l=async d=>{const p={...t,...d,axios:d.axios??t.axios??n,headers:iv(t.headers,d.headers)};p.security&&await xP({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.body=p.bodySerializer(p.body));const f=$E(p);return{opts:p,url:f}},c=async d=>{const{opts:p,url:f}=await l(d);try{const m=p.axios,{auth:v,...w}=p,E=await m({...w,baseURL:"",data:yP(p),headers:p.headers,params:p.paramsSerializer?p.query:void 0,url:f});let{data:b}=E;return p.responseType==="json"&&(p.responseValidator&&await p.responseValidator(b),p.responseTransformer&&(b=await p.responseTransformer(b))),{...E,data:b??{}}}catch(m){const v=m;if(p.throwOnError)throw v;return v.error=v.response?.data??{},v}},o=d=>p=>c({...p,method:d}),u=d=>async p=>{const{opts:f,url:m}=await l(p);return dP({...f,body:f.body,headers:f.headers,method:d,signal:f.signal,url:m})};return{buildUrl:$E,connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),getConfig:i,head:o("HEAD"),instance:n,options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),request:c,setConfig:s,sse:{connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),head:u("HEAD"),options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),trace:u("TRACE")},trace:o("TRACE")}},CP=(e={})=>({...e,baseURL:e.baseURL}),Mt=wP(CP(SD())),kP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/sessions",...e}),TP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/sessions",...e,headers:{"Content-Type":"application/json",...e?.headers}}),RP=e=>(e.client??Mt).delete({responseType:"json",url:"/v1/sessions/{sessionId}/abort",...e}),AP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/sessions/{id}/messages",...e}),NP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/sessions/{id}/messages",...e,headers:{"Content-Type":"application/json",...e.headers}}),OP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/config",...e}),DP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/config/providers/{provider}/models",...e}),IP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/files",...e}),LP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/git/status",...e}),MP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/git/diff",...e}),BP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/git/branch",...e}),FP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/stage",...e,headers:{"Content-Type":"application/json",...e.headers}}),jP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/unstage",...e,headers:{"Content-Type":"application/json",...e.headers}}),PP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/commit",...e,headers:{"Content-Type":"application/json",...e.headers}}),UP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/git/generate-commit-message",...e,headers:{"Content-Type":"application/json",...e?.headers}}),HP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/git/push",...e,headers:{"Content-Type":"application/json",...e?.headers}}),zP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/restore",...e,headers:{"Content-Type":"application/json",...e.headers}}),qP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/delete",...e,headers:{"Content-Type":"application/json",...e.headers}}),$P=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/terminals",...e}),GP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/terminals",...e,headers:{"Content-Type":"application/json",...e.headers}}),WP={};function xD(){const e=WP?.VITE_API_BASE_URL;if(e)return e;if(typeof window<"u"){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(t.__AGI_API_URL__)return t.__AGI_API_URL__}return"http://localhost:9100"}function VP(){return xD()}const Ic=xD();function ft(e){if(!e)return"Unknown error";if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(t.error&&typeof t.error=="object"){const n=t.error;if(typeof n.message=="string")return n.message}if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message;try{return JSON.stringify(e)}catch{return"Error occurred (unable to parse)"}}return"Unknown error"}function KP(){const t=window.AGI_SERVER_URL||Ic;Mt.setConfig({baseURL:t})}KP();function Op(e){return{...e,title:e.title??null,createdAt:typeof e.createdAt=="string"?new Date(e.createdAt).getTime():e.createdAt,lastActiveAt:typeof e.lastActiveAt=="string"?new Date(e.lastActiveAt).getTime():e.lastActiveAt}}function YP(e){return{...e,createdAt:typeof e.createdAt=="string"?new Date(e.createdAt).getTime():e.createdAt,completedAt:e.completedAt?typeof e.completedAt=="string"?new Date(e.completedAt).getTime():e.completedAt:null}}class XP{get baseUrl(){const t=window;return t.AGI_SERVER_URL?t.AGI_SERVER_URL:Ic}async getSessions(){const t=await kP();if(t.error)throw new Error(ft(t.error));return(t.data||[]).map(Op)}async createSession(t){const n=await TP({body:t});if(n.error)throw new Error(ft(n.error));if(!n.data)throw new Error("No data returned from create session");return Op(n.data)}async updateSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to update session"}));throw new Error(ft(l))}const s=await i.json();return Op(s)}async deleteSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete session"}));throw new Error(ft(i))}return await n.json()}async abortSession(t){const n=await RP({path:{sessionId:t}});if(n.error)throw new Error(ft(n.error));return n.data}async abortMessage(t,n){const i=this.baseUrl,s=await fetch(`${i}/v1/sessions/${t}/abort`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:n})});if(!s.ok)throw new Error("Failed to abort message");return s.json()}async getQueueState(t){const n=this.baseUrl,i=await fetch(`${n}/v1/sessions/${t}/queue`);if(!i.ok)throw new Error("Failed to get queue state");return i.json()}async removeFromQueue(t,n){const i=this.baseUrl,s=await fetch(`${i}/v1/sessions/${t}/queue/${n}`,{method:"DELETE"});if(!s.ok)throw new Error("Failed to remove from queue");return s.json()}async getMessages(t){const n=await AP({path:{id:t}});if(n.error)throw new Error(ft(n.error));return(n.data||[]).map(YP)}async sendMessage(t,n){const i=await NP({path:{id:t},body:n});if(i.error)throw new Error(ft(i.error));return i.data}getStreamUrl(t){return`${this.baseUrl}/v1/sessions/${t}/stream`}async getConfig(){const t=await OP();if(t.error)throw new Error(ft(t.error));return t.data}async getModels(t){const n=await DP({path:{provider:t}});if(n.error)throw new Error(ft(n.error));return n.data}async getAllModels(){const t=await fetch(`${this.baseUrl}/v1/config/models`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to fetch models"}));throw new Error(ft(n))}return await t.json()}async updateDefaults(t){const n=await fetch(`${this.baseUrl}/v1/config/defaults`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to update defaults"}));throw new Error(ft(i))}return await n.json()}async getGitStatus(){const t=await LP();if(t.error)throw new Error(ft(t.error));return t.data?.data}async getGitDiff(t,n=!1){const i=await MP({query:{file:t,staged:n?"true":"false"}});if(i.error)throw new Error(ft(i.error));return i.data?.data}async generateCommitMessage(t){const n=await UP({body:t?{sessionId:t}:{}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async stageFiles(t){const n=await FP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async unstageFiles(t){const n=await jP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async restoreFiles(t){const n=await zP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async deleteFiles(t){const n=await qP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async commitChanges(t){const n=await PP({body:{message:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async getGitBranch(){const t=await BP();if(t.error)throw new Error(ft(t.error));return t.data?.data}async pushCommits(){const t=await HP({body:{}});if(t.error)throw new Error(ft(t.error));return t.data?.data}async listFiles(){const t=await IP();if(t.error)throw new Error(ft(t.error));return t.data}async getSessionFiles(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/files`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch session files"}));throw new Error(ft(i))}return await n.json()}async createBranch(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create branch"}));throw new Error(ft(s))}return await i.json()}async listBranches(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/branches`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to list branches"}));throw new Error(ft(i))}return await n.json()}async getParentSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/parent`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to get parent session"}));throw new Error(ft(i))}return await n.json()}async getSolforgeBalance(){try{const t=await fetch(`${this.baseUrl}/v1/solforge/balance`,{method:"GET",headers:{"Content-Type":"application/json"}});return t.ok?await t.json():null}catch{return null}}async getSolforgeWallet(){try{const t=await fetch(`${this.baseUrl}/v1/solforge/wallet`,{method:"GET",headers:{"Content-Type":"application/json"}});return t.ok?await t.json():{configured:!1}}catch{return{configured:!1}}}async getSolforgeUsdcBalance(t="mainnet"){try{const n=await fetch(`${this.baseUrl}/v1/solforge/usdc-balance?network=${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():null}catch{return null}}async getShareStatus(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():{shared:!1}}async shareSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to share session"}));throw new Error(ft(i))}return await n.json()}async syncSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"PUT",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to sync session"}));throw new Error(ft(i))}return await n.json()}async approveToolCall(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/approval`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:i})});if(!s.ok)throw new Error("Failed to send tool approval");return await s.json()}async getPendingApprovals(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/approval/pending`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():{ok:!1,pending:[]}}}const qe=new XP;function Xv(e){const{data:t,isLoading:n,error:i}=qn({queryKey:["share-status",e],queryFn:()=>qe.getShareStatus(e),enabled:!!e,staleTime:3e4});return{data:t,isLoading:n,error:i}}const ED=[{id:"models",label:"/models",description:"Open model selector",icon:Vo},{id:"agents",label:"/agents",description:"Open agent selector",icon:ba},{id:"new",label:"/new",description:"Create new session",icon:Wo},{id:"stop",label:"/stop",description:"Stop current generation",icon:kO},{id:"help",label:"/help",description:"Show keyboard shortcuts and help",icon:MO},{id:"vim",label:"/vim",description:e=>e.vimModeEnabled?"Disable Vim mode":"Enable Vim mode",icon:mB},{id:"reasoning",label:"/reasoning",description:e=>e.reasoningEnabled?"Disable extended thinking":"Enable extended thinking",icon:Uv},{id:"stage",label:"/stage",description:"Stage all changes (git add -A)",icon:zn},{id:"commit",label:"/commit",description:"Commit staged changes",icon:Mi},{id:"compact",label:"/compact",description:"Compact conversation to reduce context size",icon:dF},{id:"branch",label:"/branch",description:"Branch session from last message",icon:wF},{id:"delete",label:"/delete",description:"Delete current session",icon:zv},{id:"share",label:"/share",description:"Share session publicly",icon:Hv},{id:"sync",label:"/sync",description:"Sync new messages to shared session",icon:Ea}];function wD(e,t){return typeof e.description=="function"?e.description(t):e.description}function ZP(e,t){const n=ED.filter(l=>!(l.id==="share"&&t.isShared||l.id==="sync"&&!t.isShared));if(!e)return n;const i=e.toLowerCase(),s=[];for(const l of n){const c=wD(l,t),o=l.label.toLowerCase().includes(i),u=c.toLowerCase().includes(i);if(o||u){const d=o?10:5;s.push({...l,matchScore:d})}}return s.sort((l,c)=>{const o=c.matchScore-l.matchScore;return o!==0?o:l.label.localeCompare(c.label)})}function QP({query:e,selectedIndex:t,onSelect:n,onEnterSelect:i,onClose:s,sessionId:l}){const{preferences:c}=Jo(),{data:o}=Xv(l),u=q.useMemo(()=>({vimModeEnabled:c.vimMode,reasoningEnabled:c.reasoningEnabled,isShared:o?.shared}),[c.vimMode,c.reasoningEnabled,o?.shared]),d=q.useMemo(()=>ZP(e,u),[e,u]);return q.useEffect(()=>{document.getElementById(`command-item-${t}`)?.scrollIntoView({block:"nearest"})},[t]),q.useEffect(()=>{i(d[t]?.id)},[d,t,i]),q.useEffect(()=>{const p=f=>{f.target.closest("[data-command-popup]")||s()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]),d.length===0?y.jsx("div",{"data-command-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg z-50 p-3",children:y.jsx("span",{className:"text-muted-foreground text-sm",children:"No commands found"})}):y.jsx("div",{"data-command-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg max-h-[300px] overflow-y-auto z-50",children:d.map((p,f)=>{const m=p.icon;return y.jsx("button",{type:"button",id:`command-item-${f}`,onMouseDown:v=>{v.preventDefault(),n(p.id)},className:`w-full text-left px-3 py-2 hover:bg-accent ${f===t?"bg-accent":""}`,children:y.jsxs("div",{className:"flex items-center gap-3 w-full",children:[y.jsx(m,{className:"w-4 h-4 flex-shrink-0 text-primary"}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("div",{className:"font-mono text-sm font-medium text-foreground",children:p.label}),y.jsx("div",{className:"text-xs text-muted-foreground truncate",children:wD(p,u)})]})]})},p.id)})})}const JP={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"};function al({isOpen:e,onClose:t,title:n,children:i,showCloseButton:s=!0,closeOnBackdropClick:l=!0,closeOnEscape:c=!0,maxWidth:o="md"}){if(q.useEffect(()=>{if(!e||!c)return;const d=p=>{const f=p.target,m=f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.isContentEditable;(p.key==="Escape"||p.key==="q"&&!m)&&(p.preventDefault(),p.stopPropagation(),t())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,c,t]),q.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e)return null;const u=d=>{l&&d.target===d.currentTarget&&t()};return y.jsxs(y.Fragment,{children:[y.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999] cursor-default",onClick:u,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&u(d)},"aria-label":"Close modal"}),y.jsx("div",{className:`fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[9999] w-full ${JP[o]} px-4`,children:y.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-lg",children:[(n||s)&&y.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[n&&y.jsx("div",{className:"text-lg font-semibold text-foreground",children:n}),s&&y.jsx("button",{type:"button",onClick:t,className:"text-muted-foreground hover:text-foreground transition-colors ml-auto","aria-label":"Close",children:y.jsx(Un,{className:"h-5 w-5"})})]}),y.jsx("div",{className:"p-4",children:i})]})})]})}const e7=[{keys:["Ctrl","H"],description:"Navigate to left sidebar (sessions)",category:"Navigation"},{keys:["Ctrl","L"],description:"Navigate to right sidebar (git)",category:"Navigation"},{keys:["Ctrl","/"],description:"Toggle left sidebar collapse/expand",category:"Navigation"},{keys:["Ctrl","\\"],description:"Toggle right sidebar collapse/expand",category:"Navigation"},{keys:["Ctrl","N"],description:"Create new session",category:"Navigation"},{keys:["ESC"],description:"Close sidebar and return to center",category:"Navigation"},{keys:["J"],description:"Navigate to next item (in focused list)",category:"List Navigation"},{keys:["K"],description:"Navigate to previous item (in focused list)",category:"List Navigation"},{keys:["Enter"],description:"Select focused item and return to input",category:"List Navigation"},{keys:["Space"],description:"Toggle stage/unstage for focused file (git panel)",category:"Git Operations"},{keys:["A"],description:"Stage all unstaged files",category:"Git Operations"},{keys:["U"],description:"Unstage all staged files",category:"Git Operations"},{keys:["C"],description:"Open commit modal (if files are staged)",category:"Git Operations"},{keys:["Tab"],description:"Toggle plan mode",category:"Chat"},{keys:["Enter"],description:"Send message",category:"Chat"},{keys:["Shift","Enter"],description:"New line in message",category:"Chat"},{keys:["@"],description:"Mention file (opens file picker)",category:"Chat"},{keys:["/"],description:"Slash command (opens command menu)",category:"Chat"}],t7=[{keys:["i"],description:"Enter insert mode at cursor (vim mode)",category:"Vim Mode"},{keys:["a"],description:"Enter insert mode after cursor (vim mode)",category:"Vim Mode"},{keys:["I"],description:"Enter insert mode at line start (vim mode)",category:"Vim Mode"},{keys:["A"],description:"Enter insert mode at line end (vim mode)",category:"Vim Mode"},{keys:["o"],description:"New line below and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["O"],description:"New line above and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["ESC"],description:"Return to normal mode (vim mode)",category:"Vim Mode"},{keys:["Enter"],description:"Send message in normal mode (vim mode)",category:"Vim Mode"},{keys:["w"],description:"Jump to next word start (vim mode)",category:"Vim Mode"},{keys:["e"],description:"Jump to next word end (vim mode)",category:"Vim Mode"},{keys:["b"],description:"Jump to previous word start (vim mode)",category:"Vim Mode"},{keys:["x"],description:"Delete character under cursor (vim mode)",category:"Vim Mode"},{keys:["s"],description:"Delete character and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["S"],description:"Delete line and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["f","{char}"],description:"Find and jump to next character on line (vim mode)",category:"Vim Mode"},{keys:["d","d"],description:"Delete current line (vim mode)",category:"Vim Mode"},{keys:["0"],description:"Jump to line start (vim mode)",category:"Vim Mode"},{keys:["$"],description:"Jump to line end (vim mode)",category:"Vim Mode"}],n7=[{command:"/models",description:"Open model selector"},{command:"/agents",description:"Open agent selector"},{command:"/new",description:"Create new session"},{command:"/help",description:"Show keyboard shortcuts and help (this modal)"},{command:"/compact",description:"Compact conversation to reduce context size"}];function r7(e){const t={};for(const n of e)t[n.category]||(t[n.category]=[]),t[n.category].push(n);return t}function i7({isOpen:e,onClose:t}){const n=[...e7,...t7],i=r7(n),s=q.useRef(null),l=q.useRef(null);return q.useEffect(()=>{e?(l.current=document.activeElement,l.current&&l.current.blur()):l.current&&(l.current.focus(),l.current=null)},[e]),q.useEffect(()=>{if(!e)return;const c=o=>{const u=o.target;if(!(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable))if(o.key==="j"){o.preventDefault();const p=s.current;p&&p.scrollBy({top:100,behavior:"smooth"})}else if(o.key==="k"){o.preventDefault();const p=s.current;p&&p.scrollBy({top:-100,behavior:"smooth"})}else o.key==="Enter"&&(o.preventDefault(),t())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,t]),y.jsx(al,{isOpen:e,onClose:t,title:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(MO,{className:"w-5 h-5"}),y.jsx("span",{children:"Keyboard Shortcuts & Help"})]}),maxWidth:"2xl",closeOnEscape:!0,closeOnBackdropClick:!0,children:y.jsxs("div",{ref:s,className:"space-y-6 max-h-[70vh] overflow-y-auto",children:[Object.entries(i).map(([c,o])=>y.jsxs("div",{children:[y.jsxs("h3",{className:"text-sm font-semibold text-foreground mb-3 flex items-center gap-2",children:[y.jsx(vE,{className:"w-4 h-4"}),c]}),y.jsx("div",{className:"space-y-2",children:o.map((u,d)=>y.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:[y.jsx("span",{className:"text-sm text-foreground",children:u.description}),y.jsx("div",{className:"flex items-center gap-1",children:u.keys.map(p=>y.jsxs("span",{className:"flex items-center gap-1",children:[y.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-background border border-border rounded shadow-sm",children:p}),u.keys.indexOf(p)<u.keys.length-1&&y.jsx("span",{className:"text-muted-foreground",children:"+"})]},p))})]},`${c}-${u.description}`))})]},c)),y.jsxs("div",{children:[y.jsxs("h3",{className:"text-sm font-semibold text-foreground mb-3 flex items-center gap-2",children:[y.jsx(vE,{className:"w-4 h-4"}),"Slash Commands"]}),y.jsx("div",{className:"space-y-2",children:n7.map((c,o)=>y.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:[y.jsx("span",{className:"text-sm text-foreground",children:c.description}),y.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-background border border-border rounded shadow-sm",children:c.command})]},c.command))})]}),y.jsx("div",{className:"pt-4 border-t border-border",children:y.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.jsx("strong",{children:"Tip:"})," Shortcuts are disabled when typing in input fields. Press ",y.jsx("kbd",{className:"text-xs",children:"ESC"})," to close popups and return focus to chat input."]})})]})})}const a7=`<svg width="24" height="24" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
24
+ `);try{X=JSON.parse(P),Y=!0}catch{X=P}}Y&&(s&&await s(X),i&&(X=await i(X))),n?.({data:X,event:V,id:f,retry:E}),K.length&&(yield X)}}}finally{_.removeEventListener("abort",D),A.releaseLock()}break}catch(S){if(t?.(S),c!==void 0&&b>=c)break;const k=Math.min(E*2**(b-1),o??3e4);await m(k)}}}()}},hP=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},pP=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},fP=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},vD=({allowReserved:e,explode:t,name:n,style:i,value:s})=>{if(!t){const o=(e?s:s.map(u=>encodeURIComponent(u))).join(pP(i));switch(i){case"label":return`.${o}`;case"matrix":return`;${n}=${o}`;case"simple":return o;default:return`${n}=${o}`}}const l=hP(i),c=s.map(o=>i==="label"||i==="simple"?e?o:encodeURIComponent(o):Dc({allowReserved:e,name:n,value:o})).join(l);return i==="label"||i==="matrix"?l+c:c},Dc=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},_D=({allowReserved:e,explode:t,name:n,style:i,value:s,valueOnly:l})=>{if(s instanceof Date)return l?s.toISOString():`${n}=${s.toISOString()}`;if(i!=="deepObject"&&!t){let u=[];Object.entries(s).forEach(([p,f])=>{u=[...u,p,e?f:encodeURIComponent(f)]});const d=u.join(",");switch(i){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}const c=fP(i),o=Object.entries(s).map(([u,d])=>Dc({allowReserved:e,name:i==="deepObject"?`${n}[${u}]`:u,value:d})).join(c);return i==="label"||i==="matrix"?c+o:o},mP=/\{[^{}]+\}/g,gP=({path:e,url:t})=>{let n=t;const i=t.match(mP);if(i)for(const s of i){let l=!1,c=s.substring(1,s.length-1),o="simple";c.endsWith("*")&&(l=!0,c=c.substring(0,c.length-1)),c.startsWith(".")?(c=c.substring(1),o="label"):c.startsWith(";")&&(c=c.substring(1),o="matrix");const u=e[c];if(u==null)continue;if(Array.isArray(u)){n=n.replace(s,vD({explode:l,name:c,style:o,value:u}));continue}if(typeof u=="object"){n=n.replace(s,_D({explode:l,name:c,style:o,value:u,valueOnly:!0}));continue}if(o==="matrix"){n=n.replace(s,`;${Dc({name:c,value:u})}`);continue}const d=encodeURIComponent(o==="label"?`.${u}`:u);n=n.replace(s,d)}return n},bP=({baseUrl:e,path:t,query:n,querySerializer:i,url:s})=>{const l=s.startsWith("/")?s:`/${s}`;let c=(e??"")+l;t&&(c=gP({path:t,url:c}));let o=n?i(n):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(c+=`?${o}`),c};function yP(e){const t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}const vP=async(e,t)=>{const n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},_P=({allowReserved:e,array:t,object:n}={})=>s=>{const l=[];if(s&&typeof s=="object")for(const c in s){const o=s[c];if(o!=null)if(Array.isArray(o)){const u=vD({allowReserved:e,explode:!0,name:c,style:"form",value:o,...t});u&&l.push(u)}else if(typeof o=="object"){const u=_D({allowReserved:e,explode:!0,name:c,style:"deepObject",value:o,...n});u&&l.push(u)}else{const u=Dc({allowReserved:e,name:c,value:o});u&&l.push(u)}}return l.join("&")},SP=(e,t)=>t?t in e.headers||e.query?.[t]?!0:"Cookie"in e.headers&&e.headers.Cookie&&typeof e.headers.Cookie=="string"?e.headers.Cookie.includes(`${t}=`):!1:!1,xP=async({security:e,...t})=>{for(const n of e){if(SP(t,n.name))continue;const i=await vP(n,t.auth);if(!i)continue;const s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=i;break;case"cookie":{const l=`${s}=${i}`;"Cookie"in t.headers&&t.headers.Cookie?t.headers.Cookie=`${t.headers.Cookie}; ${l}`:t.headers.Cookie=l;break}default:t.headers[s]=i;break}}},$E=e=>{const t=e.axios?.defaults?.baseURL,n=e.baseURL&&typeof e.baseURL=="string"?e.baseURL:t;return bP({baseUrl:n,path:e.path,query:e.paramsSerializer?void 0:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_P(e.querySerializer),url:e.url})},GE=(e,t)=>{const n={...e,...t};return n.headers=iv(e.headers,t.headers),n},EP=["common","delete","get","head","patch","post","put"],iv=(...e)=>{const t={};for(const n of e){if(!n||typeof n!="object")continue;const i=Object.entries(n);for(const[s,l]of i)if(EP.includes(s)&&typeof l=="object")t[s]={...t[s],...l};else if(l===null)delete t[s];else if(Array.isArray(l))for(const c of l)t[s]=[...t[s]??[],c];else l!==void 0&&(t[s]=typeof l=="object"?JSON.stringify(l):l)}return t},SD=(e={})=>({...e}),wP=(e={})=>{let t=GE(SD(),e),n;if(t.axios&&!("Axios"in t.axios))n=t.axios;else{const{auth:d,...p}=t;n=jt.create(p)}const i=()=>({...t}),s=d=>(t=GE(t,d),n.defaults={...n.defaults,...t,headers:iv(n.defaults.headers,t.headers)},i()),l=async d=>{const p={...t,...d,axios:d.axios??t.axios??n,headers:iv(t.headers,d.headers)};p.security&&await xP({...p,security:p.security}),p.requestValidator&&await p.requestValidator(p),p.body!==void 0&&p.bodySerializer&&(p.body=p.bodySerializer(p.body));const f=$E(p);return{opts:p,url:f}},c=async d=>{const{opts:p,url:f}=await l(d);try{const m=p.axios,{auth:v,...w}=p,E=await m({...w,baseURL:"",data:yP(p),headers:p.headers,params:p.paramsSerializer?p.query:void 0,url:f});let{data:b}=E;return p.responseType==="json"&&(p.responseValidator&&await p.responseValidator(b),p.responseTransformer&&(b=await p.responseTransformer(b))),{...E,data:b??{}}}catch(m){const v=m;if(p.throwOnError)throw v;return v.error=v.response?.data??{},v}},o=d=>p=>c({...p,method:d}),u=d=>async p=>{const{opts:f,url:m}=await l(p);return dP({...f,body:f.body,headers:f.headers,method:d,signal:f.signal,url:m})};return{buildUrl:$E,connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),getConfig:i,head:o("HEAD"),instance:n,options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),request:c,setConfig:s,sse:{connect:u("CONNECT"),delete:u("DELETE"),get:u("GET"),head:u("HEAD"),options:u("OPTIONS"),patch:u("PATCH"),post:u("POST"),put:u("PUT"),trace:u("TRACE")},trace:o("TRACE")}},CP=(e={})=>({...e,baseURL:e.baseURL}),Mt=wP(CP(SD())),kP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/sessions",...e}),TP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/sessions",...e,headers:{"Content-Type":"application/json",...e?.headers}}),RP=e=>(e.client??Mt).delete({responseType:"json",url:"/v1/sessions/{sessionId}/abort",...e}),AP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/sessions/{id}/messages",...e}),NP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/sessions/{id}/messages",...e,headers:{"Content-Type":"application/json",...e.headers}}),OP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/config",...e}),DP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/config/providers/{provider}/models",...e}),IP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/files",...e}),LP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/git/status",...e}),MP=e=>(e.client??Mt).get({responseType:"json",url:"/v1/git/diff",...e}),BP=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/git/branch",...e}),FP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/stage",...e,headers:{"Content-Type":"application/json",...e.headers}}),jP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/unstage",...e,headers:{"Content-Type":"application/json",...e.headers}}),PP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/commit",...e,headers:{"Content-Type":"application/json",...e.headers}}),UP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/git/generate-commit-message",...e,headers:{"Content-Type":"application/json",...e?.headers}}),HP=e=>(e?.client??Mt).post({responseType:"json",url:"/v1/git/push",...e,headers:{"Content-Type":"application/json",...e?.headers}}),zP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/restore",...e,headers:{"Content-Type":"application/json",...e.headers}}),qP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/git/delete",...e,headers:{"Content-Type":"application/json",...e.headers}}),$P=e=>(e?.client??Mt).get({responseType:"json",url:"/v1/terminals",...e}),GP=e=>(e.client??Mt).post({responseType:"json",url:"/v1/terminals",...e,headers:{"Content-Type":"application/json",...e.headers}}),WP={};function xD(){const e=WP?.VITE_API_BASE_URL;if(e)return e;if(typeof window<"u"){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(t.__AGI_API_URL__)return t.__AGI_API_URL__}return"http://localhost:9100"}function VP(){return xD()}const Ic=xD();function ft(e){if(!e)return"Unknown error";if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(t.error&&typeof t.error=="object"){const n=t.error;if(typeof n.message=="string")return n.message}if(typeof t.error=="string")return t.error;if(typeof t.message=="string")return t.message;try{return JSON.stringify(e)}catch{return"Error occurred (unable to parse)"}}return"Unknown error"}function KP(){const t=window.AGI_SERVER_URL||Ic;Mt.setConfig({baseURL:t})}KP();function Op(e){return{...e,title:e.title??null,createdAt:typeof e.createdAt=="string"?new Date(e.createdAt).getTime():e.createdAt,lastActiveAt:typeof e.lastActiveAt=="string"?new Date(e.lastActiveAt).getTime():e.lastActiveAt}}function YP(e){return{...e,createdAt:typeof e.createdAt=="string"?new Date(e.createdAt).getTime():e.createdAt,completedAt:e.completedAt?typeof e.completedAt=="string"?new Date(e.completedAt).getTime():e.completedAt:null}}class XP{get baseUrl(){const t=window;return t.AGI_SERVER_URL?t.AGI_SERVER_URL:Ic}async getSessions(){const t=await kP();if(t.error)throw new Error(ft(t.error));return(t.data||[]).map(Op)}async createSession(t){const n=await TP({body:t});if(n.error)throw new Error(ft(n.error));if(!n.data)throw new Error("No data returned from create session");return Op(n.data)}async updateSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to update session"}));throw new Error(ft(l))}const s=await i.json();return Op(s)}async deleteSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete session"}));throw new Error(ft(i))}return await n.json()}async abortSession(t){const n=await RP({path:{sessionId:t}});if(n.error)throw new Error(ft(n.error));return n.data}async abortMessage(t,n){const i=this.baseUrl,s=await fetch(`${i}/v1/sessions/${t}/abort`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:n})});if(!s.ok)throw new Error("Failed to abort message");return s.json()}async getQueueState(t){const n=this.baseUrl,i=await fetch(`${n}/v1/sessions/${t}/queue`);if(!i.ok)throw new Error("Failed to get queue state");return i.json()}async removeFromQueue(t,n){const i=this.baseUrl,s=await fetch(`${i}/v1/sessions/${t}/queue/${n}`,{method:"DELETE"});if(!s.ok)throw new Error("Failed to remove from queue");return s.json()}async getMessages(t){const n=await AP({path:{id:t}});if(n.error)throw new Error(ft(n.error));return(n.data||[]).map(YP)}async sendMessage(t,n){const i=await NP({path:{id:t},body:n});if(i.error)throw new Error(ft(i.error));return i.data}getStreamUrl(t){return`${this.baseUrl}/v1/sessions/${t}/stream`}async getConfig(){const t=await OP();if(t.error)throw new Error(ft(t.error));return t.data}async getModels(t){const n=await DP({path:{provider:t}});if(n.error)throw new Error(ft(n.error));return n.data}async getAllModels(){const t=await fetch(`${this.baseUrl}/v1/config/models`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to fetch models"}));throw new Error(ft(n))}return await t.json()}async updateDefaults(t){const n=await fetch(`${this.baseUrl}/v1/config/defaults`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to update defaults"}));throw new Error(ft(i))}return await n.json()}async getGitStatus(){const t=await LP();if(t.error)throw new Error(ft(t.error));return t.data?.data}async getGitDiff(t,n=!1){const i=await MP({query:{file:t,staged:n?"true":"false"}});if(i.error)throw new Error(ft(i.error));return i.data?.data}async generateCommitMessage(t){const n=await UP({body:t?{sessionId:t}:{}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async stageFiles(t){const n=await FP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async unstageFiles(t){const n=await jP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async restoreFiles(t){const n=await zP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async deleteFiles(t){const n=await qP({body:{files:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async commitChanges(t){const n=await PP({body:{message:t}});if(n.error)throw new Error(ft(n.error));return n.data?.data}async getGitBranch(){const t=await BP();if(t.error)throw new Error(ft(t.error));return t.data?.data}async pushCommits(){const t=await HP({body:{}});if(t.error)throw new Error(ft(t.error));return t.data?.data}async listFiles(){const t=await IP();if(t.error)throw new Error(ft(t.error));return t.data}async getSessionFiles(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/files`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch session files"}));throw new Error(ft(i))}return await n.json()}async createBranch(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create branch"}));throw new Error(ft(s))}return await i.json()}async listBranches(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/branches`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to list branches"}));throw new Error(ft(i))}return await n.json()}async getParentSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/parent`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to get parent session"}));throw new Error(ft(i))}return await n.json()}async getSetuBalance(){try{const t=await fetch(`${this.baseUrl}/v1/setu/balance`,{method:"GET",headers:{"Content-Type":"application/json"}});return t.ok?await t.json():null}catch{return null}}async getSetuWallet(){try{const t=await fetch(`${this.baseUrl}/v1/setu/wallet`,{method:"GET",headers:{"Content-Type":"application/json"}});return t.ok?await t.json():{configured:!1}}catch{return{configured:!1}}}async getSetuUsdcBalance(t="mainnet"){try{const n=await fetch(`${this.baseUrl}/v1/setu/usdc-balance?network=${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():null}catch{return null}}async getShareStatus(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():{shared:!1}}async shareSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to share session"}));throw new Error(ft(i))}return await n.json()}async syncSession(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/share`,{method:"PUT",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to sync session"}));throw new Error(ft(i))}return await n.json()}async approveToolCall(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/approval`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:i})});if(!s.ok)throw new Error("Failed to send tool approval");return await s.json()}async getPendingApprovals(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/approval/pending`,{method:"GET",headers:{"Content-Type":"application/json"}});return n.ok?await n.json():{ok:!1,pending:[]}}}const qe=new XP;function Xv(e){const{data:t,isLoading:n,error:i}=qn({queryKey:["share-status",e],queryFn:()=>qe.getShareStatus(e),enabled:!!e,staleTime:3e4});return{data:t,isLoading:n,error:i}}const ED=[{id:"models",label:"/models",description:"Open model selector",icon:Vo},{id:"agents",label:"/agents",description:"Open agent selector",icon:ba},{id:"new",label:"/new",description:"Create new session",icon:Wo},{id:"stop",label:"/stop",description:"Stop current generation",icon:kO},{id:"help",label:"/help",description:"Show keyboard shortcuts and help",icon:MO},{id:"vim",label:"/vim",description:e=>e.vimModeEnabled?"Disable Vim mode":"Enable Vim mode",icon:mB},{id:"reasoning",label:"/reasoning",description:e=>e.reasoningEnabled?"Disable extended thinking":"Enable extended thinking",icon:Uv},{id:"stage",label:"/stage",description:"Stage all changes (git add -A)",icon:zn},{id:"commit",label:"/commit",description:"Commit staged changes",icon:Mi},{id:"compact",label:"/compact",description:"Compact conversation to reduce context size",icon:dF},{id:"branch",label:"/branch",description:"Branch session from last message",icon:wF},{id:"delete",label:"/delete",description:"Delete current session",icon:zv},{id:"share",label:"/share",description:"Share session publicly",icon:Hv},{id:"sync",label:"/sync",description:"Sync new messages to shared session",icon:Ea}];function wD(e,t){return typeof e.description=="function"?e.description(t):e.description}function ZP(e,t){const n=ED.filter(l=>!(l.id==="share"&&t.isShared||l.id==="sync"&&!t.isShared));if(!e)return n;const i=e.toLowerCase(),s=[];for(const l of n){const c=wD(l,t),o=l.label.toLowerCase().includes(i),u=c.toLowerCase().includes(i);if(o||u){const d=o?10:5;s.push({...l,matchScore:d})}}return s.sort((l,c)=>{const o=c.matchScore-l.matchScore;return o!==0?o:l.label.localeCompare(c.label)})}function QP({query:e,selectedIndex:t,onSelect:n,onEnterSelect:i,onClose:s,sessionId:l}){const{preferences:c}=Jo(),{data:o}=Xv(l),u=q.useMemo(()=>({vimModeEnabled:c.vimMode,reasoningEnabled:c.reasoningEnabled,isShared:o?.shared}),[c.vimMode,c.reasoningEnabled,o?.shared]),d=q.useMemo(()=>ZP(e,u),[e,u]);return q.useEffect(()=>{document.getElementById(`command-item-${t}`)?.scrollIntoView({block:"nearest"})},[t]),q.useEffect(()=>{i(d[t]?.id)},[d,t,i]),q.useEffect(()=>{const p=f=>{f.target.closest("[data-command-popup]")||s()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]),d.length===0?y.jsx("div",{"data-command-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg z-50 p-3",children:y.jsx("span",{className:"text-muted-foreground text-sm",children:"No commands found"})}):y.jsx("div",{"data-command-popup":!0,className:"absolute bottom-full left-0 right-0 mb-2 bg-card border border-border rounded-lg shadow-lg max-h-[300px] overflow-y-auto z-50",children:d.map((p,f)=>{const m=p.icon;return y.jsx("button",{type:"button",id:`command-item-${f}`,onMouseDown:v=>{v.preventDefault(),n(p.id)},className:`w-full text-left px-3 py-2 hover:bg-accent ${f===t?"bg-accent":""}`,children:y.jsxs("div",{className:"flex items-center gap-3 w-full",children:[y.jsx(m,{className:"w-4 h-4 flex-shrink-0 text-primary"}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("div",{className:"font-mono text-sm font-medium text-foreground",children:p.label}),y.jsx("div",{className:"text-xs text-muted-foreground truncate",children:wD(p,u)})]})]})},p.id)})})}const JP={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"};function al({isOpen:e,onClose:t,title:n,children:i,showCloseButton:s=!0,closeOnBackdropClick:l=!0,closeOnEscape:c=!0,maxWidth:o="md"}){if(q.useEffect(()=>{if(!e||!c)return;const d=p=>{const f=p.target,m=f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.isContentEditable;(p.key==="Escape"||p.key==="q"&&!m)&&(p.preventDefault(),p.stopPropagation(),t())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,c,t]),q.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e)return null;const u=d=>{l&&d.target===d.currentTarget&&t()};return y.jsxs(y.Fragment,{children:[y.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999] cursor-default",onClick:u,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&u(d)},"aria-label":"Close modal"}),y.jsx("div",{className:`fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[9999] w-full ${JP[o]} px-4`,children:y.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-lg",children:[(n||s)&&y.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[n&&y.jsx("div",{className:"text-lg font-semibold text-foreground",children:n}),s&&y.jsx("button",{type:"button",onClick:t,className:"text-muted-foreground hover:text-foreground transition-colors ml-auto","aria-label":"Close",children:y.jsx(Un,{className:"h-5 w-5"})})]}),y.jsx("div",{className:"p-4",children:i})]})})]})}const e7=[{keys:["Ctrl","H"],description:"Navigate to left sidebar (sessions)",category:"Navigation"},{keys:["Ctrl","L"],description:"Navigate to right sidebar (git)",category:"Navigation"},{keys:["Ctrl","/"],description:"Toggle left sidebar collapse/expand",category:"Navigation"},{keys:["Ctrl","\\"],description:"Toggle right sidebar collapse/expand",category:"Navigation"},{keys:["Ctrl","N"],description:"Create new session",category:"Navigation"},{keys:["ESC"],description:"Close sidebar and return to center",category:"Navigation"},{keys:["J"],description:"Navigate to next item (in focused list)",category:"List Navigation"},{keys:["K"],description:"Navigate to previous item (in focused list)",category:"List Navigation"},{keys:["Enter"],description:"Select focused item and return to input",category:"List Navigation"},{keys:["Space"],description:"Toggle stage/unstage for focused file (git panel)",category:"Git Operations"},{keys:["A"],description:"Stage all unstaged files",category:"Git Operations"},{keys:["U"],description:"Unstage all staged files",category:"Git Operations"},{keys:["C"],description:"Open commit modal (if files are staged)",category:"Git Operations"},{keys:["Tab"],description:"Toggle plan mode",category:"Chat"},{keys:["Enter"],description:"Send message",category:"Chat"},{keys:["Shift","Enter"],description:"New line in message",category:"Chat"},{keys:["@"],description:"Mention file (opens file picker)",category:"Chat"},{keys:["/"],description:"Slash command (opens command menu)",category:"Chat"}],t7=[{keys:["i"],description:"Enter insert mode at cursor (vim mode)",category:"Vim Mode"},{keys:["a"],description:"Enter insert mode after cursor (vim mode)",category:"Vim Mode"},{keys:["I"],description:"Enter insert mode at line start (vim mode)",category:"Vim Mode"},{keys:["A"],description:"Enter insert mode at line end (vim mode)",category:"Vim Mode"},{keys:["o"],description:"New line below and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["O"],description:"New line above and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["ESC"],description:"Return to normal mode (vim mode)",category:"Vim Mode"},{keys:["Enter"],description:"Send message in normal mode (vim mode)",category:"Vim Mode"},{keys:["w"],description:"Jump to next word start (vim mode)",category:"Vim Mode"},{keys:["e"],description:"Jump to next word end (vim mode)",category:"Vim Mode"},{keys:["b"],description:"Jump to previous word start (vim mode)",category:"Vim Mode"},{keys:["x"],description:"Delete character under cursor (vim mode)",category:"Vim Mode"},{keys:["s"],description:"Delete character and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["S"],description:"Delete line and enter insert mode (vim mode)",category:"Vim Mode"},{keys:["f","{char}"],description:"Find and jump to next character on line (vim mode)",category:"Vim Mode"},{keys:["d","d"],description:"Delete current line (vim mode)",category:"Vim Mode"},{keys:["0"],description:"Jump to line start (vim mode)",category:"Vim Mode"},{keys:["$"],description:"Jump to line end (vim mode)",category:"Vim Mode"}],n7=[{command:"/models",description:"Open model selector"},{command:"/agents",description:"Open agent selector"},{command:"/new",description:"Create new session"},{command:"/help",description:"Show keyboard shortcuts and help (this modal)"},{command:"/compact",description:"Compact conversation to reduce context size"}];function r7(e){const t={};for(const n of e)t[n.category]||(t[n.category]=[]),t[n.category].push(n);return t}function i7({isOpen:e,onClose:t}){const n=[...e7,...t7],i=r7(n),s=q.useRef(null),l=q.useRef(null);return q.useEffect(()=>{e?(l.current=document.activeElement,l.current&&l.current.blur()):l.current&&(l.current.focus(),l.current=null)},[e]),q.useEffect(()=>{if(!e)return;const c=o=>{const u=o.target;if(!(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable))if(o.key==="j"){o.preventDefault();const p=s.current;p&&p.scrollBy({top:100,behavior:"smooth"})}else if(o.key==="k"){o.preventDefault();const p=s.current;p&&p.scrollBy({top:-100,behavior:"smooth"})}else o.key==="Enter"&&(o.preventDefault(),t())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,t]),y.jsx(al,{isOpen:e,onClose:t,title:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(MO,{className:"w-5 h-5"}),y.jsx("span",{children:"Keyboard Shortcuts & Help"})]}),maxWidth:"2xl",closeOnEscape:!0,closeOnBackdropClick:!0,children:y.jsxs("div",{ref:s,className:"space-y-6 max-h-[70vh] overflow-y-auto",children:[Object.entries(i).map(([c,o])=>y.jsxs("div",{children:[y.jsxs("h3",{className:"text-sm font-semibold text-foreground mb-3 flex items-center gap-2",children:[y.jsx(vE,{className:"w-4 h-4"}),c]}),y.jsx("div",{className:"space-y-2",children:o.map((u,d)=>y.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:[y.jsx("span",{className:"text-sm text-foreground",children:u.description}),y.jsx("div",{className:"flex items-center gap-1",children:u.keys.map(p=>y.jsxs("span",{className:"flex items-center gap-1",children:[y.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-background border border-border rounded shadow-sm",children:p}),u.keys.indexOf(p)<u.keys.length-1&&y.jsx("span",{className:"text-muted-foreground",children:"+"})]},p))})]},`${c}-${u.description}`))})]},c)),y.jsxs("div",{children:[y.jsxs("h3",{className:"text-sm font-semibold text-foreground mb-3 flex items-center gap-2",children:[y.jsx(vE,{className:"w-4 h-4"}),"Slash Commands"]}),y.jsx("div",{className:"space-y-2",children:n7.map((c,o)=>y.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:[y.jsx("span",{className:"text-sm text-foreground",children:c.description}),y.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-background border border-border rounded shadow-sm",children:c.command})]},c.command))})]}),y.jsx("div",{className:"pt-4 border-t border-border",children:y.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.jsx("strong",{children:"Tip:"})," Shortcuts are disabled when typing in input fields. Press ",y.jsx("kbd",{className:"text-xs",children:"ESC"})," to close popups and return focus to chat input."]})})]})})}const a7=`<svg width="24" height="24" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
25
25
  <path d="M26.9568 9.88184H22.1265L30.7753 31.7848H35.4917L26.9568 9.88184ZM13.028 9.88184L4.4917 31.7848H9.32203L11.2305 27.1793H20.2166L22.0126 31.6724H26.8444L18.0832 9.88184H13.028ZM12.5783 23.1361L15.4987 15.3853L18.5315 23.1361H12.5783Z" fill="currentColor"/>
26
26
  </svg>`,s7=`<svg width="24" height="24" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
27
27
  <path d="M32.8377 17.282C33.2127 16.25 33.3072 15.218 33.2127 14.1875C33.1197 13.1571 32.7447 12.1251 32.2752 11.1876C31.4322 9.78209 30.2127 8.6571 28.8072 8.0001C27.3072 7.34461 25.7127 7.15711 24.1197 7.53211C23.3698 6.78212 22.5253 6.12512 21.5878 5.65713C20.6503 5.18913 19.5253 5.00013 18.4948 5.00013C16.8851 4.99074 15.3125 5.48246 13.9948 6.40712C12.6824 7.34311 11.7449 8.6571 11.2754 10.1571C10.1504 10.4376 9.21289 10.9071 8.27539 11.4696C7.4324 12.1251 6.77541 12.9696 6.21291 13.8126C5.36992 15.2195 5.08792 16.8125 5.27542 18.407C5.46399 19.9968 6.11605 21.496 7.1504 22.718C6.79608 23.7086 6.66795 24.7659 6.77541 25.8124C6.86991 26.8444 7.2449 27.8749 7.7129 28.8124C8.55739 30.2194 9.77538 31.3444 11.1824 31.9999C12.6824 32.6569 14.2753 32.8444 15.8698 32.4694C16.6198 33.2194 17.4628 33.8749 18.4003 34.3444C19.3378 34.8139 20.4628 34.9999 21.4948 34.9999C23.1043 35.0097 24.6769 34.5185 25.9947 33.5944C27.3072 32.6569 28.2447 31.3444 28.7127 29.8444C29.7719 29.6432 30.7682 29.1934 31.6197 28.5319C32.4627 27.8749 33.2127 27.1249 33.6822 26.1874C34.5251 24.7819 34.8071 23.1875 34.6196 21.5945C34.4322 20 33.8697 18.5015 32.8377 17.282ZM21.5878 33.0304C20.0878 33.0304 18.9628 32.5609 17.9323 31.7179C17.9323 31.7179 18.0253 31.6234 18.1198 31.6234L24.1197 28.1554C24.2862 28.0803 24.4196 27.9469 24.4947 27.7804C24.5698 27.636 24.6021 27.4731 24.5877 27.3109V18.875L27.1197 20.375V27.3124C27.1455 28.0547 27.0215 28.7945 26.755 29.4878C26.4885 30.181 26.085 30.8134 25.5687 31.3473C25.0523 31.8811 24.4337 32.3054 23.7497 32.5949C23.0658 32.8843 22.3305 33.0314 21.5878 33.0304ZM9.49488 27.8749C8.83789 26.7499 8.55739 25.4374 8.83789 24.125C8.83789 24.125 8.93239 24.2195 9.02539 24.2195L15.0253 27.6874C15.1693 27.7638 15.3325 27.7966 15.4948 27.7819C15.6823 27.7819 15.8698 27.7819 15.9628 27.6874L23.2753 23.4695V26.3749L17.1823 29.9374C16.5506 30.3042 15.8527 30.5427 15.1287 30.6393C14.4046 30.7358 13.6686 30.6884 12.9629 30.4999C11.4629 30.1249 10.2449 29.1874 9.49488 27.8749ZM7.9004 14.8445C8.56239 13.7234 9.58826 12.8627 10.8074 12.4056V19.532C10.8074 19.718 10.8074 19.907 10.9004 20C10.9755 20.1665 11.1089 20.2998 11.2754 20.375L18.5878 24.5944L16.0573 26.0944L10.0574 22.625C9.41842 22.2639 8.85742 21.7797 8.40684 21.2004C7.95627 20.6211 7.62506 19.9582 7.4324 19.25C7.05741 17.8445 7.1504 16.157 7.9004 14.8445ZM28.6197 19.625L21.3073 15.407L23.8377 13.9071L29.8377 17.375C30.7752 17.9375 31.5252 18.6875 31.9947 19.625C32.4642 20.5625 32.7447 21.5945 32.6502 22.7195C32.5603 23.7755 32.1699 24.7837 31.5252 25.6249C30.8697 26.4694 30.0252 27.1249 28.9947 27.4999V20.375C28.9947 20.1875 28.9947 20 28.9002 19.907C28.9002 19.907 28.8072 19.718 28.6197 19.625ZM31.1502 15.875C31.1502 15.875 31.0572 15.782 30.9627 15.782L24.9627 12.3126C24.7752 12.2196 24.6822 12.2196 24.4947 12.2196C24.3072 12.2196 24.1197 12.2196 24.0252 12.3126L16.7128 16.532V13.6251L22.8073 10.0626C23.7448 9.50009 24.7752 9.31259 25.9002 9.31259C26.9322 9.31259 27.9627 9.68759 28.9002 10.3446C29.7447 11.0001 30.4947 11.8446 30.8697 12.7821C31.2447 13.7196 31.3377 14.8445 31.1502 15.875ZM15.4003 21.125L12.8699 19.625V12.5946C12.8699 11.5626 13.1503 10.4376 13.7128 9.59459C14.2753 8.6571 15.1198 8.0001 16.0573 7.53211C17.0127 7.05249 18.0956 6.88812 19.1503 7.06261C20.1823 7.15711 21.2128 7.62511 22.0573 8.2821C22.0573 8.2821 21.9628 8.3751 21.8698 8.3751L15.8698 11.8446C15.7033 11.9197 15.57 12.0531 15.4948 12.2196C15.4003 12.4071 15.4003 12.5001 15.4003 12.6876V21.125ZM16.7128 18.125L19.9948 16.25L23.2753 18.125V21.875L19.9948 23.75L16.7128 21.875V18.125Z" fill="currentColor"/>
@@ -47,7 +47,7 @@ Error generating stack: `+g.message+`
47
47
  </svg>`,p7=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
48
48
  <path opacity="0.2" d="M19.2002 17.4H8.40017V13.8H15.6002V10.2H19.2002V17.4ZM8.40017 13.8H4.80017V10.2H8.40017V13.8Z" fill="currentColor"/>
49
49
  <path d="M8.40005 17.4H19.2001V21H4.80005V13.8H8.40005V17.4ZM15.6001 10.2V13.8H8.40005V10.2H15.6001ZM19.2001 10.2H15.6001V6.6H4.80005V3H19.2001V10.2Z" fill="currentColor"/>
50
- </svg>`,f7={anthropic:a7,openai:s7,google:o7,openrouter:l7,groq:u7,deepseek:c7,xai:d7,zai:WE,"zai-coding":WE,solforge:h7,opencode:p7},Lc=q.memo(function({provider:t,className:n="",size:i=16}){const s=f7[t.toLowerCase()];return s?y.jsx("span",{className:`inline-flex items-center justify-center text-foreground/70 dark:text-foreground/80 ${n}`,style:{width:i,height:i},title:t,dangerouslySetInnerHTML:{__html:s.replace(/<svg/,`<svg width="${i}" height="${i}" style="width:${i}px;height:${i}px"`)}}):y.jsx("span",{className:`inline-flex items-center justify-center text-[10px] font-medium text-muted-foreground uppercase ${n}`,style:{width:i,height:i},title:t,children:t.slice(0,2)})});function m7(){return qn({queryKey:["files"],queryFn:async()=>await qe.listFiles(),staleTime:1e4,refetchOnWindowFocus:!0,retry:1})}function g7({enabled:e,onSend:t,textareaRef:n,setMessage:i}){const[s,l]=q.useState(e?"normal":"insert"),[c,o]=q.useState(""),u=q.useCallback((m,v)=>{for(;v<m.length&&/\S/.test(m[v]);)v++;for(;v<m.length&&/\s/.test(m[v]);)v++;return Math.min(v,m.length)},[]),d=q.useCallback((m,v)=>{for(v<m.length&&/\S/.test(m[v])&&v++;v<m.length&&/\s/.test(m[v]);)v++;for(;v<m.length&&/\S/.test(m[v]);)v++;return Math.max(0,v-1)},[]),p=q.useCallback((m,v)=>{for(v=Math.max(0,v-1);v>0&&/\s/.test(m[v]);)v--;for(;v>0&&/\S/.test(m[v-1]);)v--;return v},[]),f=q.useCallback(m=>{const v=n.current;if(!v)return!1;const w=m.key;if(w==="i")return m.preventDefault(),l("insert"),!0;if(w==="a"){m.preventDefault(),l("insert");const E=v.selectionStart;return setTimeout(()=>{v.setSelectionRange(E+1,E+1)},0),!0}if(w==="I"){m.preventDefault(),l("insert");const b=v.value.lastIndexOf(`
50
+ </svg>`,f7={anthropic:a7,openai:s7,google:o7,openrouter:l7,groq:u7,deepseek:c7,xai:d7,zai:WE,"zai-coding":WE,setu:h7,opencode:p7},Lc=q.memo(function({provider:t,className:n="",size:i=16}){const s=f7[t.toLowerCase()];return s?y.jsx("span",{className:`inline-flex items-center justify-center text-foreground/70 dark:text-foreground/80 ${n}`,style:{width:i,height:i},title:t,dangerouslySetInnerHTML:{__html:s.replace(/<svg/,`<svg width="${i}" height="${i}" style="width:${i}px;height:${i}px"`)}}):y.jsx("span",{className:`inline-flex items-center justify-center text-[10px] font-medium text-muted-foreground uppercase ${n}`,style:{width:i,height:i},title:t,children:t.slice(0,2)})});function m7(){return qn({queryKey:["files"],queryFn:async()=>await qe.listFiles(),staleTime:1e4,refetchOnWindowFocus:!0,retry:1})}function g7({enabled:e,onSend:t,textareaRef:n,setMessage:i}){const[s,l]=q.useState(e?"normal":"insert"),[c,o]=q.useState(""),u=q.useCallback((m,v)=>{for(;v<m.length&&/\S/.test(m[v]);)v++;for(;v<m.length&&/\s/.test(m[v]);)v++;return Math.min(v,m.length)},[]),d=q.useCallback((m,v)=>{for(v<m.length&&/\S/.test(m[v])&&v++;v<m.length&&/\s/.test(m[v]);)v++;for(;v<m.length&&/\S/.test(m[v]);)v++;return Math.max(0,v-1)},[]),p=q.useCallback((m,v)=>{for(v=Math.max(0,v-1);v>0&&/\s/.test(m[v]);)v--;for(;v>0&&/\S/.test(m[v-1]);)v--;return v},[]),f=q.useCallback(m=>{const v=n.current;if(!v)return!1;const w=m.key;if(w==="i")return m.preventDefault(),l("insert"),!0;if(w==="a"){m.preventDefault(),l("insert");const E=v.selectionStart;return setTimeout(()=>{v.setSelectionRange(E+1,E+1)},0),!0}if(w==="I"){m.preventDefault(),l("insert");const b=v.value.lastIndexOf(`
51
51
  `,v.selectionStart-1)+1;return setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}if(w==="A"){m.preventDefault(),l("insert");const E=v.value;let b=E.indexOf(`
52
52
  `,v.selectionStart);return b===-1&&(b=E.length),setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}if(w==="0"){m.preventDefault();const b=v.value.lastIndexOf(`
53
53
  `,v.selectionStart-1)+1;return v.setSelectionRange(b,b),!0}if(w==="$"){m.preventDefault();const E=v.value;let b=E.indexOf(`
@@ -64,11 +64,11 @@ ${E.slice(b)}`;return i(_),setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}if(c=
64
64
  `,v.selectionStart-1)+1;let _=E.indexOf(`
65
65
  `,v.selectionStart);_===-1?_=E.length:_+=1;const x=E.slice(0,b)+E.slice(_);return i(x),o(""),setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}return m.preventDefault(),o("d"),setTimeout(()=>o(""),1e3),!0}if(w==="Enter")return m.preventDefault(),t(),!0;if(w==="Escape")return m.preventDefault(),!0;if(w==="w"){m.preventDefault();const E=v.value,b=u(E,v.selectionStart);return v.setSelectionRange(b,b),!0}if(w==="e"){m.preventDefault();const E=v.value,b=d(E,v.selectionStart);return v.setSelectionRange(b,b),!0}if(w==="b"){m.preventDefault();const E=v.value,b=p(E,v.selectionStart);return v.setSelectionRange(b,b),!0}if(w==="x"){m.preventDefault();const E=v.value,b=v.selectionStart;if(b<E.length){const _=E.slice(0,b)+E.slice(b+1);i(_),setTimeout(()=>{v.setSelectionRange(b,b)},0)}return!0}if(w==="s"){m.preventDefault();const E=v.value,b=v.selectionStart;if(b<E.length){const _=E.slice(0,b)+E.slice(b+1);i(_),l("insert"),setTimeout(()=>{v.setSelectionRange(b,b)},0)}else l("insert");return!0}if(w==="S"){m.preventDefault();const E=v.value,b=E.lastIndexOf(`
66
66
  `,v.selectionStart-1)+1;let _=E.indexOf(`
67
- `,v.selectionStart);_===-1&&(_=E.length);const x=E.slice(0,b)+E.slice(_);return i(x),l("insert"),setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}return!1},[c,t,n,i,u,d,p]);return{vimMode:s,setVimMode:l,handleVimNormalMode:f}}function b7(){const[e,t]=q.useState(!1),[n,i]=q.useState(""),[s,l]=q.useState(0),[c,o]=q.useState(),u=q.useCallback((f,m,v)=>{const w=m.current;if(!w)return;const E=w.value,b=w.selectionStart,x=E.slice(0,b).match(/@(\S*)$/);if(!x)return;const S=b-x[0].length,k=`${E.slice(0,S)}@${f} ${E.slice(b)}`;v(k),t(!1),setTimeout(()=>{const O=S+f.length+2;w.setSelectionRange(O,O),w.focus()},0)},[]),d=q.useCallback(f=>{o(f)},[]),p=q.useCallback((f,m)=>{const w=f.slice(0,m).match(/@(\S*)$/);w?(t(!0),i(w[1]),l(0)):t(!1)},[]);return{showFileMention:e,mentionQuery:n,mentionSelectedIndex:s,currentFileToSelect:c,setShowFileMention:t,setMentionQuery:i,setMentionSelectedIndex:l,setCurrentFileToSelect:o,handleFileSelect:u,handleEnterSelect:d,checkForMention:p}}function y7({onCommand:e,updatePreferences:t,vimModeEnabled:n,reasoningEnabled:i,textareaRef:s,setMessage:l,setShowShortcutsModal:c,sessionId:o}){const[u,d]=q.useState(!1),[p,f]=q.useState(""),[m,v]=q.useState(0),[w,E]=q.useState(),b=q.useCallback(async S=>{const k=()=>{l(""),d(!1),s.current&&(s.current.style.height="auto"),s.current?.focus()};if(S==="help"){c(!0),k();return}if(S==="vim"){t({vimMode:!n}),k();return}if(S==="reasoning"){t({reasoningEnabled:!i}),k();return}if(S==="stop"){if(o)try{await qe.abortSession(o)}catch(O){console.error("Failed to stop generation:",O)}k();return}e&&e(S),k()},[e,n,i,t,s,l,c,o]),_=q.useCallback(S=>{E(S)},[]),x=q.useCallback(S=>{S.startsWith("/")&&!S.includes(" ")?(d(!0),f(S.slice(1)),v(0)):d(!1)},[]);return{showCommandSuggestions:u,commandQuery:p,commandSelectedIndex:m,currentCommandToSelect:w,setShowCommandSuggestions:d,setCommandQuery:f,setCommandSelectedIndex:v,setCurrentCommandToSelect:E,handleCommandSelect:b,handleCommandEnterSelect:_,checkForCommand:x}}function v7(e){return t=>{const{showFileMention:n,showCommandSuggestions:i,mentionSelectedIndex:s,commandSelectedIndex:l,currentFileToSelect:c,currentCommandToSelect:o,isPlanMode:u,vimModeEnabled:d,vimMode:p,setMentionSelectedIndex:f,setCommandSelectedIndex:m,setShowFileMention:v,setShowCommandSuggestions:w,setIsPlanMode:E,setVimMode:b,handleFileSelect:_,handleCommandSelect:x,handleSend:S,handleVimNormalMode:k,onPlanModeToggle:O}=e;if(i){const T=ED.length;t.key==="ArrowDown"||t.ctrlKey&&t.key==="j"?(t.preventDefault(),m((l+1)%T)):t.key==="ArrowUp"||t.ctrlKey&&t.key==="k"?(t.preventDefault(),m((l-1+T)%T)):t.key==="Enter"?(t.preventDefault(),o&&x(o)):t.key==="Escape"&&(t.preventDefault(),w(!1));return}if(n){t.key==="ArrowDown"||t.ctrlKey&&t.key==="j"?(t.preventDefault(),f((s+1)%20)):t.key==="ArrowUp"||t.ctrlKey&&t.key==="k"?(t.preventDefault(),f((s-1+20)%20)):t.key==="Enter"?(t.preventDefault(),c&&_(c)):t.key==="Escape"&&(t.preventDefault(),v(!1),d&&b("normal"));return}if(!(d&&p==="normal"&&k(t))){if(d&&p==="insert"&&t.key==="Escape"){t.preventDefault(),b("normal");return}if(t.key==="Tab"){t.preventDefault();const T=!u;E(T),O?.(T)}else t.key==="Enter"&&!t.shiftKey&&(!d||p==="normal")&&(t.preventDefault(),S())}}}const cn=$n(e=>({balance:null,usdcBalance:null,network:"mainnet",isPaymentPending:!1,lastPaymentAmount:null,walletAddress:null,isLoading:!1,setBalance:t=>e({balance:t}),setUsdcBalance:t=>e({usdcBalance:t}),setNetwork:t=>e({network:t}),setPaymentPending:t=>e({isPaymentPending:t}),setLastPaymentAmount:t=>e({lastPaymentAmount:t}),setWalletAddress:t=>e({walletAddress:t}),setLoading:t=>e({isLoading:t})})),_7=q.memo(q.forwardRef(function({onSend:t,onCommand:n,disabled:i,onConfigClick:s,onPlanModeToggle:l,isPlanMode:c,reasoningEnabled:o,sessionId:u,images:d=[],documents:p=[],onFileRemove:f,isDragging:m=!1,onPaste:v,visionEnabled:w=!1,modelName:E,providerName:b,authType:_,researchContexts:x=[],onResearchContextRemove:S,onRefreshBalance:k,isBalanceLoading:O=!1},T){const[A,R]=q.useState(""),[D,L]=q.useState(c||!1),[I,H]=q.useState(!1),B=q.useRef(null),{data:W,isLoading:K}=m7(),{preferences:V,updatePreferences:X}=Jo(),Y=W?.files||[],P=W?.changedFiles||[],M=cn(Me=>Me.balance),j=b==="solforge",$=q.useRef(()=>{}),{showFileMention:U,mentionQuery:J,mentionSelectedIndex:oe,currentFileToSelect:he,setShowFileMention:Z,setMentionSelectedIndex:z,setCurrentFileToSelect:ne,handleFileSelect:ce,handleEnterSelect:ge,checkForMention:be}=b7(),{showCommandSuggestions:we,commandQuery:$e,commandSelectedIndex:Pe,currentCommandToSelect:We,setShowCommandSuggestions:xe,setCommandSelectedIndex:gt,setCurrentCommandToSelect:ot,handleCommandSelect:vt,handleCommandEnterSelect:Se,checkForCommand:Fe}=y7({onCommand:n,updatePreferences:X,vimModeEnabled:V.vimMode,reasoningEnabled:V.reasoningEnabled,textareaRef:B,setMessage:R,setShowShortcutsModal:H,sessionId:u}),{vimMode:Re,setVimMode:Le,handleVimNormalMode:Ge}=g7({enabled:V.vimMode,onSend:()=>$.current(),textareaRef:B,setMessage:R});q.useEffect(()=>{B.current?.focus()},[]),q.useEffect(()=>{c!==void 0&&L(c)},[c]),q.useImperativeHandle(T,()=>({focus:()=>{B.current?.focus()},setValue:Me=>{R(Me),B.current?.focus()}}));const re=q.useCallback(()=>{const Me=B.current;Me&&(Me.style.height="auto",Me.style.height=`${Me.scrollHeight}px`)},[]);q.useEffect(()=>{re()},[re,A]);const de=q.useCallback(()=>{Z(!1),ne(void 0)},[Z,ne]),ye=q.useCallback(()=>{xe(!1),ot(void 0)},[xe,ot]),ke=q.useCallback(Me=>{ce(Me,B,R)},[ce]),Oe=q.useCallback(()=>{!A.trim()||i||(t(A),R(""),Z(!1),xe(!1),ne(void 0),ot(void 0),B.current&&(B.current.style.height="auto"),V.vimMode&&Le("normal"),B.current?.focus())},[A,i,t,V.vimMode,Z,xe,ne,ot,Le]);q.useEffect(()=>{$.current=Oe},[Oe]);const xt=q.useCallback(Me=>{if(V.vimMode&&Re==="normal")return;const Nt=Me.target.value;R(Nt),Fe(Nt),Nt.startsWith("/")&&!Nt.includes(" ")?(Z(!1),ne(void 0)):(xe(!1),ot(void 0),be(Nt,Me.target.selectionStart))},[V.vimMode,Re,Fe,Z,ne,xe,ot,be]),je=q.useMemo(()=>v7({showFileMention:U,showCommandSuggestions:we,mentionSelectedIndex:oe,commandSelectedIndex:Pe,currentFileToSelect:he,currentCommandToSelect:We,isPlanMode:D,vimModeEnabled:V.vimMode,vimMode:Re,setMentionSelectedIndex:z,setCommandSelectedIndex:gt,setShowFileMention:Z,setShowCommandSuggestions:xe,setIsPlanMode:L,setVimMode:Le,handleFileSelect:ke,handleCommandSelect:vt,handleSend:Oe,handleVimNormalMode:Ge,onPlanModeToggle:l}),[U,we,oe,Pe,he,We,D,V.vimMode,Re,z,gt,Z,xe,Le,ke,vt,Oe,Ge,l]);q.useEffect(()=>{V.vimMode||Le("insert")},[V.vimMode,Le]);const Et=q.useCallback(Me=>{v?.(Me)},[v]),lt=d.length>0,_t=p.length>0,tt=lt||_t;return y.jsxs(y.Fragment,{children:[m&&y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm pointer-events-none",children:y.jsxs("div",{className:"flex flex-col items-center gap-4 p-8 rounded-2xl bg-card border-2 border-dashed border-primary/50",children:[y.jsx("div",{className:"p-4 rounded-full bg-primary/10",children:y.jsx(Li,{className:"w-12 h-12 text-primary"})}),y.jsxs("div",{className:"text-center",children:[y.jsx("p",{className:"text-lg font-medium text-foreground",children:"Drop files here"}),y.jsx("p",{className:"text-sm text-muted-foreground",children:"Images, PDF, Markdown, Text up to 10MB"})]})]})}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 pt-16 pb-6 md:pb-8 px-2 md:px-4 bg-gradient-to-t from-background via-background to-transparent pointer-events-none z-20 safe-area-inset-bottom",children:y.jsxs("div",{className:"max-w-3xl mx-auto pointer-events-auto mb-2 md:mb-0 relative",children:[V.vimMode&&Re==="normal"&&y.jsx("div",{className:"absolute -top-6 right-0 px-2 py-0.5 text-xs font-mono font-semibold bg-amber-500/90 text-white rounded shadow-sm",children:"NORMAL"}),V.vimMode&&Re==="insert"&&y.jsx("div",{className:"absolute -top-6 right-0 px-2 py-0.5 text-xs font-mono font-semibold bg-green-500/90 text-white rounded shadow-sm",children:"INSERT"}),y.jsxs("div",{className:`relative flex flex-col rounded-3xl p-1 transition-all touch-manipulation ${D?"bg-slate-100 dark:bg-slate-900/40 border border-slate-300 dark:border-slate-700 focus-within:border-slate-400 dark:focus-within:border-slate-600 focus-within:ring-1 focus-within:ring-slate-300 dark:focus-within:ring-slate-700":"bg-card border border-border focus-within:border-primary/60 focus-within:ring-1 focus-within:ring-primary/40"}`,children:[tt&&y.jsxs("div",{className:"flex flex-wrap gap-2 px-3 pt-2 pb-1",children:[d.map(Me=>y.jsxs("div",{className:"relative group w-12 h-12 rounded-lg overflow-hidden bg-muted",children:[y.jsx("img",{src:Me.preview,alt:"Attachment",className:"w-full h-full object-cover"}),y.jsx("button",{type:"button",onClick:()=>f?.(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id)),p.map(Me=>y.jsxs("div",{className:"relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-muted max-w-[200px]",children:[Me.type==="pdf"?y.jsx(Li,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):y.jsx(kc,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate",children:Me.name}),y.jsx("button",{type:"button",onClick:()=>f?.(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id))]}),x.length>0&&y.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-2 pb-1",children:x.map(Me=>y.jsxs("div",{className:"relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30 max-w-[200px]",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate text-teal-600 dark:text-teal-400",children:Me.label}),S&&y.jsx("button",{type:"button",onClick:()=>S(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id))}),y.jsxs("div",{className:"flex items-end gap-1",children:[s&&y.jsx("button",{type:"button",onClick:s,className:"flex items-center justify-center w-10 h-10 rounded-full hover:bg-background/50 active:bg-background/70 transition-colors text-muted-foreground hover:text-foreground flex-shrink-0 touch-manipulation",children:y.jsx(TB,{className:"w-4 h-4"})}),y.jsx(Cc,{ref:B,value:A,onChange:xt,onKeyDown:je,onPaste:Et,placeholder:D?"Plan mode - Type a message...":"Type a message...",disabled:i,rows:1,className:`border-0 bg-transparent pl-1 pr-2 py-2 max-h-[200px] overflow-y-auto leading-normal resize-none scrollbar-hide text-base ${V.vimMode&&Re==="normal"?"caret-[6px]":""}`,style:{height:"2.5rem"}}),y.jsx("button",{type:"button",onClick:Oe,disabled:i||!A.trim()&&!tt,className:`flex items-center justify-center w-10 h-10 rounded-full transition-colors flex-shrink-0 touch-manipulation ${A.trim()||tt?"bg-primary hover:bg-primary/90 active:bg-primary/80 text-primary-foreground":"bg-transparent text-muted-foreground"}`,children:y.jsx(CO,{className:"w-4 h-4"})})]})]}),(o||w||E||b||_)&&y.jsxs("div",{className:"grid grid-cols-3 items-center mt-1 px-3",children:[y.jsx("div",{className:"justify-self-start",children:o&&y.jsxs("span",{className:"text-[10px] text-indigo-600 dark:text-indigo-300 flex items-center gap-1",children:[y.jsx(Uv,{className:"h-3 w-3"}),"Extended thinking"]})}),y.jsx("div",{className:"justify-self-center",children:(b||E||_)&&y.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[b&&y.jsxs(y.Fragment,{children:[y.jsx(Lc,{provider:b,size:12,className:"opacity-70"}),y.jsx("span",{className:"opacity-40",children:"/"})]}),E&&y.jsx("span",{children:E}),_&&_!=="api"&&y.jsxs("span",{className:"opacity-50",children:["(",_==="oauth"?"pro":"wallet",")"]}),j&&M!==null&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["$",M.toFixed(2)]}),k&&y.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),k()},disabled:O,className:"p-0.5 hover:bg-background/50 rounded transition-colors disabled:opacity-50",children:y.jsx(Ea,{className:`h-2.5 w-2.5 text-muted-foreground ${O?"animate-spin":""}`})})]})]})}),y.jsx("div",{className:"justify-self-end",children:w&&y.jsxs("span",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 flex items-center gap-1",children:[y.jsx(LO,{className:"h-3 w-3"}),"Supports images"]})})]}),U&&!K&&y.jsx(A8,{files:Y,changedFiles:P,query:J,selectedIndex:oe,onSelect:ke,onEnterSelect:ge,onClose:de}),we&&y.jsx(QP,{query:$e,selectedIndex:Pe,onSelect:vt,onEnterSelect:Se,onClose:ye,sessionId:u}),y.jsx(i7,{isOpen:I,onClose:()=>H(!1)})]})})]})}));function pc(e){return qn({queryKey:["messages",e],queryFn:()=>{if(!e)throw new Error("Session ID is required");return qe.getMessages(e)},enabled:!!e})}function S7(e){const t=Lt();return Xt({mutationFn:n=>qe.sendMessage(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["messages",e]}),t.invalidateQueries({queryKey:["sessions"]})}})}function Mc(){return qn({queryKey:["sessions"],queryFn:()=>qe.getSessions(),refetchInterval:5e3})}function CD(e){const{data:t}=Mc();return t?.find(n=>n.id===e)}function x7(){const e=Lt();return Xt({mutationFn:t=>qe.createSession(t),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}function kD(e){const t=Lt();return Xt({mutationFn:n=>qe.updateSession(e,n),onSuccess:async()=>{await t.invalidateQueries({queryKey:["sessions"]}),await t.invalidateQueries({queryKey:["session",e]})}})}function E7(){const e=Lt();return Xt({mutationFn:t=>qe.deleteSession(t),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}function Zv(){return qn({queryKey:["config"],queryFn:()=>qe.getConfig()})}function Bc(){return qn({queryKey:["models","all"],queryFn:()=>qe.getAllModels()})}function w7(){const e=Lt();return Xt({mutationFn:t=>qe.updateDefaults(t),onSuccess:()=>{e.invalidateQueries({queryKey:["config"]})}})}const kr=$n(e=>({isExpanded:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),dn.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1})})),jn=$n((e,t)=>({isExpanded:!1,activeResearchSessionId:null,parentSessionId:null,toggleSidebar:()=>{e(n=>{const i=!n.isExpanded;return i&&(Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:i}})},expandSidebar:()=>{Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),kr.getState().collapseSidebar(),e({isExpanded:!0})},collapseSidebar:()=>e({isExpanded:!1}),selectResearchSession:n=>e({activeResearchSessionId:n}),setParentSessionId:n=>{t().parentSessionId!==n&&e({parentSessionId:n,activeResearchSessionId:null})},reset:()=>e({activeResearchSessionId:null,parentSessionId:null})})),Yt=$n(e=>({isExpanded:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0,isDiffOpen:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>{Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar(),e({isExpanded:!0})},collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0}),openDiff:(t,n)=>e({selectedFile:t,allOperations:n,selectedOperationIndex:n.length-1,isDiffOpen:!0,isExpanded:!0}),selectOperation:t=>e({selectedOperationIndex:t}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0})})),dn=$n(e=>({isExpanded:!1,selectedTerminalId:null,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,selectedTerminalId:null}),selectTerminal:t=>e({selectedTerminalId:t})})),Tt=$n(e=>({isExpanded:!1,selectedFile:null,selectedFileStaged:!1,isDiffOpen:!1,isCommitModalOpen:!1,commitSessionId:null,wasSessionListCollapsed:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null}),openDiff:(t,n)=>e({selectedFile:t,selectedFileStaged:n,isDiffOpen:!0,isExpanded:!0}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null}),switchFile:(t,n)=>e({selectedFile:t,selectedFileStaged:n}),openCommitModal:()=>e({isCommitModalOpen:!0}),openCommitModalForSession:t=>e({isCommitModalOpen:!0,commitSessionId:t}),closeCommitModal:()=>e({isCommitModalOpen:!1,commitSessionId:null}),setSessionListCollapsed:t=>e({wasSessionListCollapsed:t})}));function Fc(){const e=Tt(t=>t.isExpanded);return qn({queryKey:["git","status"],queryFn:()=>qe.getGitStatus(),refetchInterval:e?5e3:!1,retry:1,staleTime:3e3})}function C7(e,t=!1){return qn({queryKey:["git","diff",e,t],queryFn:()=>e?qe.getGitDiff(e,t):null,enabled:!!e,retry:1,refetchInterval:!1})}function k7(e){return Xt({mutationFn:()=>qe.generateCommitMessage(e??void 0)})}function jc(){const e=Lt();return Xt({mutationFn:t=>qe.stageFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function Qv(){const e=Lt();return Xt({mutationFn:t=>qe.unstageFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function TD(){const e=Lt();return Xt({mutationFn:t=>qe.restoreFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function RD(){const e=Lt();return Xt({mutationFn:t=>qe.deleteFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function T7(){const e=Lt();return Xt({mutationFn:t=>qe.commitChanges(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}function R7(){const e=Lt();return Xt({mutationFn:()=>qe.pushCommits(),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}const AD=["image/png","image/jpeg","image/gif","image/webp"],ND=["application/pdf"],OD=["text/plain","text/markdown","text/x-markdown"],DD=[".txt",".md",".markdown"],A7=[...AD,...ND,...OD];function N7(){return`file-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function O7(e){if(AD.includes(e.type))return"image";if(ND.includes(e.type))return"pdf";if(OD.includes(e.type))return"text";const t=e.name.toLowerCase().slice(e.name.lastIndexOf("."));return DD.includes(t)?"text":null}function Nu(e){if(A7.includes(e.type))return!0;const t=e.name.toLowerCase().slice(e.name.lastIndexOf("."));return DD.includes(t)}async function VE(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>{const l=i.result.split(",")[1];t(l)},i.onerror=n,i.readAsDataURL(e)})}async function D7(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=n,i.readAsText(e)})}async function I7(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=n,i.readAsDataURL(e)})}function L7(e={}){const{maxFiles:t=10,maxSizeMB:n=10,pageWide:i=!0}=e,[s,l]=q.useState([]),[c,o]=q.useState(!1),[u,d]=q.useState(null),p=n*1024*1024,f=q.useCallback(T=>Nu(T)?T.size>p?`File too large: ${(T.size/1024/1024).toFixed(1)}MB. Max: ${n}MB`:null:`Unsupported file type: ${T.type||T.name}. Supported: images, PDF, markdown, text`,[p,n]),m=q.useCallback(async T=>{d(null);const A=Array.from(T),R=t-s.length;if(R<=0){d(`Maximum ${t} files allowed`);return}const D=A.slice(0,R),L=[];for(const I of D){const H=f(I);if(H){d(H);continue}const B=O7(I);if(B)try{let W,K,V,X=I.type;if(B==="image")[W,K]=await Promise.all([I7(I),VE(I)]);else if(B==="pdf")K=await VE(I),X="application/pdf";else if(V=await D7(I),K=V,!X){const Y=I.name.toLowerCase();X=Y.endsWith(".md")||Y.endsWith(".markdown")?"text/markdown":"text/plain"}L.push({id:N7(),file:I,type:B,name:I.name,preview:W,data:K,mediaType:X,textContent:V})}catch{d(`Failed to process file: ${I.name}`)}}L.length>0&&l(I=>[...I,...L])},[s.length,t,f]),v=q.useCallback(T=>{l(A=>A.filter(R=>R.id!==T)),d(null)},[]),w=q.useCallback(()=>{l([]),d(null)},[]),E=q.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&o(!0)},[]),b=q.useCallback(T=>{T.preventDefault(),T.stopPropagation();const A=T.currentTarget.getBoundingClientRect(),R=T.clientX,D=T.clientY;(R<A.left||R>A.right||D<A.top||D>A.bottom)&&o(!1)},[]),_=q.useCallback(T=>{T.preventDefault(),T.stopPropagation()},[]),x=q.useCallback(T=>{T.preventDefault(),T.stopPropagation(),o(!1);const A=T.dataTransfer.files;if(A.length>0){const R=Array.from(A).filter(Nu);R.length>0&&m(R)}},[m]),S=q.useCallback(T=>{const A=T.clipboardData?.items;if(!A)return;const R=[];for(const D of Array.from(A))if(D.kind==="file"){const L=D.getAsFile();L&&Nu(L)&&R.push(L)}R.length>0&&(T.preventDefault(),m(R))},[m]);q.useEffect(()=>{if(!i)return;let T=0;const A=I=>{I.preventDefault(),I.dataTransfer?.types.includes("Files")&&(T++,T===1&&o(!0))},R=I=>{I.preventDefault(),T--,T===0&&o(!1)},D=I=>{I.preventDefault()},L=I=>{I.preventDefault(),T=0,o(!1);const H=I.dataTransfer?.files;if(H&&H.length>0){const B=Array.from(H).filter(Nu);B.length>0&&m(B)}};return document.addEventListener("dragenter",A),document.addEventListener("dragleave",R),document.addEventListener("dragover",D),document.addEventListener("drop",L),()=>{document.removeEventListener("dragenter",A),document.removeEventListener("dragleave",R),document.removeEventListener("dragover",D),document.removeEventListener("drop",L)}},[i,m]);const k=s.filter(T=>T.type==="image"),O=s.filter(T=>T.type==="pdf"||T.type==="text");return{files:s,images:k,documents:O,isDragging:c,error:u,addFiles:m,removeFile:v,clearFiles:w,handleDragEnter:E,handleDragLeave:b,handleDragOver:_,handleDrop:x,handlePaste:S}}const av=$n((e,t)=>({pendingRestoreText:null,setPendingRestoreText:n=>e({pendingRestoreText:n}),consumeRestoreText:()=>{const n=t().pendingRestoreText;return e({pendingRestoreText:null}),n}})),Vu=$n((e,t)=>({pendingContexts:new Map,addContext:(n,i)=>{e(s=>{const l=new Map(s.pendingContexts),c=l.get(n)||[];return c.some(o=>o.id===i.id)||l.set(n,[...c,i]),{pendingContexts:l}})},removeContext:(n,i)=>{e(s=>{const l=new Map(s.pendingContexts),c=l.get(n)||[];return l.set(n,c.filter(o=>o.id!==i)),{pendingContexts:l}})},getContexts:n=>t().pendingContexts.get(n)||[],clearContexts:n=>{e(i=>{const s=new Map(i.pendingContexts);return s.delete(n),{pendingContexts:s}})},consumeContexts:n=>{const i=t().getContexts(n);return t().clearContexts(n),i}})),M7=/<research-context\s+from="([^"]+)"\s+label="([^"]+)"[^>]*>([\s\S]*?)<\/research-context>/g;function B7(e){const t=[];let n=e;const i=new RegExp(M7);let s=i.exec(e);for(;s!==null;){const[l,c,o,u]=s;t.push({id:c,from:c,label:o,content:u.trim()}),n=n.replace(l,""),s=i.exec(e)}return n=n.trim(),{researchContexts:t,cleanContent:n}}function F7(e){return e.length===0?"":e.map(t=>t.content).join(`
67
+ `,v.selectionStart);_===-1&&(_=E.length);const x=E.slice(0,b)+E.slice(_);return i(x),l("insert"),setTimeout(()=>{v.setSelectionRange(b,b)},0),!0}return!1},[c,t,n,i,u,d,p]);return{vimMode:s,setVimMode:l,handleVimNormalMode:f}}function b7(){const[e,t]=q.useState(!1),[n,i]=q.useState(""),[s,l]=q.useState(0),[c,o]=q.useState(),u=q.useCallback((f,m,v)=>{const w=m.current;if(!w)return;const E=w.value,b=w.selectionStart,x=E.slice(0,b).match(/@(\S*)$/);if(!x)return;const S=b-x[0].length,k=`${E.slice(0,S)}@${f} ${E.slice(b)}`;v(k),t(!1),setTimeout(()=>{const O=S+f.length+2;w.setSelectionRange(O,O),w.focus()},0)},[]),d=q.useCallback(f=>{o(f)},[]),p=q.useCallback((f,m)=>{const w=f.slice(0,m).match(/@(\S*)$/);w?(t(!0),i(w[1]),l(0)):t(!1)},[]);return{showFileMention:e,mentionQuery:n,mentionSelectedIndex:s,currentFileToSelect:c,setShowFileMention:t,setMentionQuery:i,setMentionSelectedIndex:l,setCurrentFileToSelect:o,handleFileSelect:u,handleEnterSelect:d,checkForMention:p}}function y7({onCommand:e,updatePreferences:t,vimModeEnabled:n,reasoningEnabled:i,textareaRef:s,setMessage:l,setShowShortcutsModal:c,sessionId:o}){const[u,d]=q.useState(!1),[p,f]=q.useState(""),[m,v]=q.useState(0),[w,E]=q.useState(),b=q.useCallback(async S=>{const k=()=>{l(""),d(!1),s.current&&(s.current.style.height="auto"),s.current?.focus()};if(S==="help"){c(!0),k();return}if(S==="vim"){t({vimMode:!n}),k();return}if(S==="reasoning"){t({reasoningEnabled:!i}),k();return}if(S==="stop"){if(o)try{await qe.abortSession(o)}catch(O){console.error("Failed to stop generation:",O)}k();return}e&&e(S),k()},[e,n,i,t,s,l,c,o]),_=q.useCallback(S=>{E(S)},[]),x=q.useCallback(S=>{S.startsWith("/")&&!S.includes(" ")?(d(!0),f(S.slice(1)),v(0)):d(!1)},[]);return{showCommandSuggestions:u,commandQuery:p,commandSelectedIndex:m,currentCommandToSelect:w,setShowCommandSuggestions:d,setCommandQuery:f,setCommandSelectedIndex:v,setCurrentCommandToSelect:E,handleCommandSelect:b,handleCommandEnterSelect:_,checkForCommand:x}}function v7(e){return t=>{const{showFileMention:n,showCommandSuggestions:i,mentionSelectedIndex:s,commandSelectedIndex:l,currentFileToSelect:c,currentCommandToSelect:o,isPlanMode:u,vimModeEnabled:d,vimMode:p,setMentionSelectedIndex:f,setCommandSelectedIndex:m,setShowFileMention:v,setShowCommandSuggestions:w,setIsPlanMode:E,setVimMode:b,handleFileSelect:_,handleCommandSelect:x,handleSend:S,handleVimNormalMode:k,onPlanModeToggle:O}=e;if(i){const T=ED.length;t.key==="ArrowDown"||t.ctrlKey&&t.key==="j"?(t.preventDefault(),m((l+1)%T)):t.key==="ArrowUp"||t.ctrlKey&&t.key==="k"?(t.preventDefault(),m((l-1+T)%T)):t.key==="Enter"?(t.preventDefault(),o&&x(o)):t.key==="Escape"&&(t.preventDefault(),w(!1));return}if(n){t.key==="ArrowDown"||t.ctrlKey&&t.key==="j"?(t.preventDefault(),f((s+1)%20)):t.key==="ArrowUp"||t.ctrlKey&&t.key==="k"?(t.preventDefault(),f((s-1+20)%20)):t.key==="Enter"?(t.preventDefault(),c&&_(c)):t.key==="Escape"&&(t.preventDefault(),v(!1),d&&b("normal"));return}if(!(d&&p==="normal"&&k(t))){if(d&&p==="insert"&&t.key==="Escape"){t.preventDefault(),b("normal");return}if(t.key==="Tab"){t.preventDefault();const T=!u;E(T),O?.(T)}else t.key==="Enter"&&!t.shiftKey&&(!d||p==="normal")&&(t.preventDefault(),S())}}}const cn=$n(e=>({balance:null,usdcBalance:null,network:"mainnet",isPaymentPending:!1,lastPaymentAmount:null,walletAddress:null,isLoading:!1,setBalance:t=>e({balance:t}),setUsdcBalance:t=>e({usdcBalance:t}),setNetwork:t=>e({network:t}),setPaymentPending:t=>e({isPaymentPending:t}),setLastPaymentAmount:t=>e({lastPaymentAmount:t}),setWalletAddress:t=>e({walletAddress:t}),setLoading:t=>e({isLoading:t})})),_7=q.memo(q.forwardRef(function({onSend:t,onCommand:n,disabled:i,onConfigClick:s,onPlanModeToggle:l,isPlanMode:c,reasoningEnabled:o,sessionId:u,images:d=[],documents:p=[],onFileRemove:f,isDragging:m=!1,onPaste:v,visionEnabled:w=!1,modelName:E,providerName:b,authType:_,researchContexts:x=[],onResearchContextRemove:S,onRefreshBalance:k,isBalanceLoading:O=!1},T){const[A,R]=q.useState(""),[D,L]=q.useState(c||!1),[I,H]=q.useState(!1),B=q.useRef(null),{data:W,isLoading:K}=m7(),{preferences:V,updatePreferences:X}=Jo(),Y=W?.files||[],P=W?.changedFiles||[],M=cn(Me=>Me.balance),j=b==="setu",$=q.useRef(()=>{}),{showFileMention:U,mentionQuery:J,mentionSelectedIndex:oe,currentFileToSelect:he,setShowFileMention:Z,setMentionSelectedIndex:z,setCurrentFileToSelect:ne,handleFileSelect:ce,handleEnterSelect:ge,checkForMention:be}=b7(),{showCommandSuggestions:we,commandQuery:$e,commandSelectedIndex:Pe,currentCommandToSelect:We,setShowCommandSuggestions:xe,setCommandSelectedIndex:gt,setCurrentCommandToSelect:ot,handleCommandSelect:vt,handleCommandEnterSelect:Se,checkForCommand:Fe}=y7({onCommand:n,updatePreferences:X,vimModeEnabled:V.vimMode,reasoningEnabled:V.reasoningEnabled,textareaRef:B,setMessage:R,setShowShortcutsModal:H,sessionId:u}),{vimMode:Re,setVimMode:Le,handleVimNormalMode:Ge}=g7({enabled:V.vimMode,onSend:()=>$.current(),textareaRef:B,setMessage:R});q.useEffect(()=>{B.current?.focus()},[]),q.useEffect(()=>{c!==void 0&&L(c)},[c]),q.useImperativeHandle(T,()=>({focus:()=>{B.current?.focus()},setValue:Me=>{R(Me),B.current?.focus()}}));const re=q.useCallback(()=>{const Me=B.current;Me&&(Me.style.height="auto",Me.style.height=`${Me.scrollHeight}px`)},[]);q.useEffect(()=>{re()},[re,A]);const de=q.useCallback(()=>{Z(!1),ne(void 0)},[Z,ne]),ye=q.useCallback(()=>{xe(!1),ot(void 0)},[xe,ot]),ke=q.useCallback(Me=>{ce(Me,B,R)},[ce]),Oe=q.useCallback(()=>{!A.trim()||i||(t(A),R(""),Z(!1),xe(!1),ne(void 0),ot(void 0),B.current&&(B.current.style.height="auto"),V.vimMode&&Le("normal"),B.current?.focus())},[A,i,t,V.vimMode,Z,xe,ne,ot,Le]);q.useEffect(()=>{$.current=Oe},[Oe]);const xt=q.useCallback(Me=>{if(V.vimMode&&Re==="normal")return;const Nt=Me.target.value;R(Nt),Fe(Nt),Nt.startsWith("/")&&!Nt.includes(" ")?(Z(!1),ne(void 0)):(xe(!1),ot(void 0),be(Nt,Me.target.selectionStart))},[V.vimMode,Re,Fe,Z,ne,xe,ot,be]),je=q.useMemo(()=>v7({showFileMention:U,showCommandSuggestions:we,mentionSelectedIndex:oe,commandSelectedIndex:Pe,currentFileToSelect:he,currentCommandToSelect:We,isPlanMode:D,vimModeEnabled:V.vimMode,vimMode:Re,setMentionSelectedIndex:z,setCommandSelectedIndex:gt,setShowFileMention:Z,setShowCommandSuggestions:xe,setIsPlanMode:L,setVimMode:Le,handleFileSelect:ke,handleCommandSelect:vt,handleSend:Oe,handleVimNormalMode:Ge,onPlanModeToggle:l}),[U,we,oe,Pe,he,We,D,V.vimMode,Re,z,gt,Z,xe,Le,ke,vt,Oe,Ge,l]);q.useEffect(()=>{V.vimMode||Le("insert")},[V.vimMode,Le]);const Et=q.useCallback(Me=>{v?.(Me)},[v]),lt=d.length>0,_t=p.length>0,tt=lt||_t;return y.jsxs(y.Fragment,{children:[m&&y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm pointer-events-none",children:y.jsxs("div",{className:"flex flex-col items-center gap-4 p-8 rounded-2xl bg-card border-2 border-dashed border-primary/50",children:[y.jsx("div",{className:"p-4 rounded-full bg-primary/10",children:y.jsx(Li,{className:"w-12 h-12 text-primary"})}),y.jsxs("div",{className:"text-center",children:[y.jsx("p",{className:"text-lg font-medium text-foreground",children:"Drop files here"}),y.jsx("p",{className:"text-sm text-muted-foreground",children:"Images, PDF, Markdown, Text up to 10MB"})]})]})}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 pt-16 pb-6 md:pb-8 px-2 md:px-4 bg-gradient-to-t from-background via-background to-transparent pointer-events-none z-20 safe-area-inset-bottom",children:y.jsxs("div",{className:"max-w-3xl mx-auto pointer-events-auto mb-2 md:mb-0 relative",children:[V.vimMode&&Re==="normal"&&y.jsx("div",{className:"absolute -top-6 right-0 px-2 py-0.5 text-xs font-mono font-semibold bg-amber-500/90 text-white rounded shadow-sm",children:"NORMAL"}),V.vimMode&&Re==="insert"&&y.jsx("div",{className:"absolute -top-6 right-0 px-2 py-0.5 text-xs font-mono font-semibold bg-green-500/90 text-white rounded shadow-sm",children:"INSERT"}),y.jsxs("div",{className:`relative flex flex-col rounded-3xl p-1 transition-all touch-manipulation ${D?"bg-slate-100 dark:bg-slate-900/40 border border-slate-300 dark:border-slate-700 focus-within:border-slate-400 dark:focus-within:border-slate-600 focus-within:ring-1 focus-within:ring-slate-300 dark:focus-within:ring-slate-700":"bg-card border border-border focus-within:border-primary/60 focus-within:ring-1 focus-within:ring-primary/40"}`,children:[tt&&y.jsxs("div",{className:"flex flex-wrap gap-2 px-3 pt-2 pb-1",children:[d.map(Me=>y.jsxs("div",{className:"relative group w-12 h-12 rounded-lg overflow-hidden bg-muted",children:[y.jsx("img",{src:Me.preview,alt:"Attachment",className:"w-full h-full object-cover"}),y.jsx("button",{type:"button",onClick:()=>f?.(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id)),p.map(Me=>y.jsxs("div",{className:"relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-muted max-w-[200px]",children:[Me.type==="pdf"?y.jsx(Li,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):y.jsx(kc,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate",children:Me.name}),y.jsx("button",{type:"button",onClick:()=>f?.(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id))]}),x.length>0&&y.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-2 pb-1",children:x.map(Me=>y.jsxs("div",{className:"relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30 max-w-[200px]",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate text-teal-600 dark:text-teal-400",children:Me.label}),S&&y.jsx("button",{type:"button",onClick:()=>S(Me.id),className:"absolute top-0 right-0 p-0.5 bg-black/60 rounded-bl-md opacity-0 group-hover:opacity-100 transition-opacity",children:y.jsx(Un,{className:"w-3 h-3 text-white"})})]},Me.id))}),y.jsxs("div",{className:"flex items-end gap-1",children:[s&&y.jsx("button",{type:"button",onClick:s,className:"flex items-center justify-center w-10 h-10 rounded-full hover:bg-background/50 active:bg-background/70 transition-colors text-muted-foreground hover:text-foreground flex-shrink-0 touch-manipulation",children:y.jsx(TB,{className:"w-4 h-4"})}),y.jsx(Cc,{ref:B,value:A,onChange:xt,onKeyDown:je,onPaste:Et,placeholder:D?"Plan mode - Type a message...":"Type a message...",disabled:i,rows:1,className:`border-0 bg-transparent pl-1 pr-2 py-2 max-h-[200px] overflow-y-auto leading-normal resize-none scrollbar-hide text-base ${V.vimMode&&Re==="normal"?"caret-[6px]":""}`,style:{height:"2.5rem"}}),y.jsx("button",{type:"button",onClick:Oe,disabled:i||!A.trim()&&!tt,className:`flex items-center justify-center w-10 h-10 rounded-full transition-colors flex-shrink-0 touch-manipulation ${A.trim()||tt?"bg-primary hover:bg-primary/90 active:bg-primary/80 text-primary-foreground":"bg-transparent text-muted-foreground"}`,children:y.jsx(CO,{className:"w-4 h-4"})})]})]}),(o||w||E||b||_)&&y.jsxs("div",{className:"grid grid-cols-3 items-center mt-1 px-3",children:[y.jsx("div",{className:"justify-self-start",children:o&&y.jsxs("span",{className:"text-[10px] text-indigo-600 dark:text-indigo-300 flex items-center gap-1",children:[y.jsx(Uv,{className:"h-3 w-3"}),"Extended thinking"]})}),y.jsx("div",{className:"justify-self-center",children:(b||E||_)&&y.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[b&&y.jsxs(y.Fragment,{children:[y.jsx(Lc,{provider:b,size:12,className:"opacity-70"}),y.jsx("span",{className:"opacity-40",children:"/"})]}),E&&y.jsx("span",{children:E}),_&&_!=="api"&&y.jsxs("span",{className:"opacity-50",children:["(",_==="oauth"?"pro":"wallet",")"]}),j&&M!==null&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["$",M.toFixed(2)]}),k&&y.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),k()},disabled:O,className:"p-0.5 hover:bg-background/50 rounded transition-colors disabled:opacity-50",children:y.jsx(Ea,{className:`h-2.5 w-2.5 text-muted-foreground ${O?"animate-spin":""}`})})]})]})}),y.jsx("div",{className:"justify-self-end",children:w&&y.jsxs("span",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 flex items-center gap-1",children:[y.jsx(LO,{className:"h-3 w-3"}),"Supports images"]})})]}),U&&!K&&y.jsx(A8,{files:Y,changedFiles:P,query:J,selectedIndex:oe,onSelect:ke,onEnterSelect:ge,onClose:de}),we&&y.jsx(QP,{query:$e,selectedIndex:Pe,onSelect:vt,onEnterSelect:Se,onClose:ye,sessionId:u}),y.jsx(i7,{isOpen:I,onClose:()=>H(!1)})]})})]})}));function pc(e){return qn({queryKey:["messages",e],queryFn:()=>{if(!e)throw new Error("Session ID is required");return qe.getMessages(e)},enabled:!!e})}function S7(e){const t=Lt();return Xt({mutationFn:n=>qe.sendMessage(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["messages",e]}),t.invalidateQueries({queryKey:["sessions"]})}})}function Mc(){return qn({queryKey:["sessions"],queryFn:()=>qe.getSessions(),refetchInterval:5e3})}function CD(e){const{data:t}=Mc();return t?.find(n=>n.id===e)}function x7(){const e=Lt();return Xt({mutationFn:t=>qe.createSession(t),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}function kD(e){const t=Lt();return Xt({mutationFn:n=>qe.updateSession(e,n),onSuccess:async()=>{await t.invalidateQueries({queryKey:["sessions"]}),await t.invalidateQueries({queryKey:["session",e]})}})}function E7(){const e=Lt();return Xt({mutationFn:t=>qe.deleteSession(t),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}function Zv(){return qn({queryKey:["config"],queryFn:()=>qe.getConfig()})}function Bc(){return qn({queryKey:["models","all"],queryFn:()=>qe.getAllModels()})}function w7(){const e=Lt();return Xt({mutationFn:t=>qe.updateDefaults(t),onSuccess:()=>{e.invalidateQueries({queryKey:["config"]})}})}const kr=$n(e=>({isExpanded:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),dn.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1})})),jn=$n((e,t)=>({isExpanded:!1,activeResearchSessionId:null,parentSessionId:null,toggleSidebar:()=>{e(n=>{const i=!n.isExpanded;return i&&(Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:i}})},expandSidebar:()=>{Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),kr.getState().collapseSidebar(),e({isExpanded:!0})},collapseSidebar:()=>e({isExpanded:!1}),selectResearchSession:n=>e({activeResearchSessionId:n}),setParentSessionId:n=>{t().parentSessionId!==n&&e({parentSessionId:n,activeResearchSessionId:null})},reset:()=>e({activeResearchSessionId:null,parentSessionId:null})})),Yt=$n(e=>({isExpanded:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0,isDiffOpen:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>{Tt.getState().collapseSidebar(),dn.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar(),e({isExpanded:!0})},collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0}),openDiff:(t,n)=>e({selectedFile:t,allOperations:n,selectedOperationIndex:n.length-1,isDiffOpen:!0,isExpanded:!0}),selectOperation:t=>e({selectedOperationIndex:t}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null,allOperations:[],selectedOperationIndex:0})})),dn=$n(e=>({isExpanded:!1,selectedTerminalId:null,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(Tt.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,selectedTerminalId:null}),selectTerminal:t=>e({selectedTerminalId:t})})),Tt=$n(e=>({isExpanded:!1,selectedFile:null,selectedFileStaged:!1,isDiffOpen:!1,isCommitModalOpen:!1,commitSessionId:null,wasSessionListCollapsed:!1,toggleSidebar:()=>{e(t=>{const n=!t.isExpanded;return n&&(dn.getState().collapseSidebar(),Yt.getState().collapseSidebar(),jn.getState().collapseSidebar(),kr.getState().collapseSidebar()),{isExpanded:n}})},expandSidebar:()=>e({isExpanded:!0}),collapseSidebar:()=>e({isExpanded:!1,isDiffOpen:!1,selectedFile:null}),openDiff:(t,n)=>e({selectedFile:t,selectedFileStaged:n,isDiffOpen:!0,isExpanded:!0}),closeDiff:()=>e({isDiffOpen:!1,selectedFile:null}),switchFile:(t,n)=>e({selectedFile:t,selectedFileStaged:n}),openCommitModal:()=>e({isCommitModalOpen:!0}),openCommitModalForSession:t=>e({isCommitModalOpen:!0,commitSessionId:t}),closeCommitModal:()=>e({isCommitModalOpen:!1,commitSessionId:null}),setSessionListCollapsed:t=>e({wasSessionListCollapsed:t})}));function Fc(){const e=Tt(t=>t.isExpanded);return qn({queryKey:["git","status"],queryFn:()=>qe.getGitStatus(),refetchInterval:e?5e3:!1,retry:1,staleTime:3e3})}function C7(e,t=!1){return qn({queryKey:["git","diff",e,t],queryFn:()=>e?qe.getGitDiff(e,t):null,enabled:!!e,retry:1,refetchInterval:!1})}function k7(e){return Xt({mutationFn:()=>qe.generateCommitMessage(e??void 0)})}function jc(){const e=Lt();return Xt({mutationFn:t=>qe.stageFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function Qv(){const e=Lt();return Xt({mutationFn:t=>qe.unstageFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function TD(){const e=Lt();return Xt({mutationFn:t=>qe.restoreFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function RD(){const e=Lt();return Xt({mutationFn:t=>qe.deleteFiles(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]})}})}function T7(){const e=Lt();return Xt({mutationFn:t=>qe.commitChanges(t),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}function R7(){const e=Lt();return Xt({mutationFn:()=>qe.pushCommits(),onSuccess:()=>{e.invalidateQueries({queryKey:["git","status"]}),e.invalidateQueries({queryKey:["git","branch"]})}})}const AD=["image/png","image/jpeg","image/gif","image/webp"],ND=["application/pdf"],OD=["text/plain","text/markdown","text/x-markdown"],DD=[".txt",".md",".markdown"],A7=[...AD,...ND,...OD];function N7(){return`file-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function O7(e){if(AD.includes(e.type))return"image";if(ND.includes(e.type))return"pdf";if(OD.includes(e.type))return"text";const t=e.name.toLowerCase().slice(e.name.lastIndexOf("."));return DD.includes(t)?"text":null}function Nu(e){if(A7.includes(e.type))return!0;const t=e.name.toLowerCase().slice(e.name.lastIndexOf("."));return DD.includes(t)}async function VE(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>{const l=i.result.split(",")[1];t(l)},i.onerror=n,i.readAsDataURL(e)})}async function D7(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=n,i.readAsText(e)})}async function I7(e){return new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=n,i.readAsDataURL(e)})}function L7(e={}){const{maxFiles:t=10,maxSizeMB:n=10,pageWide:i=!0}=e,[s,l]=q.useState([]),[c,o]=q.useState(!1),[u,d]=q.useState(null),p=n*1024*1024,f=q.useCallback(T=>Nu(T)?T.size>p?`File too large: ${(T.size/1024/1024).toFixed(1)}MB. Max: ${n}MB`:null:`Unsupported file type: ${T.type||T.name}. Supported: images, PDF, markdown, text`,[p,n]),m=q.useCallback(async T=>{d(null);const A=Array.from(T),R=t-s.length;if(R<=0){d(`Maximum ${t} files allowed`);return}const D=A.slice(0,R),L=[];for(const I of D){const H=f(I);if(H){d(H);continue}const B=O7(I);if(B)try{let W,K,V,X=I.type;if(B==="image")[W,K]=await Promise.all([I7(I),VE(I)]);else if(B==="pdf")K=await VE(I),X="application/pdf";else if(V=await D7(I),K=V,!X){const Y=I.name.toLowerCase();X=Y.endsWith(".md")||Y.endsWith(".markdown")?"text/markdown":"text/plain"}L.push({id:N7(),file:I,type:B,name:I.name,preview:W,data:K,mediaType:X,textContent:V})}catch{d(`Failed to process file: ${I.name}`)}}L.length>0&&l(I=>[...I,...L])},[s.length,t,f]),v=q.useCallback(T=>{l(A=>A.filter(R=>R.id!==T)),d(null)},[]),w=q.useCallback(()=>{l([]),d(null)},[]),E=q.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&o(!0)},[]),b=q.useCallback(T=>{T.preventDefault(),T.stopPropagation();const A=T.currentTarget.getBoundingClientRect(),R=T.clientX,D=T.clientY;(R<A.left||R>A.right||D<A.top||D>A.bottom)&&o(!1)},[]),_=q.useCallback(T=>{T.preventDefault(),T.stopPropagation()},[]),x=q.useCallback(T=>{T.preventDefault(),T.stopPropagation(),o(!1);const A=T.dataTransfer.files;if(A.length>0){const R=Array.from(A).filter(Nu);R.length>0&&m(R)}},[m]),S=q.useCallback(T=>{const A=T.clipboardData?.items;if(!A)return;const R=[];for(const D of Array.from(A))if(D.kind==="file"){const L=D.getAsFile();L&&Nu(L)&&R.push(L)}R.length>0&&(T.preventDefault(),m(R))},[m]);q.useEffect(()=>{if(!i)return;let T=0;const A=I=>{I.preventDefault(),I.dataTransfer?.types.includes("Files")&&(T++,T===1&&o(!0))},R=I=>{I.preventDefault(),T--,T===0&&o(!1)},D=I=>{I.preventDefault()},L=I=>{I.preventDefault(),T=0,o(!1);const H=I.dataTransfer?.files;if(H&&H.length>0){const B=Array.from(H).filter(Nu);B.length>0&&m(B)}};return document.addEventListener("dragenter",A),document.addEventListener("dragleave",R),document.addEventListener("dragover",D),document.addEventListener("drop",L),()=>{document.removeEventListener("dragenter",A),document.removeEventListener("dragleave",R),document.removeEventListener("dragover",D),document.removeEventListener("drop",L)}},[i,m]);const k=s.filter(T=>T.type==="image"),O=s.filter(T=>T.type==="pdf"||T.type==="text");return{files:s,images:k,documents:O,isDragging:c,error:u,addFiles:m,removeFile:v,clearFiles:w,handleDragEnter:E,handleDragLeave:b,handleDragOver:_,handleDrop:x,handlePaste:S}}const av=$n((e,t)=>({pendingRestoreText:null,setPendingRestoreText:n=>e({pendingRestoreText:n}),consumeRestoreText:()=>{const n=t().pendingRestoreText;return e({pendingRestoreText:null}),n}})),Vu=$n((e,t)=>({pendingContexts:new Map,addContext:(n,i)=>{e(s=>{const l=new Map(s.pendingContexts),c=l.get(n)||[];return c.some(o=>o.id===i.id)||l.set(n,[...c,i]),{pendingContexts:l}})},removeContext:(n,i)=>{e(s=>{const l=new Map(s.pendingContexts),c=l.get(n)||[];return l.set(n,c.filter(o=>o.id!==i)),{pendingContexts:l}})},getContexts:n=>t().pendingContexts.get(n)||[],clearContexts:n=>{e(i=>{const s=new Map(i.pendingContexts);return s.delete(n),{pendingContexts:s}})},consumeContexts:n=>{const i=t().getContexts(n);return t().clearContexts(n),i}})),M7=/<research-context\s+from="([^"]+)"\s+label="([^"]+)"[^>]*>([\s\S]*?)<\/research-context>/g;function B7(e){const t=[];let n=e;const i=new RegExp(M7);let s=i.exec(e);for(;s!==null;){const[l,c,o,u]=s;t.push({id:c,from:c,label:o,content:u.trim()}),n=n.replace(l,""),s=i.exec(e)}return n=n.trim(),{researchContexts:t,cleanContent:n}}function F7(e){return e.length===0?"":e.map(t=>t.content).join(`
68
68
 
69
- `)}function Jv(e){const t=cn(d=>d.setBalance),n=cn(d=>d.setUsdcBalance),i=cn(d=>d.setWalletAddress),s=cn(d=>d.setLoading),l=cn(d=>d.balance),c=cn(d=>d.usdcBalance),o=cn(d=>d.network),u=q.useCallback(async()=>{if(e==="solforge"){s(!0);try{const[d,p]=await Promise.all([qe.getSolforgeBalance(),qe.getSolforgeUsdcBalance(o)]);d&&(t(d.balance),i(d.walletAddress)),p&&n(p.usdcBalance)}catch{}finally{s(!1)}}},[e,o,t,n,i,s]);return q.useEffect(()=>{e==="solforge"&&(l===null||c===null)&&u()},[e,l,c,u]),{fetchBalance:u}}const ID=q.forwardRef(function({provider:t,model:n,onChange:i,disabled:s=!1},l){const{data:c,isLoading:o}=Bc(),[u,d]=q.useState(!1),[p,f]=q.useState(""),[m,v]=q.useState(0),w=q.useRef(null),E=q.useRef(null),b=q.useRef([]);q.useImperativeHandle(l,()=>({openAndFocus:()=>{d(!0)}}));const _=q.useMemo(()=>{if(!c)return[];const D=[];for(const[L,I]of Object.entries(c))for(const H of I.models)D.push({providerKey:L,providerLabel:I.label,modelId:H.id,modelLabel:H.label,toolCall:H.toolCall,reasoningText:H.reasoningText});return D},[c]),x=q.useMemo(()=>new Fi(_,{keys:[{name:"modelLabel",weight:1},{name:"modelId",weight:.5},{name:"providerLabel",weight:.3}],threshold:.5,ignoreLocation:!0,includeScore:!0,distance:100,minMatchCharLength:1,findAllMatches:!0}),[_]),S=q.useMemo(()=>{if(!c)return{};if(!p.trim())return c;const L=x.search(p).sort((H,B)=>{const W=H.score??1,K=B.score??1;if(Math.abs(W-K)<.001){const V=H.item.modelLabel.toLowerCase(),X=B.item.modelLabel.toLowerCase(),Y=p.toLowerCase(),P=V.indexOf(Y),M=X.indexOf(Y);if(P>=0&&M<0)return-1;if(M>=0&&P<0)return 1;if(P>=0&&M>=0)return P-M}return W-K}),I={};for(const H of L){const B=H.item;I[B.providerKey]||(I[B.providerKey]={label:B.providerLabel,models:[]}),I[B.providerKey].models.find(K=>K.id===B.modelId)||I[B.providerKey].models.push({id:B.modelId,label:B.modelLabel,toolCall:B.toolCall,reasoningText:B.reasoningText})}return I},[c,p,x]),k=q.useMemo(()=>{const D=[];for(const[L,I]of Object.entries(S))for(const H of I.models)D.push({providerKey:L,providerLabel:I.label,modelId:H.id,modelLabel:H.label,toolCall:H.toolCall,reasoningText:H.reasoningText});return D},[S]);q.useEffect(()=>{u&&v(0)},[u]),q.useEffect(()=>{u&&m>=0&&m<b.current.length&&b.current[m]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[m,u]),q.useEffect(()=>{const D=I=>{w.current&&!w.current.contains(I.target)&&d(!1)},L=I=>{const H=I.target,B=H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable;(I.key==="Escape"||I.key==="q"&&!B)&&d(!1)};return u&&(document.addEventListener("mousedown",D),document.addEventListener("keydown",L),setTimeout(()=>E.current?.focus(),0)),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",L)}},[u]);const O=(D,L)=>{i(D,L),d(!1),f("")},T=D=>{if(k.length!==0){if(D.key==="ArrowDown"||D.ctrlKey&&D.key==="j")D.preventDefault(),v(L=>L<k.length-1?L+1:0);else if(D.key==="ArrowUp"||D.ctrlKey&&D.key==="k")D.preventDefault(),v(L=>L>0?L-1:k.length-1);else if(D.key==="Enter"){D.preventDefault();const L=k[m];L&&O(L.providerKey,L.modelId)}}},A=c?.[t]?.label||t,R=c?.[t]?.models.find(D=>D.id===n)?.label||n;return y.jsxs("div",{ref:w,className:"relative w-full",children:[y.jsxs("button",{type:"button",onClick:()=>!s&&d(!u),disabled:s||o,className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded-md hover:bg-[hsl(var(--accent))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsxs("span",{className:"flex items-center gap-2 text-sm truncate",children:[y.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:A}),y.jsx("span",{className:"text-[hsl(var(--muted-foreground))]/50",children:"/"}),y.jsx("span",{className:"text-[hsl(var(--foreground))]",children:R})]}),y.jsx(xa,{className:`w-4 h-4 text-[hsl(var(--muted-foreground))] transition-transform ${u?"rotate-180":""}`})]}),u&&!o&&c&&y.jsxs("div",{className:"absolute z-50 mt-1 w-full bg-[hsl(var(--popover))] border border-[hsl(var(--border))] rounded-md shadow-lg max-h-80 overflow-hidden flex flex-col",children:[y.jsx("div",{className:"p-2 border-b border-[hsl(var(--border))]",children:y.jsxs("div",{className:"relative",children:[y.jsx(Qo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[hsl(var(--muted-foreground))]"}),y.jsx("input",{ref:E,type:"text",value:p,onChange:D=>f(D.target.value),onKeyDown:T,placeholder:"Search providers and models...",className:"w-full pl-9 pr-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded text-sm text-[hsl(var(--foreground))] placeholder-[hsl(var(--muted-foreground))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"})]})}),y.jsx("div",{className:"overflow-y-auto",children:Object.keys(S).length===0?y.jsx("div",{className:"p-4 text-center text-[hsl(var(--muted-foreground))] text-sm",children:"No models found"}):Object.entries(S).map(([D,L])=>y.jsxs("div",{className:"border-b border-[hsl(var(--border))] last:border-0",children:[y.jsx("div",{className:"sticky top-0 px-3 py-2 text-xs font-semibold text-[hsl(var(--muted-foreground))] uppercase tracking-wider bg-[hsl(var(--muted))] z-10",children:L.label}),y.jsx("div",{children:L.models.map(I=>{const H=D===t&&I.id===n,B=k.findIndex(K=>K.providerKey===D&&K.modelId===I.id),W=B===m;return y.jsxs("button",{ref:K=>{B>=0&&(b.current[B]=K)},type:"button",onClick:()=>O(D,I.id),onMouseEnter:()=>v(B),className:`w-full text-left px-4 py-2 text-sm flex items-center justify-between transition-colors ${W?"bg-[hsl(var(--accent))]":"hover:bg-[hsl(var(--accent))]"} ${H?"text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--foreground))]"}`,children:[y.jsx("span",{className:"truncate",children:I.label}),(I.toolCall||I.reasoningText)&&y.jsxs("div",{className:"flex gap-1 ml-2 flex-shrink-0",children:[I.toolCall&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-600/20 text-green-400 rounded",children:"Tools"}),I.reasoningText&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-purple-600/20 text-purple-400 rounded",children:"Reasoning"})]})]},I.id)})})]},D))})]})]})}),j7=q.forwardRef(function({agent:t,agents:n,onChange:i,disabled:s=!1},l){const[c,o]=q.useState(!1),[u,d]=q.useState(""),[p,f]=q.useState(0),m=q.useRef(null),v=q.useRef(null),w=q.useRef([]);q.useImperativeHandle(l,()=>({openAndFocus:()=>{o(!0)}}));const E=q.useMemo(()=>new Fi(n,{threshold:.4,ignoreLocation:!0}),[n]),b=q.useMemo(()=>u.trim()?E.search(u).map(k=>k.item):n,[n,u,E]);q.useEffect(()=>{c&&f(0)},[c]),q.useEffect(()=>{c&&p>=0&&p<w.current.length&&w.current[p]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[p,c]),q.useEffect(()=>{const S=O=>{m.current&&!m.current.contains(O.target)&&o(!1)},k=O=>{const T=O.target,A=T.tagName==="INPUT"||T.tagName==="TEXTAREA"||T.isContentEditable;(O.key==="Escape"||O.key==="q"&&!A)&&o(!1)};return c&&(document.addEventListener("mousedown",S),document.addEventListener("keydown",k),setTimeout(()=>v.current?.focus(),0)),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",k)}},[c]);const _=S=>{i(S),o(!1),d("")},x=S=>{if(b.length!==0){if(S.key==="ArrowDown"||S.ctrlKey&&S.key==="j")S.preventDefault(),f(k=>k<b.length-1?k+1:0);else if(S.key==="ArrowUp"||S.ctrlKey&&S.key==="k")S.preventDefault(),f(k=>k>0?k-1:b.length-1);else if(S.key==="Enter"){S.preventDefault();const k=b[p];k&&_(k)}}};return y.jsxs("div",{ref:m,className:"relative w-full",children:[y.jsxs("button",{type:"button",onClick:()=>!s&&o(!c),disabled:s,className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded-md hover:bg-[hsl(var(--accent))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx("span",{className:"text-sm text-[hsl(var(--foreground))] truncate",children:t}),y.jsx(xa,{className:`w-4 h-4 text-[hsl(var(--muted-foreground))] transition-transform ${c?"rotate-180":""}`})]}),c&&y.jsxs("div",{className:"absolute z-50 mt-1 w-full bg-[hsl(var(--popover))] border border-[hsl(var(--border))] rounded-md shadow-lg max-h-80 overflow-hidden flex flex-col",children:[y.jsx("div",{className:"p-2 border-b border-[hsl(var(--border))]",children:y.jsxs("div",{className:"relative",children:[y.jsx(Qo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[hsl(var(--muted-foreground))]"}),y.jsx("input",{ref:v,type:"text",value:u,onChange:S=>d(S.target.value),onKeyDown:x,placeholder:"Search agents...",className:"w-full pl-9 pr-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded text-sm text-[hsl(var(--foreground))] placeholder-[hsl(var(--muted-foreground))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"})]})}),y.jsx("div",{className:"overflow-y-auto",children:b.length===0?y.jsx("div",{className:"p-4 text-center text-[hsl(var(--muted-foreground))] text-sm",children:"No agents found"}):b.map((S,k)=>{const O=S===t,T=k===p;return y.jsx("button",{ref:A=>{w.current[k]=A},type:"button",onClick:()=>_(S),onMouseEnter:()=>f(k),className:`w-full text-left px-4 py-2 text-sm transition-colors ${T?"bg-[hsl(var(--accent))]":"hover:bg-[hsl(var(--accent))]"} ${O?"text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--foreground))]"}`,children:y.jsx("span",{className:"truncate",children:S})},S)})})]})]})});function P7({isOpen:e,onClose:t,initialFocus:n,chatInputRef:i,agent:s,provider:l,model:c,modelSupportsReasoning:o,onAgentChange:u,onProviderChange:d,onModelChange:p,onModelSelectorChange:f}){const{data:m,isLoading:v}=Zv(),{preferences:w,updatePreferences:E}=Jo(),b=q.useRef(null),_=q.useRef(null);q.useEffect(()=>{e&&n&&setTimeout(()=>{n==="agent"?b.current?.openAndFocus():n==="model"&&_.current?.openAndFocus()},100)},[e,n]);const x=()=>{t(),setTimeout(()=>{i?.current?.focus()},100)},S=(k,O)=>{f?f(k,O):(d(k),p(O))};return y.jsx(al,{isOpen:e,onClose:x,title:"Configuration",closeOnEscape:!0,closeOnBackdropClick:!0,children:v?y.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading configuration..."}):m?y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{children:[y.jsx("div",{className:"block text-sm font-medium text-foreground mb-2",children:"Agent"}),y.jsx(j7,{ref:b,agent:s,agents:m.agents,onChange:u})]}),y.jsxs("div",{children:[y.jsx("div",{className:"block text-sm font-medium text-foreground mb-2",children:"Provider / Model"}),y.jsx(ID,{ref:_,provider:l,model:c,onChange:S})]}),o&&y.jsxs("div",{className:"flex items-center justify-between py-2",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium text-foreground",children:"Extended Thinking"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Enable reasoning for deeper analysis"})]}),y.jsx("button",{type:"button",role:"switch","aria-checked":w.reasoningEnabled,onClick:()=>E({reasoningEnabled:!w.reasoningEnabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${w.reasoningEnabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${w.reasoningEnabled?"translate-x-6":"translate-x-1"} ${w.reasoningEnabled?"bg-primary-foreground":"bg-foreground"}`})})]})]}):null})}const U7=q.memo(q.forwardRef(function({sessionId:t,userContext:n,onNewSession:i,onDeleteSession:s},l){const c=CD(t),[o,u]=q.useState(""),[d,p]=q.useState(""),[f,m]=q.useState(""),[v,w]=q.useState(!1),[E,b]=q.useState(null),[_,x]=q.useState(0),S=q.useRef(null),k=S7(t);pc(t);const O=kD(t),T=E7(),{data:A}=Bc(),{preferences:R}=Jo(),{data:D}=Fc(),L=jc(),I=Tt(Se=>Se.openCommitModal),H=Lt(),{images:B,documents:W,isDragging:K,removeFile:V,clearFiles:X,handlePaste:Y}=L7(),P=A?.[d]?.models?.find(Se=>Se.id===f)?.reasoningText,M=A?.[d]?.models?.find(Se=>Se.id===f)?.vision,j=Vu(Se=>Se.pendingContexts),$=Vu(Se=>Se.removeContext),U=Vu(Se=>Se.consumeContexts),J=j.get(t)||[],oe=q.useMemo(()=>J.map(Se=>({id:Se.id,label:Se.label})),[J]),he=q.useCallback(Se=>{$(t,Se)},[t,$]),Z=A?.[d]?.authType,{fetchBalance:z}=Jv(d),ne=cn(Se=>Se.isLoading);q.useEffect(()=>{c&&(u(c.agent),p(c.provider),m(c.model))},[c]),q.useEffect(()=>{x(Se=>Se+1)},[]);const ce=av(Se=>Se.pendingRestoreText),ge=av(Se=>Se.consumeRestoreText);q.useEffect(()=>{if(ce){const Se=ge();Se&&S.current?.setValue(Se)}},[ce,ge]),q.useImperativeHandle(l,()=>({focus:()=>{S.current?.focus()}}));const be=q.useCallback(async Se=>{try{const Fe=U(t),Re=F7(Fe),Le=Re?`${Re}
69
+ `)}function Jv(e){const t=cn(d=>d.setBalance),n=cn(d=>d.setUsdcBalance),i=cn(d=>d.setWalletAddress),s=cn(d=>d.setLoading),l=cn(d=>d.balance),c=cn(d=>d.usdcBalance),o=cn(d=>d.network),u=q.useCallback(async()=>{if(e==="setu"){s(!0);try{const[d,p]=await Promise.all([qe.getSetuBalance(),qe.getSetuUsdcBalance(o)]);d&&(t(d.balance),i(d.walletAddress)),p&&n(p.usdcBalance)}catch{}finally{s(!1)}}},[e,o,t,n,i,s]);return q.useEffect(()=>{e==="setu"&&(l===null||c===null)&&u()},[e,l,c,u]),{fetchBalance:u}}const ID=q.forwardRef(function({provider:t,model:n,onChange:i,disabled:s=!1},l){const{data:c,isLoading:o}=Bc(),[u,d]=q.useState(!1),[p,f]=q.useState(""),[m,v]=q.useState(0),w=q.useRef(null),E=q.useRef(null),b=q.useRef([]);q.useImperativeHandle(l,()=>({openAndFocus:()=>{d(!0)}}));const _=q.useMemo(()=>{if(!c)return[];const D=[];for(const[L,I]of Object.entries(c))for(const H of I.models)D.push({providerKey:L,providerLabel:I.label,modelId:H.id,modelLabel:H.label,toolCall:H.toolCall,reasoningText:H.reasoningText});return D},[c]),x=q.useMemo(()=>new Fi(_,{keys:[{name:"modelLabel",weight:1},{name:"modelId",weight:.5},{name:"providerLabel",weight:.3}],threshold:.5,ignoreLocation:!0,includeScore:!0,distance:100,minMatchCharLength:1,findAllMatches:!0}),[_]),S=q.useMemo(()=>{if(!c)return{};if(!p.trim())return c;const L=x.search(p).sort((H,B)=>{const W=H.score??1,K=B.score??1;if(Math.abs(W-K)<.001){const V=H.item.modelLabel.toLowerCase(),X=B.item.modelLabel.toLowerCase(),Y=p.toLowerCase(),P=V.indexOf(Y),M=X.indexOf(Y);if(P>=0&&M<0)return-1;if(M>=0&&P<0)return 1;if(P>=0&&M>=0)return P-M}return W-K}),I={};for(const H of L){const B=H.item;I[B.providerKey]||(I[B.providerKey]={label:B.providerLabel,models:[]}),I[B.providerKey].models.find(K=>K.id===B.modelId)||I[B.providerKey].models.push({id:B.modelId,label:B.modelLabel,toolCall:B.toolCall,reasoningText:B.reasoningText})}return I},[c,p,x]),k=q.useMemo(()=>{const D=[];for(const[L,I]of Object.entries(S))for(const H of I.models)D.push({providerKey:L,providerLabel:I.label,modelId:H.id,modelLabel:H.label,toolCall:H.toolCall,reasoningText:H.reasoningText});return D},[S]);q.useEffect(()=>{u&&v(0)},[u]),q.useEffect(()=>{u&&m>=0&&m<b.current.length&&b.current[m]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[m,u]),q.useEffect(()=>{const D=I=>{w.current&&!w.current.contains(I.target)&&d(!1)},L=I=>{const H=I.target,B=H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable;(I.key==="Escape"||I.key==="q"&&!B)&&d(!1)};return u&&(document.addEventListener("mousedown",D),document.addEventListener("keydown",L),setTimeout(()=>E.current?.focus(),0)),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",L)}},[u]);const O=(D,L)=>{i(D,L),d(!1),f("")},T=D=>{if(k.length!==0){if(D.key==="ArrowDown"||D.ctrlKey&&D.key==="j")D.preventDefault(),v(L=>L<k.length-1?L+1:0);else if(D.key==="ArrowUp"||D.ctrlKey&&D.key==="k")D.preventDefault(),v(L=>L>0?L-1:k.length-1);else if(D.key==="Enter"){D.preventDefault();const L=k[m];L&&O(L.providerKey,L.modelId)}}},A=c?.[t]?.label||t,R=c?.[t]?.models.find(D=>D.id===n)?.label||n;return y.jsxs("div",{ref:w,className:"relative w-full",children:[y.jsxs("button",{type:"button",onClick:()=>!s&&d(!u),disabled:s||o,className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded-md hover:bg-[hsl(var(--accent))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsxs("span",{className:"flex items-center gap-2 text-sm truncate",children:[y.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:A}),y.jsx("span",{className:"text-[hsl(var(--muted-foreground))]/50",children:"/"}),y.jsx("span",{className:"text-[hsl(var(--foreground))]",children:R})]}),y.jsx(xa,{className:`w-4 h-4 text-[hsl(var(--muted-foreground))] transition-transform ${u?"rotate-180":""}`})]}),u&&!o&&c&&y.jsxs("div",{className:"absolute z-50 mt-1 w-full bg-[hsl(var(--popover))] border border-[hsl(var(--border))] rounded-md shadow-lg max-h-80 overflow-hidden flex flex-col",children:[y.jsx("div",{className:"p-2 border-b border-[hsl(var(--border))]",children:y.jsxs("div",{className:"relative",children:[y.jsx(Qo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[hsl(var(--muted-foreground))]"}),y.jsx("input",{ref:E,type:"text",value:p,onChange:D=>f(D.target.value),onKeyDown:T,placeholder:"Search providers and models...",className:"w-full pl-9 pr-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded text-sm text-[hsl(var(--foreground))] placeholder-[hsl(var(--muted-foreground))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"})]})}),y.jsx("div",{className:"overflow-y-auto",children:Object.keys(S).length===0?y.jsx("div",{className:"p-4 text-center text-[hsl(var(--muted-foreground))] text-sm",children:"No models found"}):Object.entries(S).map(([D,L])=>y.jsxs("div",{className:"border-b border-[hsl(var(--border))] last:border-0",children:[y.jsx("div",{className:"sticky top-0 px-3 py-2 text-xs font-semibold text-[hsl(var(--muted-foreground))] uppercase tracking-wider bg-[hsl(var(--muted))] z-10",children:L.label}),y.jsx("div",{children:L.models.map(I=>{const H=D===t&&I.id===n,B=k.findIndex(K=>K.providerKey===D&&K.modelId===I.id),W=B===m;return y.jsxs("button",{ref:K=>{B>=0&&(b.current[B]=K)},type:"button",onClick:()=>O(D,I.id),onMouseEnter:()=>v(B),className:`w-full text-left px-4 py-2 text-sm flex items-center justify-between transition-colors ${W?"bg-[hsl(var(--accent))]":"hover:bg-[hsl(var(--accent))]"} ${H?"text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--foreground))]"}`,children:[y.jsx("span",{className:"truncate",children:I.label}),(I.toolCall||I.reasoningText)&&y.jsxs("div",{className:"flex gap-1 ml-2 flex-shrink-0",children:[I.toolCall&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-600/20 text-green-400 rounded",children:"Tools"}),I.reasoningText&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-purple-600/20 text-purple-400 rounded",children:"Reasoning"})]})]},I.id)})})]},D))})]})]})}),j7=q.forwardRef(function({agent:t,agents:n,onChange:i,disabled:s=!1},l){const[c,o]=q.useState(!1),[u,d]=q.useState(""),[p,f]=q.useState(0),m=q.useRef(null),v=q.useRef(null),w=q.useRef([]);q.useImperativeHandle(l,()=>({openAndFocus:()=>{o(!0)}}));const E=q.useMemo(()=>new Fi(n,{threshold:.4,ignoreLocation:!0}),[n]),b=q.useMemo(()=>u.trim()?E.search(u).map(k=>k.item):n,[n,u,E]);q.useEffect(()=>{c&&f(0)},[c]),q.useEffect(()=>{c&&p>=0&&p<w.current.length&&w.current[p]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[p,c]),q.useEffect(()=>{const S=O=>{m.current&&!m.current.contains(O.target)&&o(!1)},k=O=>{const T=O.target,A=T.tagName==="INPUT"||T.tagName==="TEXTAREA"||T.isContentEditable;(O.key==="Escape"||O.key==="q"&&!A)&&o(!1)};return c&&(document.addEventListener("mousedown",S),document.addEventListener("keydown",k),setTimeout(()=>v.current?.focus(),0)),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",k)}},[c]);const _=S=>{i(S),o(!1),d("")},x=S=>{if(b.length!==0){if(S.key==="ArrowDown"||S.ctrlKey&&S.key==="j")S.preventDefault(),f(k=>k<b.length-1?k+1:0);else if(S.key==="ArrowUp"||S.ctrlKey&&S.key==="k")S.preventDefault(),f(k=>k>0?k-1:b.length-1);else if(S.key==="Enter"){S.preventDefault();const k=b[p];k&&_(k)}}};return y.jsxs("div",{ref:m,className:"relative w-full",children:[y.jsxs("button",{type:"button",onClick:()=>!s&&o(!c),disabled:s,className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded-md hover:bg-[hsl(var(--accent))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[y.jsx("span",{className:"text-sm text-[hsl(var(--foreground))] truncate",children:t}),y.jsx(xa,{className:`w-4 h-4 text-[hsl(var(--muted-foreground))] transition-transform ${c?"rotate-180":""}`})]}),c&&y.jsxs("div",{className:"absolute z-50 mt-1 w-full bg-[hsl(var(--popover))] border border-[hsl(var(--border))] rounded-md shadow-lg max-h-80 overflow-hidden flex flex-col",children:[y.jsx("div",{className:"p-2 border-b border-[hsl(var(--border))]",children:y.jsxs("div",{className:"relative",children:[y.jsx(Qo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[hsl(var(--muted-foreground))]"}),y.jsx("input",{ref:v,type:"text",value:u,onChange:S=>d(S.target.value),onKeyDown:x,placeholder:"Search agents...",className:"w-full pl-9 pr-3 py-2 bg-[hsl(var(--secondary))] border border-[hsl(var(--border))] rounded text-sm text-[hsl(var(--foreground))] placeholder-[hsl(var(--muted-foreground))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"})]})}),y.jsx("div",{className:"overflow-y-auto",children:b.length===0?y.jsx("div",{className:"p-4 text-center text-[hsl(var(--muted-foreground))] text-sm",children:"No agents found"}):b.map((S,k)=>{const O=S===t,T=k===p;return y.jsx("button",{ref:A=>{w.current[k]=A},type:"button",onClick:()=>_(S),onMouseEnter:()=>f(k),className:`w-full text-left px-4 py-2 text-sm transition-colors ${T?"bg-[hsl(var(--accent))]":"hover:bg-[hsl(var(--accent))]"} ${O?"text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--foreground))]"}`,children:y.jsx("span",{className:"truncate",children:S})},S)})})]})]})});function P7({isOpen:e,onClose:t,initialFocus:n,chatInputRef:i,agent:s,provider:l,model:c,modelSupportsReasoning:o,onAgentChange:u,onProviderChange:d,onModelChange:p,onModelSelectorChange:f}){const{data:m,isLoading:v}=Zv(),{preferences:w,updatePreferences:E}=Jo(),b=q.useRef(null),_=q.useRef(null);q.useEffect(()=>{e&&n&&setTimeout(()=>{n==="agent"?b.current?.openAndFocus():n==="model"&&_.current?.openAndFocus()},100)},[e,n]);const x=()=>{t(),setTimeout(()=>{i?.current?.focus()},100)},S=(k,O)=>{f?f(k,O):(d(k),p(O))};return y.jsx(al,{isOpen:e,onClose:x,title:"Configuration",closeOnEscape:!0,closeOnBackdropClick:!0,children:v?y.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading configuration..."}):m?y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{children:[y.jsx("div",{className:"block text-sm font-medium text-foreground mb-2",children:"Agent"}),y.jsx(j7,{ref:b,agent:s,agents:m.agents,onChange:u})]}),y.jsxs("div",{children:[y.jsx("div",{className:"block text-sm font-medium text-foreground mb-2",children:"Provider / Model"}),y.jsx(ID,{ref:_,provider:l,model:c,onChange:S})]}),o&&y.jsxs("div",{className:"flex items-center justify-between py-2",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium text-foreground",children:"Extended Thinking"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Enable reasoning for deeper analysis"})]}),y.jsx("button",{type:"button",role:"switch","aria-checked":w.reasoningEnabled,onClick:()=>E({reasoningEnabled:!w.reasoningEnabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${w.reasoningEnabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${w.reasoningEnabled?"translate-x-6":"translate-x-1"} ${w.reasoningEnabled?"bg-primary-foreground":"bg-foreground"}`})})]})]}):null})}const U7=q.memo(q.forwardRef(function({sessionId:t,userContext:n,onNewSession:i,onDeleteSession:s},l){const c=CD(t),[o,u]=q.useState(""),[d,p]=q.useState(""),[f,m]=q.useState(""),[v,w]=q.useState(!1),[E,b]=q.useState(null),[_,x]=q.useState(0),S=q.useRef(null),k=S7(t);pc(t);const O=kD(t),T=E7(),{data:A}=Bc(),{preferences:R}=Jo(),{data:D}=Fc(),L=jc(),I=Tt(Se=>Se.openCommitModal),H=Lt(),{images:B,documents:W,isDragging:K,removeFile:V,clearFiles:X,handlePaste:Y}=L7(),P=A?.[d]?.models?.find(Se=>Se.id===f)?.reasoningText,M=A?.[d]?.models?.find(Se=>Se.id===f)?.vision,j=Vu(Se=>Se.pendingContexts),$=Vu(Se=>Se.removeContext),U=Vu(Se=>Se.consumeContexts),J=j.get(t)||[],oe=q.useMemo(()=>J.map(Se=>({id:Se.id,label:Se.label})),[J]),he=q.useCallback(Se=>{$(t,Se)},[t,$]),Z=A?.[d]?.authType,{fetchBalance:z}=Jv(d),ne=cn(Se=>Se.isLoading);q.useEffect(()=>{c&&(u(c.agent),p(c.provider),m(c.model))},[c]),q.useEffect(()=>{x(Se=>Se+1)},[]);const ce=av(Se=>Se.pendingRestoreText),ge=av(Se=>Se.consumeRestoreText);q.useEffect(()=>{if(ce){const Se=ge();Se&&S.current?.setValue(Se)}},[ce,ge]),q.useImperativeHandle(l,()=>({focus:()=>{S.current?.focus()}}));const be=q.useCallback(async Se=>{try{const Fe=U(t),Re=F7(Fe),Le=Re?`${Re}
70
70
 
71
- ${Se}`:Se,Ge=B.length>0?B.map(de=>({data:de.data,mediaType:de.mediaType})):void 0,re=W.length>0?W.map(de=>({type:de.type,name:de.name,data:de.data,mediaType:de.mediaType,textContent:de.textContent})):void 0;await k.mutateAsync({content:Le,images:Ge,files:re,agent:o||void 0,provider:d||void 0,model:f||void 0,userContext:n||void 0,reasoningText:P&&R.reasoningEnabled?!0:void 0}),X()}catch(Fe){console.error("Failed to send message:",Fe)}},[k,W,B,X,o,d,f,n,P,R.reasoningEnabled,t,U]),we=q.useCallback(()=>{w(Se=>!Se)},[]),$e=q.useCallback(()=>{w(!1),b(null)},[]),Pe=q.useCallback(async Se=>{if(Se==="models")b("model"),w(!0);else if(Se==="agents")b("agent"),w(!0);else if(Se==="new")i?.();else if(Se==="stage"){const Fe=D?.unstaged?.map(Ge=>Ge.path)??[],Re=D?.untracked?.map(Ge=>Ge.path)??[],Le=[...Fe,...Re];Le.length>0&&L.mutate(Le)}else if(Se==="commit")I();else if(Se==="compact")be("/compact");else if(Se==="delete")T.mutate(t,{onSuccess:()=>{s?.()}});else if(Se==="share"){const Fe=Kt.loading("Sharing session...");try{const Re=await qe.shareSession(t);Re.shared&&(Kt.successWithAction(Re.message==="Already shared"?"Already shared":"Session shared!",{label:"Open",href:Re.url}),H.invalidateQueries({queryKey:["share-status",t]}))}catch(Re){Kt.error(Re instanceof Error?Re.message:"Failed to share")}finally{Cr.getState().removeToast(Fe)}}else if(Se==="sync"){const Fe=Kt.loading("Syncing session...");try{const Re=await qe.syncSession(t);if(Re.synced){const Le=Re.newMessages>0?`Synced ${Re.newMessages} new messages`:"Already synced";Kt.successWithAction(Le,{label:"Open",href:Re.url}),H.invalidateQueries({queryKey:["share-status",t]})}}catch(Re){Kt.error(Re instanceof Error?Re.message:"Failed to sync")}finally{Cr.getState().removeToast(Fe)}}},[i,D,L,I,be,T,t,s,H]),We=q.useCallback(async Se=>{u(Se);try{await O.mutateAsync({agent:Se})}catch(Fe){console.error("Failed to update agent:",Fe)}},[O]),xe=q.useCallback(async(Se,Fe)=>{p(Se),m(Fe);try{await O.mutateAsync({provider:Se,model:Fe})}catch(Re){console.error("Failed to update model:",Re)}},[O]),gt=q.useCallback(async Se=>{if(p(Se),f)try{await O.mutateAsync({provider:Se,model:f})}catch(Fe){console.error("Failed to update provider:",Fe)}},[f,O]),ot=q.useCallback(async Se=>{m(Se);try{await O.mutateAsync({provider:d,model:Se})}catch(Fe){console.error("Failed to update model:",Fe)}},[d,O]),vt=q.useCallback(async Se=>{const Fe=Se?"plan":"build";u(Fe);try{await O.mutateAsync({agent:Fe})}catch(Re){console.error("Failed to switch agent:",Re)}},[O]);return y.jsxs(y.Fragment,{children:[y.jsx(P7,{isOpen:v,onClose:$e,initialFocus:E,chatInputRef:S,agent:o,provider:d,model:f,modelSupportsReasoning:P,onAgentChange:We,onProviderChange:gt,onModelChange:ot,onModelSelectorChange:xe}),y.jsx(_7,{ref:S,onSend:be,onCommand:Pe,disabled:k.isPending,onConfigClick:we,onPlanModeToggle:vt,isPlanMode:o==="plan",reasoningEnabled:P&&R.reasoningEnabled,sessionId:t,images:B,documents:W,onFileRemove:V,isDragging:K,onPaste:Y,visionEnabled:M,modelName:f,providerName:d,authType:Z,researchContexts:oe,onResearchContextRemove:he,onRefreshBalance:d==="solforge"?z:void 0,isBalanceLoading:ne},_)]})}));function H7({sessionId:e,onStop:t,disabled:n}){const[i,s]=q.useState(!1),l=async()=>{if(!i){s(!0);try{await qe.abortSession(e),t?.()}catch(c){console.error("Failed to abort stream:",c)}finally{setTimeout(()=>s(!1),1e3)}}};return y.jsxs("button",{type:"button",onClick:l,disabled:n||i,className:"flex items-center gap-1.5 text-sm text-destructive hover:text-destructive/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Stop generation",children:[y.jsx(kO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:i?"Stopping...":"Stop"})]})}function z7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const q7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G7={};function KE(e,t){return(G7.jsx?$7:q7).test(e)}const W7=/[ \t\n\f\r]/g;function V7(e){return typeof e=="object"?e.type==="text"?YE(e.value):!1:YE(e)}function YE(e){return e.replace(W7,"")===""}class sl{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}sl.prototype.normal={};sl.prototype.property={};sl.prototype.space=void 0;function LD(e,t){const n={},i={};for(const s of e)Object.assign(n,s.property),Object.assign(i,s.normal);return new sl(n,i,t)}function sv(e){return e.toLowerCase()}class Tn{constructor(t,n){this.attribute=n,this.property=t}}Tn.prototype.attribute="";Tn.prototype.booleanish=!1;Tn.prototype.boolean=!1;Tn.prototype.commaOrSpaceSeparated=!1;Tn.prototype.commaSeparated=!1;Tn.prototype.defined=!1;Tn.prototype.mustUseProperty=!1;Tn.prototype.number=!1;Tn.prototype.overloadedBoolean=!1;Tn.prototype.property="";Tn.prototype.spaceSeparated=!1;Tn.prototype.space=void 0;let K7=0;const ze=wa(),qt=wa(),ov=wa(),ve=wa(),St=wa(),vs=wa(),Bn=wa();function wa(){return 2**++K7}const lv=Object.freeze(Object.defineProperty({__proto__:null,boolean:ze,booleanish:qt,commaOrSpaceSeparated:Bn,commaSeparated:vs,number:ve,overloadedBoolean:ov,spaceSeparated:St},Symbol.toStringTag,{value:"Module"})),Dp=Object.keys(lv);class e1 extends Tn{constructor(t,n,i,s){let l=-1;if(super(t,n),XE(this,"space",s),typeof i=="number")for(;++l<Dp.length;){const c=Dp[l];XE(this,Dp[l],(i&lv[c])===lv[c])}}}e1.prototype.defined=!0;function XE(e,t,n){n&&(e[t]=n)}function Ts(e){const t={},n={};for(const[i,s]of Object.entries(e.properties)){const l=new e1(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(l.mustUseProperty=!0),t[i]=l,n[sv(i)]=i,n[sv(l.attribute)]=i}return new sl(t,n,e.space)}const MD=Ts({properties:{ariaActiveDescendant:null,ariaAtomic:qt,ariaAutoComplete:null,ariaBusy:qt,ariaChecked:qt,ariaColCount:ve,ariaColIndex:ve,ariaColSpan:ve,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:qt,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:qt,ariaFlowTo:St,ariaGrabbed:qt,ariaHasPopup:null,ariaHidden:qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:ve,ariaLive:null,ariaModal:qt,ariaMultiLine:qt,ariaMultiSelectable:qt,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:ve,ariaPressed:qt,ariaReadOnly:qt,ariaRelevant:null,ariaRequired:qt,ariaRoleDescription:St,ariaRowCount:ve,ariaRowIndex:ve,ariaRowSpan:ve,ariaSelected:qt,ariaSetSize:ve,ariaSort:null,ariaValueMax:ve,ariaValueMin:ve,ariaValueNow:ve,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function BD(e,t){return t in e?e[t]:t}function FD(e,t){return BD(e,t.toLowerCase())}const Y7=Ts({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:vs,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:ze,allowPaymentRequest:ze,allowUserMedia:ze,alt:null,as:null,async:ze,autoCapitalize:null,autoComplete:St,autoFocus:ze,autoPlay:ze,blocking:St,capture:null,charSet:null,checked:ze,cite:null,className:St,cols:ve,colSpan:null,content:null,contentEditable:qt,controls:ze,controlsList:St,coords:ve|vs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ze,defer:ze,dir:null,dirName:null,disabled:ze,download:ov,draggable:qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ze,formTarget:null,headers:St,height:ve,hidden:ov,high:ve,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:ze,inputMode:null,integrity:null,is:null,isMap:ze,itemId:null,itemProp:St,itemRef:St,itemScope:ze,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ze,low:ve,manifest:null,max:null,maxLength:ve,media:null,method:null,min:null,minLength:ve,multiple:ze,muted:ze,name:null,nonce:null,noModule:ze,noValidate:ze,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ze,optimum:ve,pattern:null,ping:St,placeholder:null,playsInline:ze,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ze,referrerPolicy:null,rel:St,required:ze,reversed:ze,rows:ve,rowSpan:ve,sandbox:St,scope:null,scoped:ze,seamless:ze,selected:ze,shadowRootClonable:ze,shadowRootDelegatesFocus:ze,shadowRootMode:null,shape:null,size:ve,sizes:null,slot:null,span:ve,spellCheck:qt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ve,step:null,style:null,tabIndex:ve,target:null,title:null,translate:null,type:null,typeMustMatch:ze,useMap:null,value:qt,width:ve,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:ve,borderColor:null,bottomMargin:ve,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ze,declare:ze,event:null,face:null,frame:null,frameBorder:null,hSpace:ve,leftMargin:ve,link:null,longDesc:null,lowSrc:null,marginHeight:ve,marginWidth:ve,noResize:ze,noHref:ze,noShade:ze,noWrap:ze,object:null,profile:null,prompt:null,rev:null,rightMargin:ve,rules:null,scheme:null,scrolling:qt,standby:null,summary:null,text:null,topMargin:ve,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ve,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ze,disableRemotePlayback:ze,prefix:null,property:null,results:ve,security:null,unselectable:null},space:"html",transform:FD}),X7=Ts({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Bn,accentHeight:ve,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ve,amplitude:ve,arabicForm:null,ascent:ve,attributeName:null,attributeType:null,azimuth:ve,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ve,by:null,calcMode:null,capHeight:ve,className:St,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ve,diffuseConstant:ve,direction:null,display:null,dur:null,divisor:ve,dominantBaseline:null,download:ze,dx:null,dy:null,edgeMode:null,editable:null,elevation:ve,enableBackground:null,end:null,event:null,exponent:ve,externalResourcesRequired:null,fill:null,fillOpacity:ve,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:vs,g2:vs,glyphName:vs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ve,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ve,horizOriginX:ve,horizOriginY:ve,id:null,ideographic:ve,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ve,k:ve,k1:ve,k2:ve,k3:ve,k4:ve,kernelMatrix:Bn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ve,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ve,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ve,overlineThickness:ve,paintOrder:null,panose1:null,path:null,pathLength:ve,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ve,pointsAtY:ve,pointsAtZ:ve,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Bn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Bn,rev:Bn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Bn,requiredFeatures:Bn,requiredFonts:Bn,requiredFormats:Bn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ve,specularExponent:ve,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ve,strikethroughThickness:ve,string:null,stroke:null,strokeDashArray:Bn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ve,strokeOpacity:ve,strokeWidth:null,style:null,surfaceScale:ve,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Bn,tabIndex:ve,tableValues:null,target:null,targetX:ve,targetY:ve,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Bn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ve,underlineThickness:ve,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ve,values:null,vAlphabetic:ve,vMathematical:ve,vectorEffect:null,vHanging:ve,vIdeographic:ve,version:null,vertAdvY:ve,vertOriginX:ve,vertOriginY:ve,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ve,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:BD}),jD=Ts({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),PD=Ts({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:FD}),UD=Ts({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Z7={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Q7=/[A-Z]/g,ZE=/-[a-z]/g,J7=/^data[-\w.:]+$/i;function eU(e,t){const n=sv(t);let i=t,s=Tn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&J7.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(ZE,nU);i="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!ZE.test(l)){let c=l.replace(Q7,tU);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}s=e1}return new s(i,t)}function tU(e){return"-"+e.toLowerCase()}function nU(e){return e.charAt(1).toUpperCase()}const rU=LD([MD,Y7,jD,PD,UD],"html"),t1=LD([MD,X7,jD,PD,UD],"svg");function iU(e){return e.join(" ").trim()}var ds={},Ip,QE;function aU(){if(QE)return Ip;QE=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,o=/^\s+|\s+$/g,u=`
71
+ ${Se}`:Se,Ge=B.length>0?B.map(de=>({data:de.data,mediaType:de.mediaType})):void 0,re=W.length>0?W.map(de=>({type:de.type,name:de.name,data:de.data,mediaType:de.mediaType,textContent:de.textContent})):void 0;await k.mutateAsync({content:Le,images:Ge,files:re,agent:o||void 0,provider:d||void 0,model:f||void 0,userContext:n||void 0,reasoningText:P&&R.reasoningEnabled?!0:void 0}),X()}catch(Fe){console.error("Failed to send message:",Fe)}},[k,W,B,X,o,d,f,n,P,R.reasoningEnabled,t,U]),we=q.useCallback(()=>{w(Se=>!Se)},[]),$e=q.useCallback(()=>{w(!1),b(null)},[]),Pe=q.useCallback(async Se=>{if(Se==="models")b("model"),w(!0);else if(Se==="agents")b("agent"),w(!0);else if(Se==="new")i?.();else if(Se==="stage"){const Fe=D?.unstaged?.map(Ge=>Ge.path)??[],Re=D?.untracked?.map(Ge=>Ge.path)??[],Le=[...Fe,...Re];Le.length>0&&L.mutate(Le)}else if(Se==="commit")I();else if(Se==="compact")be("/compact");else if(Se==="delete")T.mutate(t,{onSuccess:()=>{s?.()}});else if(Se==="share"){const Fe=Kt.loading("Sharing session...");try{const Re=await qe.shareSession(t);Re.shared&&(Kt.successWithAction(Re.message==="Already shared"?"Already shared":"Session shared!",{label:"Open",href:Re.url}),H.invalidateQueries({queryKey:["share-status",t]}))}catch(Re){Kt.error(Re instanceof Error?Re.message:"Failed to share")}finally{Cr.getState().removeToast(Fe)}}else if(Se==="sync"){const Fe=Kt.loading("Syncing session...");try{const Re=await qe.syncSession(t);if(Re.synced){const Le=Re.newMessages>0?`Synced ${Re.newMessages} new messages`:"Already synced";Kt.successWithAction(Le,{label:"Open",href:Re.url}),H.invalidateQueries({queryKey:["share-status",t]})}}catch(Re){Kt.error(Re instanceof Error?Re.message:"Failed to sync")}finally{Cr.getState().removeToast(Fe)}}},[i,D,L,I,be,T,t,s,H]),We=q.useCallback(async Se=>{u(Se);try{await O.mutateAsync({agent:Se})}catch(Fe){console.error("Failed to update agent:",Fe)}},[O]),xe=q.useCallback(async(Se,Fe)=>{p(Se),m(Fe);try{await O.mutateAsync({provider:Se,model:Fe})}catch(Re){console.error("Failed to update model:",Re)}},[O]),gt=q.useCallback(async Se=>{if(p(Se),f)try{await O.mutateAsync({provider:Se,model:f})}catch(Fe){console.error("Failed to update provider:",Fe)}},[f,O]),ot=q.useCallback(async Se=>{m(Se);try{await O.mutateAsync({provider:d,model:Se})}catch(Fe){console.error("Failed to update model:",Fe)}},[d,O]),vt=q.useCallback(async Se=>{const Fe=Se?"plan":"build";u(Fe);try{await O.mutateAsync({agent:Fe})}catch(Re){console.error("Failed to switch agent:",Re)}},[O]);return y.jsxs(y.Fragment,{children:[y.jsx(P7,{isOpen:v,onClose:$e,initialFocus:E,chatInputRef:S,agent:o,provider:d,model:f,modelSupportsReasoning:P,onAgentChange:We,onProviderChange:gt,onModelChange:ot,onModelSelectorChange:xe}),y.jsx(_7,{ref:S,onSend:be,onCommand:Pe,disabled:k.isPending,onConfigClick:we,onPlanModeToggle:vt,isPlanMode:o==="plan",reasoningEnabled:P&&R.reasoningEnabled,sessionId:t,images:B,documents:W,onFileRemove:V,isDragging:K,onPaste:Y,visionEnabled:M,modelName:f,providerName:d,authType:Z,researchContexts:oe,onResearchContextRemove:he,onRefreshBalance:d==="setu"?z:void 0,isBalanceLoading:ne},_)]})}));function H7({sessionId:e,onStop:t,disabled:n}){const[i,s]=q.useState(!1),l=async()=>{if(!i){s(!0);try{await qe.abortSession(e),t?.()}catch(c){console.error("Failed to abort stream:",c)}finally{setTimeout(()=>s(!1),1e3)}}};return y.jsxs("button",{type:"button",onClick:l,disabled:n||i,className:"flex items-center gap-1.5 text-sm text-destructive hover:text-destructive/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Stop generation",children:[y.jsx(kO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:i?"Stopping...":"Stop"})]})}function z7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const q7=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$7=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G7={};function KE(e,t){return(G7.jsx?$7:q7).test(e)}const W7=/[ \t\n\f\r]/g;function V7(e){return typeof e=="object"?e.type==="text"?YE(e.value):!1:YE(e)}function YE(e){return e.replace(W7,"")===""}class sl{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}sl.prototype.normal={};sl.prototype.property={};sl.prototype.space=void 0;function LD(e,t){const n={},i={};for(const s of e)Object.assign(n,s.property),Object.assign(i,s.normal);return new sl(n,i,t)}function sv(e){return e.toLowerCase()}class Tn{constructor(t,n){this.attribute=n,this.property=t}}Tn.prototype.attribute="";Tn.prototype.booleanish=!1;Tn.prototype.boolean=!1;Tn.prototype.commaOrSpaceSeparated=!1;Tn.prototype.commaSeparated=!1;Tn.prototype.defined=!1;Tn.prototype.mustUseProperty=!1;Tn.prototype.number=!1;Tn.prototype.overloadedBoolean=!1;Tn.prototype.property="";Tn.prototype.spaceSeparated=!1;Tn.prototype.space=void 0;let K7=0;const ze=wa(),qt=wa(),ov=wa(),ve=wa(),St=wa(),vs=wa(),Bn=wa();function wa(){return 2**++K7}const lv=Object.freeze(Object.defineProperty({__proto__:null,boolean:ze,booleanish:qt,commaOrSpaceSeparated:Bn,commaSeparated:vs,number:ve,overloadedBoolean:ov,spaceSeparated:St},Symbol.toStringTag,{value:"Module"})),Dp=Object.keys(lv);class e1 extends Tn{constructor(t,n,i,s){let l=-1;if(super(t,n),XE(this,"space",s),typeof i=="number")for(;++l<Dp.length;){const c=Dp[l];XE(this,Dp[l],(i&lv[c])===lv[c])}}}e1.prototype.defined=!0;function XE(e,t,n){n&&(e[t]=n)}function Ts(e){const t={},n={};for(const[i,s]of Object.entries(e.properties)){const l=new e1(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(l.mustUseProperty=!0),t[i]=l,n[sv(i)]=i,n[sv(l.attribute)]=i}return new sl(t,n,e.space)}const MD=Ts({properties:{ariaActiveDescendant:null,ariaAtomic:qt,ariaAutoComplete:null,ariaBusy:qt,ariaChecked:qt,ariaColCount:ve,ariaColIndex:ve,ariaColSpan:ve,ariaControls:St,ariaCurrent:null,ariaDescribedBy:St,ariaDetails:null,ariaDisabled:qt,ariaDropEffect:St,ariaErrorMessage:null,ariaExpanded:qt,ariaFlowTo:St,ariaGrabbed:qt,ariaHasPopup:null,ariaHidden:qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:St,ariaLevel:ve,ariaLive:null,ariaModal:qt,ariaMultiLine:qt,ariaMultiSelectable:qt,ariaOrientation:null,ariaOwns:St,ariaPlaceholder:null,ariaPosInSet:ve,ariaPressed:qt,ariaReadOnly:qt,ariaRelevant:null,ariaRequired:qt,ariaRoleDescription:St,ariaRowCount:ve,ariaRowIndex:ve,ariaRowSpan:ve,ariaSelected:qt,ariaSetSize:ve,ariaSort:null,ariaValueMax:ve,ariaValueMin:ve,ariaValueNow:ve,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function BD(e,t){return t in e?e[t]:t}function FD(e,t){return BD(e,t.toLowerCase())}const Y7=Ts({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:vs,acceptCharset:St,accessKey:St,action:null,allow:null,allowFullScreen:ze,allowPaymentRequest:ze,allowUserMedia:ze,alt:null,as:null,async:ze,autoCapitalize:null,autoComplete:St,autoFocus:ze,autoPlay:ze,blocking:St,capture:null,charSet:null,checked:ze,cite:null,className:St,cols:ve,colSpan:null,content:null,contentEditable:qt,controls:ze,controlsList:St,coords:ve|vs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ze,defer:ze,dir:null,dirName:null,disabled:ze,download:ov,draggable:qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ze,formTarget:null,headers:St,height:ve,hidden:ov,high:ve,href:null,hrefLang:null,htmlFor:St,httpEquiv:St,id:null,imageSizes:null,imageSrcSet:null,inert:ze,inputMode:null,integrity:null,is:null,isMap:ze,itemId:null,itemProp:St,itemRef:St,itemScope:ze,itemType:St,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ze,low:ve,manifest:null,max:null,maxLength:ve,media:null,method:null,min:null,minLength:ve,multiple:ze,muted:ze,name:null,nonce:null,noModule:ze,noValidate:ze,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ze,optimum:ve,pattern:null,ping:St,placeholder:null,playsInline:ze,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ze,referrerPolicy:null,rel:St,required:ze,reversed:ze,rows:ve,rowSpan:ve,sandbox:St,scope:null,scoped:ze,seamless:ze,selected:ze,shadowRootClonable:ze,shadowRootDelegatesFocus:ze,shadowRootMode:null,shape:null,size:ve,sizes:null,slot:null,span:ve,spellCheck:qt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ve,step:null,style:null,tabIndex:ve,target:null,title:null,translate:null,type:null,typeMustMatch:ze,useMap:null,value:qt,width:ve,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:St,axis:null,background:null,bgColor:null,border:ve,borderColor:null,bottomMargin:ve,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ze,declare:ze,event:null,face:null,frame:null,frameBorder:null,hSpace:ve,leftMargin:ve,link:null,longDesc:null,lowSrc:null,marginHeight:ve,marginWidth:ve,noResize:ze,noHref:ze,noShade:ze,noWrap:ze,object:null,profile:null,prompt:null,rev:null,rightMargin:ve,rules:null,scheme:null,scrolling:qt,standby:null,summary:null,text:null,topMargin:ve,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ve,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ze,disableRemotePlayback:ze,prefix:null,property:null,results:ve,security:null,unselectable:null},space:"html",transform:FD}),X7=Ts({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Bn,accentHeight:ve,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ve,amplitude:ve,arabicForm:null,ascent:ve,attributeName:null,attributeType:null,azimuth:ve,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ve,by:null,calcMode:null,capHeight:ve,className:St,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ve,diffuseConstant:ve,direction:null,display:null,dur:null,divisor:ve,dominantBaseline:null,download:ze,dx:null,dy:null,edgeMode:null,editable:null,elevation:ve,enableBackground:null,end:null,event:null,exponent:ve,externalResourcesRequired:null,fill:null,fillOpacity:ve,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:vs,g2:vs,glyphName:vs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ve,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ve,horizOriginX:ve,horizOriginY:ve,id:null,ideographic:ve,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ve,k:ve,k1:ve,k2:ve,k3:ve,k4:ve,kernelMatrix:Bn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ve,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ve,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ve,overlineThickness:ve,paintOrder:null,panose1:null,path:null,pathLength:ve,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:St,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ve,pointsAtY:ve,pointsAtZ:ve,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Bn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Bn,rev:Bn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Bn,requiredFeatures:Bn,requiredFonts:Bn,requiredFormats:Bn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ve,specularExponent:ve,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ve,strikethroughThickness:ve,string:null,stroke:null,strokeDashArray:Bn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ve,strokeOpacity:ve,strokeWidth:null,style:null,surfaceScale:ve,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Bn,tabIndex:ve,tableValues:null,target:null,targetX:ve,targetY:ve,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Bn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ve,underlineThickness:ve,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ve,values:null,vAlphabetic:ve,vMathematical:ve,vectorEffect:null,vHanging:ve,vIdeographic:ve,version:null,vertAdvY:ve,vertOriginX:ve,vertOriginY:ve,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ve,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:BD}),jD=Ts({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),PD=Ts({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:FD}),UD=Ts({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Z7={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Q7=/[A-Z]/g,ZE=/-[a-z]/g,J7=/^data[-\w.:]+$/i;function eU(e,t){const n=sv(t);let i=t,s=Tn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&J7.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(ZE,nU);i="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!ZE.test(l)){let c=l.replace(Q7,tU);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}s=e1}return new s(i,t)}function tU(e){return"-"+e.toLowerCase()}function nU(e){return e.charAt(1).toUpperCase()}const rU=LD([MD,Y7,jD,PD,UD],"html"),t1=LD([MD,X7,jD,PD,UD],"svg");function iU(e){return e.join(" ").trim()}var ds={},Ip,QE;function aU(){if(QE)return Ip;QE=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,o=/^\s+|\s+$/g,u=`
72
72
  `,d="/",p="*",f="",m="comment",v="declaration";function w(b,_){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];_=_||{};var x=1,S=1;function k(W){var K=W.match(t);K&&(x+=K.length);var V=W.lastIndexOf(u);S=~V?W.length-V:S+W.length}function O(){var W={line:x,column:S};return function(K){return K.position=new T(W),D(),K}}function T(W){this.start=W,this.end={line:x,column:S},this.source=_.source}T.prototype.content=b;function A(W){var K=new Error(_.source+":"+x+":"+S+": "+W);if(K.reason=W,K.filename=_.source,K.line=x,K.column=S,K.source=b,!_.silent)throw K}function R(W){var K=W.exec(b);if(K){var V=K[0];return k(V),b=b.slice(V.length),K}}function D(){R(n)}function L(W){var K;for(W=W||[];K=I();)K!==!1&&W.push(K);return W}function I(){var W=O();if(!(d!=b.charAt(0)||p!=b.charAt(1))){for(var K=2;f!=b.charAt(K)&&(p!=b.charAt(K)||d!=b.charAt(K+1));)++K;if(K+=2,f===b.charAt(K-1))return A("End of comment missing");var V=b.slice(2,K-2);return S+=2,k(V),b=b.slice(K),S+=2,W({type:m,comment:V})}}function H(){var W=O(),K=R(i);if(K){if(I(),!R(s))return A("property missing ':'");var V=R(l),X=W({type:v,property:E(K[0].replace(e,f)),value:V?E(V[0].replace(e,f)):f});return R(c),X}}function B(){var W=[];L(W);for(var K;K=H();)K!==!1&&(W.push(K),L(W));return W}return D(),B()}function E(b){return b?b.replace(o,f):f}return Ip=w,Ip}var JE;function sU(){if(JE)return ds;JE=1;var e=ds&&ds.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ds,"__esModule",{value:!0}),ds.default=n;const t=e(aU());function n(i,s){let l=null;if(!i||typeof i!="string")return l;const c=(0,t.default)(i),o=typeof s=="function";return c.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:p}=u;o?s(d,p,u):p&&(l=l||{},l[d]=p)}),l}return ds}var Oo={},ew;function oU(){if(ew)return Oo;ew=1,Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,l=function(d){return!d||n.test(d)||e.test(d)},c=function(d,p){return p.toUpperCase()},o=function(d,p){return"".concat(p,"-")},u=function(d,p){return p===void 0&&(p={}),l(d)?d:(d=d.toLowerCase(),p.reactCompat?d=d.replace(s,o):d=d.replace(i,o),d.replace(t,c))};return Oo.camelCase=u,Oo}var Do,tw;function lU(){if(tw)return Do;tw=1;var e=Do&&Do.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(sU()),n=oU();function i(s,l){var c={};return!s||typeof s!="string"||(0,t.default)(s,function(o,u){o&&u&&(c[(0,n.camelCase)(o,l)]=u)}),c}return i.default=i,Do=i,Do}var uU=lU();const cU=vc(uU),HD=zD("end"),n1=zD("start");function zD(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function dU(e){const t=n1(e),n=HD(e);if(t&&n)return{start:t,end:n}}function jo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?nw(e.position):"start"in e||"end"in e?nw(e):"line"in e||"column"in e?uv(e):""}function uv(e){return rw(e&&e.line)+":"+rw(e&&e.column)}function nw(e){return uv(e&&e.start)+"-"+uv(e&&e.end)}function rw(e){return e&&typeof e=="number"?e:1}class on extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let s="",l={},c=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?s=t:!l.cause&&t&&(c=!0,s=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof i=="string"){const u=i.indexOf(":");u===-1?l.ruleId=i:(l.source=i.slice(0,u),l.ruleId=i.slice(u+1))}if(!l.place&&l.ancestors&&l.ancestors){const u=l.ancestors[l.ancestors.length-1];u&&(l.place=u.position)}const o=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=o?o.line:void 0,this.name=jo(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}on.prototype.file="";on.prototype.name="";on.prototype.reason="";on.prototype.message="";on.prototype.stack="";on.prototype.column=void 0;on.prototype.line=void 0;on.prototype.ancestors=void 0;on.prototype.cause=void 0;on.prototype.fatal=void 0;on.prototype.place=void 0;on.prototype.ruleId=void 0;on.prototype.source=void 0;const r1={}.hasOwnProperty,hU=new Map,pU=/[A-Z]/g,fU=new Set(["table","tbody","thead","tfoot","tr"]),mU=new Set(["td","th"]),qD="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gU(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=wU(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=EU(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?t1:rU,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=$D(s,e,void 0);return l&&typeof l!="string"?l:s.create(e,s.Fragment,{children:l||void 0},void 0)}function $D(e,t,n){if(t.type==="element")return bU(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return yU(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return _U(e,t,n);if(t.type==="mdxjsEsm")return vU(e,t);if(t.type==="root")return SU(e,t,n);if(t.type==="text")return xU(e,t)}function bU(e,t,n){const i=e.schema;let s=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=t1,e.schema=s),e.ancestors.push(t);const l=WD(e,t.tagName,!1),c=CU(e,t);let o=a1(e,t);return fU.has(t.tagName)&&(o=o.filter(function(u){return typeof u=="string"?!V7(u):!0})),GD(e,c,l,t),i1(c,o),e.ancestors.pop(),e.schema=i,e.create(t,l,c,n)}function yU(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Ko(e,t.position)}function vU(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ko(e,t.position)}function _U(e,t,n){const i=e.schema;let s=i;t.name==="svg"&&i.space==="html"&&(s=t1,e.schema=s),e.ancestors.push(t);const l=t.name===null?e.Fragment:WD(e,t.name,!0),c=kU(e,t),o=a1(e,t);return GD(e,c,l,t),i1(c,o),e.ancestors.pop(),e.schema=i,e.create(t,l,c,n)}function SU(e,t,n){const i={};return i1(i,a1(e,t)),e.create(t,e.Fragment,i,n)}function xU(e,t){return t.value}function GD(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function i1(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function EU(e,t,n){return i;function i(s,l,c,o){const d=Array.isArray(c.children)?n:t;return o?d(l,c,o):d(l,c)}}function wU(e,t){return n;function n(i,s,l,c){const o=Array.isArray(l.children),u=n1(i);return t(s,l,c,o,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function CU(e,t){const n={};let i,s;for(s in t.properties)if(s!=="children"&&r1.call(t.properties,s)){const l=TU(e,s,t.properties[s]);if(l){const[c,o]=l;e.tableCellAlignToStyle&&c==="align"&&typeof o=="string"&&mU.has(t.tagName)?i=o:n[c]=o}}if(i){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function kU(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const l=i.data.estree.body[0];l.type;const c=l.expression;c.type;const o=c.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Ko(e,t.position);else{const s=i.name;let l;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const o=i.value.data.estree.body[0];o.type,l=e.evaluater.evaluateExpression(o.expression)}else Ko(e,t.position);else l=i.value===null?!0:i.value;n[s]=l}return n}function a1(e,t){const n=[];let i=-1;const s=e.passKeys?new Map:hU;for(;++i<t.children.length;){const l=t.children[i];let c;if(e.passKeys){const u=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(u){const d=s.get(u)||0;c=u+"-"+d,s.set(u,d+1)}}const o=$D(e,l,c);o!==void 0&&n.push(o)}return n}function TU(e,t,n){const i=eU(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?z7(n):iU(n)),i.property==="style"){let s=typeof n=="object"?n:RU(e,String(n));return e.stylePropertyNameCase==="css"&&(s=AU(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&i.space?Z7[i.property]||i.property:i.attribute,n]}}function RU(e,t){try{return cU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const i=n,s=new on("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=qD+"#cannot-parse-style-attribute",s}}function WD(e,t,n){let i;if(!n)i={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let l=-1,c;for(;++l<s.length;){const o=KE(s[l])?{type:"Identifier",name:s[l]}:{type:"Literal",value:s[l]};c=c?{type:"MemberExpression",object:c,property:o,computed:!!(l&&o.type==="Literal"),optional:!1}:o}i=c}else i=KE(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const s=i.value;return r1.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(i);Ko(e)}function Ko(e,t){const n=new on("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=qD+"#cannot-handle-mdx-estrees-without-createevaluater",n}function AU(e){const t={};let n;for(n in e)r1.call(e,n)&&(t[NU(n)]=e[n]);return t}function NU(e){let t=e.replace(pU,OU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function OU(e){return"-"+e.toLowerCase()}const Lp={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},DU={};function s1(e,t){const n=DU,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return VD(e,i,s)}function VD(e,t,n){if(IU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return iw(e.children,t,n)}return Array.isArray(e)?iw(e,t,n):""}function iw(e,t,n){const i=[];let s=-1;for(;++s<e.length;)i[s]=VD(e[s],t,n);return i.join("")}function IU(e){return!!(e&&typeof e=="object")}const aw=document.createElement("i");function o1(e){const t="&"+e+";";aw.innerHTML=t;const n=aw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Hn(e,t,n,i){const s=e.length;let l=0,c;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,i.length<1e4)c=Array.from(i),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<i.length;)c=i.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function ir(e,t){return e.length>0?(Hn(e,e.length,0,t),e):t}const sw={}.hasOwnProperty;function KD(e){const t={};let n=-1;for(;++n<e.length;)LU(t,e[n]);return t}function LU(e,t){let n;for(n in t){const s=(sw.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){sw.call(s,c)||(s[c]=[]);const o=l[c];MU(s[c],Array.isArray(o)?o:o?[o]:[])}}}function MU(e,t){let n=-1;const i=[];for(;++n<t.length;)(t[n].add==="after"?e:i).push(t[n]);Hn(e,0,0,i)}function YD(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function dr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const hn=ji(/[A-Za-z]/),sn=ji(/[\dA-Za-z]/),BU=ji(/[#-'*+\--9=?A-Z^-~]/);function fc(e){return e!==null&&(e<32||e===127)}const cv=ji(/\d/),FU=ji(/[\dA-Fa-f]/),jU=ji(/[!-/:-@[-`{-~]/);function Ae(e){return e!==null&&e<-2}function yt(e){return e!==null&&(e<0||e===32)}function Xe(e){return e===-2||e===-1||e===32}const Pc=ji(new RegExp("\\p{P}|\\p{S}","u")),va=ji(/\s/);function ji(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Rs(e){const t=[];let n=-1,i=0,s=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&sn(e.charCodeAt(n+1))&&sn(e.charCodeAt(n+2)))s=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const o=e.charCodeAt(n+1);l<56320&&o>56319&&o<57344?(c=String.fromCharCode(l,o),s=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(i,n),encodeURIComponent(c)),i=n+s+1,c=""),s&&(n+=s,s=0)}return t.join("")+e.slice(i)}function nt(e,t,n,i){const s=i?i-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(u){return Xe(u)?(e.enter(n),o(u)):t(u)}function o(u){return Xe(u)&&l++<s?(e.consume(u),o):(e.exit(n),t(u))}}const PU={tokenize:UU};function UU(e){const t=e.attempt(this.parser.constructs.contentInitial,i,s);let n;return t;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),nt(e,t,"linePrefix")}function s(o){return e.enter("paragraph"),l(o)}function l(o){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,c(o)}function c(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return Ae(o)?(e.consume(o),e.exit("chunkText"),l):(e.consume(o),c)}}const HU={tokenize:zU},ow={tokenize:qU};function zU(e){const t=this,n=[];let i=0,s,l,c;return o;function o(S){if(i<n.length){const k=n[i];return t.containerState=k[1],e.attempt(k[0].continuation,u,d)(S)}return d(S)}function u(S){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&x();const k=t.events.length;let O=k,T;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){T=t.events[O][1].end;break}_(i);let A=k;for(;A<t.events.length;)t.events[A][1].end={...T},A++;return Hn(t.events,O+1,0,t.events.slice(k)),t.events.length=A,d(S)}return o(S)}function d(S){if(i===n.length){if(!s)return m(S);if(s.currentConstruct&&s.currentConstruct.concrete)return w(S);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ow,p,f)(S)}function p(S){return s&&x(),_(i),m(S)}function f(S){return t.parser.lazy[t.now().line]=i!==n.length,c=t.now().offset,w(S)}function m(S){return t.containerState={},e.attempt(ow,v,w)(S)}function v(S){return i++,n.push([t.currentConstruct,t.containerState]),m(S)}function w(S){if(S===null){s&&x(),_(0),e.consume(S);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:l}),E(S)}function E(S){if(S===null){b(e.exit("chunkFlow"),!0),_(0),e.consume(S);return}return Ae(S)?(e.consume(S),b(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(S),E)}function b(S,k){const O=t.sliceStream(S);if(k&&O.push(null),S.previous=l,l&&(l.next=S),l=S,s.defineSkip(S.start),s.write(O),t.parser.lazy[S.start.line]){let T=s.events.length;for(;T--;)if(s.events[T][1].start.offset<c&&(!s.events[T][1].end||s.events[T][1].end.offset>c))return;const A=t.events.length;let R=A,D,L;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(D){L=t.events[R][1].end;break}D=!0}for(_(i),T=A;T<t.events.length;)t.events[T][1].end={...L},T++;Hn(t.events,R+1,0,t.events.slice(A)),t.events.length=T}}function _(S){let k=n.length;for(;k-- >S;){const O=n[k];t.containerState=O[1],O[0].exit.call(t,e)}n.length=S}function x(){s.write([null]),l=void 0,s=void 0,t.containerState._closeFlow=void 0}}function qU(e,t,n){return nt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Es(e){if(e===null||yt(e)||va(e))return 1;if(Pc(e))return 2}function Uc(e,t,n){const i=[];let s=-1;for(;++s<e.length;){const l=e[s].resolveAll;l&&!i.includes(l)&&(t=l(t,n),i.push(l))}return t}const dv={name:"attention",resolveAll:$U,tokenize:GU};function $U(e,t){let n=-1,i,s,l,c,o,u,d,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(i=n;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[i][1].end},m={...e[n][1].start};lw(f,-u),lw(m,u),c={type:u>1?"strongSequence":"emphasisSequence",start:f,end:{...e[i][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},l={type:u>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},s={type:u>1?"strong":"emphasis",start:{...c.start},end:{...o.end}},e[i][1].end={...c.start},e[n][1].start={...o.end},d=[],e[i][1].end.offset-e[i][1].start.offset&&(d=ir(d,[["enter",e[i][1],t],["exit",e[i][1],t]])),d=ir(d,[["enter",s,t],["enter",c,t],["exit",c,t],["enter",l,t]]),d=ir(d,Uc(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),d=ir(d,[["exit",l,t],["enter",o,t],["exit",o,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,d=ir(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Hn(e,i-1,n-i+3,d),n=i+d.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function GU(e,t){const n=this.parser.constructs.attentionMarkers.null,i=this.previous,s=Es(i);let l;return c;function c(u){return l=u,e.enter("attentionSequence"),o(u)}function o(u){if(u===l)return e.consume(u),o;const d=e.exit("attentionSequence"),p=Es(u),f=!p||p===2&&s||n.includes(u),m=!s||s===2&&p||n.includes(i);return d._open=!!(l===42?f:f&&(s||!m)),d._close=!!(l===42?m:m&&(p||!f)),t(u)}}function lw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const WU={name:"autolink",tokenize:VU};function VU(e,t,n){let i=0;return s;function s(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(v){return hn(v)?(e.consume(v),c):v===64?n(v):d(v)}function c(v){return v===43||v===45||v===46||sn(v)?(i=1,o(v)):d(v)}function o(v){return v===58?(e.consume(v),i=0,u):(v===43||v===45||v===46||sn(v))&&i++<32?(e.consume(v),o):(i=0,d(v))}function u(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||fc(v)?n(v):(e.consume(v),u)}function d(v){return v===64?(e.consume(v),p):BU(v)?(e.consume(v),d):n(v)}function p(v){return sn(v)?f(v):n(v)}function f(v){return v===46?(e.consume(v),i=0,p):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):m(v)}function m(v){if((v===45||sn(v))&&i++<63){const w=v===45?m:f;return e.consume(v),w}return n(v)}}const ol={partial:!0,tokenize:KU};function KU(e,t,n){return i;function i(l){return Xe(l)?nt(e,s,"linePrefix")(l):s(l)}function s(l){return l===null||Ae(l)?t(l):n(l)}}const XD={continuation:{tokenize:XU},exit:ZU,name:"blockQuote",tokenize:YU};function YU(e,t,n){const i=this;return s;function s(c){if(c===62){const o=i.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Xe(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function XU(e,t,n){const i=this;return s;function s(c){return Xe(c)?nt(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(XD,t,n)(c)}}function ZU(e){e.exit("blockQuote")}const ZD={name:"characterEscape",tokenize:QU};function QU(e,t,n){return i;function i(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),s}function s(l){return jU(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const QD={name:"characterReference",tokenize:JU};function JU(e,t,n){const i=this;let s=0,l,c;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),u}function u(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),l=31,c=sn,p(f))}function d(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=FU,p):(e.enter("characterReferenceValue"),l=7,c=cv,p(f))}function p(f){if(f===59&&s){const m=e.exit("characterReferenceValue");return c===sn&&!o1(i.sliceSerialize(m))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(f)&&s++<l?(e.consume(f),p):n(f)}}const uw={partial:!0,tokenize:t9},cw={concrete:!0,name:"codeFenced",tokenize:e9};function e9(e,t,n){const i=this,s={partial:!0,tokenize:O};let l=0,c=0,o;return u;function u(T){return d(T)}function d(T){const A=i.events[i.events.length-1];return l=A&&A[1].type==="linePrefix"?A[2].sliceSerialize(A[1],!0).length:0,o=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===o?(c++,e.consume(T),p):c<3?n(T):(e.exit("codeFencedFenceSequence"),Xe(T)?nt(e,f,"whitespace")(T):f(T))}function f(T){return T===null||Ae(T)?(e.exit("codeFencedFence"),i.interrupt?t(T):e.check(uw,E,k)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||Ae(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(T)):Xe(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),nt(e,v,"whitespace")(T)):T===96&&T===o?n(T):(e.consume(T),m)}function v(T){return T===null||Ae(T)?f(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||Ae(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(T)):T===96&&T===o?n(T):(e.consume(T),w)}function E(T){return e.attempt(s,k,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),_}function _(T){return l>0&&Xe(T)?nt(e,x,"linePrefix",l+1)(T):x(T)}function x(T){return T===null||Ae(T)?e.check(uw,E,k)(T):(e.enter("codeFlowValue"),S(T))}function S(T){return T===null||Ae(T)?(e.exit("codeFlowValue"),x(T)):(e.consume(T),S)}function k(T){return e.exit("codeFenced"),t(T)}function O(T,A,R){let D=0;return L;function L(K){return T.enter("lineEnding"),T.consume(K),T.exit("lineEnding"),I}function I(K){return T.enter("codeFencedFence"),Xe(K)?nt(T,H,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):H(K)}function H(K){return K===o?(T.enter("codeFencedFenceSequence"),B(K)):R(K)}function B(K){return K===o?(D++,T.consume(K),B):D>=c?(T.exit("codeFencedFenceSequence"),Xe(K)?nt(T,W,"whitespace")(K):W(K)):R(K)}function W(K){return K===null||Ae(K)?(T.exit("codeFencedFence"),A(K)):R(K)}}}function t9(e,t,n){const i=this;return s;function s(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return i.parser.lazy[i.now().line]?n(c):t(c)}}const Mp={name:"codeIndented",tokenize:r9},n9={partial:!0,tokenize:i9};function r9(e,t,n){const i=this;return s;function s(d){return e.enter("codeIndented"),nt(e,l,"linePrefix",5)(d)}function l(d){const p=i.events[i.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?c(d):n(d)}function c(d){return d===null?u(d):Ae(d)?e.attempt(n9,c,u)(d):(e.enter("codeFlowValue"),o(d))}function o(d){return d===null||Ae(d)?(e.exit("codeFlowValue"),c(d)):(e.consume(d),o)}function u(d){return e.exit("codeIndented"),t(d)}}function i9(e,t,n){const i=this;return s;function s(c){return i.parser.lazy[i.now().line]?n(c):Ae(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),s):nt(e,l,"linePrefix",5)(c)}function l(c){const o=i.events[i.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(c):Ae(c)?s(c):n(c)}}const a9={name:"codeText",previous:o9,resolve:s9,tokenize:l9};function s9(e){let t=e.length-4,n=3,i,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i<t;)if(e[i][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(i=n-1,t++;++i<=t;)s===void 0?i!==t&&e[i][1].type!=="lineEnding"&&(s=i):(i===t||e[i][1].type==="lineEnding")&&(e[s][1].type="codeTextData",i!==s+2&&(e[s][1].end=e[i-1][1].end,e.splice(s+2,i-s-2),t-=i-s-2,i=s+2),s=void 0);return e}function o9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function l9(e,t,n){let i=0,s,l;return c;function c(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),i++,o):(e.exit("codeTextSequence"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),u):f===96?(l=e.enter("codeTextSequence"),s=0,p(f)):Ae(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||Ae(f)?(e.exit("codeTextData"),u(f)):(e.consume(f),d)}function p(f){return f===96?(e.consume(f),s++,p):s===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(l.type="codeTextData",d(f))}}class u9{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const i=n??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(t,i):t>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const s=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return i&&Io(this.left,i),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Io(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Io(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Io(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Io(this.left,n.reverse())}}}function Io(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function JD(e){const t={};let n=-1,i,s,l,c,o,u,d;const p=new u9(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(i=p.get(n),n&&i[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(u=i[1]._tokenizer.events,l=0,l<u.length&&u[l][1].type==="lineEndingBlank"&&(l+=2),l<u.length&&u[l][1].type==="content"))for(;++l<u.length&&u[l][1].type!=="content";)u[l][1].type==="chunkText"&&(u[l][1]._isInFirstContentOfListItem=!0,l++);if(i[0]==="enter")i[1].contentType&&(Object.assign(t,c9(p,n)),n=t[n],d=!0);else if(i[1]._container){for(l=n,s=void 0;l--;)if(c=p.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),c[1].type="lineEnding",s=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;s&&(i[1].end={...p.get(s)[1].start},o=p.slice(s,n),o.unshift(i),p.splice(s,n-s+1,o))}}return Hn(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!d}function c9(e,t){const n=e.get(t)[1],i=e.get(t)[2];let s=t-1;const l=[];let c=n._tokenizer;c||(c=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const o=c.events,u=[],d={};let p,f,m=-1,v=n,w=0,E=0;const b=[E];for(;v;){for(;e.get(++s)[1]!==v;);l.push(s),v._tokenizer||(p=i.sliceStream(v),v.next||p.push(null),f&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(p),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),f=v,v=v.next}for(v=n;++m<o.length;)o[m][0]==="exit"&&o[m-1][0]==="enter"&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(E=m+1,b.push(E),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):b.pop(),m=b.length;m--;){const _=o.slice(b[m],b[m+1]),x=l.pop();u.push([x,x+_.length-1]),e.splice(x,2,_)}for(u.reverse(),m=-1;++m<u.length;)d[w+u[m][0]]=w+u[m][1],w+=u[m][1]-u[m][0]-1;return d}const d9={resolve:p9,tokenize:f9},h9={partial:!0,tokenize:m9};function p9(e){return JD(e),e}function f9(e,t){let n;return i;function i(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(o)}function s(o){return o===null?l(o):Ae(o)?e.check(h9,c,l)(o):(e.consume(o),s)}function l(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function c(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function m9(e,t,n){const i=this;return s;function s(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),nt(e,l,"linePrefix")}function l(c){if(c===null||Ae(c))return n(c);const o=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(c):e.interrupt(i.parser.constructs.flow,n,t)(c)}}function eI(e,t,n,i,s,l,c,o,u){const d=u||Number.POSITIVE_INFINITY;let p=0;return f;function f(_){return _===60?(e.enter(i),e.enter(s),e.enter(l),e.consume(_),e.exit(l),m):_===null||_===32||_===41||fc(_)?n(_):(e.enter(i),e.enter(c),e.enter(o),e.enter("chunkString",{contentType:"string"}),E(_))}function m(_){return _===62?(e.enter(l),e.consume(_),e.exit(l),e.exit(s),e.exit(i),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),v(_))}function v(_){return _===62?(e.exit("chunkString"),e.exit(o),m(_)):_===null||_===60||Ae(_)?n(_):(e.consume(_),_===92?w:v)}function w(_){return _===60||_===62||_===92?(e.consume(_),v):v(_)}function E(_){return!p&&(_===null||_===41||yt(_))?(e.exit("chunkString"),e.exit(o),e.exit(c),e.exit(i),t(_)):p<d&&_===40?(e.consume(_),p++,E):_===41?(e.consume(_),p--,E):_===null||_===32||_===40||fc(_)?n(_):(e.consume(_),_===92?b:E)}function b(_){return _===40||_===41||_===92?(e.consume(_),E):E(_)}}function tI(e,t,n,i,s,l){const c=this;let o=0,u;return d;function d(v){return e.enter(i),e.enter(s),e.consume(v),e.exit(s),e.enter(l),p}function p(v){return o>999||v===null||v===91||v===93&&!u||v===94&&!o&&"_hiddenFootnoteSupport"in c.parser.constructs?n(v):v===93?(e.exit(l),e.enter(s),e.consume(v),e.exit(s),e.exit(i),t):Ae(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),f(v))}function f(v){return v===null||v===91||v===93||Ae(v)||o++>999?(e.exit("chunkString"),p(v)):(e.consume(v),u||(u=!Xe(v)),v===92?m:f)}function m(v){return v===91||v===92||v===93?(e.consume(v),o++,f):f(v)}}function nI(e,t,n,i,s,l){let c;return o;function o(m){return m===34||m===39||m===40?(e.enter(i),e.enter(s),e.consume(m),e.exit(s),c=m===40?41:m,u):n(m)}function u(m){return m===c?(e.enter(s),e.consume(m),e.exit(s),e.exit(i),t):(e.enter(l),d(m))}function d(m){return m===c?(e.exit(l),u(c)):m===null?n(m):Ae(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),nt(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===c||m===null||Ae(m)?(e.exit("chunkString"),d(m)):(e.consume(m),m===92?f:p)}function f(m){return m===c||m===92?(e.consume(m),p):p(m)}}function Po(e,t){let n;return i;function i(s){return Ae(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,i):Xe(s)?nt(e,i,n?"linePrefix":"lineSuffix")(s):t(s)}}const g9={name:"definition",tokenize:y9},b9={partial:!0,tokenize:v9};function y9(e,t,n){const i=this;let s;return l;function l(v){return e.enter("definition"),c(v)}function c(v){return tI.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function o(v){return s=dr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),u):n(v)}function u(v){return yt(v)?Po(e,d)(v):d(v)}function d(v){return eI(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function p(v){return e.attempt(b9,f,f)(v)}function f(v){return Xe(v)?nt(e,m,"whitespace")(v):m(v)}function m(v){return v===null||Ae(v)?(e.exit("definition"),i.parser.defined.push(s),t(v)):n(v)}}function v9(e,t,n){return i;function i(o){return yt(o)?Po(e,s)(o):n(o)}function s(o){return nI(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function l(o){return Xe(o)?nt(e,c,"whitespace")(o):c(o)}function c(o){return o===null||Ae(o)?t(o):n(o)}}const _9={name:"hardBreakEscape",tokenize:S9};function S9(e,t,n){return i;function i(l){return e.enter("hardBreakEscape"),e.consume(l),s}function s(l){return Ae(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const x9={name:"headingAtx",resolve:E9,tokenize:w9};function E9(e,t){let n=e.length-2,i=3,s,l;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(s={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},l={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},Hn(e,i,n-i+1,[["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t]])),e}function w9(e,t,n){let i=0;return s;function s(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),c(p)}function c(p){return p===35&&i++<6?(e.consume(p),c):p===null||yt(p)?(e.exit("atxHeadingSequence"),o(p)):n(p)}function o(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||Ae(p)?(e.exit("atxHeading"),t(p)):Xe(p)?nt(e,o,"whitespace")(p):(e.enter("atxHeadingText"),d(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),o(p))}function d(p){return p===null||p===35||yt(p)?(e.exit("atxHeadingText"),o(p)):(e.consume(p),d)}}const C9=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],dw=["pre","script","style","textarea"],k9={concrete:!0,name:"htmlFlow",resolveTo:A9,tokenize:N9},T9={partial:!0,tokenize:D9},R9={partial:!0,tokenize:O9};function A9(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function N9(e,t,n){const i=this;let s,l,c,o,u;return d;function d(U){return p(U)}function p(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),f}function f(U){return U===33?(e.consume(U),m):U===47?(e.consume(U),l=!0,E):U===63?(e.consume(U),s=3,i.interrupt?t:M):hn(U)?(e.consume(U),c=String.fromCharCode(U),b):n(U)}function m(U){return U===45?(e.consume(U),s=2,v):U===91?(e.consume(U),s=5,o=0,w):hn(U)?(e.consume(U),s=4,i.interrupt?t:M):n(U)}function v(U){return U===45?(e.consume(U),i.interrupt?t:M):n(U)}function w(U){const J="CDATA[";return U===J.charCodeAt(o++)?(e.consume(U),o===J.length?i.interrupt?t:H:w):n(U)}function E(U){return hn(U)?(e.consume(U),c=String.fromCharCode(U),b):n(U)}function b(U){if(U===null||U===47||U===62||yt(U)){const J=U===47,oe=c.toLowerCase();return!J&&!l&&dw.includes(oe)?(s=1,i.interrupt?t(U):H(U)):C9.includes(c.toLowerCase())?(s=6,J?(e.consume(U),_):i.interrupt?t(U):H(U)):(s=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(U):l?x(U):S(U))}return U===45||sn(U)?(e.consume(U),c+=String.fromCharCode(U),b):n(U)}function _(U){return U===62?(e.consume(U),i.interrupt?t:H):n(U)}function x(U){return Xe(U)?(e.consume(U),x):L(U)}function S(U){return U===47?(e.consume(U),L):U===58||U===95||hn(U)?(e.consume(U),k):Xe(U)?(e.consume(U),S):L(U)}function k(U){return U===45||U===46||U===58||U===95||sn(U)?(e.consume(U),k):O(U)}function O(U){return U===61?(e.consume(U),T):Xe(U)?(e.consume(U),O):S(U)}function T(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),u=U,A):Xe(U)?(e.consume(U),T):R(U)}function A(U){return U===u?(e.consume(U),u=null,D):U===null||Ae(U)?n(U):(e.consume(U),A)}function R(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||yt(U)?O(U):(e.consume(U),R)}function D(U){return U===47||U===62||Xe(U)?S(U):n(U)}function L(U){return U===62?(e.consume(U),I):n(U)}function I(U){return U===null||Ae(U)?H(U):Xe(U)?(e.consume(U),I):n(U)}function H(U){return U===45&&s===2?(e.consume(U),V):U===60&&s===1?(e.consume(U),X):U===62&&s===4?(e.consume(U),j):U===63&&s===3?(e.consume(U),M):U===93&&s===5?(e.consume(U),P):Ae(U)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(T9,$,B)(U)):U===null||Ae(U)?(e.exit("htmlFlowData"),B(U)):(e.consume(U),H)}function B(U){return e.check(R9,W,$)(U)}function W(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),K}function K(U){return U===null||Ae(U)?B(U):(e.enter("htmlFlowData"),H(U))}function V(U){return U===45?(e.consume(U),M):H(U)}function X(U){return U===47?(e.consume(U),c="",Y):H(U)}function Y(U){if(U===62){const J=c.toLowerCase();return dw.includes(J)?(e.consume(U),j):H(U)}return hn(U)&&c.length<8?(e.consume(U),c+=String.fromCharCode(U),Y):H(U)}function P(U){return U===93?(e.consume(U),M):H(U)}function M(U){return U===62?(e.consume(U),j):U===45&&s===2?(e.consume(U),M):H(U)}function j(U){return U===null||Ae(U)?(e.exit("htmlFlowData"),$(U)):(e.consume(U),j)}function $(U){return e.exit("htmlFlow"),t(U)}}function O9(e,t,n){const i=this;return s;function s(c){return Ae(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return i.parser.lazy[i.now().line]?n(c):t(c)}}function D9(e,t,n){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(ol,t,n)}}const I9={name:"htmlText",tokenize:L9};function L9(e,t,n){const i=this;let s,l,c;return o;function o(M){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(M),u}function u(M){return M===33?(e.consume(M),d):M===47?(e.consume(M),O):M===63?(e.consume(M),S):hn(M)?(e.consume(M),R):n(M)}function d(M){return M===45?(e.consume(M),p):M===91?(e.consume(M),l=0,w):hn(M)?(e.consume(M),x):n(M)}function p(M){return M===45?(e.consume(M),v):n(M)}function f(M){return M===null?n(M):M===45?(e.consume(M),m):Ae(M)?(c=f,X(M)):(e.consume(M),f)}function m(M){return M===45?(e.consume(M),v):f(M)}function v(M){return M===62?V(M):M===45?m(M):f(M)}function w(M){const j="CDATA[";return M===j.charCodeAt(l++)?(e.consume(M),l===j.length?E:w):n(M)}function E(M){return M===null?n(M):M===93?(e.consume(M),b):Ae(M)?(c=E,X(M)):(e.consume(M),E)}function b(M){return M===93?(e.consume(M),_):E(M)}function _(M){return M===62?V(M):M===93?(e.consume(M),_):E(M)}function x(M){return M===null||M===62?V(M):Ae(M)?(c=x,X(M)):(e.consume(M),x)}function S(M){return M===null?n(M):M===63?(e.consume(M),k):Ae(M)?(c=S,X(M)):(e.consume(M),S)}function k(M){return M===62?V(M):S(M)}function O(M){return hn(M)?(e.consume(M),T):n(M)}function T(M){return M===45||sn(M)?(e.consume(M),T):A(M)}function A(M){return Ae(M)?(c=A,X(M)):Xe(M)?(e.consume(M),A):V(M)}function R(M){return M===45||sn(M)?(e.consume(M),R):M===47||M===62||yt(M)?D(M):n(M)}function D(M){return M===47?(e.consume(M),V):M===58||M===95||hn(M)?(e.consume(M),L):Ae(M)?(c=D,X(M)):Xe(M)?(e.consume(M),D):V(M)}function L(M){return M===45||M===46||M===58||M===95||sn(M)?(e.consume(M),L):I(M)}function I(M){return M===61?(e.consume(M),H):Ae(M)?(c=I,X(M)):Xe(M)?(e.consume(M),I):D(M)}function H(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),s=M,B):Ae(M)?(c=H,X(M)):Xe(M)?(e.consume(M),H):(e.consume(M),W)}function B(M){return M===s?(e.consume(M),s=void 0,K):M===null?n(M):Ae(M)?(c=B,X(M)):(e.consume(M),B)}function W(M){return M===null||M===34||M===39||M===60||M===61||M===96?n(M):M===47||M===62||yt(M)?D(M):(e.consume(M),W)}function K(M){return M===47||M===62||yt(M)?D(M):n(M)}function V(M){return M===62?(e.consume(M),e.exit("htmlTextData"),e.exit("htmlText"),t):n(M)}function X(M){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),Y}function Y(M){return Xe(M)?nt(e,P,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):P(M)}function P(M){return e.enter("htmlTextData"),c(M)}}const l1={name:"labelEnd",resolveAll:j9,resolveTo:P9,tokenize:U9},M9={tokenize:H9},B9={tokenize:z9},F9={tokenize:q9};function j9(e){let t=-1;const n=[];for(;++t<e.length;){const i=e[t][1];if(n.push(e[t]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const s=i.type==="labelImage"?4:2;i.type="data",t+=s}}return e.length!==n.length&&Hn(e,0,e.length,n),e}function P9(e,t){let n=e.length,i=0,s,l,c,o;for(;n--;)if(s=e[n][1],l){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(l=n,s.type!=="labelLink")){i=2;break}}else s.type==="labelEnd"&&(c=n);const u={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},p={type:"labelText",start:{...e[l+i+2][1].end},end:{...e[c-2][1].start}};return o=[["enter",u,t],["enter",d,t]],o=ir(o,e.slice(l+1,l+i+3)),o=ir(o,[["enter",p,t]]),o=ir(o,Uc(t.parser.constructs.insideSpan.null,e.slice(l+i+4,c-3),t)),o=ir(o,[["exit",p,t],e[c-2],e[c-1],["exit",d,t]]),o=ir(o,e.slice(c+1)),o=ir(o,[["exit",u,t]]),Hn(e,l,e.length,o),e}function U9(e,t,n){const i=this;let s=i.events.length,l,c;for(;s--;)if((i.events[s][1].type==="labelImage"||i.events[s][1].type==="labelLink")&&!i.events[s][1]._balanced){l=i.events[s][1];break}return o;function o(m){return l?l._inactive?f(m):(c=i.parser.defined.includes(dr(i.sliceSerialize({start:l.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):n(m)}function u(m){return m===40?e.attempt(M9,p,c?p:f)(m):m===91?e.attempt(B9,p,c?d:f)(m):c?p(m):f(m)}function d(m){return e.attempt(F9,p,f)(m)}function p(m){return t(m)}function f(m){return l._balanced=!0,n(m)}}function H9(e,t,n){return i;function i(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return yt(f)?Po(e,l)(f):l(f)}function l(f){return f===41?p(f):eI(e,c,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function c(f){return yt(f)?Po(e,u)(f):p(f)}function o(f){return n(f)}function u(f){return f===34||f===39||f===40?nI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):p(f)}function d(f){return yt(f)?Po(e,p)(f):p(f)}function p(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function z9(e,t,n){const i=this;return s;function s(o){return tI.call(i,e,l,c,"reference","referenceMarker","referenceString")(o)}function l(o){return i.parser.defined.includes(dr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function c(o){return n(o)}}function q9(e,t,n){return i;function i(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),s}function s(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const $9={name:"labelStartImage",resolveAll:l1.resolveAll,tokenize:G9};function G9(e,t,n){const i=this;return s;function s(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),l}function l(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),c):n(o)}function c(o){return o===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(o):t(o)}}const W9={name:"labelStartLink",resolveAll:l1.resolveAll,tokenize:V9};function V9(e,t,n){const i=this;return s;function s(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(c):t(c)}}const Bp={name:"lineEnding",tokenize:K9};function K9(e,t){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),nt(e,t,"linePrefix")}}const Ku={name:"thematicBreak",tokenize:Y9};function Y9(e,t,n){let i=0,s;return l;function l(d){return e.enter("thematicBreak"),c(d)}function c(d){return s=d,o(d)}function o(d){return d===s?(e.enter("thematicBreakSequence"),u(d)):i>=3&&(d===null||Ae(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===s?(e.consume(d),i++,u):(e.exit("thematicBreakSequence"),Xe(d)?nt(e,o,"whitespace")(d):o(d))}}const Sn={continuation:{tokenize:J9},exit:tH,name:"list",tokenize:Q9},X9={partial:!0,tokenize:nH},Z9={partial:!0,tokenize:eH};function Q9(e,t,n){const i=this,s=i.events[i.events.length-1];let l=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,c=0;return o;function o(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:cv(v)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(Ku,n,d)(v):d(v);if(!i.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(v)}return n(v)}function u(v){return cv(v)&&++c<10?(e.consume(v),u):(!i.interrupt||c<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),d(v)):n(v)}function d(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,e.check(ol,i.interrupt?n:p,e.attempt(X9,m,f))}function p(v){return i.containerState.initialBlankLine=!0,l++,m(v)}function f(v){return Xe(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),m):n(v)}function m(v){return i.containerState.size=l+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function J9(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(ol,s,l);function s(o){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,nt(e,t,"listItemIndent",i.containerState.size+1)(o)}function l(o){return i.containerState.furtherBlankLines||!Xe(o)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(o)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Z9,t,c)(o))}function c(o){return i.containerState._closeFlow=!0,i.interrupt=void 0,nt(e,e.attempt(Sn,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function eH(e,t,n){const i=this;return nt(e,s,"listItemIndent",i.containerState.size+1);function s(l){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?t(l):n(l)}}function tH(e){e.exit(this.containerState.type)}function nH(e,t,n){const i=this;return nt(e,s,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(l){const c=i.events[i.events.length-1];return!Xe(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const hw={name:"setextUnderline",resolveTo:rH,tokenize:iH};function rH(e,t){let n=e.length,i,s,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const c={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",l?(e.splice(s,0,["enter",c,t]),e.splice(l+1,0,["exit",e[i][1],t]),e[i][1].end={...e[l][1].end}):e[i][1]=c,e.push(["exit",c,t]),e}function iH(e,t,n){const i=this;let s;return l;function l(d){let p=i.events.length,f;for(;p--;)if(i.events[p][1].type!=="lineEnding"&&i.events[p][1].type!=="linePrefix"&&i.events[p][1].type!=="content"){f=i.events[p][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||f)?(e.enter("setextHeadingLine"),s=d,c(d)):n(d)}function c(d){return e.enter("setextHeadingLineSequence"),o(d)}function o(d){return d===s?(e.consume(d),o):(e.exit("setextHeadingLineSequence"),Xe(d)?nt(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ae(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const aH={tokenize:sH};function sH(e){const t=this,n=e.attempt(ol,i,e.attempt(this.parser.constructs.flowInitial,s,nt(e,e.attempt(this.parser.constructs.flow,s,e.attempt(d9,s)),"linePrefix")));return n;function i(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const oH={resolveAll:iI()},lH=rI("string"),uH=rI("text");function rI(e){return{resolveAll:iI(e==="text"?cH:void 0),tokenize:t};function t(n){const i=this,s=this.parser.constructs[e],l=n.attempt(s,c,o);return c;function c(p){return d(p)?l(p):o(p)}function o(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return d(p)?(n.exit("data"),l(p)):(n.consume(p),u)}function d(p){if(p===null)return!0;const f=s[p];let m=-1;if(f)for(;++m<f.length;){const v=f[m];if(!v.previous||v.previous.call(i,i.previous))return!0}return!1}}}function iI(e){return t;function t(n,i){let s=-1,l;for(;++s<=n.length;)l===void 0?n[s]&&n[s][1].type==="data"&&(l=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==l+2&&(n[l][1].end=n[s-1][1].end,n.splice(l+2,s-l-2),s=l+2),l=void 0);return e?e(n,i):n}}function cH(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const i=e[n-1][1],s=t.sliceStream(i);let l=s.length,c=-1,o=0,u;for(;l--;){const d=s[l];if(typeof d=="string"){for(c=d.length;d.charCodeAt(c-1)===32;)o++,c--;if(c)break;c=-1}else if(d===-2)u=!0,o++;else if(d!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const d={type:n===e.length||u||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:i.start._bufferIndex+c,_index:i.start._index+l,line:i.end.line,column:i.end.column-o,offset:i.end.offset-o},end:{...i.end}};i.end={...d.start},i.start.offset===i.end.offset?Object.assign(i,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const dH={42:Sn,43:Sn,45:Sn,48:Sn,49:Sn,50:Sn,51:Sn,52:Sn,53:Sn,54:Sn,55:Sn,56:Sn,57:Sn,62:XD},hH={91:g9},pH={[-2]:Mp,[-1]:Mp,32:Mp},fH={35:x9,42:Ku,45:[hw,Ku],60:k9,61:hw,95:Ku,96:cw,126:cw},mH={38:QD,92:ZD},gH={[-5]:Bp,[-4]:Bp,[-3]:Bp,33:$9,38:QD,42:dv,60:[WU,I9],91:W9,92:[_9,ZD],93:l1,95:dv,96:a9},bH={null:[dv,oH]},yH={null:[42,95]},vH={null:[]},_H=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:yH,contentInitial:hH,disable:vH,document:dH,flow:fH,flowInitial:pH,insideSpan:bH,string:mH,text:gH},Symbol.toStringTag,{value:"Module"}));function SH(e,t,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},l=[];let c=[],o=[];const u={attempt:A(O),check:A(T),consume:x,enter:S,exit:k,interrupt:A(T,{interrupt:!0})},d={code:null,containerState:{},defineSkip:E,events:[],now:w,parser:e,previous:null,sliceSerialize:m,sliceStream:v,write:f};let p=t.tokenize.call(d,u);return t.resolveAll&&l.push(t),d;function f(I){return c=ir(c,I),b(),c[c.length-1]!==null?[]:(R(t,0),d.events=Uc(l,d.events,d),d.events)}function m(I,H){return EH(v(I),H)}function v(I){return xH(c,I)}function w(){const{_bufferIndex:I,_index:H,line:B,column:W,offset:K}=i;return{_bufferIndex:I,_index:H,line:B,column:W,offset:K}}function E(I){s[I.line]=I.column,L()}function b(){let I;for(;i._index<c.length;){const H=c[i._index];if(typeof H=="string")for(I=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===I&&i._bufferIndex<H.length;)_(H.charCodeAt(i._bufferIndex));else _(H)}}function _(I){p=p(I)}function x(I){Ae(I)?(i.line++,i.column=1,i.offset+=I===-3?2:1,L()):I!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),d.previous=I}function S(I,H){const B=H||{};return B.type=I,B.start=w(),d.events.push(["enter",B,d]),o.push(B),B}function k(I){const H=o.pop();return H.end=w(),d.events.push(["exit",H,d]),H}function O(I,H){R(I,H.from)}function T(I,H){H.restore()}function A(I,H){return B;function B(W,K,V){let X,Y,P,M;return Array.isArray(W)?$(W):"tokenize"in W?$([W]):j(W);function j(he){return Z;function Z(z){const ne=z!==null&&he[z],ce=z!==null&&he.null,ge=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(ce)?ce:ce?[ce]:[]];return $(ge)(z)}}function $(he){return X=he,Y=0,he.length===0?V:U(he[Y])}function U(he){return Z;function Z(z){return M=D(),P=he,he.partial||(d.currentConstruct=he),he.name&&d.parser.constructs.disable.null.includes(he.name)?oe():he.tokenize.call(H?Object.assign(Object.create(d),H):d,u,J,oe)(z)}}function J(he){return I(P,M),K}function oe(he){return M.restore(),++Y<X.length?U(X[Y]):V}}}function R(I,H){I.resolveAll&&!l.includes(I)&&l.push(I),I.resolve&&Hn(d.events,H,d.events.length-H,I.resolve(d.events.slice(H),d)),I.resolveTo&&(d.events=I.resolveTo(d.events,d))}function D(){const I=w(),H=d.previous,B=d.currentConstruct,W=d.events.length,K=Array.from(o);return{from:W,restore:V};function V(){i=I,d.previous=H,d.currentConstruct=B,d.events.length=W,o=K,L()}}function L(){i.line in s&&i.column<2&&(i.column=s[i.line],i.offset+=s[i.line]-1)}}function xH(e,t){const n=t.start._index,i=t.start._bufferIndex,s=t.end._index,l=t.end._bufferIndex;let c;if(n===s)c=[e[n].slice(i,l)];else{if(c=e.slice(n,s),i>-1){const o=c[0];typeof o=="string"?c[0]=o.slice(i):c.shift()}l>0&&c.push(e[s].slice(0,l))}return c}function EH(e,t){let n=-1;const i=[];let s;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
73
73
  `;break}case-3:{c=`\r
74
74
  `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&s)continue;c=" ";break}default:c=String.fromCharCode(l)}s=l===-2,i.push(c)}return i.join("")}function wH(e){const i={constructs:KD([_H,...(e||{}).extensions||[]]),content:s(PU),defined:[],document:s(HU),flow:s(aH),lazy:{},string:s(lH),text:s(uH)};return i;function s(l){return c;function c(o){return SH(i,l,o)}}}function CH(e){for(;!JD(e););return e}const pw=/[\0\t\n\r]/g;function kH(){let e=1,t="",n=!0,i;return s;function s(l,c,o){const u=[];let d,p,f,m,v;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),f=0,t="",n&&(l.charCodeAt(0)===65279&&f++,n=void 0);f<l.length;){if(pw.lastIndex=f,d=pw.exec(l),m=d&&d.index!==void 0?d.index:l.length,v=l.charCodeAt(m),!d){t=l.slice(f);break}if(v===10&&f===m&&i)u.push(-3),i=void 0;else switch(i&&(u.push(-5),i=void 0),f<m&&(u.push(l.slice(f,m)),e+=m-f),v){case 0:{u.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,u.push(-2);e++<p;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:i=!0,e=1}f=m+1}return o&&(i&&u.push(-5),t&&u.push(t),u.push(null)),u}}const TH=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function RH(e){return e.replace(TH,AH)}function AH(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),l=s===120||s===88;return YD(n.slice(l?2:1),l?16:10)}return o1(n)||e}const aI={}.hasOwnProperty;function NH(e,t,n){return typeof t!="string"&&(n=t,t=void 0),OH(n)(CH(wH(n).document().write(kH()(e,t,!0))))}function OH(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(ot),autolinkProtocol:D,autolinkEmail:D,atxHeading:l(Pe),blockQuote:l(ce),characterEscape:D,characterReference:D,codeFenced:l(ge),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(ge,c),codeText:l(be,c),codeTextData:D,data:D,codeFlowValue:D,definition:l(we),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l($e),hardBreakEscape:l(We),hardBreakTrailing:l(We),htmlFlow:l(xe,c),htmlFlowData:D,htmlText:l(xe,c),htmlTextData:D,image:l(gt),label:c,link:l(ot),listItem:l(Se),listItemValue:m,listOrdered:l(vt,f),listUnordered:l(vt),paragraph:l(Fe),reference:U,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(Pe),strong:l(Re),thematicBreak:l(Ge)},exit:{atxHeading:u(),atxHeadingSequence:O,autolink:u(),autolinkEmail:ne,autolinkProtocol:z,blockQuote:u(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:he,characterReference:Z,codeFenced:u(b),codeFencedFence:E,codeFencedFenceInfo:v,codeFencedFenceMeta:w,codeFlowValue:L,codeIndented:u(_),codeText:u(K),codeTextData:L,data:L,definition:u(),definitionDestinationString:k,definitionLabelString:x,definitionTitleString:S,emphasis:u(),hardBreakEscape:u(H),hardBreakTrailing:u(H),htmlFlow:u(B),htmlFlowData:L,htmlText:u(W),htmlTextData:L,image:u(X),label:P,labelText:Y,lineEnding:I,link:u(V),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:J,resourceDestinationString:M,resourceTitleString:j,resource:$,setextHeading:u(R),setextHeadingLineSequence:A,setextHeadingText:T,strong:u(),thematicBreak:u()}};sI(t,(e||{}).mdastExtensions||[]);const n={};return i;function i(re){let de={type:"root",children:[]};const ye={stack:[de],tokenStack:[],config:t,enter:o,exit:d,buffer:c,resume:p,data:n},ke=[];let Oe=-1;for(;++Oe<re.length;)if(re[Oe][1].type==="listOrdered"||re[Oe][1].type==="listUnordered")if(re[Oe][0]==="enter")ke.push(Oe);else{const xt=ke.pop();Oe=s(re,xt,Oe)}for(Oe=-1;++Oe<re.length;){const xt=t[re[Oe][0]];aI.call(xt,re[Oe][1].type)&&xt[re[Oe][1].type].call(Object.assign({sliceSerialize:re[Oe][2].sliceSerialize},ye),re[Oe][1])}if(ye.tokenStack.length>0){const xt=ye.tokenStack[ye.tokenStack.length-1];(xt[1]||fw).call(ye,void 0,xt[0])}for(de.position={start:ki(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:ki(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},Oe=-1;++Oe<t.transforms.length;)de=t.transforms[Oe](de)||de;return de}function s(re,de,ye){let ke=de-1,Oe=-1,xt=!1,je,Et,lt,_t;for(;++ke<=ye;){const tt=re[ke];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?Oe++:Oe--,_t=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(je&&!_t&&!Oe&&!lt&&(lt=ke),_t=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_t=void 0}if(!Oe&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||Oe===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(je){let Me=ke;for(Et=void 0;Me--;){const Nt=re[Me];if(Nt[1].type==="lineEnding"||Nt[1].type==="lineEndingBlank"){if(Nt[0]==="exit")continue;Et&&(re[Et][1].type="lineEndingBlank",xt=!0),Nt[1].type="lineEnding",Et=Me}else if(!(Nt[1].type==="linePrefix"||Nt[1].type==="blockQuotePrefix"||Nt[1].type==="blockQuotePrefixWhitespace"||Nt[1].type==="blockQuoteMarker"||Nt[1].type==="listItemIndent"))break}lt&&(!Et||lt<Et)&&(je._spread=!0),je.end=Object.assign({},Et?re[Et][1].start:tt[1].end),re.splice(Et||ke,0,["exit",je,tt[2]]),ke++,ye++}if(tt[1].type==="listItemPrefix"){const Me={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};je=Me,re.splice(ke,0,["enter",Me,tt[2]]),ke++,ye++,lt=void 0,_t=!0}}}return re[de][1]._spread=xt,ye}function l(re,de){return ye;function ye(ke){o.call(this,re(ke),ke),de&&de.call(this,ke)}}function c(){this.stack.push({type:"fragment",children:[]})}function o(re,de,ye){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([de,ye||void 0]),re.position={start:ki(de.start),end:void 0}}function u(re){return de;function de(ye){re&&re.call(this,ye),d.call(this,ye)}}function d(re,de){const ye=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==re.type&&(de?de.call(this,re,ke[0]):(ke[1]||fw).call(this,re,ke[0]));else throw new Error("Cannot close `"+re.type+"` ("+jo({start:re.start,end:re.end})+"): it’s not open");ye.position.end=ki(re.end)}function p(){return s1(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function m(re){if(this.data.expectingFirstListItemValue){const de=this.stack[this.stack.length-2];de.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function v(){const re=this.resume(),de=this.stack[this.stack.length-1];de.lang=re}function w(){const re=this.resume(),de=this.stack[this.stack.length-1];de.meta=re}function E(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const re=this.resume(),de=this.stack[this.stack.length-1];de.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const re=this.resume(),de=this.stack[this.stack.length-1];de.value=re.replace(/(\r?\n|\r)$/g,"")}function x(re){const de=this.resume(),ye=this.stack[this.stack.length-1];ye.label=de,ye.identifier=dr(this.sliceSerialize(re)).toLowerCase()}function S(){const re=this.resume(),de=this.stack[this.stack.length-1];de.title=re}function k(){const re=this.resume(),de=this.stack[this.stack.length-1];de.url=re}function O(re){const de=this.stack[this.stack.length-1];if(!de.depth){const ye=this.sliceSerialize(re).length;de.depth=ye}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function A(re){const de=this.stack[this.stack.length-1];de.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function D(re){const ye=this.stack[this.stack.length-1].children;let ke=ye[ye.length-1];(!ke||ke.type!=="text")&&(ke=Le(),ke.position={start:ki(re.start),end:void 0},ye.push(ke)),this.stack.push(ke)}function L(re){const de=this.stack.pop();de.value+=this.sliceSerialize(re),de.position.end=ki(re.end)}function I(re){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=de.children[de.children.length-1];ye.position.end=ki(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(de.type)&&(D.call(this,re),L.call(this,re))}function H(){this.data.atHardBreak=!0}function B(){const re=this.resume(),de=this.stack[this.stack.length-1];de.value=re}function W(){const re=this.resume(),de=this.stack[this.stack.length-1];de.value=re}function K(){const re=this.resume(),de=this.stack[this.stack.length-1];de.value=re}function V(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=de,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function X(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=de,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function Y(re){const de=this.sliceSerialize(re),ye=this.stack[this.stack.length-2];ye.label=RH(de),ye.identifier=dr(de).toLowerCase()}function P(){const re=this.stack[this.stack.length-1],de=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const ke=re.children;ye.children=ke}else ye.alt=de}function M(){const re=this.resume(),de=this.stack[this.stack.length-1];de.url=re}function j(){const re=this.resume(),de=this.stack[this.stack.length-1];de.title=re}function $(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function J(re){const de=this.resume(),ye=this.stack[this.stack.length-1];ye.label=de,ye.identifier=dr(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function oe(re){this.data.characterReferenceType=re.type}function he(re){const de=this.sliceSerialize(re),ye=this.data.characterReferenceType;let ke;ye?(ke=YD(de,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=o1(de);const Oe=this.stack[this.stack.length-1];Oe.value+=ke}function Z(re){const de=this.stack.pop();de.position.end=ki(re.end)}function z(re){L.call(this,re);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(re)}function ne(re){L.call(this,re);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(re)}function ce(){return{type:"blockquote",children:[]}}function ge(){return{type:"code",lang:null,meta:null,value:""}}function be(){return{type:"inlineCode",value:""}}function we(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function Pe(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function xe(){return{type:"html",value:""}}function gt(){return{type:"image",title:null,url:"",alt:null}}function ot(){return{type:"link",title:null,url:"",children:[]}}function vt(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function Se(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function Fe(){return{type:"paragraph",children:[]}}function Re(){return{type:"strong",children:[]}}function Le(){return{type:"text",value:""}}function Ge(){return{type:"thematicBreak"}}}function ki(e){return{line:e.line,column:e.column,offset:e.offset}}function sI(e,t){let n=-1;for(;++n<t.length;){const i=t[n];Array.isArray(i)?sI(e,i):DH(e,i)}}function DH(e,t){let n;for(n in t)if(aI.call(t,n))switch(n){case"canContainEols":{const i=t[n];i&&e[n].push(...i);break}case"transforms":{const i=t[n];i&&e[n].push(...i);break}case"enter":case"exit":{const i=t[n];i&&Object.assign(e[n],i);break}}}function fw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+jo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+jo({start:t.start,end:t.end})+") is still open")}function IH(e){const t=this;t.parser=n;function n(i){return NH(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function LH(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function MH(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -115,14 +115,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
115
115
  `),maxHeight:"max-h-80",children:y.jsx("div",{className:"divide-y divide-border/50",children:u.map(_=>y.jsx("div",{className:"px-3 py-1 font-mono text-foreground/80 truncate hover:bg-muted/20",children:String(_)},String(_)))})}),v===0&&y.jsx(At,{title:"results",maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No results found"})})]})]})}function gJ({toolDurationMs:e}){const t=pn(e);return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"Done"}),t&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/70",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80",children:t})]})]})})}function bJ({toolName:e,contentJson:t,toolDurationMs:n,isExpanded:i,onToggle:s,compact:l}){const c=t.result,o=pn(n),u=c&&Object.keys(c).length>0,d=document?.documentElement.classList.contains("dark")?ei:Rr,p=t.error||c&&typeof c=="object"&&"ok"in c&&c.ok===!1,f=typeof t.error=="string"?t.error:c&&typeof c=="object"&&"error"in c&&typeof c.error=="string"?c.error:null,m=c&&typeof c=="object"&&"stack"in c&&typeof c.stack=="string"?c.stack:void 0;return y.jsxs("div",{className:"text-xs",children:[y.jsxs("button",{type:"button",onClick:s,className:`flex items-center gap-2 transition-colors w-full ${p?"text-red-700 dark:text-red-300 hover:text-red-600 dark:hover:text-red-200":"text-foreground hover:text-foreground/80"}`,children:[y.jsx(nn,{className:`h-3 w-3 flex-shrink-0 transition-transform ${i?"rotate-90":""}`}),p&&y.jsx(Qr,{className:"h-3 w-3 flex-shrink-0 text-red-600 dark:text-red-400"}),y.jsxs("span",{className:"font-medium flex-shrink-0",children:[e,p?" error":""]}),!l&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),y.jsx("span",{className:"text-muted-foreground/80 flex-shrink-0",children:o})]})]}),i&&p&&f&&y.jsx(kn,{error:f,stack:m,showStack:!0}),i&&!p&&u&&y.jsx("div",{className:"mt-2 ml-5 bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:y.jsx("div",{className:"overflow-x-auto max-w-full",children:y.jsx(Cn,{language:"json",style:d,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:JSON.stringify(c,null,2)})})})]})}function yJ({contentJson:e,toolDurationMs:t}){return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"text-muted-foreground",children:[y.jsxs("div",{children:["Tool: ",e.name]}),y.jsxs("div",{children:["Duration: ",t,"ms"]}),y.jsx("pre",{className:"mt-2 text-[10px] bg-card border border-border p-2 rounded overflow-x-auto",children:JSON.stringify(e,null,2)})]})})}function vJ({contentJson:e}){const t=e.result||{},n=t.items||[],i=t.note;return y.jsx("div",{className:"text-xs",children:y.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/30 dark:bg-blue-500/5 dark:border-blue-500/20 rounded-lg p-3 space-y-2",children:[i&&y.jsx("div",{className:"text-blue-700 dark:text-blue-300 text-sm font-medium mb-3",children:i}),y.jsx("div",{className:"space-y-1.5",children:n.map((s,l)=>y.jsxs("div",{className:"flex items-start gap-2",children:[s.status==="completed"&&y.jsx(sB,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300 flex-shrink-0 mt-0.5"}),s.status==="in_progress"&&y.jsx(q6,{className:"h-4 w-4 text-blue-700 dark:text-blue-300 flex-shrink-0 mt-0.5 animate-pulse"}),s.status==="pending"&&y.jsx(hB,{className:"h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5"}),s.status==="cancelled"&&y.jsx(TO,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0 mt-0.5"}),y.jsx("span",{className:`text-sm ${s.status==="completed"?"text-muted-foreground line-through":s.status==="in_progress"?"text-foreground":s.status==="cancelled"?"text-muted-foreground/50 line-through":"text-muted-foreground/80"}`,children:s.step})]},`${s.step}-${l}`))})]})})}function _J({contentJson:e}){const t=e.result||{},n=String(t.message||"Processing..."),i=t.stage?String(t.stage):void 0,s=t.pct?Number(t.pct):void 0;return y.jsxs("div",{className:"flex items-center gap-2 text-sm text-violet-700 dark:text-violet-300 animate-pulse",children:[i&&y.jsxs("span",{className:"text-muted-foreground/80",children:["[",i,"]"]}),y.jsx("span",{children:n}),s!==void 0&&y.jsxs("span",{className:"text-muted-foreground/80",children:["(",s,"%)"]})]})}function SJ({contentJson:e,toolDurationMs:t,isExpanded:n,onToggle:i}){const s=e.result||{},l=e.args||{},c=pn(t),o=As(s)||!!e.error,u=Ns(s)||(typeof e.error=="string"?e.error:null),d=s&&typeof s=="object"&&"stack"in s?String(s.stack):void 0,p="results"in s,f=s.results||[],m=s,v=typeof l.query=="string"?l.query:void 0,w=typeof l.url=="string"?l.url:m.url;if(p)return y.jsxs("div",{className:"text-xs",children:[y.jsxs(Zr,{toolName:"web search",isExpanded:n,onToggle:i,isError:o,colorVariant:"purple",canExpand:!0,children:[v&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsxs("span",{className:"font-mono text-foreground/90 text-[11px] truncate min-w-0",title:v,children:['"',v.length>25?`${v.slice(0,25)}…`:v,'"']})]}),y.jsx(mt,{}),y.jsxs(cl,{children:[f.length," ",f.length===1?"result":"results"]}),y.jsx(mt,{}),y.jsx(hr,{children:c})]}),n&&o&&u&&y.jsx(kn,{error:u,stack:d,showStack:!0}),n&&!o&&y.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[y.jsx(At,{title:"query",icon:y.jsx(ZB,{className:"h-3 w-3"}),copyText:v,maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 font-mono text-xs bg-muted/10 break-all",children:v||"(empty)"})}),f.length>0&&y.jsx(At,{title:"results",copyText:f.map(b=>`${b.title}
116
116
  ${b.url}`).join(`
117
117
 
118
- `),maxHeight:"max-h-80",children:y.jsx("div",{className:"divide-y divide-border/50",children:f.map((b,_)=>y.jsxs("div",{className:"px-3 py-2 hover:bg-muted/20",children:[y.jsxs("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:[b.title,y.jsx(wr,{className:"h-3 w-3 flex-shrink-0"})]}),y.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:b.snippet}),y.jsx("p",{className:"text-xs text-muted-foreground/60 truncate mt-0.5",children:b.url})]},`${b.url}-${_}`))})}),f.length===0&&y.jsx(At,{title:"results",maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No results found"})})]})]});const E=w&&w.length>50?`${w.slice(0,50)}...`:w;return y.jsxs("div",{className:"text-xs",children:[y.jsxs(Zr,{toolName:"web fetch",isExpanded:n,onToggle:i,isError:o,colorVariant:"purple",canExpand:!0,children:[E&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx("span",{className:"text-foreground/70 truncate min-w-0",title:w,children:E})]}),y.jsx(mt,{}),y.jsx(hr,{children:c})]}),n&&o&&u&&y.jsx(kn,{error:u,stack:d,showStack:!0}),n&&!o&&y.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[y.jsx(At,{title:"url",icon:y.jsx(aF,{className:"h-3 w-3"}),copyText:w,maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 font-mono text-xs bg-muted/10 break-all",children:y.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:w})})}),m.content&&y.jsx(At,{title:"content",copyText:m.content,maxHeight:"max-h-80",children:y.jsx("div",{className:"px-3 py-2 text-xs text-foreground/80 whitespace-pre-wrap break-words",children:m.content})}),!m.content&&y.jsx(At,{title:"content",maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No content returned"})})]})]})}function xJ({contentJson:e,debug:t}){const[n,i]=q.useState(!1);let s,l,c,o=!1;e.error&&typeof e.error=="object"?(s=e.error,s.message&&typeof s.message=="string"&&(l=s.message),s.type&&typeof s.type=="string"&&(c=s.type)):e.details&&typeof e.details=="object"?(s=e.details,e.message&&typeof e.message=="string"&&(l=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(o=!0)):(e.message&&typeof e.message=="string"&&(l=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(o=!0),s=e);let u;if(s?.responseBody&&typeof s.responseBody=="string")try{const m=JSON.parse(s.responseBody);m.error&&typeof m.error=="object"&&(u={type:typeof m.error.type=="string"?m.error.type:void 0,message:typeof m.error.message=="string"?m.error.message:void 0})}catch{}const d=m=>{if(m==null)return y.jsx("span",{className:"text-muted-foreground",children:"null"});if(typeof m=="boolean")return y.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(m)});if(typeof m=="number")return y.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:m});if(typeof m=="string"){if(m.startsWith("{")||m.startsWith("["))try{const v=JSON.parse(m);return y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(v,null,2)})})}catch{}return y.jsx("span",{className:"text-foreground",children:m})}return typeof m=="object"?y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(m,null,2)})}):y.jsx("span",{className:"text-foreground",children:String(m)})},p=["name","statusCode","url","model","isRetryable","cause"],f=new Set;return y.jsxs("div",{className:"space-y-2 text-sm",children:[o&&y.jsx("div",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Request aborted"}),u?.message&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"API Error:"}),y.jsx("div",{className:"text-foreground",children:u.message}),u.type&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",u.type]})]}),!u?.message&&l&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),y.jsx("div",{className:"text-foreground",children:l}),c&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",c]})]}),s&&y.jsx("div",{className:"space-y-1.5",children:p.map(m=>{const v=s[m];return v==null?null:(f.add(m),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:"font-medium text-muted-foreground min-w-[100px]",children:[m,":"]}),d(v)]},m))})}),s&&y.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[y.jsxs("button",{type:"button",onClick:()=>i(!n),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[n?y.jsx(xa,{className:"h-3 w-3"}):y.jsx(nn,{className:"h-3 w-3"}),n?"Hide":"View"," Raw Error Details"]}),n&&y.jsx("div",{className:"mt-2",children:y.jsx("pre",{className:"p-3 bg-muted/50 rounded text-xs overflow-x-auto max-h-96 overflow-y-auto",children:y.jsx("code",{children:JSON.stringify(s,null,2)})})})]}),t&&y.jsxs("details",{className:"mt-4 text-xs",children:[y.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Debug Info"}),y.jsx("pre",{className:"mt-2 p-2 bg-muted/30 rounded overflow-x-auto",children:y.jsx("code",{children:JSON.stringify({contentJson:e,errorDetails:s,apiError:u},null,2)})})]})]})}function iL(e){return e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}function Iy({session:e,onNavigate:t,compact:n}){return n?y.jsxs("button",{type:"button",onClick:()=>t?.(e.id),disabled:!t,className:"w-full text-left py-1 px-2 rounded text-xs hover:bg-muted/50 transition-colors flex items-center justify-between gap-2",children:[y.jsx("span",{className:"truncate text-foreground",children:e.title||"Untitled"}),t&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):y.jsxs("button",{type:"button",onClick:()=>t?.(e.id),disabled:!t,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"font-medium text-sm truncate text-foreground",children:e.title||"Untitled"}),t&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.agent&&y.jsx("span",{className:"text-violet-600 dark:text-violet-400",children:e.agent}),e.agent&&e.provider&&y.jsx("span",{children:"·"}),e.provider&&y.jsx("span",{children:e.provider}),e.messageCount!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsxs("span",{children:[e.messageCount," msgs"]})]}),e.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsx("span",{children:iL(e.createdAt)})]})]})]})}function kN({message:e,onNavigate:t,compact:n}){const i="sessionId"in e?e.sessionId:"",s="sessionTitle"in e?e.sessionTitle:null,l="content"in e?e.content:"contentPreview"in e?e.contentPreview:"matchedContent"in e?e.matchedContent:"";return n?y.jsxs("button",{type:"button",onClick:()=>t?.(i),disabled:!t||!i,className:"w-full text-left py-1 px-2 rounded text-xs hover:bg-muted/50 transition-colors flex items-center justify-between gap-2",children:[y.jsx("span",{className:"truncate text-foreground/80",children:l?.slice(0,50)||s||i.slice(0,8)}),t&&i&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):y.jsxs("button",{type:"button",onClick:()=>t?.(i),disabled:!t||!i,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-xs text-muted-foreground",children:s||i.slice(0,8)}),t&&i&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),l&&y.jsx("div",{className:"text-xs text-foreground/80 mt-1 line-clamp-2",children:l}),y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.role&&y.jsx("span",{className:"capitalize",children:e.role}),e.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsx("span",{children:iL(e.createdAt)})]})]})]})}function TN({args:e,toolName:t}){const n=(c,o)=>o==null||typeof o=="boolean"&&!o||Array.isArray(o)&&o.length===0?null:y.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[y.jsxs("span",{className:"opacity-60",children:[c,":"]}),y.jsx("span",{className:"text-foreground/80",children:typeof o=="string"?o:JSON.stringify(o)})]},c),l=({query_sessions:["agent","sessionType","startDate","endDate"],query_messages:["sessionId","role","search","toolName"],search_history:["query"],get_session_context:["sessionId","includeMessages"],get_parent_session:["includeMessages"]}[t]||Object.keys(e).slice(0,3)).filter(c=>e[c]!==void 0&&e[c]!==null).map(c=>n(c,e[c])).filter(Boolean);return l.length===0?null:y.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-xs mb-2 pb-2 border-b border-border",children:[y.jsx(VB,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),l]})}function EJ({toolName:e,contentJson:t,toolDurationMs:n,isExpanded:i,onToggle:s,onNavigateToSession:l,compact:c}){const o=t.result||{},u=t.args||{},d=typeof o=="object"&&"ok"in o&&o.ok===!1,p=d&&"error"in o&&typeof o.error=="string"?o.error:null,f=pn(n);if(e==="present_action"){const w=o.links||[],E=o.summary,b=o.title;return w.length===0&&!E?null:y.jsxs("div",{className:"mt-2 mb-1",children:[b&&y.jsx("div",{className:"text-sm font-medium text-foreground mb-1.5",children:b}),E&&y.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1.5",children:[y.jsx(rF,{className:"w-3.5 h-3.5 text-teal-500"}),y.jsx("span",{children:E})]}),w.length>0&&y.jsx("div",{className:"space-y-1.5",children:w.map(_=>y.jsxs("button",{type:"button",onClick:()=>l?.(_.sessionId),disabled:!l,className:"w-full text-left px-3 py-2 rounded-lg border border-teal-500/30 bg-teal-500/5 hover:bg-teal-500/10 transition-colors group flex items-center justify-between gap-2",children:[y.jsxs("div",{children:[y.jsx("div",{className:"font-medium text-sm text-foreground",children:_.title}),_.description&&y.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:_.description})]}),l&&y.jsx(wr,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 opacity-60 group-hover:opacity-100 transition-opacity flex-shrink-0"})]},_.sessionId))})]})}const m=()=>{switch(e){case"query_sessions":{const w=o.sessions||[],E=o.total;return`${w.length} session${w.length!==1?"s":""}${E?` of ${E}`:""}`}case"query_messages":{const w=o.messages||[];return`${w.length} message${w.length!==1?"s":""}`}case"search_history":{const w=u.query,E=o.results||[],b=w?`"${w.slice(0,20)}${w.length>20?"…":""}"`:"";return`${E.length} result${E.length!==1?"s":""}${b?` for ${b}`:""}`}case"get_session_context":return o.session?.title||u.sessionId?.slice(0,8)||"session";case"get_parent_session":return o.parentSession?.title||"parent session";default:return e}},v=()=>{const w=Object.keys(u).length>0&&!c;switch(e){case"query_sessions":{const E=o.sessions||[];return y.jsxs("div",{className:c?"p-1":"p-2",children:[w&&y.jsx(TN,{args:u,toolName:e}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No sessions found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map(b=>y.jsx(Iy,{session:b,onNavigate:l,compact:c},b.id)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"query_messages":{const E=o.messages||[];return y.jsxs("div",{className:c?"p-1":"p-2",children:[w&&y.jsx(TN,{args:u,toolName:e}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map(b=>y.jsx(kN,{message:b,onNavigate:l,compact:c},b.id)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"search_history":{const E=o.results||[],b=u.query;return y.jsxs("div",{className:c?"p-1":"p-2",children:[b&&!c&&y.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-2 pb-2 border-b border-border",children:[y.jsx(Qo,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),y.jsx("span",{className:"text-muted-foreground",children:"Query:"}),y.jsxs("span",{className:"text-foreground font-medium",children:['"',b,'"']})]}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No results found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map((_,x)=>y.jsx(kN,{message:_,onNavigate:l,compact:c},`${_.sessionId}-${_.messageId}-${x}`)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"get_session_context":case"get_parent_session":{const E=e==="get_parent_session"?o.parentSession:o.session,b=o.stats,_=o.messages;return E?c?y.jsx("div",{className:"p-1",children:y.jsx(Iy,{session:E,onNavigate:l,compact:!0})}):y.jsxs("div",{className:"p-2 space-y-3",children:[y.jsx(Iy,{session:E,onNavigate:l}),b&&y.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[b.totalMessages!==void 0&&y.jsxs("span",{children:[b.totalMessages," messages"]}),b.totalToolCalls!==void 0&&y.jsxs("span",{children:[b.totalToolCalls," tool calls"]})]}),_&&_.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Recent messages:"}),y.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:_.slice(0,5).map(x=>y.jsxs("div",{className:"text-xs p-1.5 rounded bg-muted/30",children:[y.jsxs("span",{className:"font-medium capitalize text-foreground/70",children:[x.role,":"," "]}),y.jsx("span",{className:"text-foreground/60 line-clamp-2",children:x.content})]},x.id))})]})]}):y.jsx("div",{className:`text-xs text-muted-foreground ${c?"p-1":"p-2"}`,children:"Session not found"})}default:return y.jsx("pre",{className:"text-xs p-2 overflow-auto max-h-48",children:JSON.stringify(o,null,2)})}};return y.jsxs("div",{className:"text-xs",children:[y.jsxs(Zr,{toolName:e,isExpanded:i,onToggle:s,isError:d,colorVariant:"default",canExpand:!0,children:[!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx("span",{className:"text-foreground/70 min-w-0 truncate",children:m()})]}),!d&&!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx(R1,{children:"Done"}),y.jsx(mt,{}),y.jsx(hr,{children:f})]}),d&&!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx(A1,{children:"Error"}),y.jsxs(hr,{children:["· ",f]})]})]}),i&&d&&p&&y.jsx(kn,{error:p}),i&&!d&&y.jsx("div",{className:c?"mt-1 ml-3":"mt-2 ml-5",children:c?y.jsx("div",{className:"border border-border rounded-md overflow-hidden max-h-48 overflow-y-auto",children:v()}):y.jsx(At,{title:"results",maxHeight:"max-h-96",children:v()})})]})}function wJ({part:e}){const[t,n]=q.useState(!0),i=q.useRef(null);let s="";const l=e.contentJson||e.content;return l&&typeof l=="object"&&"text"in l?s=String(l.text):typeof l=="string"&&(s=l),q.useEffect(()=>{i.current&&t&&!e.completedAt&&(i.current.scrollTop=i.current.scrollHeight)},[t,e.completedAt]),!s||!s.trim()?null:y.jsxs("div",{className:"w-full",children:[y.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full",children:[t?y.jsx(xa,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(nn,{className:"h-3 w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium",children:"Reasoning"}),!e.completedAt&&y.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"thinking..."})]}),t&&y.jsx("div",{ref:i,className:"mt-2 p-3 bg-muted/30 rounded-md border border-border max-h-48 overflow-y-auto",children:y.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:s})})]})}const CJ={Read:"read",Write:"write",Edit:"edit",Ls:"ls",Tree:"tree",Cd:"cd",Pwd:"pwd",Glob:"glob",Grep:"ripgrep",Bash:"bash",Terminal:"terminal",GitStatus:"git_status",GitDiff:"git_diff",GitCommit:"git_commit",ApplyPatch:"apply_patch",UpdateTodos:"update_todos",UpdatePlan:"update_todos",ProgressUpdate:"progress_update",Finish:"finish",WebSearch:"websearch"};function kJ(e){return CJ[e]??e}function RN({toolName:e,contentJson:t,toolDurationMs:n,debug:i,onNavigateToSession:s,compact:l}){const[c,o]=q.useState(!1),u=kJ(e),p={contentJson:t,toolDurationMs:n??void 0,isExpanded:c,onToggle:()=>o(!c),compact:l};if(i)return y.jsx(yJ,{...p,toolName:e});switch(u){case"read":return y.jsx(eJ,{...p});case"write":return y.jsx(tJ,{...p});case"edit":return y.jsx(nJ,{...p});case"bash":return y.jsx(aJ,{...p});case"git_status":return y.jsx(uJ,{...p});case"git_diff":return y.jsx(cJ,{...p});case"git_commit":return y.jsx(dJ,{...p});case"apply_patch":return y.jsx(hJ,{...p});case"ls":return y.jsx(pJ,{...p});case"tree":return y.jsx(fJ,{...p});case"ripgrep":case"grep":case"glob":return y.jsx(mJ,{...p});case"websearch":return y.jsx(SJ,{...p});case"finish":return y.jsx(gJ,{...p});case"update_todos":case"update_plan":return y.jsx(vJ,{...p});case"progress_update":return y.jsx(_J,{...p});case"error":return y.jsx(xJ,{...p});case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":case"present_action":return y.jsx(EJ,{toolName:e,...p,onNavigateToSession:s});default:return y.jsx(bJ,{...p,toolName:e})}}function _v(e){const t=e.contentJson;if(t&&typeof t=="object")return t;try{if(e.content){const n=JSON.parse(e.content);if(n&&typeof n=="object"&&!Array.isArray(n))return n}}catch{}return null}function TJ(e){const t=_v(e);if(!t)return;const n=t.args;if(n&&typeof n=="object"&&!Array.isArray(n))return n}function RJ(e){if(!e)return null;const t=["cmd","command","script","input"];for(const n of t){const i=e[n];if(typeof i=="string"&&i.trim().length>0)return i.trim()}return null}function AJ(e,t){if(!t)return null;const n=[{key:"path",match:!0},{key:"file",match:!0},{key:"target",match:!0},{key:"cwd",match:!0},{key:"query",match:!0},{key:"pattern",match:!0},{key:"glob",match:!0},{key:"dir",match:!0}];for(const{key:i}of n){const s=t[i];if(typeof s=="string"&&s.trim().length>0)return{key:i,value:s.trim()}}if(e==="bash"){const i=t.command;if(typeof i=="string"&&i.trim().length>0)return{key:"command",value:i.trim()}}return null}function NJ(e,t){if(!e)return null;const n=[];for(const[s,l]of Object.entries(e))if(!(t&&s===t)){if(typeof l=="string"||typeof l=="number"){const c=`${s}=${String(l)}`;n.push(c)}if(n.length>=3)break}if(!n.length)return null;const i=n.join(" ");return i.length>120?`${i.slice(0,117)}…`:i}const AN=q.memo(function({part:t,showLine:n,isLastToolCall:i,isLastProgressUpdate:s,onNavigateToSession:l,compact:c,pendingApproval:o,onApprove:u,onReject:d}){if(t.type==="tool_call"&&!i&&!o||t.type==="tool_result"&&t.toolName==="progress_update"&&!s)return null;if(t.type==="text"){const b=t.contentJson||t.content;let _="";if(b&&typeof b=="object"&&"text"in b?_=String(b.text):typeof b=="string"&&(_=b),!_||!_.trim())return null}if(t.type==="reasoning"){const b=t.contentJson||t.content;let _="";if(b&&typeof b=="object"&&"text"in b?_=String(b.text):typeof b=="string"&&(_=b),!_||!_.trim())return null}const p=t.type==="tool_call"||t.type==="tool_result",f=["flex-1","min-w-0","max-w-full"];p||t.type==="reasoning"?f.push("pt-1"):t.type==="error"?f.push("pt-0.5"):t.type==="text"?(f.push("pt-0"),f.push("-mt-0.5")):f.push("pt-0");const m=f.join(" "),v=()=>{if(t.type==="reasoning")return y.jsx(Uv,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"});if(t.type==="tool_call")return y.jsx(Ni,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(t.type==="error")return _v(t)?.isAborted===!0?y.jsx(pF,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):y.jsx(Qr,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(t.type==="tool_result"){const b=t.toolName||"";return b==="read"?y.jsx(kc,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):b==="write"?y.jsx(ga,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="edit"?y.jsx(ga,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="ls"?y.jsx(oF,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):b==="tree"?y.jsx(IO,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):b==="bash"?y.jsx(ba,{className:"h-4 w-4 text-muted-foreground"}):b==="ripgrep"||b==="grep"||b==="glob"?y.jsx(Qo,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):b==="apply_patch"?y.jsx(_E,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="git_status"?y.jsx(zn,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):b==="git_diff"?y.jsx(_E,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="git_commit"?y.jsx(uc,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="finish"?y.jsx(Mi,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="query_sessions"||b==="query_messages"||b==="search_history"||b==="get_session_context"||b==="get_parent_session"?y.jsx(EB,{className:"h-4 w-4 text-teal-600 dark:text-teal-300"}):y.jsx(ba,{className:"h-4 w-4 text-muted-foreground"})}return y.jsx(Vo,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},w=()=>{const b=t.toolName||"";let _;try{t.contentJson&&typeof t.contentJson=="object"?_=t.contentJson:typeof t.content=="string"?_=JSON.parse(t.content):_={}}catch{_={result:t.content}}return y.jsx(RN,{toolName:b,contentJson:_,toolDurationMs:t.toolDurationMs,debug:!1,onNavigateToSession:l,compact:c})},E=()=>{if(t.type==="reasoning")return y.jsx(wJ,{part:t});if(t.type==="text"){let b="";const _=t.contentJson||t.content;return _&&typeof _=="object"&&"text"in _?b=String(_.text):typeof _=="string"?b=_:_&&(b=JSON.stringify(_,null,2)),y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"absolute -top-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:b,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})}),y.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-hidden",children:y.jsx(mI,{remarkPlugins:[PI],components:{pre:({children:x,...S})=>{const k=(()=>{if(!x)return"";const O=Array.isArray(x)?x[0]:x;if(O&&typeof O=="object"&&"props"in O){const T=O.props;if(typeof T.children=="string")return T.children}return""})();return y.jsxs("div",{className:"relative group/code my-3",children:[y.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover/code:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:k,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"sm"})}),y.jsx("pre",{...S,className:"overflow-x-auto",children:x})]})}},children:b})}),b.length>500&&y.jsx("div",{className:"absolute -bottom-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:b,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})})]})}if(t.type==="error"){let b;try{t.contentJson&&typeof t.contentJson=="object"?b=t.contentJson:typeof t.content=="string"?b=JSON.parse(t.content):b={}}catch{b={message:t.content||"Unknown error"}}return y.jsx(RN,{toolName:"error",contentJson:b,toolDurationMs:t.toolDurationMs,debug:!1,compact:c})}if(t.type==="tool_call"){const b=_v(t),_=t.toolName||(typeof b?.name=="string"?b.name:"tool"),x=_.replace(/_/g," "),S=TJ(t),k=o?.args,O=S||k,T=AJ(_,O),A=NJ(O,T?.key),R=_==="bash"?RJ(O):null,D=[];if(R?D.push({key:"cmd",node:y.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:R})}):T&&D.push({key:"primary",node:y.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:T.value})}),A&&D.push({key:"args",node:y.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:A})}),o&&o.callId===t.toolCallId)return y.jsx(ZQ,{toolName:_,args:O,pendingApproval:o,onApprove:u,onReject:d});D.length===0&&D.push({key:"running",node:y.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const I=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return t.ephemeral&&I.push("animate-pulse"),y.jsxs("div",{className:I.join(" "),children:[y.jsx("span",{className:"font-medium text-foreground",children:x}),D.map(H=>y.jsxs(q.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/65",children:"·"}),H.node]},H.key))]})}return t.type==="tool_result"?w():null};return y.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[y.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:v()}),n&&y.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),y.jsx("div",{className:m,children:E()})]})},(e,t)=>e.part.id===t.part.id&&e.part.content===t.part.content&&e.part.contentJson===t.part.contentJson&&e.part.ephemeral===t.part.ephemeral&&e.part.completedAt===t.part.completedAt&&e.showLine===t.showLine&&e.isLastToolCall===t.isLastToolCall&&e.isLastProgressUpdate===t.isLastProgressUpdate&&e.onNavigateToSession===t.onNavigateToSession&&e.pendingApproval?.callId===t.pendingApproval?.callId&&e.onApprove===t.onApprove&&e.onReject===t.onReject),NN={currentMessageId:null,queuedMessages:[],queueLength:0};function OJ(e){const{data:t}=qn({queryKey:["queueState",e],enabled:!!e,initialData:NN,staleTime:1/0});return t??NN}function aL(e,t){const n=OJ(e);if(!e||!n)return{isQueued:!1,isRunning:!1,position:null};if(n.currentMessageId===t)return{isQueued:!1,isRunning:!0,position:null};const i=n.queuedMessages.find(s=>s.messageId===t);return i?{isQueued:!0,isRunning:!1,position:i.position}:{isQueued:!1,isRunning:!1,position:null}}function DJ(e){const t=Lt();return Xt({mutationFn:n=>{if(!e)throw new Error("No session ID");return qe.createBranch(e,n)},onSuccess:()=>{t.invalidateQueries({queryKey:["sessions"]}),e&&t.invalidateQueries({queryKey:["branches",e]})}})}function sL(e){return qn({queryKey:["parentSession",e],queryFn:()=>{if(!e)throw new Error("No session ID");return qe.getParentSession(e)},enabled:!!e})}function IJ({isOpen:e,onClose:t,sessionId:n,message:i,onBranchCreated:s}){const l=CD(n),c=DJ(n),[o,u]=q.useState(""),[d,p]=q.useState(!0),f=q.useId(),m=q.useId(),v=i.parts?.find(b=>b.type==="text")?.content||"",w=(()=>{try{return JSON.parse(v)?.text?.slice(0,100)||""}catch{return v.slice(0,100)}})(),E=async b=>{b.preventDefault();try{const _=await c.mutateAsync({fromMessageId:i.id,title:o.trim()||void 0,provider:d?l?.provider:void 0,model:d?l?.model:void 0,agent:d?l?.agent:void 0});t(),s&&_.session&&s(_.session.id)}catch(_){console.error("Failed to create branch:",_)}};return y.jsx(al,{isOpen:e,onClose:t,title:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(zn,{className:"h-5 w-5 text-primary"}),y.jsx("span",{children:"Branch Session"})]}),maxWidth:"md",children:y.jsxs("form",{onSubmit:E,className:"space-y-4",children:[y.jsxs("div",{className:"text-sm text-muted-foreground",children:[y.jsx("p",{children:"Creating branch from message:"}),y.jsxs("p",{className:"mt-1 p-2 bg-muted/50 rounded text-foreground italic truncate",children:['"',w,'..."']})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("label",{htmlFor:f,className:"block text-sm font-medium text-foreground",children:"Branch Title (optional)"}),y.jsx("input",{id:f,type:"text",value:o,onChange:b=>u(b.target.value),placeholder:`Branch of ${l?.title||"Untitled"}`,className:"w-full px-3 py-2 bg-background border border-border rounded-md text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("input",{id:m,type:"checkbox",checked:d,onChange:b=>p(b.target.checked),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary/50"}),y.jsx("label",{htmlFor:m,className:"text-sm text-foreground",children:"Use same provider/model/agent as parent"})]}),l&&y.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 rounded p-2",children:y.jsxs("div",{className:"flex gap-4",children:[y.jsxs("span",{children:[y.jsx("strong",{children:"Provider:"})," ",l.provider]}),y.jsxs("span",{children:[y.jsx("strong",{children:"Model:"})," ",l.model]}),y.jsxs("span",{children:[y.jsx("strong",{children:"Agent:"})," ",l.agent]})]})}),y.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[y.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),y.jsx("button",{type:"submit",disabled:c.isPending,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:c.isPending?y.jsxs(y.Fragment,{children:[y.jsx(Ni,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):y.jsxs(y.Fragment,{children:[y.jsx(zn,{className:"h-4 w-4"}),"Create Branch"]})})]}),c.isError&&y.jsx("p",{className:"text-sm text-red-500",children:c.error?.message||"Failed to create branch"})]})})}const ON=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function LJ(e){const t=e.split("").reduce((n,i)=>n+i.charCodeAt(0),0);return ON[t%ON.length]}const oL=q.memo(function({sessionId:t,message:n,showHeader:i,hasNextAssistantMessage:s,onBranchCreated:l,compact:c,showBranchButton:o=!0,onNavigateToSession:u}){const{isQueued:d}=aL(t,n.id),[p,f]=q.useState(!1),[m,v]=q.useState(!1),[w,E]=q.useState(!1),{pendingApprovals:b,removePendingApproval:_}=$v(),x=q.useCallback(async Y=>{if(t)try{await qe.approveToolCall(t,Y,!0),_(Y)}catch(P){console.error("Failed to approve tool call:",P)}},[t,_]),S=q.useCallback(async Y=>{if(t)try{await qe.approveToolCall(t,Y,!1),_(Y)}catch(P){console.error("Failed to reject tool call:",P)}},[t,_]),k=q.useMemo(()=>b.filter(Y=>Y.messageId===n.id),[b,n.id]),O=q.useCallback(async()=>{if(t)try{await Promise.all(k.map(Y=>qe.approveToolCall(t,Y.callId,!0)));for(const Y of k)_(Y.callId)}catch(Y){console.error("Failed to approve all tool calls:",Y)}},[t,k,_]),T=q.useMemo(()=>[...n.parts||[]].sort((P,M)=>{const j=(P.index??0)-(M.index??0);return j!==0?j:(P.startedAt??0)-(M.startedAt??0)}),[n.parts]),A=T.some(Y=>Y.toolName==="finish"),R=T.reduce((Y,P,M)=>P.type==="tool_result"&&P.toolName==="progress_update"?M:Y,-1),D=R>=0?T[R]:null,L=T.some(Y=>!(Y.type==="tool_result"&&Y.toolName==="progress_update")),I=T.findIndex(Y=>!(Y.type==="tool_result"&&Y.toolName==="progress_update")),H=n.status==="pending"&&!A&&!!D,B=n.status==="pending"&&!A&&!D&&!d,W=Y=>Y?new Date(Y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",K=n.status==="complete",V=q.useCallback(()=>{const Y=T.filter(P=>P.type==="text").map(P=>{try{return JSON.parse(P.content||"{}")?.text||""}catch{return P.content||""}}).join(`
119
- `);navigator.clipboard.writeText(Y),E(!0),setTimeout(()=>E(!1),2e3)},[T]),X=q.useCallback(()=>{v(!0)},[]);return d?null:y.jsxs("div",{className:"relative group",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[i&&y.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[y.jsxs("div",{className:"inline-flex items-center bg-violet-500/10 border border-violet-500/30 dark:bg-violet-500/5 dark:border-violet-500/20 rounded-full pr-3 md:pr-4 flex-shrink min-w-0",children:[y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-violet-500/50 bg-violet-500/20 dark:bg-violet-500/10",children:y.jsx(Vo,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),y.jsxs("div",{className:"flex items-center gap-x-1.5 md:gap-x-2 text-xs md:text-sm text-muted-foreground pl-2 md:pl-3 min-w-0",children:[n.agent&&!c&&y.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300 whitespace-nowrap",children:n.agent}),n.provider&&y.jsxs(y.Fragment,{children:[!c&&n.agent&&y.jsx("span",{className:"text-muted-foreground/50",children:"·"}),y.jsx(Lc,{provider:n.provider,size:14,className:"opacity-70"})]}),n.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"hidden md:inline text-muted-foreground/50",children:"·"}),y.jsx("span",{className:`hidden md:inline text-muted-foreground ${c?"truncate max-w-[120px]":""}`,title:n.model,children:n.model})]}),n.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:W(n.createdAt)})]})]})]}),p&&K&&t&&o&&y.jsx("button",{type:"button",onClick:X,className:"ml-4 p-1.5 text-muted-foreground hover:text-primary transition-colors flex-shrink-0",title:"Branch from this message",children:y.jsx(zn,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"relative ml-1",children:[T.map((Y,P)=>{const M=P===T.length-1,j=Y.type==="tool_call"&&Y.toolCallId?b.find(he=>he.callId===Y.toolCallId)??null:null,$=Y.type==="tool_result"&&Y.toolName==="finish",U=(!M||s)&&!$,J=Y.type==="tool_call"&&M;return Y.type==="tool_result"&&Y.toolName==="progress_update"?null:y.jsx(AN,{part:Y,showLine:U,isFirstPart:P===I&&!i,isLastToolCall:J,onNavigateToSession:u,compact:c,pendingApproval:j,onApprove:x,onReject:S},Y.id)}),k.length>1&&y.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 my-2 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg",children:[y.jsx(PO,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),y.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200 flex-1",children:[k.length," tools waiting for approval"]}),y.jsxs("button",{type:"button",onClick:O,title:"Approve All (A)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-amber-600 text-white hover:bg-amber-700 transition-colors",children:[y.jsx(Q6,{className:"w-3.5 h-3.5"}),"Approve All",y.jsx("kbd",{className:"ml-1 text-[10px] opacity-70",children:"A"})]})]}),H&&D&&y.jsx(AN,{part:D,showLine:s,isFirstPart:!L&&!i,isLastProgressUpdate:!0,compact:c},D.id),B&&y.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[y.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-card text-violet-700 dark:bg-background dark:text-violet-300",children:y.jsx(Vo,{className:"h-4 w-4"})})}),y.jsx("div",{className:"flex-1 pt-0.5",children:y.jsx("div",{className:"text-base text-foreground animate-pulse",children:LJ(n.id)})})]})]}),K&&t&&y.jsx("div",{className:"grid ml-7 transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:p?"1fr":"0fr"},children:y.jsx("div",{className:"overflow-hidden",children:y.jsxs("div",{className:"flex gap-2 mt-2",children:[o&&y.jsxs("button",{type:"button",onClick:X,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:[y.jsx(zn,{className:"h-3 w-3"}),"Branch"]}),y.jsx("button",{type:"button",onClick:V,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:w?y.jsxs(y.Fragment,{children:[y.jsx(Mi,{className:"h-3 w-3 text-green-500"}),"Copied"]}):y.jsxs(y.Fragment,{children:[y.jsx(AO,{className:"h-3 w-3"}),"Copy"]})})]})})}),m&&t&&y.jsx(IJ,{isOpen:m,onClose:()=>v(!1),sessionId:t,message:n,onBranchCreated:l})]})},(e,t)=>{const n=e.message.parts||[],i=t.message.parts||[];if(n.length!==i.length)return!1;for(let s=0;s<n.length;s++){const l=n[s],c=i[s];if(l.id!==c.id||l.content!==c.content||l.contentJson!==c.contentJson||l.ephemeral!==c.ephemeral||l.completedAt!==c.completedAt)return!1}return e.message.id===t.message.id&&e.message.status===t.message.status&&e.message.completedAt===t.message.completedAt&&e.showHeader===t.showHeader&&e.hasNextAssistantMessage===t.hasNextAssistantMessage&&e.isLastMessage===t.isLastMessage&&e.sessionId===t.sessionId&&e.compact===t.compact&&e.onNavigateToSession===t.onNavigateToSession}),lL=q.memo(function({sessionId:t,message:n,nextAssistantMessageId:i}){const[s,l]=q.useState(null),c=n.parts||[],o=Lt(),{isQueued:u,position:d}=aL(t,i??""),p=av(I=>I.setPendingRestoreText),f=c.filter(I=>I.type==="text"),m=c.filter(I=>I.type==="image"),v=c.filter(I=>I.type==="file"),w=f[0];let E="";if(w){const I=w.contentJson||w.content;I&&typeof I=="object"&&"text"in I?E=String(I.text):typeof I=="string"?E=I:I&&(E=JSON.stringify(I,null,2))}const{researchContexts:b,cleanContent:_}=B7(E),x=[];for(const I of m)try{const H=I.contentJson||JSON.parse(I.content||"{}");if(H&&typeof H=="object"&&"data"in H){const B=H,W=`data:${B.mediaType};base64,${B.data}`;x.push({id:I.id,src:W})}}catch{}const S=[];for(const I of v)try{const H=I.contentJson||JSON.parse(I.content||"{}");if(H&&typeof H=="object"&&"type"in H){const B=H;if(B.type==="image"&&B.data){const W=`data:${B.mediaType};base64,${B.data}`;x.push({id:I.id,src:W})}else S.push({id:I.id,type:B.type,name:B.name})}}catch{}const k=I=>I?new Date(I).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",O=_.trim().length>0,T=x.length>0,A=S.length>0,R=b.length>0;if(!O&&!T&&!A&&!R)return null;const D=async()=>{if(!(!t||!i)){p(_);try{await qe.removeFromQueue(t,i),o.invalidateQueries({queryKey:["messages",t]})}catch(I){console.error("Failed to cancel queued message:",I)}}},L=async()=>{if(!(!t||!i))try{await qe.removeFromQueue(t,i),o.invalidateQueries({queryKey:["messages",t]})}catch(I){console.error("Failed to delete queued message:",I)}};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"relative pb-8 pt-6",children:y.jsxs("div",{className:"flex gap-3 md:gap-4 justify-end",children:[y.jsxs("div",{className:"flex flex-col items-end min-w-0 flex-1 max-w-[calc(100%-3rem)] md:max-w-2xl",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{children:k(n.createdAt)}),u&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",children:[y.jsx(RO,{className:"h-3 w-3"}),"Queued",d!==null&&d>0?` #${d+1}`:""]})]})]}),y.jsxs("div",{className:"inline-block max-w-full text-sm text-foreground leading-relaxed bg-emerald-500/5 border border-emerald-500/20 rounded-xl px-4 py-3 [word-break:break-word] overflow-hidden",children:[T&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:x.map(I=>y.jsx("button",{type:"button",onClick:()=>l(I.src),className:"w-16 h-16 rounded-lg overflow-hidden bg-muted hover:ring-2 hover:ring-primary/50 transition-all",children:y.jsx("img",{src:I.src,alt:"Attachment",className:"w-full h-full object-cover"})},I.id))}),A&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:S.map(I=>y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border",children:[I.type==="pdf"?y.jsx(Li,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):y.jsx(kc,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate max-w-[150px]",children:I.name})]},I.id))}),R&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:b.map(I=>y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-teal-600 dark:text-teal-400",children:I.label})]},I.id))}),O&&y.jsx("div",{className:"prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_*]:[word-break:break-word] [&_*]:overflow-wrap-anywhere",children:y.jsx(mI,{remarkPlugins:[PI],children:_})})]}),u&&y.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[y.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors",title:"Cancel and restore to input",children:[y.jsx(FO,{className:"h-3 w-3"}),"Cancel"]}),y.jsxs("button",{type:"button",onClick:L,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-destructive/10 hover:bg-destructive/20 text-destructive transition-colors",title:"Delete from queue",children:[y.jsx(zv,{className:"h-3 w-3"}),"Delete"]})]})]}),y.jsx("div",{className:"flex-shrink-0 w-8 flex items-start justify-center",children:y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-emerald-500/50 bg-emerald-500/20 dark:bg-emerald-500/10 relative bg-background",children:y.jsx(qv,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})})})]})}),s&&y.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>l(null),onKeyDown:I=>I.key==="Escape"&&l(null),tabIndex:-1,children:[y.jsx("button",{type:"button",onClick:()=>l(null),className:"absolute top-4 right-4 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:y.jsx(Un,{className:"w-6 h-6 text-white"})}),y.jsx("img",{src:s,alt:"Expanded attachment",className:"max-w-full max-h-full object-contain rounded-lg",onClick:I=>I.stopPropagation(),onKeyDown:I=>I.key==="Enter"&&I.stopPropagation()})]})]})},(e,t)=>{const n=e.message.parts?.[0],i=t.message.parts?.[0];return e.message.id===t.message.id&&n?.content===i?.content&&n?.contentJson===i?.contentJson&&e.message.createdAt===t.message.createdAt&&e.message.parts?.length===t.message.parts?.length&&e.sessionId===t.sessionId&&e.nextAssistantMessageId===t.nextAssistantMessageId}),MJ={openai:{id:"openai",models:[{id:"codex-mini-latest",label:"Codex Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-04",releaseDate:"2025-05-16",lastUpdated:"2025-05-16",openWeights:!1,cost:{input:1.5,output:6,cacheRead:.375},limit:{context:2e5,output:1e5}},{id:"gpt-3.5-turbo",label:"GPT-3.5-turbo",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2021-09-01",releaseDate:"2023-03-01",lastUpdated:"2023-11-06",openWeights:!1,cost:{input:.5,output:1.5,cacheRead:1.25},limit:{context:16385,output:4096}},{id:"gpt-4",label:"GPT-4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-11",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:30,output:60},limit:{context:8192,output:8192}},{id:"gpt-4-turbo",label:"GPT-4 Turbo",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:10,output:30},limit:{context:128e3,output:4096}},{id:"gpt-4.1",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"gpt-4.1-mini",label:"GPT-4.1 mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"gpt-4.1-nano",label:"GPT-4.1 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.03},limit:{context:1047576,output:32768}},{id:"gpt-4o",label:"GPT-4o",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-05-13",label:"GPT-4o (2024-05-13)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:5,output:15},limit:{context:128e3,output:4096}},{id:"gpt-4o-2024-08-06",label:"GPT-4o (2024-08-06)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-08-06",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-11-20",label:"GPT-4o (2024-11-20)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-11-20",lastUpdated:"2024-11-20",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-mini",label:"GPT-4o mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-chat-latest",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"gpt-5-codex",label:"GPT-5-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-mini",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4,cacheRead:.005},limit:{context:4e5,output:128e3}},{id:"gpt-5-pro",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.13},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-chat-latest",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"gpt-5.1-codex",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-chat-latest",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.2-codex",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-pro",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"o1",label:"o1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2024-12-05",lastUpdated:"2024-12-05",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:2e5,output:1e5}},{id:"o1-mini",label:"o1-mini",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:128e3,output:65536}},{id:"o1-preview",label:"o1-preview",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:128e3,output:32768}},{id:"o1-pro",label:"o1-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2025-03-19",lastUpdated:"2025-03-19",openWeights:!1,cost:{input:150,output:600},limit:{context:2e5,output:1e5}},{id:"o3",label:"o3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"o3-deep-research",label:"o3-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:10,output:40,cacheRead:2.5},limit:{context:2e5,output:1e5}},{id:"o3-mini",label:"o3-mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-05",releaseDate:"2024-12-20",lastUpdated:"2025-01-29",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:2e5,output:1e5}},{id:"o3-pro",label:"o3-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-06-10",lastUpdated:"2025-06-10",openWeights:!1,cost:{input:20,output:80},limit:{context:2e5,output:1e5}},{id:"o4-mini",label:"o4-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"o4-mini-deep-research",label:"o4-mini-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"text-embedding-3-large",label:"text-embedding-3-large",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.13,output:0},limit:{context:8191,output:3072}},{id:"text-embedding-3-small",label:"text-embedding-3-small",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.02,output:0},limit:{context:8191,output:1536}},{id:"text-embedding-ada-002",label:"text-embedding-ada-002",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2022-12",releaseDate:"2022-12-15",lastUpdated:"2022-12-15",openWeights:!1,cost:{input:.1,output:0},limit:{context:8192,output:1536}}],label:"OpenAI",env:["OPENAI_API_KEY"],npm:"@ai-sdk/openai",doc:"https://platform.openai.com/docs/models"},anthropic:{id:"anthropic",models:[{id:"claude-3-5-haiku-20241022",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-haiku-latest",label:"Claude Haiku 3.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20240620",label:"Claude Sonnet 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-06-20",lastUpdated:"2024-06-20",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20241022",label:"Claude Sonnet 3.5 v2",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-7-sonnet-20250219",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-7-sonnet-latest",label:"Claude Sonnet 3.7 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-haiku-20240307",label:"Claude Haiku 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-13",lastUpdated:"2024-03-13",openWeights:!1,cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-3-opus-20240229",label:"Claude Opus 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-02-29",lastUpdated:"2024-02-29",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:4096}},{id:"claude-3-sonnet-20240229",label:"Claude Sonnet 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-04",lastUpdated:"2024-03-04",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-0",label:"Claude Opus 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1",label:"Claude Opus 4.1 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1-20250805",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-20250514",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-5",label:"Claude Opus 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-5-20251101",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-01",lastUpdated:"2025-11-01",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-0",label:"Claude Sonnet 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-20250514",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5",label:"Claude Sonnet 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5-20250929",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}}],label:"Anthropic",env:["ANTHROPIC_API_KEY"],npm:"@ai-sdk/anthropic",doc:"https://docs.anthropic.com/en/docs/about-claude/models"},google:{id:"google",models:[{id:"gemini-1.5-flash",label:"Gemini 1.5 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-05-14",lastUpdated:"2024-05-14",openWeights:!1,cost:{input:.075,output:.3,cacheRead:.01875},limit:{context:1e6,output:8192}},{id:"gemini-1.5-flash-8b",label:"Gemini 1.5 Flash-8B",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-10-03",lastUpdated:"2024-10-03",openWeights:!1,cost:{input:.0375,output:.15,cacheRead:.01},limit:{context:1e6,output:8192}},{id:"gemini-1.5-pro",label:"Gemini 1.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-02-15",lastUpdated:"2024-02-15",openWeights:!1,cost:{input:1.25,output:5,cacheRead:.3125},limit:{context:1e6,output:8192}},{id:"gemini-2.0-flash",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"gemini-2.0-flash-lite",label:"Gemini 2.0 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.075,output:.3},limit:{context:1048576,output:8192}},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-image",label:"Gemini 2.5 Flash Image",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-image-preview",label:"Gemini 2.5 Flash Image (Preview)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-06-17",label:"Gemini 2.5 Flash Lite Preview 06-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-09-2025",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-04-17",label:"Gemini 2.5 Flash Preview 04-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-05-20",label:"Gemini 2.5 Flash Preview 05-20",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-09-2025",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-tts",label:"Gemini 2.5 Flash Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:.5,output:10},limit:{context:8e3,output:16e3}},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-05-06",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-06-05",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-tts",label:"Gemini 2.5 Pro Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:1,output:20},limit:{context:8e3,output:16e3}},{id:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1e6,output:64e3}},{id:"gemini-embedding-001",label:"Gemini Embedding 001",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:0},limit:{context:2048,output:3072}},{id:"gemini-flash-latest",label:"Gemini Flash Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-flash-lite-latest",label:"Gemini Flash-Lite Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-live-2.5-flash",label:"Gemini Live 2.5 Flash",modalities:{input:["text","image","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-01",lastUpdated:"2025-09-01",openWeights:!1,cost:{input:.5,output:2},limit:{context:128e3,output:8e3}},{id:"gemini-live-2.5-flash-preview-native-audio",label:"Gemini Live 2.5 Flash Preview Native Audio",modalities:{input:["text","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-09-18",openWeights:!1,cost:{input:.5,output:2},limit:{context:131072,output:65536}}],label:"Google",env:["GOOGLE_GENERATIVE_AI_API_KEY","GEMINI_API_KEY"],npm:"@ai-sdk/google",doc:"https://ai.google.dev/gemini-api/docs/pricing"},openrouter:{id:"openrouter",models:[{id:"anthropic/claude-3.5-haiku",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"anthropic/claude-3.7-sonnet",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-01",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:128e3}},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-opus-4",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.1",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.5",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-30",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}},{id:"cognitivecomputations/dolphin3.0-mistral-24b",label:"Dolphin3.0 Mistral 24B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-13",lastUpdated:"2025-02-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"cognitivecomputations/dolphin3.0-r1-mistral-24b",label:"Dolphin3.0 R1 Mistral 24B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-13",lastUpdated:"2025-02-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"deepseek/deepseek-chat-v3-0324",label:"DeepSeek V3 0324",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:16384,output:8192}},{id:"deepseek/deepseek-chat-v3.1",label:"DeepSeek-V3.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-08-21",lastUpdated:"2025-08-21",openWeights:!0,cost:{input:.2,output:.8},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1-0528-qwen3-8b:free",label:"Deepseek R1 0528 Qwen3 8B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-29",lastUpdated:"2025-05-29",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"deepseek/deepseek-r1-0528:free",label:"R1 0528 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-28",lastUpdated:"2025-05-28",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1-distill-llama-70b",label:"DeepSeek R1 Distill Llama 70B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-23",lastUpdated:"2025-01-23",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"deepseek/deepseek-r1-distill-qwen-14b",label:"DeepSeek R1 Distill Qwen 14B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-29",lastUpdated:"2025-01-29",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:8192}},{id:"deepseek/deepseek-r1:free",label:"R1 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-01-20",lastUpdated:"2025-01-20",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-v3-base:free",label:"DeepSeek V3 Base (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-29",lastUpdated:"2025-03-29",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-v3.1-terminus",label:"DeepSeek V3.1 Terminus",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.1-terminus:exacto",label:"DeepSeek V3.1 Terminus (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.28,output:.4},limit:{context:163840,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"deepseek/deepseek-v3.2-speciale",label:"DeepSeek V3.2 Speciale",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.27,output:.41},limit:{context:163840,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"featherless/qwerky-72b",label:"Qwerky 72B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-20",lastUpdated:"2025-03-20",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"google/gemini-2.0-flash-exp:free",label:"Gemini 2.0 Flash Experimental (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:1048576,output:1048576}},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-07-17",lastUpdated:"2025-07-17",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite-preview-09-2025",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-preview-09-2025",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.031},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-05-06",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-06-05",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-3-flash-preview",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"google/gemini-3-pro-preview",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11",openWeights:!1,cost:{input:2,output:12},limit:{context:105e4,output:66e3},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"google/gemma-2-9b-it:free",label:"Gemma 2 9B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-06",releaseDate:"2024-06-28",lastUpdated:"2024-06-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"google/gemma-3-12b-it",label:"Gemma 3 12B IT",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"google/gemma-3-27b-it",label:"Gemma 3 27B IT",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"google/gemma-3n-e4b-it",label:"Gemma 3n E4B IT",modalities:{input:["text","image","audio"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"google/gemma-3n-e4b-it:free",label:"Gemma 3n 4B (free)",modalities:{input:["text","image","audio"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"kwaipilot/kat-coder-pro:free",label:"Kat Coder Pro (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-10",lastUpdated:"2025-11-10",openWeights:!1,cost:{input:0,output:0},limit:{context:256e3,output:65536}},{id:"meta-llama/llama-3.2-11b-vision-instruct",label:"Llama 3.2 11B Vision Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-06",lastUpdated:"2024-12-06",openWeights:!0,cost:{input:0,output:0},limit:{context:65536,output:65536}},{id:"meta-llama/llama-4-scout:free",label:"Llama 4 Scout (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2025-04-05",lastUpdated:"2025-04-05",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:64e3}},{id:"microsoft/mai-ds-r1:free",label:"MAI DS R1 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-21",lastUpdated:"2025-04-21",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"minimax/minimax-01",label:"MiniMax-01",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:1e6,output:1e6}},{id:"minimax/minimax-m1",label:"MiniMax M1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!0,cost:{input:.4,output:2.2},limit:{context:1e6,output:4e4}},{id:"minimax/minimax-m2",label:"MiniMax M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-23",lastUpdated:"2025-10-23",openWeights:!0,cost:{input:.28,output:1.15,cacheRead:.28,cacheWrite:1.15},limit:{context:196600,output:118e3},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"minimax/minimax-m2.1",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"mistralai/codestral-2508",label:"Codestral 2508",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-01",lastUpdated:"2025-08-01",openWeights:!0,cost:{input:.3,output:.9},limit:{context:256e3,output:256e3}},{id:"mistralai/devstral-2512",label:"Devstral 2 2512",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/devstral-2512:free",label:"Devstral 2 2512 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:262144}},{id:"mistralai/devstral-medium-2507",label:"Devstral Medium",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/devstral-small-2505",label:"Devstral Small",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!0,cost:{input:.06,output:.12},limit:{context:128e3,output:128e3}},{id:"mistralai/devstral-small-2505:free",label:"Devstral Small 2505 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-21",lastUpdated:"2025-05-21",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"mistralai/devstral-small-2507",label:"Devstral Small 1.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.1,output:.3},limit:{context:131072,output:131072}},{id:"mistralai/mistral-7b-instruct:free",label:"Mistral 7B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-05",releaseDate:"2024-05-27",lastUpdated:"2024-05-27",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"mistralai/mistral-medium-3",label:"Mistral Medium 3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!1,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3.1",label:"Mistral Medium 3.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-12",lastUpdated:"2025-08-12",openWeights:!1,cost:{input:.4,output:2},limit:{context:262144,output:262144}},{id:"mistralai/mistral-nemo:free",label:"Mistral Nemo (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2024-07-19",lastUpdated:"2024-07-19",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"mistralai/mistral-small-3.1-24b-instruct",label:"Mistral Small 3.1 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-17",lastUpdated:"2025-03-17",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct",label:"Mistral Small 3.2 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct:free",label:"Mistral Small 3.2 24B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:96e3}},{id:"moonshotai/kimi-dev-72b:free",label:"Kimi Dev 72b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-06-16",lastUpdated:"2025-06-16",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"moonshotai/kimi-k2",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:.55,output:2.2},limit:{context:131072,output:32768}},{id:"moonshotai/kimi-k2-0905",label:"Kimi K2 Instruct 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-0905:exacto",label:"Kimi K2 Instruct 0905 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"moonshotai/kimi-k2:free",label:"Kimi K2 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32800,output:32800}},{id:"moonshotai/kimi-k2.5",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"nousresearch/deephermes-3-llama-3-8b-preview",label:"DeepHermes 3 Llama 3 8B Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2025-02-28",lastUpdated:"2025-02-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"nousresearch/hermes-4-405b",label:"Hermes 4 405B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:1,output:3},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-70b",label:"Hermes 4 70B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:.13,output:.4},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-nano-9b-v2",label:"nvidia-nemotron-nano-9b-v2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-08-18",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:.04,output:.16},limit:{context:131072,output:131072}},{id:"openai/gpt-4.1",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"openai/gpt-4.1-mini",label:"GPT-4.1 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"openai/gpt-4o-mini",label:"GPT-4o-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"openai/gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-chat",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-codex",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-image",label:"GPT-5 Image",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-10-14",lastUpdated:"2025-10-14",openWeights:!1,cost:{input:5,output:10,cacheRead:1.25},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-mini",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-pro",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"openai/gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-chat",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.1-codex",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-max",label:"GPT-5.1-Codex-Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.1,output:9,cacheRead:.11},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-mini",label:"GPT-5.1-Codex-Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:1e5}},{id:"openai/gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-chat-latest",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.2-codex",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-pro",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"openai/gpt-oss-120b",label:"GPT OSS 120B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.072,output:.28},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:exacto",label:"GPT OSS 120B (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.24},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b",label:"GPT OSS 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.2},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-safeguard-20b",label:"GPT OSS Safeguard 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-29",lastUpdated:"2025-10-29",openWeights:!1,cost:{input:.075,output:.3},limit:{context:131072,output:65536}},{id:"openai/o4-mini",label:"o4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"openrouter/sherlock-dash-alpha",label:"Sherlock Dash Alpha",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-15",lastUpdated:"2025-12-14",openWeights:!1,cost:{input:0,output:0},limit:{context:184e4,output:0}},{id:"openrouter/sherlock-think-alpha",label:"Sherlock Think Alpha",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-15",lastUpdated:"2025-12-14",openWeights:!1,cost:{input:0,output:0},limit:{context:184e4,output:0}},{id:"qwen/qwen-2.5-coder-32b-instruct",label:"Qwen2.5 Coder 32B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2024-11-11",lastUpdated:"2024-11-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen2.5-vl-32b-instruct:free",label:"Qwen2.5 VL 32B Instruct (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"qwen/qwen2.5-vl-72b-instruct",label:"Qwen2.5 VL 72B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen2.5-vl-72b-instruct:free",label:"Qwen2.5 VL 72B Instruct (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-02",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"qwen/qwen3-14b:free",label:"Qwen3 14B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-235b-a22b-07-25",label:"Qwen3 235B A22B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:.15,output:.85},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-07-25:free",label:"Qwen3 235B A22B Instruct 2507 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-thinking-2507",label:"Qwen3 235B A22B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-25",lastUpdated:"2025-07-25",openWeights:!0,cost:{input:.078,output:.312},limit:{context:262144,output:81920}},{id:"qwen/qwen3-235b-a22b:free",label:"Qwen3 235B A22B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"qwen/qwen3-30b-a3b-instruct-2507",label:"Qwen3 30B A3B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b-thinking-2507",label:"Qwen3 30B A3B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b:free",label:"Qwen3 30B A3B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-32b:free",label:"Qwen3 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-8b:free",label:"Qwen3 8B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:262144,output:66536}},{id:"qwen/qwen3-coder-30b-a3b-instruct",label:"Qwen3 Coder 30B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-31",lastUpdated:"2025-07-31",openWeights:!0,cost:{input:.07,output:.27},limit:{context:16e4,output:65536}},{id:"qwen/qwen3-coder-flash",label:"Qwen3 Coder Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!1,cost:{input:.3,output:1.5},limit:{context:128e3,output:66536}},{id:"qwen/qwen3-coder:exacto",label:"Qwen3 Coder (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.38,output:1.53},limit:{context:131072,output:32768}},{id:"qwen/qwen3-coder:free",label:"Qwen3 Coder 480B A35B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:66536}},{id:"qwen/qwen3-max",label:"Qwen3 Max",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!1,cost:{input:1.2,output:6},limit:{context:262144,output:32768}},{id:"qwen/qwen3-next-80b-a3b-instruct",label:"Qwen3 Next 80B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3-next-80b-a3b-thinking",label:"Qwen3 Next 80B A3B Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwq-32b:free",label:"QwQ 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-05",lastUpdated:"2025-03-05",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"rekaai/reka-flash-3",label:"Reka Flash 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"sarvamai/sarvam-m:free",label:"Sarvam-M (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-25",lastUpdated:"2025-05-25",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"thudm/glm-z1-32b:free",label:"GLM Z1 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"tngtech/deepseek-r1t2-chimera:free",label:"DeepSeek R1T2 Chimera (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-08",lastUpdated:"2025-07-08",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"x-ai/grok-3",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-beta",label:"Grok 3 Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini-beta",label:"Grok 3 Mini Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-4",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:256e3,output:64e3}},{id:"x-ai/grok-4-fast",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-08-19",lastUpdated:"2025-08-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.1-fast",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-code-fast-1",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"z-ai/glm-4.5",label:"GLM 4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air",label:"GLM 4.5 Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air:free",label:"GLM 4.5 Air (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5v",label:"GLM 4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"z-ai/glm-4.6",label:"GLM 4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.6:exacto",label:"GLM 4.6 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:1.9,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:204800,output:131072},provider:{npm:"@openrouter/ai-sdk-provider"}}],label:"OpenRouter",env:["OPENROUTER_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models"},opencode:{id:"opencode",models:[{id:"big-pickle",label:"Big Pickle",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-10-17",lastUpdated:"2025-10-17",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:128e3}},{id:"claude-3-5-haiku",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-1",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-5",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-5",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"gemini-3-flash",label:"Gemini 3 Flash",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3-pro",label:"Gemini 3 Pro",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7-free",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-codex",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2-codex",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"grok-code",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-08-20",lastUpdated:"2025-08-20",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:256e3,output:256e3}},{id:"kimi-k2",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2.5",label:"Kimi K2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:1.2,output:1.2,cacheRead:.6},limit:{context:262144,output:262144}},{id:"minimax-m2.1",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"minimax-m2.1-free",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.45,output:1.8},limit:{context:262144,output:65536}}],label:"OpenCode Zen",env:["OPENCODE_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://opencode.ai/zen/v1",doc:"https://opencode.ai/docs/zen"},zai:{id:"zai",models:[{id:"glm-4.5",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:.3,output:.9},limit:{context:128e3,output:32768}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}}],label:"Z.AI",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/paas/v4",doc:"https://docs.z.ai/guides/overview/pricing"},"zai-coding":{id:"zai-coding",models:[{id:"glm-4.5",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:16384}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:32768}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.7-flash",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI Coding Plan",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/coding/paas/v4",doc:"https://docs.z.ai/devpack/overview"},moonshot:{id:"moonshot",models:[{id:"kimi-k2-0711-preview",label:"Kimi K2 0711",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-14",lastUpdated:"2025-07-14",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:131072,output:16384}},{id:"kimi-k2-0905-preview",label:"Kimi K2 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking-turbo",label:"Kimi K2 Thinking Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:1.15,output:8,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-turbo-preview",label:"Kimi K2 Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:2.4,output:10,cacheRead:.6},limit:{context:262144,output:262144}}],label:"Moonshot AI",env:["MOONSHOT_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.moonshot.ai/v1",doc:"https://platform.moonshot.ai/docs/api/chat"}},uL="solforge",BJ=e=>!!(e==="codex-mini-latest"||e.startsWith("gpt-5")||e.includes("codex")),FJ=e=>!!(e.includes("-3-5-")||e.includes("-3.5-")||e.match(/claude-(haiku|sonnet|opus)-3/)||e.includes("-4-")||e.includes("-4.")||e.match(/claude-(haiku|sonnet|opus)-4/)),jJ=[{id:"openai",npm:"@ai-sdk/openai"},{id:"anthropic",npm:"@ai-sdk/anthropic"}];function PJ(e){return{...e,modalities:e.modalities?{input:e.modalities.input?[...e.modalities.input]:void 0,output:e.modalities.output?[...e.modalities.output]:void 0}:void 0,cost:e.cost?{...e.cost}:void 0,limit:e.limit?{...e.limit}:void 0,provider:e.provider?{...e.provider}:void 0}}function UJ(e){const t=jJ.flatMap(({id:s,npm:l})=>(e[s]?.models??[]).filter(u=>s==="openai"?BJ(u.id):s==="anthropic"?FJ(u.id):!0).map(u=>{const d=PJ(u);return d.provider={...d.provider??{},npm:l},d}));if(!t.length)return null;t.sort((s,l)=>{const c=s.provider?.npm??"",o=l.provider?.npm??"";return c===o?s.id.localeCompare(l.id):c==="@ai-sdk/openai"?-1:o==="@ai-sdk/openai"?1:c.localeCompare(o)});const n="codex-mini-latest",i=t.findIndex(s=>s.id===n);if(i>0){const[s]=t.splice(i,1);t.unshift(s)}return{id:uL,label:"Solforge",env:["SOLFORGE_PRIVATE_KEY"],api:"https://router.solforge.sh/v1",doc:"https://router.solforge.sh/docs",models:t}}function HJ(e){const t=UJ(e),n={...e};return t&&(n[uL]=t),n}const zJ=HJ(MJ),qJ={openai:[{match:e=>e.includes("gpt-4o-mini"),inputPerMillion:.15,outputPerMillion:.6},{match:e=>e.includes("gpt-4o"),inputPerMillion:5,outputPerMillion:15},{match:e=>e.includes("gpt-4.1-mini"),inputPerMillion:1,outputPerMillion:4},{match:e=>e.includes("gpt-4.1"),inputPerMillion:5,outputPerMillion:15}],anthropic:[{match:e=>e.includes("claude-3-haiku"),inputPerMillion:.25,outputPerMillion:1.25},{match:e=>e.includes("claude-3-sonnet"),inputPerMillion:3,outputPerMillion:15},{match:e=>e.includes("claude-3-opus"),inputPerMillion:15,outputPerMillion:75}],google:[{match:e=>e.includes("gemini-1.5-flash"),inputPerMillion:.35,outputPerMillion:1.05},{match:e=>e.includes("gemini-1.5-pro"),inputPerMillion:3.5,outputPerMillion:10.5}],openrouter:[],opencode:[],solforge:[],zai:[],"zai-coding":[],moonshot:[]};function $J(e,t){const n=qJ[e];if(n)return n.find(i=>{try{return i.match(t)}catch{return!1}})}function GJ(e,t){const n=zJ[e];if(!n)return;const i=t.toLowerCase();return n.models.find(s=>s.id?.toLowerCase()===i)}function cL(e,t,n){const i=typeof n.inputTokens=="number"?n.inputTokens:0,s=typeof n.outputTokens=="number"?n.outputTokens:0,l=typeof n.cachedInputTokens=="number"?n.cachedInputTokens:0,c=typeof n.cacheCreationInputTokens=="number"?n.cacheCreationInputTokens:0;if(!i&&!s&&!l&&!c)return;const o=GJ(e,t);if(o?.cost?.input!=null||o?.cost?.output!=null){const m=typeof o.cost?.input=="number"?o.cost.input:0,v=typeof o.cost?.output=="number"?o.cost.output:0,w=typeof o.cost?.cacheRead=="number"?o.cost.cacheRead:0,E=typeof o.cost?.cacheWrite=="number"?o.cost.cacheWrite:0,b=i*m/1e6,_=s*v/1e6,x=l*w/1e6,S=c*E/1e6,k=b+_+x+S;return Number.isFinite(k)?Number(k.toFixed(6)):void 0}const u=$J(e,t.toLowerCase());if(!u)return;const d=i*u.inputPerMillion/1e6,p=s*u.outputPerMillion/1e6,f=d+p;return Number.isFinite(f)?Number(f.toFixed(6)):void 0}function WJ({session:e,onNavigateToSession:t}){const{data:n}=sL(e.sessionType==="branch"?e.id:void 0),{data:i}=Xv(e.id),s=q.useMemo(()=>{const v=e.totalInputTokens||0,w=e.totalOutputTokens||0,E=e.totalCachedTokens||0,b=e.totalCacheCreationTokens||0;return cL(e.provider,e.model,{inputTokens:v,outputTokens:w,cachedInputTokens:E,cacheCreationInputTokens:b})??0},[e.provider,e.model,e.totalInputTokens,e.totalOutputTokens,e.totalCachedTokens,e.totalCacheCreationTokens]),l=v=>{if(!v)return"0s";const w=Math.floor(v/1e3),E=Math.floor(w/60),b=Math.floor(E/60);return b>0?`${b}h ${E%60}m`:E>0?`${E}m ${w%60}s`:`${w}s`},c=v=>v.toLocaleString("en-US"),o=v=>v>=1e6?`${(v/1e6).toFixed(1)}M`:v>=1e3?`${(v/1e3).toFixed(1)}K`:v.toString(),u=e.totalInputTokens||0,d=e.totalOutputTokens||0,p=e.totalCachedTokens||0,f=e.sessionType==="branch",m=n?.parent;return y.jsx("div",{className:"border-b border-border bg-background/95 backdrop-blur-sm",children:y.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[f&&y.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm",children:[y.jsx(zn,{className:"h-4 w-4 text-violet-500"}),y.jsx("span",{className:"text-violet-600 dark:text-violet-400 font-medium",children:"Branch"}),m&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground",children:"from"}),y.jsxs("button",{type:"button",onClick:()=>t?.(m.id),className:"text-primary hover:underline flex items-center gap-1",children:[m.title||`Session ${m.id.slice(0,8)}`,y.jsx(wO,{className:"h-3 w-3"})]})]}),!m&&e.parentSessionId&&y.jsx("span",{className:"text-muted-foreground italic text-xs",children:"(parent deleted)"})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("h1",{className:"text-2xl font-semibold text-foreground leading-tight truncate",children:e.title||"Untitled Session"}),i?.shared&&y.jsxs("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[y.jsx(Hv,{className:"h-3 w-3"}),y.jsx("span",{children:"Shared"}),i.pendingMessages&&i.pendingMessages>0?y.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[y.jsx(Ea,{className:"h-2.5 w-2.5"}),i.pendingMessages]}):y.jsx(wr,{className:"h-2.5 w-2.5 opacity-60"})]})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 mt-4 text-sm text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(u)} input tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"in"}),y.jsx("span",{className:"font-medium text-foreground",children:o(u)})]}),y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(d)} output tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"out"}),y.jsx("span",{className:"font-medium text-foreground",children:o(d)})]}),p>0&&y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(p)} cached tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"cached"}),y.jsx("span",{className:"font-medium text-foreground",children:o(p)})]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(RO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium text-foreground",children:l(e.totalToolTimeMs)})]}),s>0&&y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(NO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium text-foreground",children:s.toFixed(4)})]}),y.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[y.jsx(Lc,{provider:e.provider,size:18}),y.jsx("span",{className:"font-medium text-foreground truncate max-w-48",children:e.model})]})]})]})})}function VJ({session:e,isVisible:t,isGenerating:n,onNavigateToSession:i}){const{data:s}=sL(e.sessionType==="branch"?e.id:void 0),{data:l}=Xv(e.id),c=q.useMemo(()=>{const m=e.totalInputTokens||0,v=e.totalOutputTokens||0,w=e.totalCachedTokens||0,E=e.totalCacheCreationTokens||0;return cL(e.provider,e.model,{inputTokens:m,outputTokens:v,cachedInputTokens:w,cacheCreationInputTokens:E})??0},[e.provider,e.model,e.totalInputTokens,e.totalOutputTokens,e.totalCachedTokens,e.totalCacheCreationTokens]),o=m=>m>=1e6?`${(m/1e6).toFixed(1)}M`:m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString(),u=e.totalInputTokens||0,d=e.totalOutputTokens||0,p=e.sessionType==="branch",f=s?.parent;return y.jsx("div",{className:`absolute top-0 left-0 right-0 h-14 border-b border-border bg-background/95 backdrop-blur-sm z-10 transition-transform duration-200 ${t?"translate-y-0":"-translate-y-full"}`,children:y.jsxs("div",{className:"h-full px-6 flex items-center justify-between gap-4 text-sm",children:[y.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 text-muted-foreground",children:[p?y.jsx(zn,{className:"w-4 h-4 flex-shrink-0 text-violet-500"}):y.jsx(BO,{className:"w-4 h-4 flex-shrink-0"}),y.jsx("span",{className:"text-foreground font-medium truncate",children:e.title||"Untitled Session"}),l?.shared&&y.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[y.jsx(Hv,{className:"h-3 w-3"}),l.pendingMessages&&l.pendingMessages>0?y.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[y.jsx(Ea,{className:"h-2.5 w-2.5"}),l.pendingMessages]}):y.jsx(wr,{className:"h-2.5 w-2.5 opacity-60"})]}),p&&f&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:"from"}),y.jsxs("button",{type:"button",onClick:()=>i?.(f.id),className:"text-primary hover:underline flex items-center gap-0.5 truncate max-w-32",title:f.title||`Session ${f.id.slice(0,8)}`,children:[y.jsx("span",{className:"truncate",children:f.title||`Session ${f.id.slice(0,8)}`}),y.jsx(wO,{className:"h-3 w-3 flex-shrink-0"})]})]})]}),y.jsxs("div",{className:"flex-shrink-0 flex items-center gap-5 text-muted-foreground",children:[n&&y.jsx(H7,{sessionId:e.id}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs opacity-70",children:"in"}),y.jsx("span",{className:"text-foreground font-medium",children:o(u)})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs opacity-70",children:"out"}),y.jsx("span",{className:"text-foreground font-medium",children:o(d)})]})]}),c>0&&y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(NO,{className:"w-4 h-4"}),y.jsx("span",{className:"text-foreground font-medium",children:c.toFixed(4)})]}),y.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[y.jsx(Lc,{provider:e.provider,size:16}),y.jsx("span",{className:"font-medium text-foreground truncate max-w-40",children:e.model})]})]})]})})}const KJ=q.memo(function({messages:t,session:n,sessionId:i,isGenerating:s,disableAutoScroll:l=!1,onSelectSession:c}){const o=q.useRef(null),u=q.useRef(null),d=q.useRef(null),[p,f]=q.useState(!0),m=q.useRef(!0),[v,w]=q.useState(!1),E=q.useRef(!1),b=q.useRef(void 0),_=q.useRef(0),x=q.useRef(void 0),S=q.useRef(!1),k=q.useRef(n?.id),O=q.useRef(t.length),T=q.useRef(s),A=q.useRef(0),R=q.useRef(0),D=q.useCallback(()=>{const H=u.current;if(!H)return;const{scrollTop:B,scrollHeight:W,clientHeight:K}=H,V=W-B-K,X=W>A.current,Y=B<R.current-5;A.current=W,R.current=B,V<100?(m.current=!0,f(!0)):Y?(m.current=!1,f(!1),E.current=!0):!X&&m.current&&(m.current=!1,f(!1)),(Y||!m.current&&V>=100)&&(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{E.current=!1},150));const P=d.current;if(P){const M=P.getBoundingClientRect(),j=H.getBoundingClientRect();w(M.bottom<j.top)}},[]);q.useEffect(()=>{if(l)return;const H=n?.id!==k.current;if(k.current=n?.id,H&&(S.current=!1),!S.current&&t.length>0){S.current=!0;const B=u.current;B&&(B.scrollTop=B.scrollHeight)}},[t.length,n?.id]),q.useEffect(()=>{if(l)return;const H=s&&!T.current,B=t.length>O.current;T.current=s,O.current=t.length,H?(E.current=!1,m.current=!0,f(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const W=u.current;W&&(W.scrollTop=W.scrollHeight)})})):B&&!E.current&&!s&&(m.current=!0,f(!0))},[t.length,s]),q.useEffect(()=>{if(l)return;const H=u.current;if(!H||!p||E.current)return;_.current=H.scrollHeight-H.clientHeight;const B=()=>{const W=u.current;if(!W||E.current)return;const K=W.scrollTop,X=W.scrollHeight-W.clientHeight-K;if(Math.abs(X)<1){W.scrollTop=W.scrollHeight-W.clientHeight;return}if(Math.abs(X)<10){W.scrollTop=W.scrollHeight-W.clientHeight;return}W.scrollTop=K+X*.15,x.current=requestAnimationFrame(B)};x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(B)},[t,p]),q.useEffect(()=>()=>{b.current&&clearTimeout(b.current),x.current&&cancelAnimationFrame(x.current)},[]);const L=()=>{E.current=!1,m.current=!0,f(!0);const H=u.current;H&&(H.scrollTop=H.scrollHeight)},I=q.useMemo(()=>t.filter(H=>H.role!=="system"),[t]);return t.length===0?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):y.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[n&&y.jsx(VJ,{session:n,isVisible:v,isGenerating:s,onNavigateToSession:c}),y.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto",onScroll:D,children:[y.jsx("div",{ref:d,children:n&&y.jsx(WJ,{session:n,onNavigateToSession:c})}),y.jsx("div",{className:"p-6 pb-64",children:y.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[I.map((H,B)=>{const W=I[B-1],K=I[B+1],V=B===I.length-1;if(H.role==="user"){const X=K&&K.role==="assistant"?K:void 0;return y.jsx(lL,{sessionId:i,message:H,isFirst:B===0,nextAssistantMessageId:X?.id},H.id)}if(H.role==="assistant"){const X=!W||W.role!=="assistant",Y=K&&K.role==="assistant";return y.jsx(oL,{sessionId:i,message:H,showHeader:X,hasNextAssistantMessage:Y,isLastMessage:V,onBranchCreated:c},H.id)}return null}),y.jsx("div",{ref:o})]})})]}),!p&&y.jsxs("button",{type:"button",onClick:L,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[y.jsx(P6,{className:"w-4 h-4"}),y.jsx("span",{children:"Scroll to bottom"})]})]})});class dL{abortController=null;handlers=new Map;running=!1;async connect(t){this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.running=!0;try{const n=await fetch(t,{headers:{Accept:"text/event-stream"},signal:this.abortController.signal});if(!n.ok){console.error("[SSE] Connection failed:",n.status);return}const i=n.body?.getReader();if(!i){console.error("[SSE] No response body");return}const s=new TextDecoder;let l="";for(;this.running;){const{done:c,value:o}=await i.read();if(c)break;l+=s.decode(o,{stream:!0});let u=l.indexOf(`
118
+ `),maxHeight:"max-h-80",children:y.jsx("div",{className:"divide-y divide-border/50",children:f.map((b,_)=>y.jsxs("div",{className:"px-3 py-2 hover:bg-muted/20",children:[y.jsxs("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:[b.title,y.jsx(wr,{className:"h-3 w-3 flex-shrink-0"})]}),y.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:b.snippet}),y.jsx("p",{className:"text-xs text-muted-foreground/60 truncate mt-0.5",children:b.url})]},`${b.url}-${_}`))})}),f.length===0&&y.jsx(At,{title:"results",maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No results found"})})]})]});const E=w&&w.length>50?`${w.slice(0,50)}...`:w;return y.jsxs("div",{className:"text-xs",children:[y.jsxs(Zr,{toolName:"web fetch",isExpanded:n,onToggle:i,isError:o,colorVariant:"purple",canExpand:!0,children:[E&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx("span",{className:"text-foreground/70 truncate min-w-0",title:w,children:E})]}),y.jsx(mt,{}),y.jsx(hr,{children:c})]}),n&&o&&u&&y.jsx(kn,{error:u,stack:d,showStack:!0}),n&&!o&&y.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[y.jsx(At,{title:"url",icon:y.jsx(aF,{className:"h-3 w-3"}),copyText:w,maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 font-mono text-xs bg-muted/10 break-all",children:y.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:w})})}),m.content&&y.jsx(At,{title:"content",copyText:m.content,maxHeight:"max-h-80",children:y.jsx("div",{className:"px-3 py-2 text-xs text-foreground/80 whitespace-pre-wrap break-words",children:m.content})}),!m.content&&y.jsx(At,{title:"content",maxHeight:"",children:y.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No content returned"})})]})]})}function xJ({contentJson:e,debug:t}){const[n,i]=q.useState(!1);let s,l,c,o=!1;e.error&&typeof e.error=="object"?(s=e.error,s.message&&typeof s.message=="string"&&(l=s.message),s.type&&typeof s.type=="string"&&(c=s.type)):e.details&&typeof e.details=="object"?(s=e.details,e.message&&typeof e.message=="string"&&(l=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(o=!0)):(e.message&&typeof e.message=="string"&&(l=e.message),e.type&&typeof e.type=="string"&&(c=e.type),e.isAborted===!0&&(o=!0),s=e);let u;if(s?.responseBody&&typeof s.responseBody=="string")try{const m=JSON.parse(s.responseBody);m.error&&typeof m.error=="object"&&(u={type:typeof m.error.type=="string"?m.error.type:void 0,message:typeof m.error.message=="string"?m.error.message:void 0})}catch{}const d=m=>{if(m==null)return y.jsx("span",{className:"text-muted-foreground",children:"null"});if(typeof m=="boolean")return y.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(m)});if(typeof m=="number")return y.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:m});if(typeof m=="string"){if(m.startsWith("{")||m.startsWith("["))try{const v=JSON.parse(m);return y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(v,null,2)})})}catch{}return y.jsx("span",{className:"text-foreground",children:m})}return typeof m=="object"?y.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:y.jsx("code",{children:JSON.stringify(m,null,2)})}):y.jsx("span",{className:"text-foreground",children:String(m)})},p=["name","statusCode","url","model","isRetryable","cause"],f=new Set;return y.jsxs("div",{className:"space-y-2 text-sm",children:[o&&y.jsx("div",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Request aborted"}),u?.message&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"API Error:"}),y.jsx("div",{className:"text-foreground",children:u.message}),u.type&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",u.type]})]}),!u?.message&&l&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),y.jsx("div",{className:"text-foreground",children:l}),c&&y.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",c]})]}),s&&y.jsx("div",{className:"space-y-1.5",children:p.map(m=>{const v=s[m];return v==null?null:(f.add(m),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("span",{className:"font-medium text-muted-foreground min-w-[100px]",children:[m,":"]}),d(v)]},m))})}),s&&y.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[y.jsxs("button",{type:"button",onClick:()=>i(!n),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[n?y.jsx(xa,{className:"h-3 w-3"}):y.jsx(nn,{className:"h-3 w-3"}),n?"Hide":"View"," Raw Error Details"]}),n&&y.jsx("div",{className:"mt-2",children:y.jsx("pre",{className:"p-3 bg-muted/50 rounded text-xs overflow-x-auto max-h-96 overflow-y-auto",children:y.jsx("code",{children:JSON.stringify(s,null,2)})})})]}),t&&y.jsxs("details",{className:"mt-4 text-xs",children:[y.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Debug Info"}),y.jsx("pre",{className:"mt-2 p-2 bg-muted/30 rounded overflow-x-auto",children:y.jsx("code",{children:JSON.stringify({contentJson:e,errorDetails:s,apiError:u},null,2)})})]})]})}function iL(e){return e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}function Iy({session:e,onNavigate:t,compact:n}){return n?y.jsxs("button",{type:"button",onClick:()=>t?.(e.id),disabled:!t,className:"w-full text-left py-1 px-2 rounded text-xs hover:bg-muted/50 transition-colors flex items-center justify-between gap-2",children:[y.jsx("span",{className:"truncate text-foreground",children:e.title||"Untitled"}),t&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):y.jsxs("button",{type:"button",onClick:()=>t?.(e.id),disabled:!t,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"font-medium text-sm truncate text-foreground",children:e.title||"Untitled"}),t&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.agent&&y.jsx("span",{className:"text-violet-600 dark:text-violet-400",children:e.agent}),e.agent&&e.provider&&y.jsx("span",{children:"·"}),e.provider&&y.jsx("span",{children:e.provider}),e.messageCount!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsxs("span",{children:[e.messageCount," msgs"]})]}),e.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsx("span",{children:iL(e.createdAt)})]})]})]})}function kN({message:e,onNavigate:t,compact:n}){const i="sessionId"in e?e.sessionId:"",s="sessionTitle"in e?e.sessionTitle:null,l="content"in e?e.content:"contentPreview"in e?e.contentPreview:"matchedContent"in e?e.matchedContent:"";return n?y.jsxs("button",{type:"button",onClick:()=>t?.(i),disabled:!t||!i,className:"w-full text-left py-1 px-2 rounded text-xs hover:bg-muted/50 transition-colors flex items-center justify-between gap-2",children:[y.jsx("span",{className:"truncate text-foreground/80",children:l?.slice(0,50)||s||i.slice(0,8)}),t&&i&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):y.jsxs("button",{type:"button",onClick:()=>t?.(i),disabled:!t||!i,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("span",{className:"text-xs text-muted-foreground",children:s||i.slice(0,8)}),t&&i&&y.jsx(wr,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),l&&y.jsx("div",{className:"text-xs text-foreground/80 mt-1 line-clamp-2",children:l}),y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.role&&y.jsx("span",{className:"capitalize",children:e.role}),e.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsx("span",{children:iL(e.createdAt)})]})]})]})}function TN({args:e,toolName:t}){const n=(c,o)=>o==null||typeof o=="boolean"&&!o||Array.isArray(o)&&o.length===0?null:y.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[y.jsxs("span",{className:"opacity-60",children:[c,":"]}),y.jsx("span",{className:"text-foreground/80",children:typeof o=="string"?o:JSON.stringify(o)})]},c),l=({query_sessions:["agent","sessionType","startDate","endDate"],query_messages:["sessionId","role","search","toolName"],search_history:["query"],get_session_context:["sessionId","includeMessages"],get_parent_session:["includeMessages"]}[t]||Object.keys(e).slice(0,3)).filter(c=>e[c]!==void 0&&e[c]!==null).map(c=>n(c,e[c])).filter(Boolean);return l.length===0?null:y.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-xs mb-2 pb-2 border-b border-border",children:[y.jsx(VB,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),l]})}function EJ({toolName:e,contentJson:t,toolDurationMs:n,isExpanded:i,onToggle:s,onNavigateToSession:l,compact:c}){const o=t.result||{},u=t.args||{},d=typeof o=="object"&&"ok"in o&&o.ok===!1,p=d&&"error"in o&&typeof o.error=="string"?o.error:null,f=pn(n);if(e==="present_action"){const w=o.links||[],E=o.summary,b=o.title;return w.length===0&&!E?null:y.jsxs("div",{className:"mt-2 mb-1",children:[b&&y.jsx("div",{className:"text-sm font-medium text-foreground mb-1.5",children:b}),E&&y.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1.5",children:[y.jsx(rF,{className:"w-3.5 h-3.5 text-teal-500"}),y.jsx("span",{children:E})]}),w.length>0&&y.jsx("div",{className:"space-y-1.5",children:w.map(_=>y.jsxs("button",{type:"button",onClick:()=>l?.(_.sessionId),disabled:!l,className:"w-full text-left px-3 py-2 rounded-lg border border-teal-500/30 bg-teal-500/5 hover:bg-teal-500/10 transition-colors group flex items-center justify-between gap-2",children:[y.jsxs("div",{children:[y.jsx("div",{className:"font-medium text-sm text-foreground",children:_.title}),_.description&&y.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:_.description})]}),l&&y.jsx(wr,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 opacity-60 group-hover:opacity-100 transition-opacity flex-shrink-0"})]},_.sessionId))})]})}const m=()=>{switch(e){case"query_sessions":{const w=o.sessions||[],E=o.total;return`${w.length} session${w.length!==1?"s":""}${E?` of ${E}`:""}`}case"query_messages":{const w=o.messages||[];return`${w.length} message${w.length!==1?"s":""}`}case"search_history":{const w=u.query,E=o.results||[],b=w?`"${w.slice(0,20)}${w.length>20?"…":""}"`:"";return`${E.length} result${E.length!==1?"s":""}${b?` for ${b}`:""}`}case"get_session_context":return o.session?.title||u.sessionId?.slice(0,8)||"session";case"get_parent_session":return o.parentSession?.title||"parent session";default:return e}},v=()=>{const w=Object.keys(u).length>0&&!c;switch(e){case"query_sessions":{const E=o.sessions||[];return y.jsxs("div",{className:c?"p-1":"p-2",children:[w&&y.jsx(TN,{args:u,toolName:e}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No sessions found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map(b=>y.jsx(Iy,{session:b,onNavigate:l,compact:c},b.id)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"query_messages":{const E=o.messages||[];return y.jsxs("div",{className:c?"p-1":"p-2",children:[w&&y.jsx(TN,{args:u,toolName:e}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map(b=>y.jsx(kN,{message:b,onNavigate:l,compact:c},b.id)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"search_history":{const E=o.results||[],b=u.query;return y.jsxs("div",{className:c?"p-1":"p-2",children:[b&&!c&&y.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-2 pb-2 border-b border-border",children:[y.jsx(Qo,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),y.jsx("span",{className:"text-muted-foreground",children:"Query:"}),y.jsxs("span",{className:"text-foreground font-medium",children:['"',b,'"']})]}),E.length===0?y.jsx("div",{className:"text-xs text-muted-foreground",children:"No results found"}):y.jsxs("div",{className:c?"space-y-0.5":"space-y-2",children:[E.slice(0,c?5:10).map((_,x)=>y.jsx(kN,{message:_,onNavigate:l,compact:c},`${_.sessionId}-${_.messageId}-${x}`)),E.length>(c?5:10)&&y.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",E.length-(c?5:10)," more"]})]})]})}case"get_session_context":case"get_parent_session":{const E=e==="get_parent_session"?o.parentSession:o.session,b=o.stats,_=o.messages;return E?c?y.jsx("div",{className:"p-1",children:y.jsx(Iy,{session:E,onNavigate:l,compact:!0})}):y.jsxs("div",{className:"p-2 space-y-3",children:[y.jsx(Iy,{session:E,onNavigate:l}),b&&y.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[b.totalMessages!==void 0&&y.jsxs("span",{children:[b.totalMessages," messages"]}),b.totalToolCalls!==void 0&&y.jsxs("span",{children:[b.totalToolCalls," tool calls"]})]}),_&&_.length>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Recent messages:"}),y.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:_.slice(0,5).map(x=>y.jsxs("div",{className:"text-xs p-1.5 rounded bg-muted/30",children:[y.jsxs("span",{className:"font-medium capitalize text-foreground/70",children:[x.role,":"," "]}),y.jsx("span",{className:"text-foreground/60 line-clamp-2",children:x.content})]},x.id))})]})]}):y.jsx("div",{className:`text-xs text-muted-foreground ${c?"p-1":"p-2"}`,children:"Session not found"})}default:return y.jsx("pre",{className:"text-xs p-2 overflow-auto max-h-48",children:JSON.stringify(o,null,2)})}};return y.jsxs("div",{className:"text-xs",children:[y.jsxs(Zr,{toolName:e,isExpanded:i,onToggle:s,isError:d,colorVariant:"default",canExpand:!0,children:[!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx("span",{className:"text-foreground/70 min-w-0 truncate",children:m()})]}),!d&&!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx(R1,{children:"Done"}),y.jsx(mt,{}),y.jsx(hr,{children:f})]}),d&&!c&&y.jsxs(y.Fragment,{children:[y.jsx(mt,{}),y.jsx(A1,{children:"Error"}),y.jsxs(hr,{children:["· ",f]})]})]}),i&&d&&p&&y.jsx(kn,{error:p}),i&&!d&&y.jsx("div",{className:c?"mt-1 ml-3":"mt-2 ml-5",children:c?y.jsx("div",{className:"border border-border rounded-md overflow-hidden max-h-48 overflow-y-auto",children:v()}):y.jsx(At,{title:"results",maxHeight:"max-h-96",children:v()})})]})}function wJ({part:e}){const[t,n]=q.useState(!0),i=q.useRef(null);let s="";const l=e.contentJson||e.content;return l&&typeof l=="object"&&"text"in l?s=String(l.text):typeof l=="string"&&(s=l),q.useEffect(()=>{i.current&&t&&!e.completedAt&&(i.current.scrollTop=i.current.scrollHeight)},[t,e.completedAt]),!s||!s.trim()?null:y.jsxs("div",{className:"w-full",children:[y.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full",children:[t?y.jsx(xa,{className:"h-3 w-3 flex-shrink-0"}):y.jsx(nn,{className:"h-3 w-3 flex-shrink-0"}),y.jsx("span",{className:"font-medium",children:"Reasoning"}),!e.completedAt&&y.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"thinking..."})]}),t&&y.jsx("div",{ref:i,className:"mt-2 p-3 bg-muted/30 rounded-md border border-border max-h-48 overflow-y-auto",children:y.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:s})})]})}const CJ={Read:"read",Write:"write",Edit:"edit",Ls:"ls",Tree:"tree",Cd:"cd",Pwd:"pwd",Glob:"glob",Grep:"ripgrep",Bash:"bash",Terminal:"terminal",GitStatus:"git_status",GitDiff:"git_diff",GitCommit:"git_commit",ApplyPatch:"apply_patch",UpdateTodos:"update_todos",UpdatePlan:"update_todos",ProgressUpdate:"progress_update",Finish:"finish",WebSearch:"websearch"};function kJ(e){return CJ[e]??e}function RN({toolName:e,contentJson:t,toolDurationMs:n,debug:i,onNavigateToSession:s,compact:l}){const[c,o]=q.useState(!1),u=kJ(e),p={contentJson:t,toolDurationMs:n??void 0,isExpanded:c,onToggle:()=>o(!c),compact:l};if(i)return y.jsx(yJ,{...p,toolName:e});switch(u){case"read":return y.jsx(eJ,{...p});case"write":return y.jsx(tJ,{...p});case"edit":return y.jsx(nJ,{...p});case"bash":return y.jsx(aJ,{...p});case"git_status":return y.jsx(uJ,{...p});case"git_diff":return y.jsx(cJ,{...p});case"git_commit":return y.jsx(dJ,{...p});case"apply_patch":return y.jsx(hJ,{...p});case"ls":return y.jsx(pJ,{...p});case"tree":return y.jsx(fJ,{...p});case"ripgrep":case"grep":case"glob":return y.jsx(mJ,{...p});case"websearch":return y.jsx(SJ,{...p});case"finish":return y.jsx(gJ,{...p});case"update_todos":case"update_plan":return y.jsx(vJ,{...p});case"progress_update":return y.jsx(_J,{...p});case"error":return y.jsx(xJ,{...p});case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":case"present_action":return y.jsx(EJ,{toolName:e,...p,onNavigateToSession:s});default:return y.jsx(bJ,{...p,toolName:e})}}function _v(e){const t=e.contentJson;if(t&&typeof t=="object")return t;try{if(e.content){const n=JSON.parse(e.content);if(n&&typeof n=="object"&&!Array.isArray(n))return n}}catch{}return null}function TJ(e){const t=_v(e);if(!t)return;const n=t.args;if(n&&typeof n=="object"&&!Array.isArray(n))return n}function RJ(e){if(!e)return null;const t=["cmd","command","script","input"];for(const n of t){const i=e[n];if(typeof i=="string"&&i.trim().length>0)return i.trim()}return null}function AJ(e,t){if(!t)return null;const n=[{key:"path",match:!0},{key:"file",match:!0},{key:"target",match:!0},{key:"cwd",match:!0},{key:"query",match:!0},{key:"pattern",match:!0},{key:"glob",match:!0},{key:"dir",match:!0}];for(const{key:i}of n){const s=t[i];if(typeof s=="string"&&s.trim().length>0)return{key:i,value:s.trim()}}if(e==="bash"){const i=t.command;if(typeof i=="string"&&i.trim().length>0)return{key:"command",value:i.trim()}}return null}function NJ(e,t){if(!e)return null;const n=[];for(const[s,l]of Object.entries(e))if(!(t&&s===t)){if(typeof l=="string"||typeof l=="number"){const c=`${s}=${String(l)}`;n.push(c)}if(n.length>=3)break}if(!n.length)return null;const i=n.join(" ");return i.length>120?`${i.slice(0,117)}…`:i}const AN=q.memo(function({part:t,showLine:n,isLastToolCall:i,isLastProgressUpdate:s,onNavigateToSession:l,compact:c,pendingApproval:o,onApprove:u,onReject:d}){if(t.type==="tool_call"&&!i&&!o||t.type==="tool_result"&&t.toolName==="progress_update"&&!s)return null;if(t.type==="text"){const b=t.contentJson||t.content;let _="";if(b&&typeof b=="object"&&"text"in b?_=String(b.text):typeof b=="string"&&(_=b),!_||!_.trim())return null}if(t.type==="reasoning"){const b=t.contentJson||t.content;let _="";if(b&&typeof b=="object"&&"text"in b?_=String(b.text):typeof b=="string"&&(_=b),!_||!_.trim())return null}const p=t.type==="tool_call"||t.type==="tool_result",f=["flex-1","min-w-0","max-w-full"];p||t.type==="reasoning"?f.push("pt-1"):t.type==="error"?f.push("pt-0.5"):t.type==="text"?(f.push("pt-0"),f.push("-mt-0.5")):f.push("pt-0");const m=f.join(" "),v=()=>{if(t.type==="reasoning")return y.jsx(Uv,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"});if(t.type==="tool_call")return y.jsx(Ni,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(t.type==="error")return _v(t)?.isAborted===!0?y.jsx(pF,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):y.jsx(Qr,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(t.type==="tool_result"){const b=t.toolName||"";return b==="read"?y.jsx(kc,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):b==="write"?y.jsx(ga,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="edit"?y.jsx(ga,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="ls"?y.jsx(oF,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):b==="tree"?y.jsx(IO,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):b==="bash"?y.jsx(ba,{className:"h-4 w-4 text-muted-foreground"}):b==="ripgrep"||b==="grep"||b==="glob"?y.jsx(Qo,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):b==="apply_patch"?y.jsx(_E,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="git_status"?y.jsx(zn,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):b==="git_diff"?y.jsx(_E,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):b==="git_commit"?y.jsx(uc,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="finish"?y.jsx(Mi,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):b==="query_sessions"||b==="query_messages"||b==="search_history"||b==="get_session_context"||b==="get_parent_session"?y.jsx(EB,{className:"h-4 w-4 text-teal-600 dark:text-teal-300"}):y.jsx(ba,{className:"h-4 w-4 text-muted-foreground"})}return y.jsx(Vo,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},w=()=>{const b=t.toolName||"";let _;try{t.contentJson&&typeof t.contentJson=="object"?_=t.contentJson:typeof t.content=="string"?_=JSON.parse(t.content):_={}}catch{_={result:t.content}}return y.jsx(RN,{toolName:b,contentJson:_,toolDurationMs:t.toolDurationMs,debug:!1,onNavigateToSession:l,compact:c})},E=()=>{if(t.type==="reasoning")return y.jsx(wJ,{part:t});if(t.type==="text"){let b="";const _=t.contentJson||t.content;return _&&typeof _=="object"&&"text"in _?b=String(_.text):typeof _=="string"?b=_:_&&(b=JSON.stringify(_,null,2)),y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"absolute -top-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:b,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})}),y.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-hidden",children:y.jsx(mI,{remarkPlugins:[PI],components:{pre:({children:x,...S})=>{const k=(()=>{if(!x)return"";const O=Array.isArray(x)?x[0]:x;if(O&&typeof O=="object"&&"props"in O){const T=O.props;if(typeof T.children=="string")return T.children}return""})();return y.jsxs("div",{className:"relative group/code my-3",children:[y.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover/code:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:k,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"sm"})}),y.jsx("pre",{...S,className:"overflow-x-auto",children:x})]})}},children:b})}),b.length>500&&y.jsx("div",{className:"absolute -bottom-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:y.jsx(Xu,{text:b,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})})]})}if(t.type==="error"){let b;try{t.contentJson&&typeof t.contentJson=="object"?b=t.contentJson:typeof t.content=="string"?b=JSON.parse(t.content):b={}}catch{b={message:t.content||"Unknown error"}}return y.jsx(RN,{toolName:"error",contentJson:b,toolDurationMs:t.toolDurationMs,debug:!1,compact:c})}if(t.type==="tool_call"){const b=_v(t),_=t.toolName||(typeof b?.name=="string"?b.name:"tool"),x=_.replace(/_/g," "),S=TJ(t),k=o?.args,O=S||k,T=AJ(_,O),A=NJ(O,T?.key),R=_==="bash"?RJ(O):null,D=[];if(R?D.push({key:"cmd",node:y.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:R})}):T&&D.push({key:"primary",node:y.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:T.value})}),A&&D.push({key:"args",node:y.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:A})}),o&&o.callId===t.toolCallId&&u&&d)return y.jsx(ZQ,{toolName:_,args:O,pendingApproval:o,onApprove:u,onReject:d});D.length===0&&D.push({key:"running",node:y.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const I=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return t.ephemeral&&I.push("animate-pulse"),y.jsxs("div",{className:I.join(" "),children:[y.jsx("span",{className:"font-medium text-foreground",children:x}),D.map(H=>y.jsxs(q.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/65",children:"·"}),H.node]},H.key))]})}return t.type==="tool_result"?w():null};return y.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[y.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:v()}),n&&y.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),y.jsx("div",{className:m,children:E()})]})},(e,t)=>e.part.id===t.part.id&&e.part.content===t.part.content&&e.part.contentJson===t.part.contentJson&&e.part.ephemeral===t.part.ephemeral&&e.part.completedAt===t.part.completedAt&&e.showLine===t.showLine&&e.isLastToolCall===t.isLastToolCall&&e.isLastProgressUpdate===t.isLastProgressUpdate&&e.onNavigateToSession===t.onNavigateToSession&&e.pendingApproval?.callId===t.pendingApproval?.callId&&e.onApprove===t.onApprove&&e.onReject===t.onReject),NN={currentMessageId:null,queuedMessages:[],queueLength:0};function OJ(e){const{data:t}=qn({queryKey:["queueState",e],enabled:!!e,initialData:NN,staleTime:1/0});return t??NN}function aL(e,t){const n=OJ(e);if(!e||!n)return{isQueued:!1,isRunning:!1,position:null};if(n.currentMessageId===t)return{isQueued:!1,isRunning:!0,position:null};const i=n.queuedMessages.find(s=>s.messageId===t);return i?{isQueued:!0,isRunning:!1,position:i.position}:{isQueued:!1,isRunning:!1,position:null}}function DJ(e){const t=Lt();return Xt({mutationFn:n=>{if(!e)throw new Error("No session ID");return qe.createBranch(e,n)},onSuccess:()=>{t.invalidateQueries({queryKey:["sessions"]}),e&&t.invalidateQueries({queryKey:["branches",e]})}})}function sL(e){return qn({queryKey:["parentSession",e],queryFn:()=>{if(!e)throw new Error("No session ID");return qe.getParentSession(e)},enabled:!!e})}function IJ({isOpen:e,onClose:t,sessionId:n,message:i,onBranchCreated:s}){const l=CD(n),c=DJ(n),[o,u]=q.useState(""),[d,p]=q.useState(!0),f=q.useId(),m=q.useId(),v=i.parts?.find(b=>b.type==="text")?.content||"",w=(()=>{try{return JSON.parse(v)?.text?.slice(0,100)||""}catch{return v.slice(0,100)}})(),E=async b=>{b.preventDefault();try{const _=await c.mutateAsync({fromMessageId:i.id,title:o.trim()||void 0,provider:d?l?.provider:void 0,model:d?l?.model:void 0,agent:d?l?.agent:void 0});t(),s&&_.session&&s(_.session.id)}catch(_){console.error("Failed to create branch:",_)}};return y.jsx(al,{isOpen:e,onClose:t,title:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(zn,{className:"h-5 w-5 text-primary"}),y.jsx("span",{children:"Branch Session"})]}),maxWidth:"md",children:y.jsxs("form",{onSubmit:E,className:"space-y-4",children:[y.jsxs("div",{className:"text-sm text-muted-foreground",children:[y.jsx("p",{children:"Creating branch from message:"}),y.jsxs("p",{className:"mt-1 p-2 bg-muted/50 rounded text-foreground italic truncate",children:['"',w,'..."']})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("label",{htmlFor:f,className:"block text-sm font-medium text-foreground",children:"Branch Title (optional)"}),y.jsx("input",{id:f,type:"text",value:o,onChange:b=>u(b.target.value),placeholder:`Branch of ${l?.title||"Untitled"}`,className:"w-full px-3 py-2 bg-background border border-border rounded-md text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("input",{id:m,type:"checkbox",checked:d,onChange:b=>p(b.target.checked),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary/50"}),y.jsx("label",{htmlFor:m,className:"text-sm text-foreground",children:"Use same provider/model/agent as parent"})]}),l&&y.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 rounded p-2",children:y.jsxs("div",{className:"flex gap-4",children:[y.jsxs("span",{children:[y.jsx("strong",{children:"Provider:"})," ",l.provider]}),y.jsxs("span",{children:[y.jsx("strong",{children:"Model:"})," ",l.model]}),y.jsxs("span",{children:[y.jsx("strong",{children:"Agent:"})," ",l.agent]})]})}),y.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[y.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),y.jsx("button",{type:"submit",disabled:c.isPending,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:c.isPending?y.jsxs(y.Fragment,{children:[y.jsx(Ni,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):y.jsxs(y.Fragment,{children:[y.jsx(zn,{className:"h-4 w-4"}),"Create Branch"]})})]}),c.isError&&y.jsx("p",{className:"text-sm text-red-500",children:c.error?.message||"Failed to create branch"})]})})}const ON=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function LJ(e){const t=e.split("").reduce((n,i)=>n+i.charCodeAt(0),0);return ON[t%ON.length]}const oL=q.memo(function({sessionId:t,message:n,showHeader:i,hasNextAssistantMessage:s,onBranchCreated:l,compact:c,showBranchButton:o=!0,onNavigateToSession:u}){const{isQueued:d}=aL(t,n.id),[p,f]=q.useState(!1),[m,v]=q.useState(!1),[w,E]=q.useState(!1),{pendingApprovals:b,removePendingApproval:_}=$v(),x=q.useCallback(async Y=>{if(t)try{await qe.approveToolCall(t,Y,!0),_(Y)}catch(P){console.error("Failed to approve tool call:",P)}},[t,_]),S=q.useCallback(async Y=>{if(t)try{await qe.approveToolCall(t,Y,!1),_(Y)}catch(P){console.error("Failed to reject tool call:",P)}},[t,_]),k=q.useMemo(()=>b.filter(Y=>Y.messageId===n.id),[b,n.id]),O=q.useCallback(async()=>{if(t)try{await Promise.all(k.map(Y=>qe.approveToolCall(t,Y.callId,!0)));for(const Y of k)_(Y.callId)}catch(Y){console.error("Failed to approve all tool calls:",Y)}},[t,k,_]),T=q.useMemo(()=>[...n.parts||[]].sort((P,M)=>{const j=(P.index??0)-(M.index??0);return j!==0?j:(P.startedAt??0)-(M.startedAt??0)}),[n.parts]),A=T.some(Y=>Y.toolName==="finish"),R=T.reduce((Y,P,M)=>P.type==="tool_result"&&P.toolName==="progress_update"?M:Y,-1),D=R>=0?T[R]:null,L=T.some(Y=>!(Y.type==="tool_result"&&Y.toolName==="progress_update")),I=T.findIndex(Y=>!(Y.type==="tool_result"&&Y.toolName==="progress_update")),H=n.status==="pending"&&!A&&!!D,B=n.status==="pending"&&!A&&!D&&!d,W=Y=>Y?new Date(Y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",K=n.status==="complete",V=q.useCallback(()=>{const Y=T.filter(P=>P.type==="text").map(P=>{try{return JSON.parse(P.content||"{}")?.text||""}catch{return P.content||""}}).join(`
119
+ `);navigator.clipboard.writeText(Y),E(!0),setTimeout(()=>E(!1),2e3)},[T]),X=q.useCallback(()=>{v(!0)},[]);return d?null:y.jsxs("div",{className:"relative group",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[i&&y.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[y.jsxs("div",{className:"inline-flex items-center bg-violet-500/10 border border-violet-500/30 dark:bg-violet-500/5 dark:border-violet-500/20 rounded-full pr-3 md:pr-4 flex-shrink min-w-0",children:[y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-violet-500/50 bg-violet-500/20 dark:bg-violet-500/10",children:y.jsx(Vo,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),y.jsxs("div",{className:"flex items-center gap-x-1.5 md:gap-x-2 text-xs md:text-sm text-muted-foreground pl-2 md:pl-3 min-w-0",children:[n.agent&&!c&&y.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300 whitespace-nowrap",children:n.agent}),n.provider&&y.jsxs(y.Fragment,{children:[!c&&n.agent&&y.jsx("span",{className:"text-muted-foreground/50",children:"·"}),y.jsx(Lc,{provider:n.provider,size:14,className:"opacity-70"})]}),n.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"hidden md:inline text-muted-foreground/50",children:"·"}),y.jsx("span",{className:`hidden md:inline text-muted-foreground ${c?"truncate max-w-[120px]":""}`,title:n.model,children:n.model})]}),n.createdAt&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:W(n.createdAt)})]})]})]}),p&&K&&t&&o&&y.jsx("button",{type:"button",onClick:X,className:"ml-4 p-1.5 text-muted-foreground hover:text-primary transition-colors flex-shrink-0",title:"Branch from this message",children:y.jsx(zn,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"relative ml-1",children:[T.map((Y,P)=>{const M=P===T.length-1,j=Y.type==="tool_call"&&Y.toolCallId?b.find(he=>he.callId===Y.toolCallId)??null:null,$=Y.type==="tool_result"&&Y.toolName==="finish",U=(!M||s)&&!$,J=Y.type==="tool_call"&&M;return Y.type==="tool_result"&&Y.toolName==="progress_update"?null:y.jsx(AN,{part:Y,showLine:U,isFirstPart:P===I&&!i,isLastToolCall:J,onNavigateToSession:u,compact:c,pendingApproval:j,onApprove:x,onReject:S},Y.id)}),k.length>1&&y.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 my-2 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg",children:[y.jsx(PO,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),y.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200 flex-1",children:[k.length," tools waiting for approval"]}),y.jsxs("button",{type:"button",onClick:O,title:"Approve All (A)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-amber-600 text-white hover:bg-amber-700 transition-colors",children:[y.jsx(Q6,{className:"w-3.5 h-3.5"}),"Approve All",y.jsx("kbd",{className:"ml-1 text-[10px] opacity-70",children:"A"})]})]}),H&&D&&y.jsx(AN,{part:D,showLine:s,isFirstPart:!L&&!i,isLastProgressUpdate:!0,compact:c},D.id),B&&y.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[y.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:y.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-card text-violet-700 dark:bg-background dark:text-violet-300",children:y.jsx(Vo,{className:"h-4 w-4"})})}),y.jsx("div",{className:"flex-1 pt-0.5",children:y.jsx("div",{className:"text-base text-foreground animate-pulse",children:LJ(n.id)})})]})]}),K&&t&&y.jsx("div",{className:"grid ml-7 transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:p?"1fr":"0fr"},children:y.jsx("div",{className:"overflow-hidden",children:y.jsxs("div",{className:"flex gap-2 mt-2",children:[o&&y.jsxs("button",{type:"button",onClick:X,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:[y.jsx(zn,{className:"h-3 w-3"}),"Branch"]}),y.jsx("button",{type:"button",onClick:V,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:w?y.jsxs(y.Fragment,{children:[y.jsx(Mi,{className:"h-3 w-3 text-green-500"}),"Copied"]}):y.jsxs(y.Fragment,{children:[y.jsx(AO,{className:"h-3 w-3"}),"Copy"]})})]})})}),m&&t&&y.jsx(IJ,{isOpen:m,onClose:()=>v(!1),sessionId:t,message:n,onBranchCreated:l})]})},(e,t)=>{const n=e.message.parts||[],i=t.message.parts||[];if(n.length!==i.length)return!1;for(let s=0;s<n.length;s++){const l=n[s],c=i[s];if(l.id!==c.id||l.content!==c.content||l.contentJson!==c.contentJson||l.ephemeral!==c.ephemeral||l.completedAt!==c.completedAt)return!1}return e.message.id===t.message.id&&e.message.status===t.message.status&&e.message.completedAt===t.message.completedAt&&e.showHeader===t.showHeader&&e.hasNextAssistantMessage===t.hasNextAssistantMessage&&e.isLastMessage===t.isLastMessage&&e.sessionId===t.sessionId&&e.compact===t.compact&&e.onNavigateToSession===t.onNavigateToSession}),lL=q.memo(function({sessionId:t,message:n,nextAssistantMessageId:i}){const[s,l]=q.useState(null),c=n.parts||[],o=Lt(),{isQueued:u,position:d}=aL(t,i??""),p=av(I=>I.setPendingRestoreText),f=c.filter(I=>I.type==="text"),m=c.filter(I=>I.type==="image"),v=c.filter(I=>I.type==="file"),w=f[0];let E="";if(w){const I=w.contentJson||w.content;I&&typeof I=="object"&&"text"in I?E=String(I.text):typeof I=="string"?E=I:I&&(E=JSON.stringify(I,null,2))}const{researchContexts:b,cleanContent:_}=B7(E),x=[];for(const I of m)try{const H=I.contentJson||JSON.parse(I.content||"{}");if(H&&typeof H=="object"&&"data"in H){const B=H,W=`data:${B.mediaType};base64,${B.data}`;x.push({id:I.id,src:W})}}catch{}const S=[];for(const I of v)try{const H=I.contentJson||JSON.parse(I.content||"{}");if(H&&typeof H=="object"&&"type"in H){const B=H;if(B.type==="image"&&B.data){const W=`data:${B.mediaType};base64,${B.data}`;x.push({id:I.id,src:W})}else S.push({id:I.id,type:B.type,name:B.name})}}catch{}const k=I=>I?new Date(I).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",O=_.trim().length>0,T=x.length>0,A=S.length>0,R=b.length>0;if(!O&&!T&&!A&&!R)return null;const D=async()=>{if(!(!t||!i)){p(_);try{await qe.removeFromQueue(t,i),o.invalidateQueries({queryKey:["messages",t]})}catch(I){console.error("Failed to cancel queued message:",I)}}},L=async()=>{if(!(!t||!i))try{await qe.removeFromQueue(t,i),o.invalidateQueries({queryKey:["messages",t]})}catch(I){console.error("Failed to delete queued message:",I)}};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"relative pb-8 pt-6",children:y.jsxs("div",{className:"flex gap-3 md:gap-4 justify-end",children:[y.jsxs("div",{className:"flex flex-col items-end min-w-0 flex-1 max-w-[calc(100%-3rem)] md:max-w-2xl",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[y.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),n.createdAt&&y.jsx("span",{children:"·"}),n.createdAt&&y.jsx("span",{children:k(n.createdAt)}),u&&y.jsxs(y.Fragment,{children:[y.jsx("span",{children:"·"}),y.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",children:[y.jsx(RO,{className:"h-3 w-3"}),"Queued",d!==null&&d>0?` #${d+1}`:""]})]})]}),y.jsxs("div",{className:"inline-block max-w-full text-sm text-foreground leading-relaxed bg-emerald-500/5 border border-emerald-500/20 rounded-xl px-4 py-3 [word-break:break-word] overflow-hidden",children:[T&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:x.map(I=>y.jsx("button",{type:"button",onClick:()=>l(I.src),className:"w-16 h-16 rounded-lg overflow-hidden bg-muted hover:ring-2 hover:ring-primary/50 transition-all",children:y.jsx("img",{src:I.src,alt:"Attachment",className:"w-full h-full object-cover"})},I.id))}),A&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:S.map(I=>y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border",children:[I.type==="pdf"?y.jsx(Li,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):y.jsx(kc,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs truncate max-w-[150px]",children:I.name})]},I.id))}),R&&y.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:b.map(I=>y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-teal-600 dark:text-teal-400",children:I.label})]},I.id))}),O&&y.jsx("div",{className:"prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_*]:[word-break:break-word] [&_*]:overflow-wrap-anywhere",children:y.jsx(mI,{remarkPlugins:[PI],children:_})})]}),u&&y.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[y.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors",title:"Cancel and restore to input",children:[y.jsx(FO,{className:"h-3 w-3"}),"Cancel"]}),y.jsxs("button",{type:"button",onClick:L,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-destructive/10 hover:bg-destructive/20 text-destructive transition-colors",title:"Delete from queue",children:[y.jsx(zv,{className:"h-3 w-3"}),"Delete"]})]})]}),y.jsx("div",{className:"flex-shrink-0 w-8 flex items-start justify-center",children:y.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-emerald-500/50 bg-emerald-500/20 dark:bg-emerald-500/10 relative bg-background",children:y.jsx(qv,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})})})]})}),s&&y.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>l(null),onKeyDown:I=>I.key==="Escape"&&l(null),tabIndex:-1,children:[y.jsx("button",{type:"button",onClick:()=>l(null),className:"absolute top-4 right-4 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:y.jsx(Un,{className:"w-6 h-6 text-white"})}),y.jsx("img",{src:s,alt:"Expanded attachment",className:"max-w-full max-h-full object-contain rounded-lg",onClick:I=>I.stopPropagation(),onKeyDown:I=>I.key==="Enter"&&I.stopPropagation()})]})]})},(e,t)=>{const n=e.message.parts?.[0],i=t.message.parts?.[0];return e.message.id===t.message.id&&n?.content===i?.content&&n?.contentJson===i?.contentJson&&e.message.createdAt===t.message.createdAt&&e.message.parts?.length===t.message.parts?.length&&e.sessionId===t.sessionId&&e.nextAssistantMessageId===t.nextAssistantMessageId}),MJ={openai:{id:"openai",models:[{id:"codex-mini-latest",label:"Codex Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-04",releaseDate:"2025-05-16",lastUpdated:"2025-05-16",openWeights:!1,cost:{input:1.5,output:6,cacheRead:.375},limit:{context:2e5,output:1e5}},{id:"gpt-3.5-turbo",label:"GPT-3.5-turbo",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2021-09-01",releaseDate:"2023-03-01",lastUpdated:"2023-11-06",openWeights:!1,cost:{input:.5,output:1.5,cacheRead:1.25},limit:{context:16385,output:4096}},{id:"gpt-4",label:"GPT-4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-11",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:30,output:60},limit:{context:8192,output:8192}},{id:"gpt-4-turbo",label:"GPT-4 Turbo",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:10,output:30},limit:{context:128e3,output:4096}},{id:"gpt-4.1",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"gpt-4.1-mini",label:"GPT-4.1 mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"gpt-4.1-nano",label:"GPT-4.1 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.03},limit:{context:1047576,output:32768}},{id:"gpt-4o",label:"GPT-4o",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-05-13",label:"GPT-4o (2024-05-13)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:5,output:15},limit:{context:128e3,output:4096}},{id:"gpt-4o-2024-08-06",label:"GPT-4o (2024-08-06)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-08-06",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-11-20",label:"GPT-4o (2024-11-20)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-11-20",lastUpdated:"2024-11-20",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-mini",label:"GPT-4o mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-chat-latest",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"gpt-5-codex",label:"GPT-5-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-mini",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4,cacheRead:.005},limit:{context:4e5,output:128e3}},{id:"gpt-5-pro",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.13},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-chat-latest",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"gpt-5.1-codex",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-chat-latest",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.2-codex",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-pro",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"o1",label:"o1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2024-12-05",lastUpdated:"2024-12-05",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:2e5,output:1e5}},{id:"o1-mini",label:"o1-mini",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:128e3,output:65536}},{id:"o1-preview",label:"o1-preview",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:128e3,output:32768}},{id:"o1-pro",label:"o1-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2025-03-19",lastUpdated:"2025-03-19",openWeights:!1,cost:{input:150,output:600},limit:{context:2e5,output:1e5}},{id:"o3",label:"o3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"o3-deep-research",label:"o3-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:10,output:40,cacheRead:2.5},limit:{context:2e5,output:1e5}},{id:"o3-mini",label:"o3-mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-05",releaseDate:"2024-12-20",lastUpdated:"2025-01-29",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:2e5,output:1e5}},{id:"o3-pro",label:"o3-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-06-10",lastUpdated:"2025-06-10",openWeights:!1,cost:{input:20,output:80},limit:{context:2e5,output:1e5}},{id:"o4-mini",label:"o4-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"o4-mini-deep-research",label:"o4-mini-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"text-embedding-3-large",label:"text-embedding-3-large",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.13,output:0},limit:{context:8191,output:3072}},{id:"text-embedding-3-small",label:"text-embedding-3-small",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.02,output:0},limit:{context:8191,output:1536}},{id:"text-embedding-ada-002",label:"text-embedding-ada-002",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2022-12",releaseDate:"2022-12-15",lastUpdated:"2022-12-15",openWeights:!1,cost:{input:.1,output:0},limit:{context:8192,output:1536}}],label:"OpenAI",env:["OPENAI_API_KEY"],npm:"@ai-sdk/openai",doc:"https://platform.openai.com/docs/models"},anthropic:{id:"anthropic",models:[{id:"claude-3-5-haiku-20241022",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-haiku-latest",label:"Claude Haiku 3.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20240620",label:"Claude Sonnet 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-06-20",lastUpdated:"2024-06-20",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20241022",label:"Claude Sonnet 3.5 v2",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-7-sonnet-20250219",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-7-sonnet-latest",label:"Claude Sonnet 3.7 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-haiku-20240307",label:"Claude Haiku 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-13",lastUpdated:"2024-03-13",openWeights:!1,cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-3-opus-20240229",label:"Claude Opus 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-02-29",lastUpdated:"2024-02-29",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:4096}},{id:"claude-3-sonnet-20240229",label:"Claude Sonnet 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-04",lastUpdated:"2024-03-04",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-0",label:"Claude Opus 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1",label:"Claude Opus 4.1 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1-20250805",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-20250514",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-5",label:"Claude Opus 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-5-20251101",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-01",lastUpdated:"2025-11-01",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-0",label:"Claude Sonnet 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-20250514",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5",label:"Claude Sonnet 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5-20250929",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}}],label:"Anthropic",env:["ANTHROPIC_API_KEY"],npm:"@ai-sdk/anthropic",doc:"https://docs.anthropic.com/en/docs/about-claude/models"},google:{id:"google",models:[{id:"gemini-1.5-flash",label:"Gemini 1.5 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-05-14",lastUpdated:"2024-05-14",openWeights:!1,cost:{input:.075,output:.3,cacheRead:.01875},limit:{context:1e6,output:8192}},{id:"gemini-1.5-flash-8b",label:"Gemini 1.5 Flash-8B",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-10-03",lastUpdated:"2024-10-03",openWeights:!1,cost:{input:.0375,output:.15,cacheRead:.01},limit:{context:1e6,output:8192}},{id:"gemini-1.5-pro",label:"Gemini 1.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-02-15",lastUpdated:"2024-02-15",openWeights:!1,cost:{input:1.25,output:5,cacheRead:.3125},limit:{context:1e6,output:8192}},{id:"gemini-2.0-flash",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"gemini-2.0-flash-lite",label:"Gemini 2.0 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.075,output:.3},limit:{context:1048576,output:8192}},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-image",label:"Gemini 2.5 Flash Image",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-image-preview",label:"Gemini 2.5 Flash Image (Preview)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-06-17",label:"Gemini 2.5 Flash Lite Preview 06-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-09-2025",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-04-17",label:"Gemini 2.5 Flash Preview 04-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-05-20",label:"Gemini 2.5 Flash Preview 05-20",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-09-2025",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-tts",label:"Gemini 2.5 Flash Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:.5,output:10},limit:{context:8e3,output:16e3}},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-05-06",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-06-05",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-tts",label:"Gemini 2.5 Pro Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:1,output:20},limit:{context:8e3,output:16e3}},{id:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1e6,output:64e3}},{id:"gemini-embedding-001",label:"Gemini Embedding 001",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:0},limit:{context:2048,output:3072}},{id:"gemini-flash-latest",label:"Gemini Flash Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-flash-lite-latest",label:"Gemini Flash-Lite Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-live-2.5-flash",label:"Gemini Live 2.5 Flash",modalities:{input:["text","image","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-01",lastUpdated:"2025-09-01",openWeights:!1,cost:{input:.5,output:2},limit:{context:128e3,output:8e3}},{id:"gemini-live-2.5-flash-preview-native-audio",label:"Gemini Live 2.5 Flash Preview Native Audio",modalities:{input:["text","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-09-18",openWeights:!1,cost:{input:.5,output:2},limit:{context:131072,output:65536}}],label:"Google",env:["GOOGLE_GENERATIVE_AI_API_KEY","GEMINI_API_KEY"],npm:"@ai-sdk/google",doc:"https://ai.google.dev/gemini-api/docs/pricing"},openrouter:{id:"openrouter",models:[{id:"anthropic/claude-3.5-haiku",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"anthropic/claude-3.7-sonnet",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-01",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:128e3}},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-opus-4",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.1",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.5",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-30",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}},{id:"cognitivecomputations/dolphin3.0-mistral-24b",label:"Dolphin3.0 Mistral 24B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-13",lastUpdated:"2025-02-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"cognitivecomputations/dolphin3.0-r1-mistral-24b",label:"Dolphin3.0 R1 Mistral 24B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-13",lastUpdated:"2025-02-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"deepseek/deepseek-chat-v3-0324",label:"DeepSeek V3 0324",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:16384,output:8192}},{id:"deepseek/deepseek-chat-v3.1",label:"DeepSeek-V3.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-08-21",lastUpdated:"2025-08-21",openWeights:!0,cost:{input:.2,output:.8},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1-0528-qwen3-8b:free",label:"Deepseek R1 0528 Qwen3 8B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-29",lastUpdated:"2025-05-29",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"deepseek/deepseek-r1-0528:free",label:"R1 0528 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-28",lastUpdated:"2025-05-28",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1-distill-llama-70b",label:"DeepSeek R1 Distill Llama 70B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-23",lastUpdated:"2025-01-23",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"deepseek/deepseek-r1-distill-qwen-14b",label:"DeepSeek R1 Distill Qwen 14B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-29",lastUpdated:"2025-01-29",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:8192}},{id:"deepseek/deepseek-r1:free",label:"R1 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-01-20",lastUpdated:"2025-01-20",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-v3-base:free",label:"DeepSeek V3 Base (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-29",lastUpdated:"2025-03-29",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-v3.1-terminus",label:"DeepSeek V3.1 Terminus",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.1-terminus:exacto",label:"DeepSeek V3.1 Terminus (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.28,output:.4},limit:{context:163840,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"deepseek/deepseek-v3.2-speciale",label:"DeepSeek V3.2 Speciale",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.27,output:.41},limit:{context:163840,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"featherless/qwerky-72b",label:"Qwerky 72B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-20",lastUpdated:"2025-03-20",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"google/gemini-2.0-flash-exp:free",label:"Gemini 2.0 Flash Experimental (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:1048576,output:1048576}},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-07-17",lastUpdated:"2025-07-17",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite-preview-09-2025",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-preview-09-2025",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.031},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-05-06",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-06-05",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-3-flash-preview",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"google/gemini-3-pro-preview",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11",openWeights:!1,cost:{input:2,output:12},limit:{context:105e4,output:66e3},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"google/gemma-2-9b-it:free",label:"Gemma 2 9B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-06",releaseDate:"2024-06-28",lastUpdated:"2024-06-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"google/gemma-3-12b-it",label:"Gemma 3 12B IT",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"google/gemma-3-27b-it",label:"Gemma 3 27B IT",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"google/gemma-3n-e4b-it",label:"Gemma 3n E4B IT",modalities:{input:["text","image","audio"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"google/gemma-3n-e4b-it:free",label:"Gemma 3n 4B (free)",modalities:{input:["text","image","audio"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"kwaipilot/kat-coder-pro:free",label:"Kat Coder Pro (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-10",lastUpdated:"2025-11-10",openWeights:!1,cost:{input:0,output:0},limit:{context:256e3,output:65536}},{id:"meta-llama/llama-3.2-11b-vision-instruct",label:"Llama 3.2 11B Vision Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-06",lastUpdated:"2024-12-06",openWeights:!0,cost:{input:0,output:0},limit:{context:65536,output:65536}},{id:"meta-llama/llama-4-scout:free",label:"Llama 4 Scout (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2025-04-05",lastUpdated:"2025-04-05",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:64e3}},{id:"microsoft/mai-ds-r1:free",label:"MAI DS R1 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-21",lastUpdated:"2025-04-21",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"minimax/minimax-01",label:"MiniMax-01",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:1e6,output:1e6}},{id:"minimax/minimax-m1",label:"MiniMax M1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!0,cost:{input:.4,output:2.2},limit:{context:1e6,output:4e4}},{id:"minimax/minimax-m2",label:"MiniMax M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-23",lastUpdated:"2025-10-23",openWeights:!0,cost:{input:.28,output:1.15,cacheRead:.28,cacheWrite:1.15},limit:{context:196600,output:118e3},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"minimax/minimax-m2.1",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"mistralai/codestral-2508",label:"Codestral 2508",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-01",lastUpdated:"2025-08-01",openWeights:!0,cost:{input:.3,output:.9},limit:{context:256e3,output:256e3}},{id:"mistralai/devstral-2512",label:"Devstral 2 2512",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/devstral-2512:free",label:"Devstral 2 2512 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:262144}},{id:"mistralai/devstral-medium-2507",label:"Devstral Medium",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/devstral-small-2505",label:"Devstral Small",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!0,cost:{input:.06,output:.12},limit:{context:128e3,output:128e3}},{id:"mistralai/devstral-small-2505:free",label:"Devstral Small 2505 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-21",lastUpdated:"2025-05-21",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"mistralai/devstral-small-2507",label:"Devstral Small 1.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.1,output:.3},limit:{context:131072,output:131072}},{id:"mistralai/mistral-7b-instruct:free",label:"Mistral 7B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-05",releaseDate:"2024-05-27",lastUpdated:"2024-05-27",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"mistralai/mistral-medium-3",label:"Mistral Medium 3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!1,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3.1",label:"Mistral Medium 3.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-12",lastUpdated:"2025-08-12",openWeights:!1,cost:{input:.4,output:2},limit:{context:262144,output:262144}},{id:"mistralai/mistral-nemo:free",label:"Mistral Nemo (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2024-07-19",lastUpdated:"2024-07-19",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"mistralai/mistral-small-3.1-24b-instruct",label:"Mistral Small 3.1 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-17",lastUpdated:"2025-03-17",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct",label:"Mistral Small 3.2 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct:free",label:"Mistral Small 3.2 24B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:96e3}},{id:"moonshotai/kimi-dev-72b:free",label:"Kimi Dev 72b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-06-16",lastUpdated:"2025-06-16",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"moonshotai/kimi-k2",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:.55,output:2.2},limit:{context:131072,output:32768}},{id:"moonshotai/kimi-k2-0905",label:"Kimi K2 Instruct 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-0905:exacto",label:"Kimi K2 Instruct 0905 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"moonshotai/kimi-k2:free",label:"Kimi K2 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32800,output:32800}},{id:"moonshotai/kimi-k2.5",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144},provider:{npm:"@openrouter/ai-sdk-provider"}},{id:"nousresearch/deephermes-3-llama-3-8b-preview",label:"DeepHermes 3 Llama 3 8B Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2025-02-28",lastUpdated:"2025-02-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"nousresearch/hermes-4-405b",label:"Hermes 4 405B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:1,output:3},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-70b",label:"Hermes 4 70B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:.13,output:.4},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-nano-9b-v2",label:"nvidia-nemotron-nano-9b-v2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-08-18",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:.04,output:.16},limit:{context:131072,output:131072}},{id:"openai/gpt-4.1",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"openai/gpt-4.1-mini",label:"GPT-4.1 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"openai/gpt-4o-mini",label:"GPT-4o-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"openai/gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-chat",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-codex",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-image",label:"GPT-5 Image",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-10-14",lastUpdated:"2025-10-14",openWeights:!1,cost:{input:5,output:10,cacheRead:1.25},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-mini",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-pro",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"openai/gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-chat",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.1-codex",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-max",label:"GPT-5.1-Codex-Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.1,output:9,cacheRead:.11},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-mini",label:"GPT-5.1-Codex-Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:1e5}},{id:"openai/gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-chat-latest",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.2-codex",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-pro",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"openai/gpt-oss-120b",label:"GPT OSS 120B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.072,output:.28},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:exacto",label:"GPT OSS 120B (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.24},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b",label:"GPT OSS 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.2},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-safeguard-20b",label:"GPT OSS Safeguard 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-29",lastUpdated:"2025-10-29",openWeights:!1,cost:{input:.075,output:.3},limit:{context:131072,output:65536}},{id:"openai/o4-mini",label:"o4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"openrouter/sherlock-dash-alpha",label:"Sherlock Dash Alpha",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-15",lastUpdated:"2025-12-14",openWeights:!1,cost:{input:0,output:0},limit:{context:184e4,output:0}},{id:"openrouter/sherlock-think-alpha",label:"Sherlock Think Alpha",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-11",releaseDate:"2025-11-15",lastUpdated:"2025-12-14",openWeights:!1,cost:{input:0,output:0},limit:{context:184e4,output:0}},{id:"qwen/qwen-2.5-coder-32b-instruct",label:"Qwen2.5 Coder 32B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2024-11-11",lastUpdated:"2024-11-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen2.5-vl-32b-instruct:free",label:"Qwen2.5 VL 32B Instruct (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"qwen/qwen2.5-vl-72b-instruct",label:"Qwen2.5 VL 72B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen2.5-vl-72b-instruct:free",label:"Qwen2.5 VL 72B Instruct (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-02",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"qwen/qwen3-14b:free",label:"Qwen3 14B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-235b-a22b-07-25",label:"Qwen3 235B A22B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:.15,output:.85},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-07-25:free",label:"Qwen3 235B A22B Instruct 2507 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-thinking-2507",label:"Qwen3 235B A22B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-25",lastUpdated:"2025-07-25",openWeights:!0,cost:{input:.078,output:.312},limit:{context:262144,output:81920}},{id:"qwen/qwen3-235b-a22b:free",label:"Qwen3 235B A22B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"qwen/qwen3-30b-a3b-instruct-2507",label:"Qwen3 30B A3B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b-thinking-2507",label:"Qwen3 30B A3B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b:free",label:"Qwen3 30B A3B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-32b:free",label:"Qwen3 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-8b:free",label:"Qwen3 8B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"qwen/qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:262144,output:66536}},{id:"qwen/qwen3-coder-30b-a3b-instruct",label:"Qwen3 Coder 30B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-31",lastUpdated:"2025-07-31",openWeights:!0,cost:{input:.07,output:.27},limit:{context:16e4,output:65536}},{id:"qwen/qwen3-coder-flash",label:"Qwen3 Coder Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!1,cost:{input:.3,output:1.5},limit:{context:128e3,output:66536}},{id:"qwen/qwen3-coder:exacto",label:"Qwen3 Coder (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.38,output:1.53},limit:{context:131072,output:32768}},{id:"qwen/qwen3-coder:free",label:"Qwen3 Coder 480B A35B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:66536}},{id:"qwen/qwen3-max",label:"Qwen3 Max",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!1,cost:{input:1.2,output:6},limit:{context:262144,output:32768}},{id:"qwen/qwen3-next-80b-a3b-instruct",label:"Qwen3 Next 80B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3-next-80b-a3b-thinking",label:"Qwen3 Next 80B A3B Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwq-32b:free",label:"QwQ 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-03",releaseDate:"2025-03-05",lastUpdated:"2025-03-05",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"rekaai/reka-flash-3",label:"Reka Flash 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"sarvamai/sarvam-m:free",label:"Sarvam-M (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-25",lastUpdated:"2025-05-25",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"thudm/glm-z1-32b:free",label:"GLM Z1 32B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"tngtech/deepseek-r1t2-chimera:free",label:"DeepSeek R1T2 Chimera (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-08",lastUpdated:"2025-07-08",openWeights:!0,cost:{input:0,output:0},limit:{context:163840,output:163840}},{id:"x-ai/grok-3",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-beta",label:"Grok 3 Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini-beta",label:"Grok 3 Mini Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-4",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:256e3,output:64e3}},{id:"x-ai/grok-4-fast",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-08-19",lastUpdated:"2025-08-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.1-fast",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-code-fast-1",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"z-ai/glm-4.5",label:"GLM 4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air",label:"GLM 4.5 Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air:free",label:"GLM 4.5 Air (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5v",label:"GLM 4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"z-ai/glm-4.6",label:"GLM 4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.6:exacto",label:"GLM 4.6 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:1.9,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:204800,output:131072},provider:{npm:"@openrouter/ai-sdk-provider"}}],label:"OpenRouter",env:["OPENROUTER_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models"},opencode:{id:"opencode",models:[{id:"big-pickle",label:"Big Pickle",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-10-17",lastUpdated:"2025-10-17",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:128e3}},{id:"claude-3-5-haiku",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-1",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-5",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-5",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"gemini-3-flash",label:"Gemini 3 Flash",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3-pro",label:"Gemini 3 Pro",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7-free",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"gpt-5",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-codex",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-nano",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2-codex",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"grok-code",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-08-20",lastUpdated:"2025-08-20",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:256e3,output:256e3}},{id:"kimi-k2",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2.5",label:"Kimi K2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:1.2,output:1.2,cacheRead:.6},limit:{context:262144,output:262144}},{id:"minimax-m2.1",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"minimax-m2.1-free",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.45,output:1.8},limit:{context:262144,output:65536}}],label:"OpenCode Zen",env:["OPENCODE_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://opencode.ai/zen/v1",doc:"https://opencode.ai/docs/zen"},zai:{id:"zai",models:[{id:"glm-4.5",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:.3,output:.9},limit:{context:128e3,output:32768}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}}],label:"Z.AI",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/paas/v4",doc:"https://docs.z.ai/guides/overview/pricing"},"zai-coding":{id:"zai-coding",models:[{id:"glm-4.5",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:0,output:0},limit:{context:64e3,output:16384}},{id:"glm-4.6",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:32768}},{id:"glm-4.7",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.7-flash",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI Coding Plan",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/coding/paas/v4",doc:"https://docs.z.ai/devpack/overview"},moonshot:{id:"moonshot",models:[{id:"kimi-k2-0711-preview",label:"Kimi K2 0711",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-14",lastUpdated:"2025-07-14",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:131072,output:16384}},{id:"kimi-k2-0905-preview",label:"Kimi K2 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking-turbo",label:"Kimi K2 Thinking Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:1.15,output:8,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-turbo-preview",label:"Kimi K2 Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:2.4,output:10,cacheRead:.6},limit:{context:262144,output:262144}}],label:"Moonshot AI",env:["MOONSHOT_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.moonshot.ai/v1",doc:"https://platform.moonshot.ai/docs/api/chat"}},uL="setu",BJ=e=>!!(e==="codex-mini-latest"||e.startsWith("gpt-5")||e.includes("codex")),FJ=e=>!!(e.includes("-3-5-")||e.includes("-3.5-")||e.match(/claude-(haiku|sonnet|opus)-3/)||e.includes("-4-")||e.includes("-4.")||e.match(/claude-(haiku|sonnet|opus)-4/)),jJ=[{id:"openai",npm:"@ai-sdk/openai"},{id:"anthropic",npm:"@ai-sdk/anthropic"}];function PJ(e){return{...e,modalities:e.modalities?{input:e.modalities.input?[...e.modalities.input]:void 0,output:e.modalities.output?[...e.modalities.output]:void 0}:void 0,cost:e.cost?{...e.cost}:void 0,limit:e.limit?{...e.limit}:void 0,provider:e.provider?{...e.provider}:void 0}}function UJ(e){const t=jJ.flatMap(({id:s,npm:l})=>(e[s]?.models??[]).filter(u=>s==="openai"?BJ(u.id):s==="anthropic"?FJ(u.id):!0).map(u=>{const d=PJ(u);return d.provider={...d.provider??{},npm:l},d}));if(!t.length)return null;t.sort((s,l)=>{const c=s.provider?.npm??"",o=l.provider?.npm??"";return c===o?s.id.localeCompare(l.id):c==="@ai-sdk/openai"?-1:o==="@ai-sdk/openai"?1:c.localeCompare(o)});const n="codex-mini-latest",i=t.findIndex(s=>s.id===n);if(i>0){const[s]=t.splice(i,1);t.unshift(s)}return{id:uL,label:"Setu",env:["SETU_PRIVATE_KEY"],api:"https://setu.agi.nitish.sh/v1",doc:"https://setu.agi.nitish.sh/docs",models:t}}function HJ(e){const t=UJ(e),n={...e};return t&&(n[uL]=t),n}const zJ=HJ(MJ),qJ={openai:[{match:e=>e.includes("gpt-4o-mini"),inputPerMillion:.15,outputPerMillion:.6},{match:e=>e.includes("gpt-4o"),inputPerMillion:5,outputPerMillion:15},{match:e=>e.includes("gpt-4.1-mini"),inputPerMillion:1,outputPerMillion:4},{match:e=>e.includes("gpt-4.1"),inputPerMillion:5,outputPerMillion:15}],anthropic:[{match:e=>e.includes("claude-3-haiku"),inputPerMillion:.25,outputPerMillion:1.25},{match:e=>e.includes("claude-3-sonnet"),inputPerMillion:3,outputPerMillion:15},{match:e=>e.includes("claude-3-opus"),inputPerMillion:15,outputPerMillion:75}],google:[{match:e=>e.includes("gemini-1.5-flash"),inputPerMillion:.35,outputPerMillion:1.05},{match:e=>e.includes("gemini-1.5-pro"),inputPerMillion:3.5,outputPerMillion:10.5}],openrouter:[],opencode:[],setu:[],zai:[],"zai-coding":[],moonshot:[]};function $J(e,t){const n=qJ[e];if(n)return n.find(i=>{try{return i.match(t)}catch{return!1}})}function GJ(e,t){const n=zJ[e];if(!n)return;const i=t.toLowerCase();return n.models.find(s=>s.id?.toLowerCase()===i)}function cL(e,t,n){const i=typeof n.inputTokens=="number"?n.inputTokens:0,s=typeof n.outputTokens=="number"?n.outputTokens:0,l=typeof n.cachedInputTokens=="number"?n.cachedInputTokens:0,c=typeof n.cacheCreationInputTokens=="number"?n.cacheCreationInputTokens:0;if(!i&&!s&&!l&&!c)return;const o=GJ(e,t);if(o?.cost?.input!=null||o?.cost?.output!=null){const m=typeof o.cost?.input=="number"?o.cost.input:0,v=typeof o.cost?.output=="number"?o.cost.output:0,w=typeof o.cost?.cacheRead=="number"?o.cost.cacheRead:0,E=typeof o.cost?.cacheWrite=="number"?o.cost.cacheWrite:0,b=i*m/1e6,_=s*v/1e6,x=l*w/1e6,S=c*E/1e6,k=b+_+x+S;return Number.isFinite(k)?Number(k.toFixed(6)):void 0}const u=$J(e,t.toLowerCase());if(!u)return;const d=i*u.inputPerMillion/1e6,p=s*u.outputPerMillion/1e6,f=d+p;return Number.isFinite(f)?Number(f.toFixed(6)):void 0}function WJ({session:e,onNavigateToSession:t}){const{data:n}=sL(e.sessionType==="branch"?e.id:void 0),{data:i}=Xv(e.id),s=q.useMemo(()=>{const v=e.totalInputTokens||0,w=e.totalOutputTokens||0,E=e.totalCachedTokens||0,b=e.totalCacheCreationTokens||0;return cL(e.provider,e.model,{inputTokens:v,outputTokens:w,cachedInputTokens:E,cacheCreationInputTokens:b})??0},[e.provider,e.model,e.totalInputTokens,e.totalOutputTokens,e.totalCachedTokens,e.totalCacheCreationTokens]),l=v=>{if(!v)return"0s";const w=Math.floor(v/1e3),E=Math.floor(w/60),b=Math.floor(E/60);return b>0?`${b}h ${E%60}m`:E>0?`${E}m ${w%60}s`:`${w}s`},c=v=>v.toLocaleString("en-US"),o=v=>v>=1e6?`${(v/1e6).toFixed(1)}M`:v>=1e3?`${(v/1e3).toFixed(1)}K`:v.toString(),u=e.totalInputTokens||0,d=e.totalOutputTokens||0,p=e.totalCachedTokens||0,f=e.sessionType==="branch",m=n?.parent;return y.jsx("div",{className:"border-b border-border bg-background/95 backdrop-blur-sm",children:y.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[f&&y.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm",children:[y.jsx(zn,{className:"h-4 w-4 text-violet-500"}),y.jsx("span",{className:"text-violet-600 dark:text-violet-400 font-medium",children:"Branch"}),m&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground",children:"from"}),y.jsxs("button",{type:"button",onClick:()=>t?.(m.id),className:"text-primary hover:underline flex items-center gap-1",children:[m.title||`Session ${m.id.slice(0,8)}`,y.jsx(wO,{className:"h-3 w-3"})]})]}),!m&&e.parentSessionId&&y.jsx("span",{className:"text-muted-foreground italic text-xs",children:"(parent deleted)"})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("h1",{className:"text-2xl font-semibold text-foreground leading-tight truncate",children:e.title||"Untitled Session"}),i?.shared&&y.jsxs("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[y.jsx(Hv,{className:"h-3 w-3"}),y.jsx("span",{children:"Shared"}),i.pendingMessages&&i.pendingMessages>0?y.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[y.jsx(Ea,{className:"h-2.5 w-2.5"}),i.pendingMessages]}):y.jsx(wr,{className:"h-2.5 w-2.5 opacity-60"})]})]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 mt-4 text-sm text-muted-foreground",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(u)} input tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"in"}),y.jsx("span",{className:"font-medium text-foreground",children:o(u)})]}),y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(d)} output tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"out"}),y.jsx("span",{className:"font-medium text-foreground",children:o(d)})]}),p>0&&y.jsxs("div",{className:"flex items-center gap-1.5",title:`${c(p)} cached tokens`,children:[y.jsx("span",{className:"text-xs opacity-70",children:"cached"}),y.jsx("span",{className:"font-medium text-foreground",children:o(p)})]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(RO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium text-foreground",children:l(e.totalToolTimeMs)})]}),s>0&&y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(NO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium text-foreground",children:s.toFixed(4)})]}),y.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[y.jsx(Lc,{provider:e.provider,size:18}),y.jsx("span",{className:"font-medium text-foreground truncate max-w-48",children:e.model})]})]})]})})}function VJ({session:e,isVisible:t,isGenerating:n,onNavigateToSession:i}){const{data:s}=sL(e.sessionType==="branch"?e.id:void 0),{data:l}=Xv(e.id),c=q.useMemo(()=>{const m=e.totalInputTokens||0,v=e.totalOutputTokens||0,w=e.totalCachedTokens||0,E=e.totalCacheCreationTokens||0;return cL(e.provider,e.model,{inputTokens:m,outputTokens:v,cachedInputTokens:w,cacheCreationInputTokens:E})??0},[e.provider,e.model,e.totalInputTokens,e.totalOutputTokens,e.totalCachedTokens,e.totalCacheCreationTokens]),o=m=>m>=1e6?`${(m/1e6).toFixed(1)}M`:m>=1e3?`${(m/1e3).toFixed(1)}K`:m.toString(),u=e.totalInputTokens||0,d=e.totalOutputTokens||0,p=e.sessionType==="branch",f=s?.parent;return y.jsx("div",{className:`absolute top-0 left-0 right-0 h-14 border-b border-border bg-background/95 backdrop-blur-sm z-10 transition-transform duration-200 ${t?"translate-y-0":"-translate-y-full"}`,children:y.jsxs("div",{className:"h-full px-6 flex items-center justify-between gap-4 text-sm",children:[y.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 text-muted-foreground",children:[p?y.jsx(zn,{className:"w-4 h-4 flex-shrink-0 text-violet-500"}):y.jsx(BO,{className:"w-4 h-4 flex-shrink-0"}),y.jsx("span",{className:"text-foreground font-medium truncate",children:e.title||"Untitled Session"}),l?.shared&&y.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[y.jsx(Hv,{className:"h-3 w-3"}),l.pendingMessages&&l.pendingMessages>0?y.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[y.jsx(Ea,{className:"h-2.5 w-2.5"}),l.pendingMessages]}):y.jsx(wr,{className:"h-2.5 w-2.5 opacity-60"})]}),p&&f&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:"from"}),y.jsxs("button",{type:"button",onClick:()=>i?.(f.id),className:"text-primary hover:underline flex items-center gap-0.5 truncate max-w-32",title:f.title||`Session ${f.id.slice(0,8)}`,children:[y.jsx("span",{className:"truncate",children:f.title||`Session ${f.id.slice(0,8)}`}),y.jsx(wO,{className:"h-3 w-3 flex-shrink-0"})]})]})]}),y.jsxs("div",{className:"flex-shrink-0 flex items-center gap-5 text-muted-foreground",children:[n&&y.jsx(H7,{sessionId:e.id}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs opacity-70",children:"in"}),y.jsx("span",{className:"text-foreground font-medium",children:o(u)})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs opacity-70",children:"out"}),y.jsx("span",{className:"text-foreground font-medium",children:o(d)})]})]}),c>0&&y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(NO,{className:"w-4 h-4"}),y.jsx("span",{className:"text-foreground font-medium",children:c.toFixed(4)})]}),y.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[y.jsx(Lc,{provider:e.provider,size:16}),y.jsx("span",{className:"font-medium text-foreground truncate max-w-40",children:e.model})]})]})]})})}const KJ=q.memo(function({messages:t,session:n,sessionId:i,isGenerating:s,disableAutoScroll:l=!1,onSelectSession:c}){const o=q.useRef(null),u=q.useRef(null),d=q.useRef(null),[p,f]=q.useState(!0),m=q.useRef(!0),[v,w]=q.useState(!1),E=q.useRef(!1),b=q.useRef(void 0),_=q.useRef(0),x=q.useRef(void 0),S=q.useRef(!1),k=q.useRef(n?.id),O=q.useRef(t.length),T=q.useRef(s),A=q.useRef(0),R=q.useRef(0),D=q.useCallback(()=>{const H=u.current;if(!H)return;const{scrollTop:B,scrollHeight:W,clientHeight:K}=H,V=W-B-K,X=W>A.current,Y=B<R.current-5;A.current=W,R.current=B,V<100?(m.current=!0,f(!0)):Y?(m.current=!1,f(!1),E.current=!0):!X&&m.current&&(m.current=!1,f(!1)),(Y||!m.current&&V>=100)&&(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{E.current=!1},150));const P=d.current;if(P){const M=P.getBoundingClientRect(),j=H.getBoundingClientRect();w(M.bottom<j.top)}},[]);q.useEffect(()=>{if(l)return;const H=n?.id!==k.current;if(k.current=n?.id,H&&(S.current=!1),!S.current&&t.length>0){S.current=!0;const B=u.current;B&&(B.scrollTop=B.scrollHeight)}},[t.length,n?.id,l]),q.useEffect(()=>{if(l)return;const H=s&&!T.current,B=t.length>O.current;T.current=s,O.current=t.length,H?(E.current=!1,m.current=!0,f(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const W=u.current;W&&(W.scrollTop=W.scrollHeight)})})):B&&!E.current&&!s&&(m.current=!0,f(!0))},[t.length,s,l]),q.useEffect(()=>{if(l)return;const H=u.current;if(!H||!p||E.current)return;_.current=H.scrollHeight-H.clientHeight;const B=()=>{const W=u.current;if(!W||E.current)return;const K=W.scrollTop,X=W.scrollHeight-W.clientHeight-K;if(Math.abs(X)<1){W.scrollTop=W.scrollHeight-W.clientHeight;return}if(Math.abs(X)<10){W.scrollTop=W.scrollHeight-W.clientHeight;return}W.scrollTop=K+X*.15,x.current=requestAnimationFrame(B)};x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(B)},[t,p]),q.useEffect(()=>()=>{b.current&&clearTimeout(b.current),x.current&&cancelAnimationFrame(x.current)},[]);const L=()=>{E.current=!1,m.current=!0,f(!0);const H=u.current;H&&(H.scrollTop=H.scrollHeight)},I=q.useMemo(()=>t.filter(H=>H.role!=="system"),[t]);return t.length===0?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):y.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[n&&y.jsx(VJ,{session:n,isVisible:v,isGenerating:s,onNavigateToSession:c}),y.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto",onScroll:D,children:[y.jsx("div",{ref:d,children:n&&y.jsx(WJ,{session:n,onNavigateToSession:c})}),y.jsx("div",{className:"p-6 pb-64",children:y.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[I.map((H,B)=>{const W=I[B-1],K=I[B+1],V=B===I.length-1;if(H.role==="user"){const X=K&&K.role==="assistant"?K:void 0;return y.jsx(lL,{sessionId:i,message:H,isFirst:B===0,nextAssistantMessageId:X?.id},H.id)}if(H.role==="assistant"){const X=!W||W.role!=="assistant",Y=K&&K.role==="assistant";return y.jsx(oL,{sessionId:i,message:H,showHeader:X,hasNextAssistantMessage:Y,isLastMessage:V,onBranchCreated:c},H.id)}return null}),y.jsx("div",{ref:o})]})})]}),!p&&y.jsxs("button",{type:"button",onClick:L,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[y.jsx(P6,{className:"w-4 h-4"}),y.jsx("span",{children:"Scroll to bottom"})]})]})});class dL{abortController=null;handlers=new Map;running=!1;async connect(t){this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.running=!0;try{const n=await fetch(t,{headers:{Accept:"text/event-stream"},signal:this.abortController.signal});if(!n.ok){console.error("[SSE] Connection failed:",n.status);return}const i=n.body?.getReader();if(!i){console.error("[SSE] No response body");return}const s=new TextDecoder;let l="";for(;this.running;){const{done:c,value:o}=await i.read();if(c)break;l+=s.decode(o,{stream:!0});let u=l.indexOf(`
120
120
 
121
121
  `);for(;u!==-1;){const d=l.slice(0,u);l=l.slice(u+2);const p=d.split(`
122
122
  `);let f="message",m="";for(const v of p)v.startsWith("event: ")?f=v.slice(7).trim():v.startsWith("data: ")?m+=(m?`
123
123
  `:"")+v.slice(6):v.startsWith(":");if(m)try{const v=JSON.parse(m);this.emit({type:f,payload:v})}catch(v){console.error(`[SSE] Failed to parse ${f}:`,v)}u=l.indexOf(`
124
124
 
125
- `)}}}catch(n){n instanceof Error&&n.name==="AbortError"||console.error("[SSE] Connection error:",n)}}disconnect(){this.running=!1,this.abortController&&(this.abortController.abort(),this.abortController=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n),()=>{this.off(t,n)}}off(t,n){const i=this.handlers.get(t);i&&(i.delete(n),i.size===0&&this.handlers.delete(t))}emit(t){const n=this.handlers.get(t.type);if(n)for(const s of n)s(t);const i=this.handlers.get("*");if(i)for(const s of i)s(t)}}function hL(e){const t=Lt(),n=q.useRef(null),i=q.useRef(null),s=q.useRef(0),{addPendingApproval:l,removePendingApproval:c,updatePendingApproval:o,setPendingApprovals:u}=$v();q.useEffect(()=>{if(!e){console.log("[useSessionStream] No sessionId, skipping");return}i.current=null,qe.getPendingApprovals(e).then(T=>{T.ok&&T.pending.length>0?u(T.pending):u([])}).catch(()=>{u([])});const d=new dL;n.current=d;const p=qe.getStreamUrl(e);console.log("[useSessionStream] Connecting to stream:",p),d.connect(p);const f=T=>{if(i.current){const A=T.findIndex(R=>R.id===i.current);if(A!==-1)return A}for(let A=T.length-1;A>=0;A-=1){const R=T[A];if(R.role==="assistant"&&R.status!=="complete")return A}return-1},m=T=>{if(T.contentJson&&typeof T.contentJson=="object"&&!Array.isArray(T.contentJson)&&"text"in T.contentJson)return String(T.contentJson.text??"");if(typeof T.content=="string"){try{const A=JSON.parse(T.content);if(A&&typeof A.text=="string")return A.text}catch{}return T.content}return""},v=T=>{const A=typeof T?.messageId=="string"?T.messageId:null,R=typeof T?.partId=="string"?T.partId:null,D=typeof T?.delta=="string"?T.delta:null;!A||!R||D===null||t.setQueryData(["messages",e],L=>{if(!L)return L;const I=[...L],H=I.findIndex(X=>X.id===A);if(H===-1)return L;const B=I[H],W=B.parts?[...B.parts]:[];let K=W.findIndex(X=>X.id===R);const V=typeof T?.stepIndex=="number"?T.stepIndex:null;if(K===-1){const X={id:R,messageId:A,index:W.length,stepIndex:V,type:"reasoning",content:JSON.stringify({text:D}),contentJson:{text:D},agent:B.agent,provider:B.provider,model:B.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};W.push(X),K=W.length-1}else{const X=W[K],P=`${m(X)}${D}`;W[K]={...X,content:JSON.stringify({text:P}),contentJson:{text:P},stepIndex:V??X.stepIndex??null,completedAt:null}}return I[H]={...B,parts:W},I})},w=T=>{const A=typeof T?.messageId=="string"?T.messageId:null,R=typeof T?.partId=="string"?T.partId:null,D=typeof T?.delta=="string"?T.delta:null;!A||!R||D===null||t.setQueryData(["messages",e],L=>{if(!L)return L;const I=[...L],H=I.findIndex(X=>X.id===A);if(H===-1)return L;const B=I[H],W=B.parts?[...B.parts]:[];let K=W.findIndex(X=>X.id===R);const V=typeof T?.stepIndex=="number"?T.stepIndex:null;if(K===-1){const X={id:R,messageId:A,index:W.length,stepIndex:V,type:"text",content:JSON.stringify({text:D}),contentJson:{text:D},agent:B.agent,provider:B.provider,model:B.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};W.push(X),K=W.length-1}else{const X=W[K],P=`${m(X)}${D}`;W[K]={...X,content:JSON.stringify({text:P}),contentJson:{text:P},stepIndex:V??X.stepIndex??null,completedAt:null}}return I[H]={...B,parts:W},I})},E=T=>{if(!T)return;const A=typeof T.callId=="string"?T.callId:null,R=typeof T.name=="string"?T.name:null;R&&t.setQueryData(["messages",e],D=>{if(!D)return D;const L=[...D];let I=f(L);if(typeof T.messageId=="string"){const Y=L.findIndex(P=>P.id===T.messageId);Y!==-1&&(I=Y)}if(I===-1)return D;const H=L[I],B=H.parts?[...H.parts]:[];let W=-1;A&&(W=B.findIndex(Y=>Y.toolCallId===A&&Y.ephemeral)),W===-1&&!A&&(W=B.findIndex(Y=>Y.ephemeral&&Y.toolName===R));const K=T.args,V=typeof T.stepIndex=="number"?T.stepIndex:null,X={name:R};if(A&&(X.callId=A),K!==void 0&&(X.args=K),W===-1){const Y={id:A?`ephemeral-tool-call-${A}`:`ephemeral-tool-call-${R}-${Date.now()}`,messageId:H.id,index:B.length,stepIndex:V,type:"tool_call",content:JSON.stringify(X),contentJson:X,agent:H.agent,provider:H.provider,model:H.model,startedAt:Date.now(),completedAt:null,toolName:R,toolCallId:A,toolDurationMs:null,ephemeral:!0};B.push(Y)}else{const Y=B[W],P={...typeof Y.contentJson=="object"&&!Array.isArray(Y.contentJson)?Y.contentJson:{},name:R};A&&(P.callId=A),K!==void 0&&(P.args=K),B[W]={...Y,content:JSON.stringify(P),contentJson:P,stepIndex:V??Y.stepIndex??null,toolCallId:A??Y.toolCallId,toolName:R}}return L[I]={...H,parts:B},L})},b=T=>{const A=typeof T?.callId=="string"?T.callId:null;A&&t.setQueryData(["messages",e],R=>{if(!R)return R;let D=!1;const L=R.map(I=>{if(!I.parts?.length)return I;const H=I.parts.filter(B=>!(B.ephemeral&&B.toolCallId===A));return H.length===I.parts.length?I:(D=!0,{...I,parts:H})});return D?L:R})},_=T=>{T&&t.setQueryData(["messages",e],A=>{if(!A)return A;const R=A.findIndex(I=>I.id===T);if(R===-1)return A;const D=A[R];if(!D.parts?.some(I=>I.ephemeral))return A;const L=[...A];return L[R]={...D,parts:D.parts?.filter(I=>!I.ephemeral)??[]},L})},x=T=>{const A=typeof T?.id=="string"?T.id:null;A&&t.setQueryData(["messages",e],R=>{if(!R)return R;const D=[...R],L=D.findIndex(H=>H.id===A);if(L===-1)return R;const I=D[L];return D[L]={...I,status:"complete",completedAt:Date.now()},D})},S=()=>{const T=Date.now();T-s.current<500||(s.current=T,t.invalidateQueries({queryKey:["messages",e]}))},k=new Set(["message.completed","tool.result","finish-step","error"]),O=d.on("*",T=>{const A=T.payload;switch(T.type){case"message.created":{const R=typeof A?.role=="string"?A.role:null,D=typeof A?.id=="string"?A.id:null;R==="assistant"&&D&&(i.current=D);break}case"message.part.delta":{w(A);break}case"reasoning.delta":{v(A);break}case"message.completed":{const R=typeof A?.id=="string"?A.id:null;R&&i.current===R&&(i.current=null),x(A),_(R);break}case"tool.delta":{(typeof A?.channel=="string"?A.channel:null)==="input"&&E(A);break}case"tool.call":{E(A);break}case"tool.result":{b(A);break}case"tool.approval.required":{const R=typeof A?.callId=="string"?A.callId:null,D=typeof A?.toolName=="string"?A.toolName:null,L=typeof A?.messageId=="string"?A.messageId:null,I=A?.args;R&&D&&L&&l({callId:R,toolName:D,args:I,messageId:L,createdAt:Date.now()});break}case"tool.approval.resolved":{const R=typeof A?.callId=="string"?A.callId:null;R&&c(R);break}case"tool.approval.updated":{const R=typeof A?.callId=="string"?A.callId:null,D=A?.args;R&&o(R,D);break}case"error":{b(A);const R=typeof A?.messageId=="string"?A.messageId:null;R&&_(R);break}case"queue.updated":{const R={currentMessageId:A?.currentMessageId,queuedMessages:A?.queuedMessages??[],queueLength:A?.queueLength??0};t.setQueryData(["queueState",e],R);break}}k.has(T.type)&&S()});return()=>{O(),d.disconnect()}},[e,t])}function YJ(e){const{pendingApprovals:t,removePendingApproval:n}=$v(),i=t,s=q.useCallback(async o=>{if(e)try{await qe.approveToolCall(e,o,!0),n(o)}catch(u){console.error("Failed to approve tool call:",u)}},[e,n]),l=q.useCallback(async o=>{if(e)try{await qe.approveToolCall(e,o,!1),n(o)}catch(u){console.error("Failed to reject tool call:",u)}},[e,n]),c=q.useCallback(async()=>{if(e)try{await Promise.all(i.map(o=>qe.approveToolCall(e,o.callId,!0)));for(const o of i)n(o.callId)}catch(o){console.error("Failed to approve all tool calls:",o)}},[e,i,n]);q.useEffect(()=>{if(!e||i.length===0)return;const o=u=>{if(u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement||u.target?.isContentEditable)return;const d=i[0];u.key==="y"||u.key==="Y"?(u.preventDefault(),s(d.callId)):u.key==="n"||u.key==="N"||u.key==="Escape"?(u.preventDefault(),l(d.callId)):(u.key==="a"||u.key==="A")&&(u.preventDefault(),c())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,i,s,l,c])}const XJ=q.memo(function({sessionId:t,onSelectSession:n}){const{data:i=[],isLoading:s}=pc(t),{data:l=[]}=Mc();hL(t),YJ(t);const c=q.useMemo(()=>l.find(u=>u.id===t),[l,t]),o=q.useMemo(()=>i.some(u=>u.role==="assistant"&&u.status==="pending"),[i]);return s?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):y.jsx(KJ,{messages:i,sessionId:t,session:c,isGenerating:o,onSelectSession:n})}),ZJ=q.memo(function({session:t,isActive:n,onClick:i}){const s=d=>{const p=new Date(d),m=new Date().getTime()-p.getTime(),v=Math.floor(m/6e4),w=Math.floor(v/60),E=Math.floor(w/24);return v<1?"just now":v<60?`${v}m ago`:w<24?`${w}h ago`:E<7?`${E}d ago`:p.toLocaleDateString()},l=t.sessionType==="branch";return y.jsx("button",{type:"button",onClick:i,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors duration-150 ${n?"bg-primary/10":"hover:bg-muted/20"}`,children:y.jsxs("div",{className:"flex items-start gap-3",children:[l?y.jsx(zn,{className:`h-4 w-4 shrink-0 mt-1 text-muted-foreground ${n?"text-primary":""}`}):y.jsx(BO,{className:`h-4 w-4 shrink-0 mt-1 text-muted-foreground ${n?"text-primary":""}`}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:t.title||`Session ${t.id.slice(0,8)}`}),l&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-violet-500/10 text-violet-600 dark:text-violet-400 rounded-full shrink-0",children:"branch"})]}),y.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-muted-foreground/80",children:[t.agent&&y.jsx("span",{className:"uppercase",children:t.agent}),t.agent&&y.jsx("span",{children:"•"}),y.jsx("span",{children:s(t.lastActiveAt||t.createdAt)})]})]})]})})}),N1=$n(e=>({currentFocus:null,sessionIndex:0,gitFileIndex:0,setFocus:t=>e({currentFocus:t}),setSessionIndex:t=>e({sessionIndex:t}),setGitFileIndex:t=>e({gitFileIndex:t}),resetGitFileIndex:()=>e({gitFileIndex:0}),resetSessionIndex:()=>e({sessionIndex:0})})),QJ=q.memo(function({activeSessionId:t,onSelectSession:n}){const{data:i=[],isLoading:s}=Mc(),{currentFocus:l,sessionIndex:c}=N1(),o=q.useRef(new Map),u=q.useCallback(p=>{n(p)},[n]),d=q.useMemo(()=>i.map(p=>({id:p.id,title:p.title,agent:p.agent,createdAt:p.createdAt})),[i]);return q.useEffect(()=>{l==="sessions"&&o.current.get(c)?.scrollIntoView({block:"nearest",behavior:"smooth"})},[l,c]),s?y.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/80",children:"Loading sessions..."}):d.length===0?y.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/80",children:"No sessions yet. Create one to get started."}):y.jsx("div",{className:"flex flex-col gap-1 px-2 py-2 overflow-y-auto scrollbar-hide",children:d.map((p,f)=>{const m=i.find(w=>w.id===p.id);if(!m)return null;const v=l==="sessions"&&c===f;return y.jsx("div",{ref:w=>{w?o.current.set(f,w):o.current.delete(f)},className:v?"ring-1 ring-primary/40 rounded-md":"",children:y.jsx(ZJ,{session:m,isActive:p.id===t,onClick:()=>u(p.id)})},p.id)})})}),JJ={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",txt:"plaintext",svelte:"svelte"};function eee(e){const t=e.split(".").pop()?.toLowerCase()??"";return t?JJ[t]??"plaintext":"plaintext"}function tee(e){const t=e.split("/");return t[t.length-1]}function nee({diff:e}){const t=document?.documentElement.classList.contains("dark")?ei:Rr,n=e.language&&e.language.trim().length>0?e.language:eee(e.file),i=tee(e.file);if(e.isNewFile&&e.content)return y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[y.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:e.file,children:i}),y.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[y.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",e.insertions]}),y.jsx("span",{className:"text-muted-foreground",children:n})]})]}),y.jsx("div",{className:"px-4 py-3 bg-green-500/10 border-b border-green-500/20",children:y.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:["New file: ",e.insertions," lines"]})}),y.jsx("div",{className:"flex-1 overflow-auto",children:y.jsx(Cn,{language:n,style:t,showLineNumbers:!0,customStyle:{margin:0,padding:"1rem",background:"transparent"},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"var(--color-muted-foreground)",userSelect:"none"},children:e.content})})]});if(e.isBinary)return y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[y.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:e.file,children:i}),y.jsx("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:y.jsx("span",{className:"text-muted-foreground",children:"Binary file"})})]}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("div",{className:"p-4 text-center",children:y.jsx("p",{className:"text-sm text-muted-foreground",children:"Binary file - cannot display diff"})})})]});const s=e.diff.split(`
125
+ `)}}}catch(n){n instanceof Error&&n.name==="AbortError"||console.error("[SSE] Connection error:",n)}}disconnect(){this.running=!1,this.abortController&&(this.abortController.abort(),this.abortController=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n),()=>{this.off(t,n)}}off(t,n){const i=this.handlers.get(t);i&&(i.delete(n),i.size===0&&this.handlers.delete(t))}emit(t){const n=this.handlers.get(t.type);if(n)for(const s of n)s(t);const i=this.handlers.get("*");if(i)for(const s of i)s(t)}}function hL(e){const t=Lt(),n=q.useRef(null),i=q.useRef(null),s=q.useRef(0),{addPendingApproval:l,removePendingApproval:c,updatePendingApproval:o,setPendingApprovals:u}=$v();q.useEffect(()=>{if(!e){console.log("[useSessionStream] No sessionId, skipping");return}i.current=null,qe.getPendingApprovals(e).then(T=>{T.ok&&T.pending.length>0?u(T.pending):u([])}).catch(()=>{u([])});const d=new dL;n.current=d;const p=qe.getStreamUrl(e);console.log("[useSessionStream] Connecting to stream:",p),d.connect(p);const f=T=>{if(i.current){const A=T.findIndex(R=>R.id===i.current);if(A!==-1)return A}for(let A=T.length-1;A>=0;A-=1){const R=T[A];if(R.role==="assistant"&&R.status!=="complete")return A}return-1},m=T=>{if(T.contentJson&&typeof T.contentJson=="object"&&!Array.isArray(T.contentJson)&&"text"in T.contentJson)return String(T.contentJson.text??"");if(typeof T.content=="string"){try{const A=JSON.parse(T.content);if(A&&typeof A.text=="string")return A.text}catch{}return T.content}return""},v=T=>{const A=typeof T?.messageId=="string"?T.messageId:null,R=typeof T?.partId=="string"?T.partId:null,D=typeof T?.delta=="string"?T.delta:null;!A||!R||D===null||t.setQueryData(["messages",e],L=>{if(!L)return L;const I=[...L],H=I.findIndex(X=>X.id===A);if(H===-1)return L;const B=I[H],W=B.parts?[...B.parts]:[];let K=W.findIndex(X=>X.id===R);const V=typeof T?.stepIndex=="number"?T.stepIndex:null;if(K===-1){const X={id:R,messageId:A,index:W.length,stepIndex:V,type:"reasoning",content:JSON.stringify({text:D}),contentJson:{text:D},agent:B.agent,provider:B.provider,model:B.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};W.push(X),K=W.length-1}else{const X=W[K],P=`${m(X)}${D}`;W[K]={...X,content:JSON.stringify({text:P}),contentJson:{text:P},stepIndex:V??X.stepIndex??null,completedAt:null}}return I[H]={...B,parts:W},I})},w=T=>{const A=typeof T?.messageId=="string"?T.messageId:null,R=typeof T?.partId=="string"?T.partId:null,D=typeof T?.delta=="string"?T.delta:null;!A||!R||D===null||t.setQueryData(["messages",e],L=>{if(!L)return L;const I=[...L],H=I.findIndex(X=>X.id===A);if(H===-1)return L;const B=I[H],W=B.parts?[...B.parts]:[];let K=W.findIndex(X=>X.id===R);const V=typeof T?.stepIndex=="number"?T.stepIndex:null;if(K===-1){const X={id:R,messageId:A,index:W.length,stepIndex:V,type:"text",content:JSON.stringify({text:D}),contentJson:{text:D},agent:B.agent,provider:B.provider,model:B.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};W.push(X),K=W.length-1}else{const X=W[K],P=`${m(X)}${D}`;W[K]={...X,content:JSON.stringify({text:P}),contentJson:{text:P},stepIndex:V??X.stepIndex??null,completedAt:null}}return I[H]={...B,parts:W},I})},E=T=>{if(!T)return;const A=typeof T.callId=="string"?T.callId:null,R=typeof T.name=="string"?T.name:null;R&&t.setQueryData(["messages",e],D=>{if(!D)return D;const L=[...D];let I=f(L);if(typeof T.messageId=="string"){const Y=L.findIndex(P=>P.id===T.messageId);Y!==-1&&(I=Y)}if(I===-1)return D;const H=L[I],B=H.parts?[...H.parts]:[];let W=-1;A&&(W=B.findIndex(Y=>Y.toolCallId===A&&Y.ephemeral)),W===-1&&!A&&(W=B.findIndex(Y=>Y.ephemeral&&Y.toolName===R));const K=T.args,V=typeof T.stepIndex=="number"?T.stepIndex:null,X={name:R};if(A&&(X.callId=A),K!==void 0&&(X.args=K),W===-1){const Y={id:A?`ephemeral-tool-call-${A}`:`ephemeral-tool-call-${R}-${Date.now()}`,messageId:H.id,index:B.length,stepIndex:V,type:"tool_call",content:JSON.stringify(X),contentJson:X,agent:H.agent,provider:H.provider,model:H.model,startedAt:Date.now(),completedAt:null,toolName:R,toolCallId:A,toolDurationMs:null,ephemeral:!0};B.push(Y)}else{const Y=B[W],P={...typeof Y.contentJson=="object"&&!Array.isArray(Y.contentJson)?Y.contentJson:{},name:R};A&&(P.callId=A),K!==void 0&&(P.args=K),B[W]={...Y,content:JSON.stringify(P),contentJson:P,stepIndex:V??Y.stepIndex??null,toolCallId:A??Y.toolCallId,toolName:R}}return L[I]={...H,parts:B},L})},b=T=>{const A=typeof T?.callId=="string"?T.callId:null;A&&t.setQueryData(["messages",e],R=>{if(!R)return R;let D=!1;const L=R.map(I=>{if(!I.parts?.length)return I;const H=I.parts.filter(B=>!(B.ephemeral&&B.toolCallId===A));return H.length===I.parts.length?I:(D=!0,{...I,parts:H})});return D?L:R})},_=T=>{T&&t.setQueryData(["messages",e],A=>{if(!A)return A;const R=A.findIndex(I=>I.id===T);if(R===-1)return A;const D=A[R];if(!D.parts?.some(I=>I.ephemeral))return A;const L=[...A];return L[R]={...D,parts:D.parts?.filter(I=>!I.ephemeral)??[]},L})},x=T=>{const A=typeof T?.id=="string"?T.id:null;A&&t.setQueryData(["messages",e],R=>{if(!R)return R;const D=[...R],L=D.findIndex(H=>H.id===A);if(L===-1)return R;const I=D[L];return D[L]={...I,status:"complete",completedAt:Date.now()},D})},S=()=>{const T=Date.now();T-s.current<500||(s.current=T,t.invalidateQueries({queryKey:["messages",e]}))},k=new Set(["message.completed","tool.result","finish-step","error"]),O=d.on("*",T=>{const A=T.payload;switch(T.type){case"message.created":{const R=typeof A?.role=="string"?A.role:null,D=typeof A?.id=="string"?A.id:null;R==="assistant"&&D&&(i.current=D);break}case"message.part.delta":{w(A);break}case"reasoning.delta":{v(A);break}case"message.completed":{const R=typeof A?.id=="string"?A.id:null;R&&i.current===R&&(i.current=null),x(A),_(R);break}case"tool.delta":{(typeof A?.channel=="string"?A.channel:null)==="input"&&E(A);break}case"tool.call":{E(A);break}case"tool.result":{b(A);break}case"tool.approval.required":{const R=typeof A?.callId=="string"?A.callId:null,D=typeof A?.toolName=="string"?A.toolName:null,L=typeof A?.messageId=="string"?A.messageId:null,I=A?.args;R&&D&&L&&l({callId:R,toolName:D,args:I,messageId:L,createdAt:Date.now()});break}case"tool.approval.resolved":{const R=typeof A?.callId=="string"?A.callId:null;R&&c(R);break}case"tool.approval.updated":{const R=typeof A?.callId=="string"?A.callId:null,D=A?.args;R&&o(R,D);break}case"error":{b(A);const R=typeof A?.messageId=="string"?A.messageId:null;R&&_(R);break}case"queue.updated":{const R={currentMessageId:A?.currentMessageId,queuedMessages:A?.queuedMessages??[],queueLength:A?.queueLength??0};t.setQueryData(["queueState",e],R);break}}k.has(T.type)&&S()});return()=>{O(),d.disconnect()}},[e,t,l,c,u,o])}function YJ(e){const{pendingApprovals:t,removePendingApproval:n}=$v(),i=t,s=q.useCallback(async o=>{if(e)try{await qe.approveToolCall(e,o,!0),n(o)}catch(u){console.error("Failed to approve tool call:",u)}},[e,n]),l=q.useCallback(async o=>{if(e)try{await qe.approveToolCall(e,o,!1),n(o)}catch(u){console.error("Failed to reject tool call:",u)}},[e,n]),c=q.useCallback(async()=>{if(e)try{await Promise.all(i.map(o=>qe.approveToolCall(e,o.callId,!0)));for(const o of i)n(o.callId)}catch(o){console.error("Failed to approve all tool calls:",o)}},[e,i,n]);q.useEffect(()=>{if(!e||i.length===0)return;const o=u=>{if(u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement||u.target?.isContentEditable)return;const d=i[0];u.key==="y"||u.key==="Y"?(u.preventDefault(),s(d.callId)):u.key==="n"||u.key==="N"||u.key==="Escape"?(u.preventDefault(),l(d.callId)):(u.key==="a"||u.key==="A")&&(u.preventDefault(),c())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,i,s,l,c])}const XJ=q.memo(function({sessionId:t,onSelectSession:n}){const{data:i=[],isLoading:s}=pc(t),{data:l=[]}=Mc();hL(t),YJ(t);const c=q.useMemo(()=>l.find(u=>u.id===t),[l,t]),o=q.useMemo(()=>i.some(u=>u.role==="assistant"&&u.status==="pending"),[i]);return s?y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):y.jsx(KJ,{messages:i,sessionId:t,session:c,isGenerating:o,onSelectSession:n})}),ZJ=q.memo(function({session:t,isActive:n,onClick:i}){const s=d=>{const p=new Date(d),m=new Date().getTime()-p.getTime(),v=Math.floor(m/6e4),w=Math.floor(v/60),E=Math.floor(w/24);return v<1?"just now":v<60?`${v}m ago`:w<24?`${w}h ago`:E<7?`${E}d ago`:p.toLocaleDateString()},l=t.sessionType==="branch";return y.jsx("button",{type:"button",onClick:i,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors duration-150 ${n?"bg-primary/10":"hover:bg-muted/20"}`,children:y.jsxs("div",{className:"flex items-start gap-3",children:[l?y.jsx(zn,{className:`h-4 w-4 shrink-0 mt-1 text-muted-foreground ${n?"text-primary":""}`}):y.jsx(BO,{className:`h-4 w-4 shrink-0 mt-1 text-muted-foreground ${n?"text-primary":""}`}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:t.title||`Session ${t.id.slice(0,8)}`}),l&&y.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-violet-500/10 text-violet-600 dark:text-violet-400 rounded-full shrink-0",children:"branch"})]}),y.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-muted-foreground/80",children:[t.agent&&y.jsx("span",{className:"uppercase",children:t.agent}),t.agent&&y.jsx("span",{children:"•"}),y.jsx("span",{children:s(t.lastActiveAt||t.createdAt)})]})]})]})})}),N1=$n(e=>({currentFocus:null,sessionIndex:0,gitFileIndex:0,setFocus:t=>e({currentFocus:t}),setSessionIndex:t=>e({sessionIndex:t}),setGitFileIndex:t=>e({gitFileIndex:t}),resetGitFileIndex:()=>e({gitFileIndex:0}),resetSessionIndex:()=>e({sessionIndex:0})})),QJ=q.memo(function({activeSessionId:t,onSelectSession:n}){const{data:i=[],isLoading:s}=Mc(),{currentFocus:l,sessionIndex:c}=N1(),o=q.useRef(new Map),u=q.useCallback(p=>{n(p)},[n]),d=q.useMemo(()=>i.map(p=>({id:p.id,title:p.title,agent:p.agent,createdAt:p.createdAt})),[i]);return q.useEffect(()=>{l==="sessions"&&o.current.get(c)?.scrollIntoView({block:"nearest",behavior:"smooth"})},[l,c]),s?y.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/80",children:"Loading sessions..."}):d.length===0?y.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/80",children:"No sessions yet. Create one to get started."}):y.jsx("div",{className:"flex flex-col gap-1 px-2 py-2 overflow-y-auto scrollbar-hide",children:d.map((p,f)=>{const m=i.find(w=>w.id===p.id);if(!m)return null;const v=l==="sessions"&&c===f;return y.jsx("div",{ref:w=>{w?o.current.set(f,w):o.current.delete(f)},className:v?"ring-1 ring-primary/40 rounded-md":"",children:y.jsx(ZJ,{session:m,isActive:p.id===t,onClick:()=>u(p.id)})},p.id)})})}),JJ={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",txt:"plaintext",svelte:"svelte"};function eee(e){const t=e.split(".").pop()?.toLowerCase()??"";return t?JJ[t]??"plaintext":"plaintext"}function tee(e){const t=e.split("/");return t[t.length-1]}function nee({diff:e}){const t=document?.documentElement.classList.contains("dark")?ei:Rr,n=e.language&&e.language.trim().length>0?e.language:eee(e.file),i=tee(e.file);if(e.isNewFile&&e.content)return y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[y.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:e.file,children:i}),y.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[y.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",e.insertions]}),y.jsx("span",{className:"text-muted-foreground",children:n})]})]}),y.jsx("div",{className:"px-4 py-3 bg-green-500/10 border-b border-green-500/20",children:y.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:["New file: ",e.insertions," lines"]})}),y.jsx("div",{className:"flex-1 overflow-auto",children:y.jsx(Cn,{language:n,style:t,showLineNumbers:!0,customStyle:{margin:0,padding:"1rem",background:"transparent"},lineNumberStyle:{minWidth:"3em",paddingRight:"1em",color:"var(--color-muted-foreground)",userSelect:"none"},children:e.content})})]});if(e.isBinary)return y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[y.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:e.file,children:i}),y.jsx("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:y.jsx("span",{className:"text-muted-foreground",children:"Binary file"})})]}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("div",{className:"p-4 text-center",children:y.jsx("p",{className:"text-sm text-muted-foreground",children:"Binary file - cannot display diff"})})})]});const s=e.diff.split(`
126
126
  `),l=[];let c=0,o=0;for(const d of s)if(d.startsWith("@@")){const p=d.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);p&&(c=parseInt(p[1],10),o=parseInt(p[2],10)),l.push({oldLineNumber:null,newLineNumber:null,content:d,codeContent:d,type:"hunk"})}else d.startsWith("diff")||d.startsWith("index")||d.startsWith("---")||d.startsWith("+++")?l.push({oldLineNumber:null,newLineNumber:null,content:d,codeContent:d,type:"meta"}):d.startsWith("+")?(l.push({oldLineNumber:null,newLineNumber:o,content:d,codeContent:d.slice(1),type:"add"}),o++):d.startsWith("-")?(l.push({oldLineNumber:c,newLineNumber:null,content:d,codeContent:d.slice(1),type:"delete"}),c++):(l.push({oldLineNumber:c,newLineNumber:o,content:d,codeContent:d,type:"context"}),c++,o++);const u=(d,p)=>{let f="flex hover:bg-muted/20",m="flex-shrink-0 w-20 px-2 py-0.5 text-xs font-mono select-none border-r border-border",v="flex-1 px-4 py-0.5 font-mono text-xs overflow-x-auto";d.type==="hunk"?(f+=" bg-blue-500/10",m+=" text-blue-600 dark:text-blue-400",v+=" text-blue-600 dark:text-blue-400 font-semibold"):d.type==="add"?(f+=" bg-green-500/10",m+=" text-green-700 dark:text-green-400",v+=" text-green-700 dark:text-green-400"):d.type==="delete"?(f+=" bg-red-500/10",m+=" text-red-600 dark:text-red-400",v+=" text-red-600 dark:text-red-400"):d.type==="meta"?(v+=" text-muted-foreground",m+=" text-muted-foreground"):(v+=" text-foreground/80",m+=" text-muted-foreground");const w=d.oldLineNumber!==null?d.oldLineNumber.toString():"",E=d.newLineNumber!==null?d.newLineNumber.toString():"";let b=d.content||" ";return d.type!=="meta"&&d.type!=="hunk"&&n!=="plaintext"&&d.codeContent.trim()&&(b=y.jsx(Cn,{language:n,style:t,customStyle:{margin:0,padding:0,background:"transparent",display:"inline",fontSize:"inherit",lineHeight:"inherit"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent"}},PreTag:"span",children:d.codeContent}),d.type==="add"?b=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"select-none",children:"+"}),b]}):d.type==="delete"&&(b=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"select-none",children:"-"}),b]}))),y.jsxs("div",{className:f,children:[y.jsx("div",{className:m,children:y.jsxs("div",{className:"flex justify-between gap-2",children:[y.jsx("span",{className:"text-right w-8",children:w}),y.jsx("span",{className:"text-right w-8",children:E})]})}),y.jsx("div",{className:v,children:b})]},p)};return y.jsxs("div",{className:"flex flex-col h-full bg-background",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[y.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:e.file,children:i}),y.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[e.insertions>0&&y.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",e.insertions]}),e.deletions>0&&y.jsxs("span",{className:"text-red-600 dark:text-red-500",children:["-",e.deletions]}),y.jsx("span",{className:"text-muted-foreground",children:n})]})]}),y.jsx("div",{className:"flex-1 overflow-auto",children:e.diff.trim()===""?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No changes to display"}):y.jsx("div",{className:"min-w-max",children:l.map(u)})})]})}function ree(e,t=2){const n=e.split("/");return n.length<=t+1?e:`../${n.slice(-t).join("/")}`}function Ly({file:e,staged:t,showModifiedIndicator:n=!1}){const{openDiff:i}=Tt(),s=jc(),l=Qv(),c=TD(),o=RD(),u=Pv(S=>S.openConfirmation),[d,p]=q.useState(t),f=async S=>{S.stopPropagation();const k=S.target.checked;p(k);try{k?await s.mutateAsync([e.path]):await l.mutateAsync([e.path])}catch(O){p(!k),console.error("Failed to stage/unstage file:",O)}},m=async S=>{S.stopPropagation(),u({title:"Restore File",message:`Restore ${e.path} to HEAD state? This will discard all changes.`,confirmLabel:"Restore",variant:"destructive",onConfirm:async()=>{try{await c.mutateAsync([e.path])}catch(k){throw console.error("Failed to restore file:",k),k}}})},v=async S=>{S.stopPropagation(),u({title:"Delete File",message:`Delete ${e.path}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{try{await o.mutateAsync([e.path])}catch(k){throw console.error("Failed to delete file:",k),k}}})},w=()=>{i(e.path,t)},b=(()=>{switch(e.status){case"added":case"untracked":return{icon:DO,color:"text-green-500",label:"A",labelColor:"text-green-500"};case"deleted":return{icon:jB,color:"text-red-500",label:"D",labelColor:"text-red-500"};case"modified":return{icon:Li,color:"text-blue-500",label:"M",labelColor:"text-blue-500"};case"renamed":return{icon:Li,color:"text-purple-500",label:"R",labelColor:"text-purple-500"};default:return{icon:Li,color:"text-muted-foreground",label:"?",labelColor:"text-muted-foreground"}}})(),_=b.icon,x=ree(e.path,2);return y.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 hover:bg-muted/50 cursor-pointer group transition-colors w-full text-left",onClick:w,children:[y.jsx("input",{type:"checkbox",checked:d,onChange:f,onClick:S=>S.stopPropagation(),className:"w-4 h-4 rounded border-border","aria-label":`${d?"Unstage":"Stage"} ${e.path}`}),y.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[y.jsx(_,{className:`w-4 h-4 flex-shrink-0 ${b.color}`}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-sm text-foreground font-mono truncate",title:`${e.path}
127
127
  ${e.absPath}`,children:x}),y.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[y.jsx("span",{className:`text-xs font-semibold ${b.labelColor}`,children:b.label}),n&&y.jsx("div",{title:"Also modified in working directory",children:y.jsx(Qr,{className:"w-3.5 h-3.5 text-orange-500"})})]})]})})]}),e.insertions!==void 0||e.deletions!==void 0?y.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[e.insertions!==void 0&&e.insertions>0&&y.jsxs("span",{className:"text-green-500",children:["+",e.insertions]}),e.deletions!==void 0&&e.deletions>0&&y.jsxs("span",{className:"text-red-500",children:["-",e.deletions]})]}):null,!t&&e.status==="untracked"&&y.jsx("button",{type:"button",onClick:v,className:"p-1.5 hover:bg-destructive/10 rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:"Delete untracked file","aria-label":`Delete ${e.path}`,children:y.jsx(zv,{className:"w-3.5 h-3.5 text-destructive"})}),!t&&e.status!=="untracked"&&e.status!=="added"&&y.jsx("button",{type:"button",onClick:m,className:"p-1.5 hover:bg-destructive/10 rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:"Restore file to HEAD (Shift+R)","aria-label":`Restore ${e.path}`,children:y.jsx(FO,{className:"w-3.5 h-3.5 text-destructive"})}),t&&!n&&y.jsx(Mi,{className:"w-4 h-4 text-green-500 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}function iee({status:e}){const{openCommitModal:t,openDiff:n}=Tt(),i=jc();Qv();const{currentFocus:s,gitFileIndex:l}=N1(),c=q.useRef(new Map),o=e.staged.length>0,u=e.unstaged.length>0||e.untracked.length>0,d=[...e.unstaged,...e.untracked],p=d.length>0;q.useMemo(()=>[...e.staged,...e.unstaged,...e.untracked],[e]);const f=new Set(e.unstaged.map(v=>v.path)),m=()=>{const v=d.map(w=>w.path);v.length>0&&i.mutate(v)};return q.useEffect(()=>{if(s==="git"&&l>=0){c.current.get(l)?.scrollIntoView({block:"nearest",behavior:"smooth"});const E=[...e.staged,...e.unstaged,...e.untracked][l];if(E){const b=e.staged.includes(E);n(E.path,b)}}},[s,l,e.staged,e.unstaged,e.untracked,n]),y.jsxs("div",{className:"flex flex-col",children:[o&&y.jsxs("div",{className:"border-b border-border",children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Staged Changes (",e.staged.length,")"]}),y.jsx("div",{className:"flex items-center gap-1",children:e.staged.length>0&&y.jsxs(st,{variant:"primary",size:"sm",onClick:t,className:"h-6 text-xs",children:[y.jsx(uc,{className:"w-3 h-3 mr-1"}),"Commit"]})})]}),y.jsx("div",{className:"divide-y divide-border",children:e.staged.map((v,w)=>{const E=w,b=s==="git"&&l===E;return y.jsx("div",{ref:_=>{_?c.current.set(E,_):c.current.delete(E)},className:b?"ring-1 ring-inset ring-primary/40":"",children:y.jsx(Ly,{file:v,staged:!0,showModifiedIndicator:f.has(v.path)})},v.path)})})]}),u&&y.jsxs("div",{children:[y.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between",children:[y.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Changes (",e.unstaged.length+e.untracked.length,")"]}),p&&y.jsxs(st,{variant:"ghost",size:"sm",onClick:m,title:"Stage all changes",className:"h-6 text-xs",children:[y.jsx(kF,{className:"w-3 h-3 mr-1"}),"Stage All"]})]}),y.jsxs("div",{className:"divide-y divide-border",children:[e.unstaged.map((v,w)=>{const E=e.staged.length+w,b=s==="git"&&l===E;return y.jsx("div",{ref:_=>{_?c.current.set(E,_):c.current.delete(E)},className:b?"ring-1 ring-inset ring-primary/40":"",children:y.jsx(Ly,{file:v,staged:!1})},v.path)}),e.untracked.map((v,w)=>{const E=e.staged.length+e.unstaged.length+w,b=s==="git"&&l===E;return y.jsx("div",{ref:_=>{_?c.current.set(E,_):c.current.delete(E)},className:b?"ring-1 ring-inset ring-primary/40":"",children:y.jsx(Ly,{file:v,staged:!1})},v.path)})]})]}),!o&&!u&&y.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No changes"})]})}const aee=q.memo(function(){const t=Tt(b=>b.isExpanded),n=Tt(b=>b.collapseSidebar),{data:i,isLoading:s,error:l,refetch:c}=Fc(),o=Lt(),u=R7(),[d,p]=q.useState(null);q.useEffect(()=>{t&&o.invalidateQueries({queryKey:["git","status"]})},[t,o]);const f=()=>{c()},m=async()=>{p(null);try{await u.mutateAsync()}catch(b){p(b instanceof Error?b.message:"Failed to push")}};if(!t)return null;const w=[...i?.staged||[],...i?.unstaged||[],...i?.untracked||[]].length,E=i&&i.ahead>0;return y.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(zn,{className:"w-4 h-4 text-muted-foreground"}),y.jsxs("span",{className:"font-medium text-foreground",children:["Git Changes",w>0&&y.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",w,")"]})]})]}),y.jsx(st,{variant:"ghost",size:"icon",onClick:n,title:"Close sidebar",children:y.jsx(nn,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto",children:s?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading git status..."}):l?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:y.jsxs("div",{className:"flex flex-col gap-2",children:[y.jsx("span",{className:"text-orange-500",children:l instanceof Error?l.message:"Failed to load git status"}),y.jsx(st,{variant:"secondary",size:"sm",onClick:f,children:"Retry"})]})}):!i||w===0?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No changes detected"}):y.jsx(iee,{status:i})}),d&&y.jsx("div",{className:"px-4 py-2 text-xs text-orange-500 border-t border-border bg-orange-50 dark:bg-orange-950/20",children:d}),y.jsxs("div",{className:"h-12 px-4 border-t border-border text-xs text-muted-foreground flex items-center justify-between gap-2",children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[y.jsx(zn,{className:"w-3 h-3 flex-shrink-0"}),i?.branch&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"truncate",children:i.branch}),i.ahead>0&&y.jsxs("span",{className:"text-green-500 flex-shrink-0",children:["↑",i.ahead]}),i.behind>0&&y.jsxs("span",{className:"text-orange-500 flex-shrink-0",children:["↓",i.behind]})]})]}),y.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[E&&y.jsx(st,{variant:"ghost",size:"icon",onClick:m,title:"Push commits to remote",className:"h-6 w-6 transition-transform duration-200 hover:scale-110",disabled:u.isPending,children:y.jsx(NF,{className:`w-3 h-3 ${u.isPending?"animate-pulse":""}`})}),y.jsx(st,{variant:"ghost",size:"icon",onClick:f,title:"Refresh git status",className:"h-6 w-6 transition-transform duration-200 hover:scale-110",disabled:s,children:y.jsx(Ea,{className:`w-3 h-3 ${s?"animate-spin":""}`})})]})]})]})}),see=q.memo(function(){const t=Tt(l=>l.isExpanded),n=Tt(l=>l.toggleSidebar),{data:i}=Fc(),s=(i?.staged?.length??0)+(i?.unstaged?.length??0)+(i?.untracked?.length??0);return y.jsxs("button",{type:"button",onClick:n,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${t?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Git",children:[y.jsx(zn,{className:"w-5 h-5 text-muted-foreground mx-auto"}),s>0&&y.jsx("span",{className:"absolute top-1 right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:s>9?"9+":s})]})});function oee(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var l;const c=u=>u===null?null:JSON.parse(u,void 0),o=(l=n.getItem(s))!=null?l:null;return o instanceof Promise?o.then(c):c(o)},setItem:(s,l)=>n.setItem(s,JSON.stringify(l,void 0)),removeItem:s=>n.removeItem(s)}}const Sv=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(i){return Sv(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return Sv(i)(n)}}}},lee=(e,t)=>(n,i,s)=>{let l={storage:oee(()=>localStorage),partialize:b=>b,version:0,merge:(b,_)=>({..._,...b}),...t},c=!1,o=0;const u=new Set,d=new Set;let p=l.storage;if(!p)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),n(...b)},i,s);const f=()=>{const b=l.partialize({...i()});return p.setItem(l.name,{state:b,version:l.version})},m=s.setState;s.setState=(b,_)=>(m(b,_),f());const v=e((...b)=>(n(...b),f()),i,s);s.getInitialState=()=>v;let w;const E=()=>{var b,_;if(!p)return;const x=++o;c=!1,u.forEach(k=>{var O;return k((O=i())!=null?O:v)});const S=((_=l.onRehydrateStorage)==null?void 0:_.call(l,(b=i())!=null?b:v))||void 0;return Sv(p.getItem.bind(p))(l.name).then(k=>{if(k)if(typeof k.version=="number"&&k.version!==l.version){if(l.migrate){const O=l.migrate(k.state,k.version);return O instanceof Promise?O.then(T=>[!0,T]):[!0,O]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,k.state];return[!1,void 0]}).then(k=>{var O;if(x!==o)return;const[T,A]=k;if(w=l.merge(A,(O=i())!=null?O:v),n(w,!0),T)return f()}).then(()=>{x===o&&(S?.(w,void 0),w=i(),c=!0,d.forEach(k=>k(w)))}).catch(k=>{x===o&&S?.(void 0,k)})};return s.persist={setOptions:b=>{l={...l,...b},b.storage&&(p=b.storage)},clearStorage:()=>{p?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>E(),hasHydrated:()=>c,onHydrate:b=>(u.add(b),()=>{u.delete(b)}),onFinishHydration:b=>(d.add(b),()=>{d.delete(b)})},l.skipHydration||E(),w||v},uee=lee,_a=$n()(uee(e=>({isCollapsed:!1,toggleCollapse:()=>e(t=>({isCollapsed:!t.isCollapsed})),setCollapsed:t=>e({isCollapsed:t})}),{name:"sidebar-storage"})),cee=q.memo(function(){const t=Tt(p=>p.isDiffOpen),n=Tt(p=>p.selectedFile),i=Tt(p=>p.selectedFileStaged),s=Tt(p=>p.closeDiff),l=_a(p=>p.setCollapsed),c=q.useRef(null),o=q.useRef(!1),{data:u,isLoading:d}=C7(n,i);return q.useEffect(()=>{if(t&&!o.current){const{isCollapsed:p}=_a.getState();c.current=p,l(!0)}else!t&&o.current&&c.current!==null&&(l(c.current),c.current=null);o.current=t},[t,l]),q.useEffect(()=>{const p=f=>{const m=f.target,v=m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.isContentEditable;(f.key==="Escape"||f.key==="q"&&!v)&&t&&s()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,s]),!t||!n?null:y.jsxs("div",{className:"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-3",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:s,title:"Close diff viewer (ESC)",children:y.jsx(Un,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[y.jsx("span",{className:"text-sm font-medium text-foreground font-mono truncate",title:`${n}
128
128
  ${u?.absPath||""}`,children:n}),i&&y.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0",children:"Staged"})]})]}),y.jsx("div",{className:"flex-1 overflow-auto",children:d?y.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading diff..."}):u?y.jsx(nee,{diff:u}):y.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No diff available"})})]})});function dee(){const{isCommitModalOpen:e,closeCommitModal:t}=Tt(),n=Tt(f=>f.commitSessionId),i=T7(),s=k7(n),[l,c]=q.useState(""),o=q.useId(),u=q.useCallback(async()=>{if(l.trim())try{await i.mutateAsync(l),c(""),t()}catch(f){console.error("Failed to commit:",f)}},[l,i,t]),d=()=>{c(""),t()},p=q.useCallback(async()=>{try{const f=await s.mutateAsync();c(f.message)}catch(f){console.error("Failed to generate commit message:",f)}},[s]);return q.useEffect(()=>{if(!e)return;const f=m=>{(m.metaKey||m.ctrlKey)&&m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),l.trim()&&!i.isPending&&u()),(m.metaKey||m.ctrlKey)&&m.key==="g"&&(m.preventDefault(),m.stopPropagation(),p())};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,l,i.isPending,u,p]),y.jsx(al,{isOpen:e,onClose:d,title:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(uc,{className:"w-5 h-5"}),y.jsx("span",{children:"Commit Changes"})]}),maxWidth:"2xl",children:y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"space-y-2",children:[y.jsx("label",{htmlFor:o,className:"text-sm font-medium text-foreground",children:"Commit Message"}),y.jsx(Cc,{id:o,value:l,onChange:f=>c(f.target.value),placeholder:"Enter commit message...",rows:6,className:"w-full resize-none",autoFocus:!0,disabled:s.isPending})]}),y.jsx(st,{variant:"secondary",onClick:p,className:"w-full",disabled:s.isPending,children:s.isPending?y.jsxs(y.Fragment,{children:[y.jsx(Ni,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):y.jsxs(y.Fragment,{children:[y.jsx(Vo,{className:"w-4 h-4 mr-2"}),"Generate commit message"," ",y.jsx("span",{className:"text-muted-foreground ml-1",children:"(⌘G)"})]})}),s.isError&&y.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:s.error?.message||"Failed to generate commit message"}),y.jsxs("div",{className:"flex items-center justify-end gap-2 pt-4 border-t border-border",children:[y.jsxs(st,{variant:"ghost",onClick:d,children:["Cancel ",y.jsx("span",{className:"text-muted-foreground ml-1",children:"(Esc)"})]}),y.jsx(st,{variant:"primary",onClick:u,disabled:!l.trim()||i.isPending,children:i.isPending?y.jsx("span",{children:"Committing..."}):y.jsxs(y.Fragment,{children:[y.jsx(uc,{className:"w-4 h-4 mr-2"}),"Commit ",y.jsx("span",{className:"text-muted-foreground ml-1",children:"(⌘↵)"})]})})]}),i.isError&&y.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:i.error?.message||"Failed to commit changes"})]})})}function O1(){return qn({queryKey:["terminals"],queryFn:async()=>{const e=await $P();if(e.error)throw new Error("Failed to fetch terminals");return e.data},refetchInterval:2e3})}function hee(){const e=Lt();return Xt({mutationFn:async t=>{const n=await GP({body:t});if(n.error)throw new Error("Failed to create terminal");return n.data},onSuccess:()=>{e.invalidateQueries({queryKey:["terminals"]})}})}const pee=q.memo(function({terminals:t,isLoading:n}){const i=dn(s=>s.selectTerminal);return n?y.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:y.jsx("div",{className:"text-sm",children:"Loading terminals..."})}):t.length===0?y.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-muted-foreground px-4 text-center",children:[y.jsx(ba,{className:"w-12 h-12 mb-3 opacity-50"}),y.jsx("div",{className:"text-sm font-medium mb-1",children:"No active terminals"}),y.jsx("div",{className:"text-xs",children:"Click the + button to create a new terminal"})]}):y.jsx("div",{className:"flex-1 overflow-y-auto",children:y.jsx("div",{className:"p-2 space-y-1",children:t.map(s=>y.jsx(st,{variant:"ghost",className:"w-full justify-start h-auto py-3 px-3",onClick:()=>i(s.id),children:y.jsxs("div",{className:"flex items-start gap-3 w-full",children:[y.jsx("div",{className:"shrink-0 mt-0.5",children:s.createdBy==="llm"?y.jsx(V6,{className:"w-4 h-4 text-blue-500"}):y.jsx(qv,{className:"w-4 h-4 text-green-500"})}),y.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[y.jsx("div",{className:"text-sm font-medium truncate",children:s.title}),y.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[s.command," ",s.args.length>0&&s.args.join(" ")]}),y.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[y.jsx("span",{className:`text-xs ${s.status==="running"?"text-green-600":"text-orange-600"}`,children:s.status==="running"?"Running":`Exited (${s.exitCode})`}),y.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",fee(s.uptime)]})]})]})]})},s.id))})})});function fee(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),i=Math.floor(n/60);return i>0?`${i}h ${n%60}m`:n>0?`${n}m`:`${t}s`}var My={exports:{}},DN;function mee(){return DN||(DN=1,(function(e,t){(function(n,i){e.exports=i()})(self,(()=>(()=>{var n={};return(()=>{var i=n;Object.defineProperty(i,"__esModule",{value:!0}),i.FitAddon=void 0,i.FitAddon=class{activate(s){this._terminal=s}dispose(){}fit(){const s=this.proposeDimensions();if(!s||!this._terminal||isNaN(s.cols)||isNaN(s.rows))return;const l=this._terminal._core;this._terminal.rows===s.rows&&this._terminal.cols===s.cols||(l._renderService.clear(),this._terminal.resize(s.cols,s.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const s=this._terminal._core,l=s._renderService.dimensions;if(l.css.cell.width===0||l.css.cell.height===0)return;const c=this._terminal.options.scrollback===0?0:s.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),u=parseInt(o.getPropertyValue("height")),d=Math.max(0,parseInt(o.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),f=u-(parseInt(p.getPropertyValue("padding-top"))+parseInt(p.getPropertyValue("padding-bottom"))),m=d-(parseInt(p.getPropertyValue("padding-right"))+parseInt(p.getPropertyValue("padding-left")))-c;return{cols:Math.max(2,Math.floor(m/l.css.cell.width)),rows:Math.max(1,Math.floor(f/l.css.cell.height))}}}})(),n})()))})(My)),My.exports}var gee=mee(),Zu={exports:{}},bee=Zu.exports,IN;function yee(){return IN||(IN=1,(function(e,t){(function(n,i){e.exports=i()})(bee,(()=>(()=>{var n={433:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV11=void 0;const d=u(938),p=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],f=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],m=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],v=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]];let w;function E(b,_){let x,S=0,k=_.length-1;if(b<_[0][0]||b>_[k][1])return!1;for(;k>=S;)if(x=S+k>>1,b>_[x][1])S=x+1;else{if(!(b<_[x][0]))return!0;k=x-1}return!1}o.UnicodeV11=class{constructor(){if(this.version="11",!w){w=new Uint8Array(65536),w.fill(1),w[0]=0,w.fill(0,1,32),w.fill(0,127,160);for(let b=0;b<p.length;++b)w.fill(0,p[b][0],p[b][1]+1);for(let b=0;b<m.length;++b)w.fill(2,m[b][0],m[b][1]+1)}}wcwidth(b){return b<32?0:b<127?1:b<65536?w[b]:E(b,f)?0:E(b,v)?2:1}charProperties(b,_){let x=this.wcwidth(b),S=x===0&&_!==0;if(S){const k=d.UnicodeService.extractWidth(_);k===0?S=!1:k>x&&(x=k)}return d.UnicodeService.createPropertyValue(0,x,S)}}},345:(c,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=u=>(this._listeners.push(u),{dispose:()=>{if(!this._disposed){for(let d=0;d<this._listeners.length;d++)if(this._listeners[d]===u)return void this._listeners.splice(d,1)}}})),this._event}fire(u,d){const p=[];for(let f=0;f<this._listeners.length;f++)p.push(this._listeners[f]);for(let f=0;f<p.length;f++)p[f].call(void 0,u,d)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(u,d){return u((p=>d.fire(p)))},o.runAndSubscribe=function(u,d){return d(void 0),u((p=>d(p)))}},490:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const d=u(938),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],f=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let m;o.UnicodeV6=class{constructor(){if(this.version="6",!m){m=new Uint8Array(65536),m.fill(1),m[0]=0,m.fill(0,1,32),m.fill(0,127,160),m.fill(2,4352,4448),m[9001]=2,m[9002]=2,m.fill(2,11904,42192),m[12351]=1,m.fill(2,44032,55204),m.fill(2,63744,64256),m.fill(2,65040,65050),m.fill(2,65072,65136),m.fill(2,65280,65377),m.fill(2,65504,65511);for(let v=0;v<p.length;++v)m.fill(0,p[v][0],p[v][1]+1)}}wcwidth(v){return v<32?0:v<127?1:v<65536?m[v]:(function(w,E){let b,_=0,x=E.length-1;if(w<E[0][0]||w>E[x][1])return!1;for(;x>=_;)if(b=_+x>>1,w>E[b][1])_=b+1;else{if(!(w<E[b][0]))return!0;x=b-1}return!1})(v,f)?0:v>=131072&&v<=196605||v>=196608&&v<=262141?2:1}charProperties(v,w){let E=this.wcwidth(v),b=E===0&&w!==0;if(b){const _=d.UnicodeService.extractWidth(w);_===0?b=!1:_>E&&(E=_)}return d.UnicodeService.createPropertyValue(0,E,b)}}},938:(c,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const d=u(345),p=u(490);class f{static extractShouldJoin(v){return(1&v)!=0}static extractWidth(v){return v>>1&3}static extractCharKind(v){return v>>3}static createPropertyValue(v,w,E=!1){return(16777215&v)<<3|(3&w)<<1|(E?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new d.EventEmitter,this.onChange=this._onChange.event;const v=new p.UnicodeV6;this.register(v),this._active=v.version,this._activeProvider=v}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(v){if(!this._providers[v])throw new Error(`unknown Unicode version "${v}"`);this._active=v,this._activeProvider=this._providers[v],this._onChange.fire(v)}register(v){this._providers[v.version]=v}wcwidth(v){return this._activeProvider.wcwidth(v)}getStringCellWidth(v){let w=0,E=0;const b=v.length;for(let _=0;_<b;++_){let x=v.charCodeAt(_);if(55296<=x&&x<=56319){if(++_>=b)return w+this.wcwidth(x);const O=v.charCodeAt(_);56320<=O&&O<=57343?x=1024*(x-55296)+O-56320+65536:w+=this.wcwidth(O)}const S=this.charProperties(x,E);let k=f.extractWidth(S);f.extractShouldJoin(S)&&(k-=f.extractWidth(E)),w+=k,E=S}return w}charProperties(v,w){return this._activeProvider.charProperties(v,w)}}o.UnicodeService=f}},i={};function s(c){var o=i[c];if(o!==void 0)return o.exports;var u=i[c]={exports:{}};return n[c](u,u.exports,s),u.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.Unicode11Addon=void 0;const o=s(433);c.Unicode11Addon=class{activate(u){u.unicode.register(new o.UnicodeV11)}dispose(){}}})(),l})()))})(Zu)),Zu.exports}var vee=yee(),By={exports:{}},LN;function _ee(){return LN||(LN=1,(function(e,t){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(c,o,u){var d=this&&this.__decorate||function(x,S,k,O){var T,A=arguments.length,R=A<3?S:O===null?O=Object.getOwnPropertyDescriptor(S,k):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,k,O);else for(var D=x.length-1;D>=0;D--)(T=x[D])&&(R=(A<3?T(R):A>3?T(S,k,R):T(S,k))||R);return A>3&&R&&Object.defineProperty(S,k,R),R},p=this&&this.__param||function(x,S){return function(k,O){S(k,O,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const f=u(9042),m=u(9924),v=u(844),w=u(4725),E=u(2585),b=u(3656);let _=o.AccessibilityManager=class extends v.Disposable{constructor(x,S,k,O){super(),this._terminal=x,this._coreBrowserService=k,this._renderService=O,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
@@ -143,4 +143,4 @@ WARNING: This link could potentially be dangerous`)){const _=window.open();if(_)
143
143
  `),n=[];let i=0,s=0,l=!1,c="";for(const o of t){if(o.startsWith("+++")||o.startsWith("*** Update File:")){const d=o.match(/\+\+\+ b\/(.+)/)||o.match(/\*\*\* Update File: (.+)/);d&&(c=d[1])}if(o.startsWith("*** Add File:")){const d=o.match(/\*\*\* Add File: (.+)/);d&&(c=d[1])}const u=o.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(u){i=Number.parseInt(u[1],10),s=Number.parseInt(u[2],10),l=!0,n.push({content:o,codeContent:o,type:"header"});continue}if(o.startsWith("***")||o.startsWith("diff ")||o.startsWith("index ")||o.startsWith("---")||o.startsWith("+++")||o.startsWith("@@")&&!l){n.push({content:o,codeContent:o,type:"meta"});continue}l?o.startsWith("+")?n.push({content:o,codeContent:o.slice(1),type:"add",newLineNum:s++}):o.startsWith("-")?n.push({content:o,codeContent:o.slice(1),type:"remove",oldLineNum:i++}):o.startsWith(" ")||o===""?n.push({content:o,codeContent:o.startsWith(" ")?o.slice(1):o,type:"context",oldLineNum:i++,newLineNum:s++}):n.push({content:o,codeContent:o,type:"context",oldLineNum:i++,newLineNum:s++}):n.push({content:o,codeContent:o,type:"meta"})}return{lines:n,filePath:c}}function Mee({patch:e}){const{lines:t,filePath:n}=Lee(e),i=Iee(n),s=document?.documentElement.classList.contains("dark")?ei:Rr;return y.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden h-full",children:y.jsx("div",{className:"overflow-x-auto overflow-y-auto h-full text-xs font-mono",children:t.map((l,c)=>{const o=`line-${c}-${l.content.slice(0,20)}`;if(l.type==="meta"||l.type==="header")return y.jsx("div",{className:`px-3 py-0.5 whitespace-pre-wrap break-all ${l.type==="header"?"text-muted-foreground/80 bg-muted/20":"text-muted-foreground/80"}`,children:l.content},o);let u="",d="";switch(l.type){case"add":u="text-emerald-700 dark:text-emerald-300",d="bg-emerald-500/10";break;case"remove":u="text-red-600 dark:text-red-300",d="bg-red-500/10";break;default:u="text-foreground/80"}let p=l.content;return l.codeContent.trim()&&i!=="text"&&(p=y.jsx(Cn,{language:i,style:s,customStyle:{margin:0,padding:0,background:"transparent",display:"inline",fontSize:"inherit",lineHeight:"inherit"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent"}},PreTag:"span",children:l.codeContent}),l.type==="add"?p=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"select-none",children:"+"}),p]}):l.type==="remove"?p=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"select-none",children:"-"}),p]}):l.type==="context"&&(p=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"select-none",children:" "}),p]}))),y.jsxs("div",{className:`flex ${d}`,children:[y.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0",children:l.oldLineNum||""}),y.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0 border-r border-border/50",children:l.newLineNum||""}),y.jsx("div",{className:`px-3 py-0.5 flex-1 min-w-0 whitespace-pre-wrap break-all ${u}`,children:p})]},o)})})})}function Bee(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}const Fee=q.memo(function(){const t=Yt(v=>v.isDiffOpen),n=Yt(v=>v.selectedFile),i=Yt(v=>v.allOperations),s=Yt(v=>v.selectedOperationIndex),l=Yt(v=>v.selectOperation),c=Yt(v=>v.closeDiff),o=_a(v=>v.setCollapsed),u=q.useRef(null),d=q.useRef(!1),p=i[s],f=q.useMemo(()=>{if(!p||!n)return null;let v=null;if(p.artifact?.patch)v=p.artifact.patch;else if(p.patch)v=p.patch;else if(p.content){const E=p.content.split(`
144
144
  `);v=`*** Add File: ${n}
145
145
  ${E.map(b=>`+${b}`).join(`
146
- `)}`}return v?/@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(v)?v:Dee(v):null},[p,n]);if(q.useEffect(()=>{if(t&&!d.current){const{isCollapsed:v}=_a.getState();u.current=v,o(!0)}else!t&&d.current&&u.current!==null&&(o(u.current),u.current=null);d.current=t},[t,o]),q.useEffect(()=>{const v=w=>{const E=w.target,b=E.tagName==="INPUT"||E.tagName==="TEXTAREA"||E.isContentEditable;(w.key==="Escape"||w.key==="q"&&!b)&&t&&c(),!b&&t&&i.length>1&&(w.key==="ArrowLeft"||w.key==="["?(w.preventDefault(),l(Math.max(0,s-1))):(w.key==="ArrowRight"||w.key==="]")&&(w.preventDefault(),l(Math.min(i.length-1,s+1))))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,c,i.length,s,l]),!t||!n||!p)return null;const m=i.length>1;return y.jsxs("div",{className:"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-3 shrink-0",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:c,title:"Close diff viewer (ESC)",children:y.jsx(Un,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[y.jsx("span",{className:"text-sm font-medium text-foreground font-mono truncate",title:n,children:n}),y.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0 capitalize",children:p.operation}),p.artifact?.summary&&y.jsxs("div",{className:"flex items-center gap-1 text-xs flex-shrink-0",children:[y.jsxs("span",{className:"text-green-500",children:["+",p.artifact.summary.additions]}),y.jsxs("span",{className:"text-red-500",children:["-",p.artifact.summary.deletions]})]})]}),m&&y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.max(0,s-1)),disabled:s===0,title:"Previous operation (←)",children:y.jsx(nB,{className:"w-4 h-4"})}),y.jsxs("span",{className:"text-xs text-muted-foreground min-w-[60px] text-center",children:[s+1," / ",i.length]}),y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.min(i.length-1,s+1)),disabled:s===i.length-1,title:"Next operation (→)",children:y.jsx(nn,{className:"w-4 h-4"})})]})]}),m&&y.jsx("div",{className:"border-b border-border px-4 py-2 flex gap-2 overflow-x-auto shrink-0",children:i.map((v,w)=>y.jsxs("button",{type:"button",onClick:()=>l(w),className:`px-3 py-1.5 text-xs rounded-md flex items-center gap-2 shrink-0 transition-colors ${w===s?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted/80 text-muted-foreground"}`,children:[y.jsx("span",{className:"capitalize",children:v.operation}),y.jsx("span",{className:"opacity-70",children:Bee(v.timestamp)}),v.artifact?.summary&&y.jsxs("span",{className:"opacity-70",children:["+",v.artifact.summary.additions,"/-",v.artifact.summary.deletions]})]},v.toolCallId))}),y.jsx("div",{className:"flex-1 overflow-hidden p-4",children:f?y.jsx(Mee,{patch:f}):y.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No diff content available"})})]})}),jee={};class Pee{get baseUrl(){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(!jee?.VITE_API_BASE_URL)return Ic}async listResearchSessions(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch research sessions"}));throw new Error(i.error||"Failed to fetch research sessions")}return n.json()}async createResearchSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create research session"}));throw new Error(s.error||"Failed to create research session")}return i.json()}async deleteResearchSession(t){const n=await fetch(`${this.baseUrl}/v1/research/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete research session"}));throw new Error(i.error||"Failed to delete research session")}return n.json()}async injectContext(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/inject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({researchSessionId:n,label:i})});if(!s.ok){const l=await s.json().catch(()=>({error:"Failed to inject context"}));throw new Error(l.error||"Failed to inject context")}return s.json()}async exportToNewSession(t,n){const i=await fetch(`${this.baseUrl}/v1/research/${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n??{})});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to export to session"}));throw new Error(s.error||"Failed to export to session")}return i.json()}}const Kc=new Pee;function mL(e){return qn({queryKey:["research","sessions",e],queryFn:()=>Kc.listResearchSessions(e),enabled:!!e,staleTime:3e4})}function Uee(){const e=Lt();return Xt({mutationFn:({parentSessionId:t,data:n})=>Kc.createResearchSession(t,n??{}),onSuccess:(t,{parentSessionId:n})=>{e.invalidateQueries({queryKey:["research","sessions",n]})}})}function Hee(){const e=Vu(t=>t.addContext);return Xt({mutationFn:({parentSessionId:t,researchSessionId:n,label:i})=>Kc.injectContext(t,n,i),onSuccess:(t,{parentSessionId:n})=>{e(n,{id:t.sessionId,sessionId:t.sessionId,label:t.label,content:t.content})}})}function zee(){const e=Lt();return Xt({mutationFn:({researchId:t,data:n})=>Kc.exportToNewSession(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}const qee=q.memo(function({parentSessionId:t,onNavigateToSession:n}){const i=jn(z=>z.isExpanded),s=jn(z=>z.collapseSidebar),l=jn(z=>z.activeResearchSessionId),c=jn(z=>z.selectResearchSession),[o,u]=q.useState(!1),[d,p]=q.useState(""),[f,m]=q.useState(!1),[v,w]=q.useState("idle"),E=q.useRef(null),b=q.useRef(null),{data:_,isLoading:x,refetch:S}=mL(t),k=Uee(),O=Hee(),T=zee(),{data:A}=Bc(),{data:R}=pc(l??void 0),{data:D}=pc(t??void 0);hL(l??void 0);const L=kD(l??""),I=Lt(),H=Xt({mutationFn:async({sessionId:z,content:ne})=>qe.sendMessage(z,{content:ne}),onSuccess:(z,{sessionId:ne})=>{I.invalidateQueries({queryKey:["messages",ne]})}});q.useEffect(()=>{t&&jn.getState().setParentSessionId(t)},[t]),q.useEffect(()=>{_?.sessions?.length?_.sessions.some(ne=>ne.id===l)||c(_.sessions[0].id):_?.sessions?.length===0&&c(null)},[_,l,c]),q.useEffect(()=>{b.current?.scrollIntoView({behavior:"smooth"})},[R]);const B=q.useCallback(()=>{const z=E.current;z&&(z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,120)}px`)},[]);q.useEffect(()=>{B()},[d,B]);const W=q.useCallback(async()=>{if(t)try{const z=await k.mutateAsync({parentSessionId:t,data:{}});await S(),c(z.session.id),u(!1)}catch(z){console.error("Failed to create research session:",z)}},[t,k,c,S]),K=q.useCallback(z=>{c(z.id),u(!1)},[c]),V=q.useCallback(async()=>{if(!t||!l)return;if(D?.some(be=>be.role==="system"&&be.parts?.some(we=>typeof we.content=="string"&&we.content.includes(`from="${l}"`)))){w("error"),setTimeout(()=>w("idle"),3e3);return}const ge=`Research ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`;try{await O.mutateAsync({parentSessionId:t,researchSessionId:l,label:ge}),w("success"),setTimeout(()=>w("idle"),5e3),I.invalidateQueries({queryKey:["messages",t]})}catch(be){console.error("Failed to inject context:",be),w("error"),setTimeout(()=>w("idle"),3e3)}},[t,l,O,D,I]),X=q.useCallback(async()=>{if(l)try{const z=await T.mutateAsync({researchId:l});n&&z.newSession?.id&&n(z.newSession.id)}catch(z){console.error("Failed to export to session:",z)}},[l,T,n]),Y=q.useCallback(async()=>{if(!(!d.trim()||!t))try{let z=l;z||(z=(await k.mutateAsync({parentSessionId:t,data:{}})).session.id,c(z)),await H.mutateAsync({sessionId:z,content:d}),p(""),E.current&&(E.current.style.height="auto")}catch(z){console.error("Failed to send message:",z)}},[d,t,l,k,c,H]),P=q.useCallback(z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),Y())},[Y]),M=q.useMemo(()=>R?.some(z=>z.role==="assistant"&&z.status==="pending")??!1,[R]),j=q.useMemo(()=>!l||!D?!1:D.some(z=>z.role==="system"&&z.parts?.some(ne=>typeof ne.content=="string"&&ne.content.includes(`from="${l}"`))),[l,D]),$=q.useCallback(async(z,ne)=>{if(l)try{await L.mutateAsync({provider:z,model:ne}),m(!1)}catch(ce){console.error("Failed to update research session model:",ce)}},[l,L]);if(!i)return null;const U=_?.sessions??[],J=U.find(z=>z.id===l),oe=R??[],he=A?.[J?.provider??""]?.label??J?.provider,Z=A?.[J?.provider??""]?.models.find(z=>z.id===J?.model)?.label??J?.model;return y.jsxs("div",{className:"w-96 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-3 flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500"}),y.jsx("span",{className:"font-medium text-foreground text-sm",children:"Research"})]}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>u(!o),title:"Research history",className:"h-8 w-8",children:y.jsx(JB,{className:"w-4 h-4"})}),y.jsx(st,{variant:"ghost",size:"icon",onClick:W,disabled:!t||k.isPending,title:"New research session",className:"h-8 w-8",children:k.isPending?y.jsx(Ni,{className:"w-4 h-4 animate-spin"}):y.jsx(Wo,{className:"w-4 h-4"})}),y.jsx(st,{variant:"ghost",size:"icon",onClick:s,title:"Close sidebar",className:"h-8 w-8",children:y.jsx(nn,{className:"w-4 h-4"})})]})]}),o?y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[y.jsx("div",{className:"p-2 border-b border-border",children:y.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Research Sessions"})}),x?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}):U.length===0?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No research sessions yet"}):y.jsx("div",{className:"p-2 space-y-1",children:U.map(z=>y.jsxs("button",{type:"button",onClick:()=>K(z),className:`w-full text-left p-2 rounded-md text-sm transition-colors ${z.id===l?"bg-teal-500/10 border border-teal-500/30 text-foreground":"hover:bg-muted"}`,children:[y.jsx("div",{className:"font-medium truncate",children:z.title||"Untitled"}),y.jsxs("div",{className:"text-xs text-muted-foreground",children:[z.messageCount," messages •"," ",$ee(z.lastActiveAt??z.createdAt)]})]},z.id))})]}):y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 research-messages text-[13px]",children:l?oe.length===0?y.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:y.jsx("p",{children:"Ask a question to start researching."})}):y.jsxs("div",{className:"space-y-1.5",children:[oe.map((z,ne)=>{if(z.role==="user"){const ce=oe[ne+1];return y.jsx(lL,{sessionId:l,message:z,isFirst:ne===0,nextAssistantMessageId:ce?.role==="assistant"?ce.id:void 0},z.id)}if(z.role==="assistant"){const ce=ne>0?oe[ne-1]:null,ge=oe[ne+1],be=ce?.role!=="assistant",we=ge?.role==="assistant";return y.jsx(oL,{sessionId:l,message:z,showHeader:be,hasNextAssistantMessage:we,isLastMessage:ne===oe.length-1,compact:!0,onNavigateToSession:n},z.id)}return null}),y.jsx("div",{ref:b})]}):y.jsxs("div",{className:"text-xs text-muted-foreground text-center py-8",children:[y.jsx(Go,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),y.jsx("p",{children:"Start researching by asking a question below."})]})}),y.jsxs("div",{className:"p-3 border-t border-border",children:[y.jsx("div",{className:"relative flex flex-col rounded-3xl bg-card border border-border focus-within:border-teal-500/60 focus-within:ring-1 focus-within:ring-teal-500/40 p-1",children:y.jsxs("div",{className:"flex items-end gap-1",children:[y.jsx(Cc,{ref:E,value:d,onChange:z=>p(z.target.value),onKeyDown:P,placeholder:"Ask anything...",disabled:!t||H.isPending||k.isPending,rows:1,className:"flex-1 border-0 bg-transparent pl-2 pr-1 py-2 max-h-[120px] overflow-y-auto leading-normal resize-none scrollbar-hide text-sm focus:ring-0 focus:outline-none",style:{height:"2.25rem"}}),y.jsx("button",{type:"button",onClick:Y,disabled:!d.trim()||!t||H.isPending||k.isPending||M,className:`flex items-center justify-center w-9 h-9 rounded-full transition-colors flex-shrink-0 ${d.trim()&&t&&!M?"bg-teal-500 hover:bg-teal-600 text-white":"bg-transparent text-muted-foreground"}`,children:H.isPending||k.isPending?y.jsx(Ni,{className:"w-4 h-4 animate-spin"}):y.jsx(CO,{className:"w-4 h-4"})})]})}),v==="success"&&y.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-teal-500/10 border border-teal-500/30 text-teal-600 dark:text-teal-400",children:[y.jsx(Mi,{className:"w-3 h-3 flex-shrink-0"}),y.jsx("span",{className:"flex-1",children:"Context injected — will be used on next request"}),y.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-teal-500",children:y.jsx(Un,{className:"w-3 h-3"})})]}),v==="error"&&y.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400",children:[y.jsx(Un,{className:"w-3 h-3 flex-shrink-0"}),y.jsx("span",{className:"flex-1",children:"Failed to inject context"}),y.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-red-500",children:y.jsx(Un,{className:"w-3 h-3"})})]}),y.jsxs("div",{className:"flex gap-2 mt-2",children:[y.jsxs("button",{type:"button",onClick:V,disabled:!l||O.isPending||M||j,className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${j?"bg-teal-500/10 text-teal-600 dark:text-teal-400 border border-teal-500/30":"bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground"}`,title:j?"Already injected into main session":"Inject findings into main session",children:[O.isPending?y.jsx(Ni,{className:"w-3 h-3 animate-spin"}):j?y.jsx(Mi,{className:"w-3 h-3"}):y.jsx(F6,{className:"w-3 h-3"}),j?"Injected":"Inject"]}),y.jsxs("button",{type:"button",onClick:X,disabled:!l||T.isPending||M,className:"flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Export to new main session",children:[T.isPending?y.jsx(Ni,{className:"w-3 h-3 animate-spin"}):y.jsx(wr,{className:"w-3 h-3"}),"Export"]})]})]})]}),y.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between",children:[y.jsxs("span",{className:"text-[10px]",children:[U.length," research session",U.length!==1?"s":""]}),J&&y.jsxs("button",{type:"button",onClick:()=>m(!0),className:"flex items-center gap-1 text-[10px] hover:text-foreground transition-colors",children:[y.jsx("span",{className:"opacity-60",children:he}),y.jsx("span",{className:"opacity-40",children:"/"}),y.jsx("span",{children:Z}),y.jsx(xa,{className:"w-3 h-3 opacity-40"})]})]}),y.jsx(al,{isOpen:f,onClose:()=>m(!1),title:"Select Model for Research",maxWidth:"md",children:J&&y.jsx(ID,{provider:J.provider,model:J.model,onChange:$})})]})});function $ee(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}const Gee=q.memo(function({parentSessionId:t}){const n=jn(c=>c.isExpanded),i=jn(c=>c.toggleSidebar),{data:s}=mL(t??null),l=s?.sessions?.length??0;return y.jsxs("button",{type:"button",onClick:i,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${n?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Research (⌘⇧R)",children:[y.jsx(Go,{className:"w-5 h-5 text-muted-foreground mx-auto"}),l>0&&y.jsx("span",{className:"absolute top-1 right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})});var Wee=Object.defineProperty,yc=Object.getOwnPropertySymbols,gL=Object.prototype.hasOwnProperty,bL=Object.prototype.propertyIsEnumerable,jN=(e,t,n)=>t in e?Wee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xv=(e,t)=>{for(var n in t||(t={}))gL.call(t,n)&&jN(e,n,t[n]);if(yc)for(var n of yc(t))bL.call(t,n)&&jN(e,n,t[n]);return e},Ev=(e,t)=>{var n={};for(var i in e)gL.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&yc)for(var i of yc(e))t.indexOf(i)<0&&bL.call(e,i)&&(n[i]=e[i]);return n};var Sa;(e=>{const t=class Ye{constructor(u,d,p,f){if(this.version=u,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let m=[];for(let w=0;w<this.size;w++)m.push(!1);for(let w=0;w<this.size;w++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(p);if(this.drawCodewords(v),f==-1){let w=1e9;for(let E=0;E<8;E++){this.applyMask(E),this.drawFormatBits(E);const b=this.getPenaltyScore();b<w&&(f=E,w=b),this.applyMask(E)}}s(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(u,d){const p=e.QrSegment.makeSegments(u);return Ye.encodeSegments(p,d)}static encodeBinary(u,d){const p=e.QrSegment.makeBytes(u);return Ye.encodeSegments([p],d)}static encodeSegments(u,d,p=1,f=40,m=-1,v=!0){if(!(Ye.MIN_VERSION<=p&&p<=f&&f<=Ye.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let w,E;for(w=p;;w++){const S=Ye.getNumDataCodewords(w,d)*8,k=c.getTotalBits(u,w);if(k<=S){E=k;break}if(w>=f)throw new RangeError("Data too long")}for(const S of[Ye.Ecc.MEDIUM,Ye.Ecc.QUARTILE,Ye.Ecc.HIGH])v&&E<=Ye.getNumDataCodewords(w,S)*8&&(d=S);let b=[];for(const S of u){n(S.mode.modeBits,4,b),n(S.numChars,S.mode.numCharCountBits(w),b);for(const k of S.getData())b.push(k)}s(b.length==E);const _=Ye.getNumDataCodewords(w,d)*8;s(b.length<=_),n(0,Math.min(4,_-b.length),b),n(0,(8-b.length%8)%8,b),s(b.length%8==0);for(let S=236;b.length<_;S^=253)n(S,8,b);let x=[];for(;x.length*8<b.length;)x.push(0);return b.forEach((S,k)=>x[k>>>3]|=S<<7-(k&7)),new Ye(w,d,x,m)}getModule(u,d){return 0<=u&&u<this.size&&0<=d&&d<this.size&&this.modules[d][u]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const u=this.getAlignmentPatternPositions(),d=u.length;for(let p=0;p<d;p++)for(let f=0;f<d;f++)p==0&&f==0||p==0&&f==d-1||p==d-1&&f==0||this.drawAlignmentPattern(u[p],u[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const d=this.errorCorrectionLevel.formatBits<<3|u;let p=d;for(let m=0;m<10;m++)p=p<<1^(p>>>9)*1335;const f=(d<<10|p)^21522;s(f>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,i(f,m));this.setFunctionModule(8,7,i(f,6)),this.setFunctionModule(8,8,i(f,7)),this.setFunctionModule(7,8,i(f,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,i(f,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,i(f,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,i(f,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const d=this.version<<12|u;s(d>>>18==0);for(let p=0;p<18;p++){const f=i(d,p),m=this.size-11+p%3,v=Math.floor(p/3);this.setFunctionModule(m,v,f),this.setFunctionModule(v,m,f)}}drawFinderPattern(u,d){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const m=Math.max(Math.abs(f),Math.abs(p)),v=u+f,w=d+p;0<=v&&v<this.size&&0<=w&&w<this.size&&this.setFunctionModule(v,w,m!=2&&m!=4)}}drawAlignmentPattern(u,d){for(let p=-2;p<=2;p++)for(let f=-2;f<=2;f++)this.setFunctionModule(u+f,d+p,Math.max(Math.abs(f),Math.abs(p))!=1)}setFunctionModule(u,d,p){this.modules[d][u]=p,this.isFunction[d][u]=!0}addEccAndInterleave(u){const d=this.version,p=this.errorCorrectionLevel;if(u.length!=Ye.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const f=Ye.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],m=Ye.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],v=Math.floor(Ye.getNumRawDataModules(d)/8),w=f-v%f,E=Math.floor(v/f);let b=[];const _=Ye.reedSolomonComputeDivisor(m);for(let S=0,k=0;S<f;S++){let O=u.slice(k,k+E-m+(S<w?0:1));k+=O.length;const T=Ye.reedSolomonComputeRemainder(O,_);S<w&&O.push(0),b.push(O.concat(T))}let x=[];for(let S=0;S<b[0].length;S++)b.forEach((k,O)=>{(S!=E-m||O>=w)&&x.push(k[S])});return s(x.length==v),x}drawCodewords(u){if(u.length!=Math.floor(Ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f<this.size;f++)for(let m=0;m<2;m++){const v=p-m,E=(p+1&2)==0?this.size-1-f:f;!this.isFunction[E][v]&&d<u.length*8&&(this.modules[E][v]=i(u[d>>>3],7-(d&7)),d++)}}s(d==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let f;switch(u){case 0:f=(p+d)%2==0;break;case 1:f=d%2==0;break;case 2:f=p%3==0;break;case 3:f=(p+d)%3==0;break;case 4:f=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:f=p*d%2+p*d%3==0;break;case 6:f=(p*d%2+p*d%3)%2==0;break;case 7:f=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&f&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let u=0;for(let m=0;m<this.size;m++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[m][b]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[m][b],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let m=0;m<this.size;m++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[b][m]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[b][m],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let v=0;v<this.size-1;v++){const w=this.modules[m][v];w==this.modules[m][v+1]&&w==this.modules[m+1][v]&&w==this.modules[m+1][v+1]&&(u+=Ye.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((v,w)=>v+(w?1:0),d);const p=this.size*this.size,f=Math.ceil(Math.abs(d*20-p*10)/p)-1;return s(0<=f&&f<=9),u+=f*Ye.PENALTY_N4,s(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let f=this.size-7;p.length<u;f-=d)p.splice(1,0,f);return p}}static getNumRawDataModules(u){if(u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;d-=(25*p-10)*p-55,u>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(u,d){return Math.floor(Ye.getNumRawDataModules(u)/8)-Ye.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u]*Ye.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let d=[];for(let f=0;f<u-1;f++)d.push(0);d.push(1);let p=1;for(let f=0;f<u;f++){for(let m=0;m<d.length;m++)d[m]=Ye.reedSolomonMultiply(d[m],p),m+1<d.length&&(d[m]^=d[m+1]);p=Ye.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(u,d){let p=d.map(f=>0);for(const f of u){const m=f^p.shift();p.push(0),d.forEach((v,w)=>p[w]^=Ye.reedSolomonMultiply(v,m))}return p}static reedSolomonMultiply(u,d){if(u>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(d>>>f&1)*u;return s(p>>>8==0),p}finderPenaltyCountPatterns(u){const d=u[1];s(d<=this.size*3);const p=d>0&&u[2]==d&&u[3]==d*3&&u[4]==d&&u[5]==d;return(p&&u[0]>=d*4&&u[6]>=d?1:0)+(p&&u[6]>=d*4&&u[0]>=d?1:0)}finderPenaltyTerminateAndCount(u,d,p){return u&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,d){d[0]==0&&(u+=this.size),d.pop(),d.unshift(u)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(o,u,d){if(u<0||u>31||o>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)d.push(o>>>p&1)}function i(o,u){return(o>>>u&1)!=0}function s(o){if(!o)throw new Error("Assertion error")}const l=class It{constructor(u,d,p){if(this.mode=u,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let d=[];for(const p of u)n(p,8,d);return new It(It.Mode.BYTE,u.length,d)}static makeNumeric(u){if(!It.isNumeric(u))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<u.length;){const f=Math.min(u.length-p,3);n(parseInt(u.substring(p,p+f),10),f*3+1,d),p+=f}return new It(It.Mode.NUMERIC,u.length,d)}static makeAlphanumeric(u){if(!It.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=u.length;p+=2){let f=It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;f+=It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),n(f,11,d)}return p<u.length&&n(It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,d),new It(It.Mode.ALPHANUMERIC,u.length,d)}static makeSegments(u){return u==""?[]:It.isNumeric(u)?[It.makeNumeric(u)]:It.isAlphanumeric(u)?[It.makeAlphanumeric(u)]:[It.makeBytes(It.toUtf8ByteArray(u))]}static makeEci(u){let d=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)n(u,8,d);else if(u<16384)n(2,2,d),n(u,14,d);else if(u<1e6)n(6,3,d),n(u,21,d);else throw new RangeError("ECI assignment value out of range");return new It(It.Mode.ECI,0,d)}static isNumeric(u){return It.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return It.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,d){let p=0;for(const f of u){const m=f.mode.numCharCountBits(d);if(f.numChars>=1<<m)return 1/0;p+=4+m+f.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let d=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?d.push(u.charCodeAt(p)):(d.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return d}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let c=l;e.QrSegment=l})(Sa||(Sa={}));(e=>{(t=>{const n=class{constructor(s,l){this.ordinal=s,this.formatBits=l}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(Sa||(Sa={}));(e=>{(t=>{const n=class{constructor(s,l){this.modeBits=s,this.numBitsCharCount=l}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(Sa||(Sa={}));var gs=Sa;var Vee={L:gs.QrCode.Ecc.LOW,M:gs.QrCode.Ecc.MEDIUM,Q:gs.QrCode.Ecc.QUARTILE,H:gs.QrCode.Ecc.HIGH},yL=128,vL="L",_L="#FFFFFF",SL="#000000",xL=!1,EL=1,Kee=4,Yee=0,Xee=.1;function wL(e,t=0){const n=[];return e.forEach(function(i,s){let l=null;i.forEach(function(c,o){if(!c&&l!==null){n.push(`M${l+t} ${s+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===i.length-1){if(!c)return;l===null?n.push(`M${o+t},${s+t} h1v1H${o+t}z`):n.push(`M${l+t},${s+t} h${o+1-l}v1H${l+t}z`);return}c&&l===null&&(l=o)})}),n.join("")}function CL(e,t){return e.slice().map((n,i)=>i<t.y||i>=t.y+t.h?n:n.map((s,l)=>l<t.x||l>=t.x+t.w?s:!1))}function Zee(e,t,n,i){if(i==null)return null;const s=e.length+n*2,l=Math.floor(t*Xee),c=s/t,o=(i.width||l)*c,u=(i.height||l)*c,d=i.x==null?e.length/2-o/2:i.x*c,p=i.y==null?e.length/2-u/2:i.y*c,f=i.opacity==null?1:i.opacity;let m=null;if(i.excavate){let w=Math.floor(d),E=Math.floor(p),b=Math.ceil(o+d-w),_=Math.ceil(u+p-E);m={x:w,y:E,w:b,h:_}}const v=i.crossOrigin;return{x:d,y:p,h:u,w:o,excavation:m,opacity:f,crossOrigin:v}}function Qee(e,t){return t!=null?Math.max(Math.floor(t),0):e?Kee:Yee}function kL({value:e,level:t,minVersion:n,includeMargin:i,marginSize:s,imageSettings:l,size:c,boostLevel:o}){let u=Je.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((E,b)=>(E.push(...gs.QrSegment.makeSegments(b)),E),[]);return gs.QrCode.encodeSegments(w,Vee[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:p,numCells:f,calculatedImageSettings:m}=Je.useMemo(()=>{let v=u.getModules();const w=Qee(i,s),E=v.length+w*2,b=Zee(v,c,w,l);return{cells:v,margin:w,numCells:E,calculatedImageSettings:b}},[u,c,l,i,s]);return{qrcode:u,margin:p,cells:d,numCells:f,calculatedImageSettings:m}}var Jee=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ete=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=yL,level:c=vL,bgColor:o=_L,fgColor:u=SL,includeMargin:d=xL,minVersion:p=EL,boostLevel:f,marginSize:m,imageSettings:v}=i,E=Ev(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=E,_=Ev(E,["style"]),x=v?.src,S=Je.useRef(null),k=Je.useRef(null),O=Je.useCallback(W=>{S.current=W,typeof n=="function"?n(W):n&&(n.current=W)},[n]),[T,A]=Je.useState(!1),{margin:R,cells:D,numCells:L,calculatedImageSettings:I}=kL({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:m,imageSettings:v,size:l});Je.useEffect(()=>{if(S.current!=null){const W=S.current,K=W.getContext("2d");if(!K)return;let V=D;const X=k.current,Y=I!=null&&X!==null&&X.complete&&X.naturalHeight!==0&&X.naturalWidth!==0;Y&&I.excavation!=null&&(V=CL(D,I.excavation));const P=window.devicePixelRatio||1;W.height=W.width=l*P;const M=l/L*P;K.scale(M,M),K.fillStyle=o,K.fillRect(0,0,L,L),K.fillStyle=u,Jee?K.fill(new Path2D(wL(V,R))):D.forEach(function(j,$){j.forEach(function(U,J){U&&K.fillRect(J+R,$+R,1,1)})}),I&&(K.globalAlpha=I.opacity),Y&&K.drawImage(X,I.x+R,I.y+R,I.w,I.h)}}),Je.useEffect(()=>{A(!1)},[x]);const H=xv({height:l,width:l},b);let B=null;return x!=null&&(B=Je.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{A(!0)},ref:k,crossOrigin:I?.crossOrigin})),Je.createElement(Je.Fragment,null,Je.createElement("canvas",xv({style:H,height:l,width:l,ref:O,role:"img"},_)),B)});ete.displayName="QRCodeCanvas";var TL=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=yL,level:c=vL,bgColor:o=_L,fgColor:u=SL,includeMargin:d=xL,minVersion:p=EL,boostLevel:f,title:m,marginSize:v,imageSettings:w}=i,E=Ev(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:_,numCells:x,calculatedImageSettings:S}=kL({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:v,imageSettings:w,size:l});let k=_,O=null;w!=null&&S!=null&&(S.excavation!=null&&(k=CL(_,S.excavation)),O=Je.createElement("image",{href:w.src,height:S.h,width:S.w,x:S.x+b,y:S.y+b,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const T=wL(k,b);return Je.createElement("svg",xv({height:l,width:l,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},E),!!m&&Je.createElement("title",null,m),Je.createElement("path",{fill:o,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),Je.createElement("path",{fill:u,d:T,shapeRendering:"crispEdges"}),O)});TL.displayName="QRCodeSVG";const Fu=q.memo(function({title:t,icon:n,children:i,action:s}){return y.jsxs("div",{className:"border-b border-border",children:[y.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 bg-muted/30",children:[n,y.jsx("span",{className:"text-sm font-medium flex-1",children:t}),s]}),y.jsx("div",{className:"px-4 py-3 space-y-3",children:i})]})}),Fy=q.memo(function({label:t,value:n}){return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsx("span",{className:"font-mono text-foreground",children:n})]})}),PN=q.memo(function({label:t,checked:n,onChange:i}){return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>i(!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${n?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${n?"translate-x-6":"translate-x-1"} ${n?"bg-primary-foreground":"bg-foreground"}`})})]})}),ju=q.memo(function({label:t,value:n,options:i,onChange:s,disabled:l}){const[c,o]=q.useState(!1),u=i.find(d=>d.id===n);return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsxs("div",{className:"relative",children:[y.jsxs("button",{type:"button",onClick:()=>!l&&o(!c),disabled:l,className:"flex items-center gap-1 px-2 py-1 text-xs font-mono bg-muted hover:bg-muted/80 rounded border border-border disabled:opacity-50",children:[y.jsx("span",{className:"max-w-[120px] truncate",children:u?.label||n||"Select..."}),y.jsx(xa,{className:"w-3 h-3"})]}),c&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),y.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-[200px] overflow-y-auto bg-popover border border-border rounded-md shadow-lg",children:i.map(d=>y.jsx("button",{type:"button",onClick:()=>{s(d.id),o(!1)},className:`w-full px-3 py-2 text-left text-xs font-mono hover:bg-muted truncate ${d.id===n?"bg-muted/50":""}`,children:d.label},d.id))})]})]})]})}),tte=q.memo(function(){const t=kr(A=>A.isExpanded),n=kr(A=>A.collapseSidebar),{data:i}=Zv(),{data:s}=Bc(),{preferences:l,updatePreferences:c}=Jo(),o=w7(),u=cn(A=>A.balance),d=cn(A=>A.walletAddress),p=cn(A=>A.usdcBalance),f=cn(A=>A.isLoading),m=i?.providers?.includes("solforge"),{fetchBalance:v}=Jv(m?"solforge":void 0),w=q.useMemo(()=>!i?.providers||!s?[]:i.providers.filter(A=>s[A]).map(A=>({id:A,label:s[A]?.label||A})),[i?.providers,s]),E=q.useMemo(()=>{const A=i?.defaults?.provider;return!A||!s?.[A]?[]:s[A].models.map(R=>({id:R.id,label:R.label}))},[i?.defaults?.provider,s]),b=q.useMemo(()=>i?.agents?i.agents.map(A=>({id:A,label:A})):[],[i?.agents]);if(!t)return null;const _=A=>{const R=s?.[A]?.models?.[0]?.id;o.mutate({provider:A,model:R||i?.defaults?.model})},x=A=>{o.mutate({model:A})},S=A=>{o.mutate({agent:A})},k=A=>A?`${A.slice(0,4)}...${A.slice(-4)}`:"Not configured",O=A=>A===null?"—":`$${A.toFixed(4)}`,T=A=>A===null?"—":`${A.toFixed(2)} USDC`;return y.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(jO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:"Settings"})]}),y.jsx(st,{variant:"ghost",size:"icon",onClick:n,children:y.jsx(nn,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[y.jsxs(Fu,{title:"Default Model",icon:y.jsx(SB,{className:"w-4 h-4 text-muted-foreground"}),children:[y.jsx(ju,{label:"Provider",value:i?.defaults?.provider??"",options:w,onChange:_,disabled:o.isPending}),y.jsx(ju,{label:"Model",value:i?.defaults?.model??"",options:E,onChange:x,disabled:o.isPending}),y.jsx(ju,{label:"Agent",value:i?.defaults?.agent??"",options:b,onChange:S,disabled:o.isPending})]}),y.jsxs(Fu,{title:"Preferences",icon:y.jsx(qv,{className:"w-4 h-4 text-muted-foreground"}),children:[y.jsx(PN,{label:"Vim Mode",checked:l.vimMode,onChange:A=>c({vimMode:A})}),y.jsx(PN,{label:"Show Reasoning",checked:l.reasoningEnabled,onChange:A=>c({reasoningEnabled:A})}),y.jsx(ju,{label:"Tool Approval",value:i?.defaults?.toolApproval??"auto",options:[{id:"auto",label:"Auto (no approval)"},{id:"dangerous",label:"Dangerous only"},{id:"all",label:"All tools"}],onChange:A=>o.mutate({toolApproval:A}),disabled:o.isPending})]}),i?.providers?.includes("solforge")&&y.jsxs(Fu,{title:"Solforge Wallet",icon:y.jsx(IF,{className:"w-4 h-4 text-muted-foreground"}),action:y.jsx("button",{type:"button",onClick:v,disabled:f,className:"p-1 hover:bg-muted rounded transition-colors disabled:opacity-50",title:"Refresh balances",children:y.jsx(Ea,{className:`w-3.5 h-3.5 text-muted-foreground ${f?"animate-spin":""}`})}),children:[d&&y.jsx("div",{className:"flex justify-center pb-3",children:y.jsx("div",{className:"p-2 bg-white rounded-lg",children:y.jsx(TL,{value:d,size:120,level:"M",includeMargin:!1})})}),y.jsx(Fy,{label:"Address",value:k(d)}),y.jsx(Fy,{label:"Balance",value:O(u)}),y.jsx(Fy,{label:"USDC",value:T(p)})]}),y.jsx(Fu,{title:"Providers",icon:y.jsx(BF,{className:"w-4 h-4 text-muted-foreground"}),children:y.jsx("div",{className:"flex flex-wrap gap-2",children:i?.providers?.map(A=>y.jsx("span",{className:"px-2 py-1 text-xs bg-muted rounded-md font-mono",children:A},A))??y.jsx("span",{className:"text-muted-foreground text-sm",children:"None"})})})]})]})}),nte=q.memo(function(){const t=kr(i=>i.isExpanded),n=kr(i=>i.toggleSidebar);return y.jsx("button",{type:"button",onClick:n,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${t?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Settings",children:y.jsx(jO,{className:"w-5 h-5 text-muted-foreground mx-auto"})})});const rte=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ite=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),UN=e=>{const t=ite(e);return t.charAt(0).toUpperCase()+t.slice(1)},RL=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),ate=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var ste={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ote=q.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:s="",children:l,iconNode:c,...o},u)=>q.createElement("svg",{ref:u,...ste,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:RL("lucide",s),...!l&&!ate(o)&&{"aria-hidden":"true"},...o},[...c.map(([d,p])=>q.createElement(d,p)),...Array.isArray(l)?l:[l]]));const dl=(e,t)=>{const n=q.forwardRef(({className:i,...s},l)=>q.createElement(ote,{ref:l,iconNode:t,className:RL(`lucide-${rte(UN(e))}`,`lucide-${e}`,i),...s}));return n.displayName=UN(e),n};const lte=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ute=dl("chevron-right",lte);const cte=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],dte=dl("moon",cte);const hte=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],HN=dl("plus",hte);const pte=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fte=dl("sun",pte);const mte=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gte=dl("x",mte),bte=q.memo(function({children:t,onNewSession:n}){const i=Tt(c=>c.isDiffOpen),s=_a(c=>c.isCollapsed),l=_a(c=>c.toggleCollapse);return q.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),s?y.jsxs("aside",{className:"w-12 md:w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out hidden md:flex",children:[y.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:n,title:"New session",className:"rounded-full touch-manipulation",children:y.jsx(HN,{className:"w-4 h-4"})})}),y.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:i?void 0:l,title:i?void 0:"Expand sidebar","aria-label":"Expand sidebar"}),y.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:y.jsx(ute,{className:"w-4 h-4"})})})]}):y.jsxs(y.Fragment,{children:[!s&&y.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:l,"aria-hidden":"true"}),y.jsxs("aside",{className:"w-full md:w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out fixed md:relative top-0 left-0 z-50 h-screen md:h-auto",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2 md:hidden bg-background",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Close menu",className:"touch-manipulation flex-shrink-0","aria-label":"Close menu",children:y.jsx(gte,{className:"w-5 h-5"})}),y.jsx("h1",{className:"text-lg font-semibold text-foreground flex-1",children:"AGI"})]}),y.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2",children:y.jsxs(st,{variant:"primary",size:"sm",onClick:n,className:"flex-1 touch-manipulation",children:[y.jsx(HN,{className:"w-4 h-4 mr-2"}),"New Session"]})}),y.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:t}),y.jsx("div",{className:"h-12 border-t border-border px-2 flex items-center justify-end",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[y.jsx("title",{children:"Collapse sidebar"}),y.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})]})}),yte=q.memo(function({sidebar:t,children:n,onNewSession:i,theme:s,onToggleTheme:l,sessionId:c,onNavigateToSession:o}){return y.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[y.jsx(bte,{onNewSession:i,children:t}),y.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden relative w-full md:w-auto",children:[y.jsx(cee,{}),y.jsx(Fee,{}),n]}),y.jsxs("div",{className:"hidden md:flex",children:[y.jsx(aee,{}),y.jsx(Nee,{sessionId:c}),y.jsx(wee,{}),y.jsx(qee,{parentSessionId:c??null,onNavigateToSession:o}),y.jsx(tte,{}),y.jsxs("div",{className:"flex flex-col w-12 border-l border-border bg-background",children:[y.jsx(see,{}),y.jsx(Oee,{sessionId:c}),y.jsx(Cee,{}),y.jsx(Gee,{parentSessionId:c}),y.jsx("div",{className:"flex-1"}),y.jsx(nte,{}),y.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:`Switch to ${s==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${s==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:s==="dark"?y.jsx(fte,{className:"w-4 h-4"}):y.jsx(dte,{className:"w-4 h-4"})})})]})]}),y.jsx(dee,{}),y.jsx(FF,{})]})}),AL="agi-theme",zN="dark";function vte(){if(typeof window>"u")return zN;const e=window.localStorage.getItem(AL);return e==="light"||e==="dark"?e:zN}function _te(){const[e,t]=q.useState(()=>vte());q.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(AL,e)}catch(s){console.warn("Failed to persist theme preference",s)}},[e]);const n=q.useCallback(()=>{t(i=>i==="dark"?"light":"dark")},[]);return q.useMemo(()=>({theme:e,setTheme:t,toggleTheme:n}),[e,n])}function Ste(){const[e,t]=q.useState(null);return q.useEffect(()=>{(async()=>{try{const l=`${window.AGI_SERVER_URL||Ic}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",l);const c=await fetch(l);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const o=await c.json();console.log("[useWorkingDirectory] Success:",o),o.dirName&&(console.log("[useWorkingDirectory] Setting title to:",o.dirName),t(o.dirName),document.title=o.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}function xte({sessionIds:e,activeSessionId:t,gitFiles:n,onSelectSession:i,onNewSession:s,onStageFile:l,onUnstageFile:c,onRestoreFile:o,onDeleteFile:u,onStageAll:d,onUnstageAll:p,onOpenCommitModal:f,onViewDiff:m,onReturnToInput:v}){const{currentFocus:w,sessionIndex:E,gitFileIndex:b,setFocus:_,setSessionIndex:x,setGitFileIndex:S,resetGitFileIndex:k}=N1(),{setCollapsed:O,toggleCollapse:T}=_a(),{isExpanded:A,toggleSidebar:R}=Tt(),D=Tt(B=>B.closeDiff),L=jn(B=>B.toggleSidebar),I=e.indexOf(t||""),H=q.useCallback(B=>{const W=B.target,K=W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable;if((B.ctrlKey||B.metaKey)&&B.key==="h"){B.preventDefault(),w==="sessions"?(document.activeElement?.blur(),_("input"),O(!0),setTimeout(()=>v?.(),50)):w==="git"?(document.activeElement?.blur(),_("input"),R(),D(),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),_("sessions"),O(!1),I>=0&&x(I));return}if((B.ctrlKey||B.metaKey)&&B.key==="l"){B.preventDefault(),w==="git"?(document.activeElement?.blur(),_("input"),R(),D(),setTimeout(()=>v?.(),50)):w==="sessions"?(document.activeElement?.blur(),_("input"),O(!0),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),A||R(),_("git"),k());return}if((B.ctrlKey||B.metaKey)&&B.key==="/"){B.preventDefault(),T();return}if((B.ctrlKey||B.metaKey)&&B.key==="\\"){B.preventDefault(),R();return}if((B.ctrlKey||B.metaKey)&&B.shiftKey&&B.key==="r"){B.preventDefault(),L();return}if((B.ctrlKey||B.metaKey)&&B.key==="n"){B.preventDefault(),s();return}if(B.key==="Escape"||B.key==="q"&&!K&&(w==="sessions"||w==="git")){B.preventDefault(),w==="sessions"?O(!0):w==="git"&&(R(),D()),_("input"),v?.();return}if(w==="sessions"&&!K){if(B.key==="j"&&e.length>0){B.preventDefault();const V=Math.min(E+1,e.length-1);x(V);return}if(B.key==="k"&&e.length>0){B.preventDefault();const V=Math.max(E-1,0);x(V);return}if(B.key==="Enter"&&e[E]){B.preventDefault(),i(e[E]),_("input");return}}if(w==="git"&&!K){if(B.key==="j"&&n.length>0){B.preventDefault();const V=Math.min(b+1,n.length-1);S(V);return}if(B.key==="k"&&n.length>0){B.preventDefault();const V=Math.max(b-1,0);S(V);return}if(B.key===" "&&n[b]){B.preventDefault();const V=n[b];V.staged?c?.(V.path):l?.(V.path);return}if(B.key==="a"){B.preventDefault(),d?.();return}if(B.key==="u"){B.preventDefault(),p?.();return}if(B.key==="R"&&n[b]){B.preventDefault();const V=n[b];!V.staged&&V.status!=="untracked"&&V.status!=="added"&&o?.(V.path);return}if(B.shiftKey&&B.key==="D"||B.key==="Backspace"){B.preventDefault();const V=n[b];V&&!V.staged&&V.status==="untracked"&&u?.(V.path);return}if(B.key==="c"){B.preventDefault(),f?.();return}if(B.key==="Enter"&&n[b]){B.preventDefault();const V=n[b];m?.(V.path,V.staged);return}}},[w,E,b,e,n,I,A,_,x,S,k,O,R,L,T,i,s,l,c,o,u,d,p,f,m,v,D]);return q.useEffect(()=>(window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)),[H]),{currentFocus:w,sessionIndex:E,gitFileIndex:b}}function Ete(e){const t=q.useRef(null),n=q.useRef(null),i=cn(o=>o.setBalance),s=cn(o=>o.setPaymentPending),l=Cr(o=>o.removeToast),c=Cr(o=>o.updateToast);q.useEffect(()=>{if(!e)return;const o=new dL;t.current=o;const u=qe.getStreamUrl(e);o.connect(u);const d=o.on("*",p=>{const f=p.payload;switch(p.type){case"solforge.payment.required":{const m=typeof f?.amountUsd=="number"?f.amountUsd:0;s(!0),n.current=Kt.loading(`💳 Payment required: $${m.toFixed(2)}`);break}case"solforge.payment.signing":{n.current?c(n.current,{message:"✍️ Signing transaction..."}):n.current=Kt.loading("✍️ Signing transaction...");break}case"solforge.payment.complete":{const m=f?.amountUsd,v=f?.newBalance,w=typeof f?.transactionId=="string"?f.transactionId:void 0,E=typeof m=="number"?m:typeof m=="string"?parseFloat(m):0,b=typeof v=="number"?v:typeof v=="string"?parseFloat(v):0;i(b),s(!1),n.current&&(l(n.current),n.current=null);const _=`✅ Paid $${E.toFixed(2)}`;w?Kt.successWithAction(_,{label:"View Tx",href:`https://orbmarkets.io/tx/${w}`}):Kt.success(_);break}case"solforge.payment.error":{const m=typeof f?.error=="string"?f.error:"Payment failed";s(!1),n.current&&(l(n.current),n.current=null),Kt.error(`❌ ${m}`);break}}});return()=>{d(),o.disconnect()}},[e,i,s,l,c])}function NL({sessionId:e}){const t=q.useRef(null),n=x7(),{data:i}=Zv(),{theme:s,toggleTheme:l}=_te(),{openCommitModal:c,openDiff:o}=Tt(),u=Ec(),{data:d=[]}=Mc(),{data:p}=Fc(),f=jc(),m=Qv(),v=TD(),w=RD(),E=Pv(A=>A.openConfirmation);Ste(),Ete(e),Jv(i?.defaults?.provider);const b=q.useCallback(()=>{setTimeout(()=>{t.current?.focus()},100)},[]),_=q.useCallback(async()=>{try{const A=await n.mutateAsync({agent:i?.defaults.agent||"general",provider:i?.defaults.provider,model:i?.defaults.model});u({to:"/sessions/$sessionId",params:{sessionId:A.id},replace:!1}),b()}catch(A){console.error("Failed to create session:",A)}},[n,i,u,b]),x=q.useCallback(()=>{u({to:"/sessions"})},[u]),S=q.useCallback(A=>{u({to:"/sessions/$sessionId",params:{sessionId:A}}),b()},[u,b]),k=q.useMemo(()=>p?[...p.staged.map(A=>({path:A.path,staged:!0,status:A.status})),...p.unstaged.map(A=>({path:A.path,staged:!1,status:A.status})),...p.untracked.map(A=>({path:A.path,staged:!1,status:A.status}))]:[],[p]),O=q.useMemo(()=>d.map(A=>A.id),[d]);xte({sessionIds:O,activeSessionId:e,gitFiles:k,onSelectSession:S,onNewSession:_,onStageFile:A=>f.mutate([A]),onUnstageFile:A=>m.mutate([A]),onRestoreFile:A=>v.mutate([A]),onDeleteFile:A=>{E({title:"Delete File",message:`Delete ${A}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await w.mutateAsync([A])}})},onStageAll:()=>{const A=k.filter(R=>!R.staged).map(R=>R.path);A.length>0&&f.mutate(A)},onUnstageAll:()=>{const A=k.filter(R=>R.staged).map(R=>R.path);A.length>0&&m.mutate(A)},onOpenCommitModal:c,onViewDiff:o,onReturnToInput:b}),q.useEffect(()=>{e&&b()},[e,b]);const T=q.useMemo(()=>e?y.jsxs(y.Fragment,{children:[y.jsx(XJ,{sessionId:e,onSelectSession:S}),y.jsx(U7,{ref:t,sessionId:e,onNewSession:_,onDeleteSession:x})]}):y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"}),[e,_,S,x]);return y.jsxs(y.Fragment,{children:[y.jsx(yte,{onNewSession:_,theme:s,onToggleTheme:l,sessionId:e,onNavigateToSession:S,sidebar:y.jsx(QJ,{activeSessionId:e,onSelectSession:S}),children:T}),y.jsx(HF,{})]})}const wte=$o("/sessions/")({component:Cte});function Cte(){return y.jsx(NL,{})}const OL=$o("/sessions/$sessionId")({component:kte});function kte(){const{sessionId:e}=OL.useParams();return y.jsx(NL,{sessionId:e})}const Tte=C6.update({id:"/",path:"/",getParentRoute:()=>wc}),Rte=wte.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>wc}),Ate=OL.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>wc}),Nte={IndexRoute:Tte,SessionsSessionIdRoute:Ate,SessionsIndexRoute:Rte},Ote=wc._addFileChildren(Nte)._addFileTypes(),Dte=()=>{const n=(typeof globalThis<"u"?globalThis.AGI_ROUTER_BASEPATH:void 0)??"/"??"/";if(!n||n==="/")return"/";const i=n.replace(/\/+$/,"")||"/";return i.startsWith("/")?i:`/${i}`},Ite=_6({routeTree:Ote,basepath:Dte()}),Lte=new E4({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function Mte(){return y.jsx(w4,{client:Lte,children:y.jsx(E6,{router:Ite})})}const DL=document.getElementById("root");if(!DL)throw new Error("Root element not found");J3.createRoot(DL).render(y.jsx(q.StrictMode,{children:y.jsx(Mte,{})}));
146
+ `)}`}return v?/@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(v)?v:Dee(v):null},[p,n]);if(q.useEffect(()=>{if(t&&!d.current){const{isCollapsed:v}=_a.getState();u.current=v,o(!0)}else!t&&d.current&&u.current!==null&&(o(u.current),u.current=null);d.current=t},[t,o]),q.useEffect(()=>{const v=w=>{const E=w.target,b=E.tagName==="INPUT"||E.tagName==="TEXTAREA"||E.isContentEditable;(w.key==="Escape"||w.key==="q"&&!b)&&t&&c(),!b&&t&&i.length>1&&(w.key==="ArrowLeft"||w.key==="["?(w.preventDefault(),l(Math.max(0,s-1))):(w.key==="ArrowRight"||w.key==="]")&&(w.preventDefault(),l(Math.min(i.length-1,s+1))))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,c,i.length,s,l]),!t||!n||!p)return null;const m=i.length>1;return y.jsxs("div",{className:"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-3 shrink-0",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:c,title:"Close diff viewer (ESC)",children:y.jsx(Un,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[y.jsx("span",{className:"text-sm font-medium text-foreground font-mono truncate",title:n,children:n}),y.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0 capitalize",children:p.operation}),p.artifact?.summary&&y.jsxs("div",{className:"flex items-center gap-1 text-xs flex-shrink-0",children:[y.jsxs("span",{className:"text-green-500",children:["+",p.artifact.summary.additions]}),y.jsxs("span",{className:"text-red-500",children:["-",p.artifact.summary.deletions]})]})]}),m&&y.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.max(0,s-1)),disabled:s===0,title:"Previous operation (←)",children:y.jsx(nB,{className:"w-4 h-4"})}),y.jsxs("span",{className:"text-xs text-muted-foreground min-w-[60px] text-center",children:[s+1," / ",i.length]}),y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.min(i.length-1,s+1)),disabled:s===i.length-1,title:"Next operation (→)",children:y.jsx(nn,{className:"w-4 h-4"})})]})]}),m&&y.jsx("div",{className:"border-b border-border px-4 py-2 flex gap-2 overflow-x-auto shrink-0",children:i.map((v,w)=>y.jsxs("button",{type:"button",onClick:()=>l(w),className:`px-3 py-1.5 text-xs rounded-md flex items-center gap-2 shrink-0 transition-colors ${w===s?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted/80 text-muted-foreground"}`,children:[y.jsx("span",{className:"capitalize",children:v.operation}),y.jsx("span",{className:"opacity-70",children:Bee(v.timestamp)}),v.artifact?.summary&&y.jsxs("span",{className:"opacity-70",children:["+",v.artifact.summary.additions,"/-",v.artifact.summary.deletions]})]},v.toolCallId))}),y.jsx("div",{className:"flex-1 overflow-hidden p-4",children:f?y.jsx(Mee,{patch:f}):y.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No diff content available"})})]})}),jee={};class Pee{get baseUrl(){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(!jee?.VITE_API_BASE_URL)return Ic}async listResearchSessions(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch research sessions"}));throw new Error(i.error||"Failed to fetch research sessions")}return n.json()}async createResearchSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create research session"}));throw new Error(s.error||"Failed to create research session")}return i.json()}async deleteResearchSession(t){const n=await fetch(`${this.baseUrl}/v1/research/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete research session"}));throw new Error(i.error||"Failed to delete research session")}return n.json()}async injectContext(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/inject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({researchSessionId:n,label:i})});if(!s.ok){const l=await s.json().catch(()=>({error:"Failed to inject context"}));throw new Error(l.error||"Failed to inject context")}return s.json()}async exportToNewSession(t,n){const i=await fetch(`${this.baseUrl}/v1/research/${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n??{})});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to export to session"}));throw new Error(s.error||"Failed to export to session")}return i.json()}}const Kc=new Pee;function mL(e){return qn({queryKey:["research","sessions",e],queryFn:()=>Kc.listResearchSessions(e),enabled:!!e,staleTime:3e4})}function Uee(){const e=Lt();return Xt({mutationFn:({parentSessionId:t,data:n})=>Kc.createResearchSession(t,n??{}),onSuccess:(t,{parentSessionId:n})=>{e.invalidateQueries({queryKey:["research","sessions",n]})}})}function Hee(){const e=Vu(t=>t.addContext);return Xt({mutationFn:({parentSessionId:t,researchSessionId:n,label:i})=>Kc.injectContext(t,n,i),onSuccess:(t,{parentSessionId:n})=>{e(n,{id:t.sessionId,sessionId:t.sessionId,label:t.label,content:t.content})}})}function zee(){const e=Lt();return Xt({mutationFn:({researchId:t,data:n})=>Kc.exportToNewSession(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}const qee=q.memo(function({parentSessionId:t,onNavigateToSession:n}){const i=jn(z=>z.isExpanded),s=jn(z=>z.collapseSidebar),l=jn(z=>z.activeResearchSessionId),c=jn(z=>z.selectResearchSession),[o,u]=q.useState(!1),[d,p]=q.useState(""),[f,m]=q.useState(!1),[v,w]=q.useState("idle"),E=q.useRef(null),b=q.useRef(null),{data:_,isLoading:x,refetch:S}=mL(t),k=Uee(),O=Hee(),T=zee(),{data:A}=Bc(),{data:R}=pc(l??void 0),{data:D}=pc(t??void 0);hL(l??void 0);const L=kD(l??""),I=Lt(),H=Xt({mutationFn:async({sessionId:z,content:ne})=>qe.sendMessage(z,{content:ne}),onSuccess:(z,{sessionId:ne})=>{I.invalidateQueries({queryKey:["messages",ne]})}});q.useEffect(()=>{t&&jn.getState().setParentSessionId(t)},[t]),q.useEffect(()=>{_?.sessions?.length?_.sessions.some(ne=>ne.id===l)||c(_.sessions[0].id):_?.sessions?.length===0&&c(null)},[_,l,c]),q.useEffect(()=>{b.current?.scrollIntoView({behavior:"smooth"})},[]);const B=q.useCallback(()=>{const z=E.current;z&&(z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,120)}px`)},[]);q.useEffect(()=>{B()},[B]);const W=q.useCallback(async()=>{if(t)try{const z=await k.mutateAsync({parentSessionId:t,data:{}});await S(),c(z.session.id),u(!1)}catch(z){console.error("Failed to create research session:",z)}},[t,k,c,S]),K=q.useCallback(z=>{c(z.id),u(!1)},[c]),V=q.useCallback(async()=>{if(!t||!l)return;if(D?.some(be=>be.role==="system"&&be.parts?.some(we=>typeof we.content=="string"&&we.content.includes(`from="${l}"`)))){w("error"),setTimeout(()=>w("idle"),3e3);return}const ge=`Research ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`;try{await O.mutateAsync({parentSessionId:t,researchSessionId:l,label:ge}),w("success"),setTimeout(()=>w("idle"),5e3),I.invalidateQueries({queryKey:["messages",t]})}catch(be){console.error("Failed to inject context:",be),w("error"),setTimeout(()=>w("idle"),3e3)}},[t,l,O,D,I]),X=q.useCallback(async()=>{if(l)try{const z=await T.mutateAsync({researchId:l});n&&z.newSession?.id&&n(z.newSession.id)}catch(z){console.error("Failed to export to session:",z)}},[l,T,n]),Y=q.useCallback(async()=>{if(!(!d.trim()||!t))try{let z=l;z||(z=(await k.mutateAsync({parentSessionId:t,data:{}})).session.id,c(z)),await H.mutateAsync({sessionId:z,content:d}),p(""),E.current&&(E.current.style.height="auto")}catch(z){console.error("Failed to send message:",z)}},[d,t,l,k,c,H]),P=q.useCallback(z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),Y())},[Y]),M=q.useMemo(()=>R?.some(z=>z.role==="assistant"&&z.status==="pending")??!1,[R]),j=q.useMemo(()=>!l||!D?!1:D.some(z=>z.role==="system"&&z.parts?.some(ne=>typeof ne.content=="string"&&ne.content.includes(`from="${l}"`))),[l,D]),$=q.useCallback(async(z,ne)=>{if(l)try{await L.mutateAsync({provider:z,model:ne}),m(!1)}catch(ce){console.error("Failed to update research session model:",ce)}},[l,L]);if(!i)return null;const U=_?.sessions??[],J=U.find(z=>z.id===l),oe=R??[],he=A?.[J?.provider??""]?.label??J?.provider,Z=A?.[J?.provider??""]?.models.find(z=>z.id===J?.model)?.label??J?.model;return y.jsxs("div",{className:"w-96 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-3 flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[y.jsx(Go,{className:"w-4 h-4 text-teal-500"}),y.jsx("span",{className:"font-medium text-foreground text-sm",children:"Research"})]}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:()=>u(!o),title:"Research history",className:"h-8 w-8",children:y.jsx(JB,{className:"w-4 h-4"})}),y.jsx(st,{variant:"ghost",size:"icon",onClick:W,disabled:!t||k.isPending,title:"New research session",className:"h-8 w-8",children:k.isPending?y.jsx(Ni,{className:"w-4 h-4 animate-spin"}):y.jsx(Wo,{className:"w-4 h-4"})}),y.jsx(st,{variant:"ghost",size:"icon",onClick:s,title:"Close sidebar",className:"h-8 w-8",children:y.jsx(nn,{className:"w-4 h-4"})})]})]}),o?y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[y.jsx("div",{className:"p-2 border-b border-border",children:y.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Research Sessions"})}),x?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}):U.length===0?y.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No research sessions yet"}):y.jsx("div",{className:"p-2 space-y-1",children:U.map(z=>y.jsxs("button",{type:"button",onClick:()=>K(z),className:`w-full text-left p-2 rounded-md text-sm transition-colors ${z.id===l?"bg-teal-500/10 border border-teal-500/30 text-foreground":"hover:bg-muted"}`,children:[y.jsx("div",{className:"font-medium truncate",children:z.title||"Untitled"}),y.jsxs("div",{className:"text-xs text-muted-foreground",children:[z.messageCount," messages •"," ",$ee(z.lastActiveAt??z.createdAt)]})]},z.id))})]}):y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 research-messages text-[13px]",children:l?oe.length===0?y.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:y.jsx("p",{children:"Ask a question to start researching."})}):y.jsxs("div",{className:"space-y-1.5",children:[oe.map((z,ne)=>{if(z.role==="user"){const ce=oe[ne+1];return y.jsx(lL,{sessionId:l,message:z,isFirst:ne===0,nextAssistantMessageId:ce?.role==="assistant"?ce.id:void 0},z.id)}if(z.role==="assistant"){const ce=ne>0?oe[ne-1]:null,ge=oe[ne+1],be=ce?.role!=="assistant",we=ge?.role==="assistant";return y.jsx(oL,{sessionId:l,message:z,showHeader:be,hasNextAssistantMessage:we,isLastMessage:ne===oe.length-1,compact:!0,onNavigateToSession:n},z.id)}return null}),y.jsx("div",{ref:b})]}):y.jsxs("div",{className:"text-xs text-muted-foreground text-center py-8",children:[y.jsx(Go,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),y.jsx("p",{children:"Start researching by asking a question below."})]})}),y.jsxs("div",{className:"p-3 border-t border-border",children:[y.jsx("div",{className:"relative flex flex-col rounded-3xl bg-card border border-border focus-within:border-teal-500/60 focus-within:ring-1 focus-within:ring-teal-500/40 p-1",children:y.jsxs("div",{className:"flex items-end gap-1",children:[y.jsx(Cc,{ref:E,value:d,onChange:z=>p(z.target.value),onKeyDown:P,placeholder:"Ask anything...",disabled:!t||H.isPending||k.isPending,rows:1,className:"flex-1 border-0 bg-transparent pl-2 pr-1 py-2 max-h-[120px] overflow-y-auto leading-normal resize-none scrollbar-hide text-sm focus:ring-0 focus:outline-none",style:{height:"2.25rem"}}),y.jsx("button",{type:"button",onClick:Y,disabled:!d.trim()||!t||H.isPending||k.isPending||M,className:`flex items-center justify-center w-9 h-9 rounded-full transition-colors flex-shrink-0 ${d.trim()&&t&&!M?"bg-teal-500 hover:bg-teal-600 text-white":"bg-transparent text-muted-foreground"}`,children:H.isPending||k.isPending?y.jsx(Ni,{className:"w-4 h-4 animate-spin"}):y.jsx(CO,{className:"w-4 h-4"})})]})}),v==="success"&&y.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-teal-500/10 border border-teal-500/30 text-teal-600 dark:text-teal-400",children:[y.jsx(Mi,{className:"w-3 h-3 flex-shrink-0"}),y.jsx("span",{className:"flex-1",children:"Context injected — will be used on next request"}),y.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-teal-500",children:y.jsx(Un,{className:"w-3 h-3"})})]}),v==="error"&&y.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400",children:[y.jsx(Un,{className:"w-3 h-3 flex-shrink-0"}),y.jsx("span",{className:"flex-1",children:"Failed to inject context"}),y.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-red-500",children:y.jsx(Un,{className:"w-3 h-3"})})]}),y.jsxs("div",{className:"flex gap-2 mt-2",children:[y.jsxs("button",{type:"button",onClick:V,disabled:!l||O.isPending||M||j,className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${j?"bg-teal-500/10 text-teal-600 dark:text-teal-400 border border-teal-500/30":"bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground"}`,title:j?"Already injected into main session":"Inject findings into main session",children:[O.isPending?y.jsx(Ni,{className:"w-3 h-3 animate-spin"}):j?y.jsx(Mi,{className:"w-3 h-3"}):y.jsx(F6,{className:"w-3 h-3"}),j?"Injected":"Inject"]}),y.jsxs("button",{type:"button",onClick:X,disabled:!l||T.isPending||M,className:"flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Export to new main session",children:[T.isPending?y.jsx(Ni,{className:"w-3 h-3 animate-spin"}):y.jsx(wr,{className:"w-3 h-3"}),"Export"]})]})]})]}),y.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between",children:[y.jsxs("span",{className:"text-[10px]",children:[U.length," research session",U.length!==1?"s":""]}),J&&y.jsxs("button",{type:"button",onClick:()=>m(!0),className:"flex items-center gap-1 text-[10px] hover:text-foreground transition-colors",children:[y.jsx("span",{className:"opacity-60",children:he}),y.jsx("span",{className:"opacity-40",children:"/"}),y.jsx("span",{children:Z}),y.jsx(xa,{className:"w-3 h-3 opacity-40"})]})]}),y.jsx(al,{isOpen:f,onClose:()=>m(!1),title:"Select Model for Research",maxWidth:"md",children:J&&y.jsx(ID,{provider:J.provider,model:J.model,onChange:$})})]})});function $ee(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}const Gee=q.memo(function({parentSessionId:t}){const n=jn(c=>c.isExpanded),i=jn(c=>c.toggleSidebar),{data:s}=mL(t??null),l=s?.sessions?.length??0;return y.jsxs("button",{type:"button",onClick:i,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${n?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Research (⌘⇧R)",children:[y.jsx(Go,{className:"w-5 h-5 text-muted-foreground mx-auto"}),l>0&&y.jsx("span",{className:"absolute top-1 right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})});var Wee=Object.defineProperty,yc=Object.getOwnPropertySymbols,gL=Object.prototype.hasOwnProperty,bL=Object.prototype.propertyIsEnumerable,jN=(e,t,n)=>t in e?Wee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xv=(e,t)=>{for(var n in t||(t={}))gL.call(t,n)&&jN(e,n,t[n]);if(yc)for(var n of yc(t))bL.call(t,n)&&jN(e,n,t[n]);return e},Ev=(e,t)=>{var n={};for(var i in e)gL.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&yc)for(var i of yc(e))t.indexOf(i)<0&&bL.call(e,i)&&(n[i]=e[i]);return n};var Sa;(e=>{const t=class Ye{constructor(u,d,p,f){if(this.version=u,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let m=[];for(let w=0;w<this.size;w++)m.push(!1);for(let w=0;w<this.size;w++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(p);if(this.drawCodewords(v),f==-1){let w=1e9;for(let E=0;E<8;E++){this.applyMask(E),this.drawFormatBits(E);const b=this.getPenaltyScore();b<w&&(f=E,w=b),this.applyMask(E)}}s(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(u,d){const p=e.QrSegment.makeSegments(u);return Ye.encodeSegments(p,d)}static encodeBinary(u,d){const p=e.QrSegment.makeBytes(u);return Ye.encodeSegments([p],d)}static encodeSegments(u,d,p=1,f=40,m=-1,v=!0){if(!(Ye.MIN_VERSION<=p&&p<=f&&f<=Ye.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let w,E;for(w=p;;w++){const S=Ye.getNumDataCodewords(w,d)*8,k=c.getTotalBits(u,w);if(k<=S){E=k;break}if(w>=f)throw new RangeError("Data too long")}for(const S of[Ye.Ecc.MEDIUM,Ye.Ecc.QUARTILE,Ye.Ecc.HIGH])v&&E<=Ye.getNumDataCodewords(w,S)*8&&(d=S);let b=[];for(const S of u){n(S.mode.modeBits,4,b),n(S.numChars,S.mode.numCharCountBits(w),b);for(const k of S.getData())b.push(k)}s(b.length==E);const _=Ye.getNumDataCodewords(w,d)*8;s(b.length<=_),n(0,Math.min(4,_-b.length),b),n(0,(8-b.length%8)%8,b),s(b.length%8==0);for(let S=236;b.length<_;S^=253)n(S,8,b);let x=[];for(;x.length*8<b.length;)x.push(0);return b.forEach((S,k)=>x[k>>>3]|=S<<7-(k&7)),new Ye(w,d,x,m)}getModule(u,d){return 0<=u&&u<this.size&&0<=d&&d<this.size&&this.modules[d][u]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const u=this.getAlignmentPatternPositions(),d=u.length;for(let p=0;p<d;p++)for(let f=0;f<d;f++)p==0&&f==0||p==0&&f==d-1||p==d-1&&f==0||this.drawAlignmentPattern(u[p],u[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const d=this.errorCorrectionLevel.formatBits<<3|u;let p=d;for(let m=0;m<10;m++)p=p<<1^(p>>>9)*1335;const f=(d<<10|p)^21522;s(f>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,i(f,m));this.setFunctionModule(8,7,i(f,6)),this.setFunctionModule(8,8,i(f,7)),this.setFunctionModule(7,8,i(f,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,i(f,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,i(f,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,i(f,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const d=this.version<<12|u;s(d>>>18==0);for(let p=0;p<18;p++){const f=i(d,p),m=this.size-11+p%3,v=Math.floor(p/3);this.setFunctionModule(m,v,f),this.setFunctionModule(v,m,f)}}drawFinderPattern(u,d){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const m=Math.max(Math.abs(f),Math.abs(p)),v=u+f,w=d+p;0<=v&&v<this.size&&0<=w&&w<this.size&&this.setFunctionModule(v,w,m!=2&&m!=4)}}drawAlignmentPattern(u,d){for(let p=-2;p<=2;p++)for(let f=-2;f<=2;f++)this.setFunctionModule(u+f,d+p,Math.max(Math.abs(f),Math.abs(p))!=1)}setFunctionModule(u,d,p){this.modules[d][u]=p,this.isFunction[d][u]=!0}addEccAndInterleave(u){const d=this.version,p=this.errorCorrectionLevel;if(u.length!=Ye.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const f=Ye.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],m=Ye.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],v=Math.floor(Ye.getNumRawDataModules(d)/8),w=f-v%f,E=Math.floor(v/f);let b=[];const _=Ye.reedSolomonComputeDivisor(m);for(let S=0,k=0;S<f;S++){let O=u.slice(k,k+E-m+(S<w?0:1));k+=O.length;const T=Ye.reedSolomonComputeRemainder(O,_);S<w&&O.push(0),b.push(O.concat(T))}let x=[];for(let S=0;S<b[0].length;S++)b.forEach((k,O)=>{(S!=E-m||O>=w)&&x.push(k[S])});return s(x.length==v),x}drawCodewords(u){if(u.length!=Math.floor(Ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f<this.size;f++)for(let m=0;m<2;m++){const v=p-m,E=(p+1&2)==0?this.size-1-f:f;!this.isFunction[E][v]&&d<u.length*8&&(this.modules[E][v]=i(u[d>>>3],7-(d&7)),d++)}}s(d==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let f;switch(u){case 0:f=(p+d)%2==0;break;case 1:f=d%2==0;break;case 2:f=p%3==0;break;case 3:f=(p+d)%3==0;break;case 4:f=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:f=p*d%2+p*d%3==0;break;case 6:f=(p*d%2+p*d%3)%2==0;break;case 7:f=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&f&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let u=0;for(let m=0;m<this.size;m++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[m][b]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[m][b],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let m=0;m<this.size;m++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[b][m]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[b][m],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let v=0;v<this.size-1;v++){const w=this.modules[m][v];w==this.modules[m][v+1]&&w==this.modules[m+1][v]&&w==this.modules[m+1][v+1]&&(u+=Ye.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((v,w)=>v+(w?1:0),d);const p=this.size*this.size,f=Math.ceil(Math.abs(d*20-p*10)/p)-1;return s(0<=f&&f<=9),u+=f*Ye.PENALTY_N4,s(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let f=this.size-7;p.length<u;f-=d)p.splice(1,0,f);return p}}static getNumRawDataModules(u){if(u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;d-=(25*p-10)*p-55,u>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(u,d){return Math.floor(Ye.getNumRawDataModules(u)/8)-Ye.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u]*Ye.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let d=[];for(let f=0;f<u-1;f++)d.push(0);d.push(1);let p=1;for(let f=0;f<u;f++){for(let m=0;m<d.length;m++)d[m]=Ye.reedSolomonMultiply(d[m],p),m+1<d.length&&(d[m]^=d[m+1]);p=Ye.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(u,d){let p=d.map(f=>0);for(const f of u){const m=f^p.shift();p.push(0),d.forEach((v,w)=>p[w]^=Ye.reedSolomonMultiply(v,m))}return p}static reedSolomonMultiply(u,d){if(u>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(d>>>f&1)*u;return s(p>>>8==0),p}finderPenaltyCountPatterns(u){const d=u[1];s(d<=this.size*3);const p=d>0&&u[2]==d&&u[3]==d*3&&u[4]==d&&u[5]==d;return(p&&u[0]>=d*4&&u[6]>=d?1:0)+(p&&u[6]>=d*4&&u[0]>=d?1:0)}finderPenaltyTerminateAndCount(u,d,p){return u&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,d){d[0]==0&&(u+=this.size),d.pop(),d.unshift(u)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(o,u,d){if(u<0||u>31||o>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)d.push(o>>>p&1)}function i(o,u){return(o>>>u&1)!=0}function s(o){if(!o)throw new Error("Assertion error")}const l=class It{constructor(u,d,p){if(this.mode=u,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let d=[];for(const p of u)n(p,8,d);return new It(It.Mode.BYTE,u.length,d)}static makeNumeric(u){if(!It.isNumeric(u))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<u.length;){const f=Math.min(u.length-p,3);n(parseInt(u.substring(p,p+f),10),f*3+1,d),p+=f}return new It(It.Mode.NUMERIC,u.length,d)}static makeAlphanumeric(u){if(!It.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=u.length;p+=2){let f=It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;f+=It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),n(f,11,d)}return p<u.length&&n(It.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,d),new It(It.Mode.ALPHANUMERIC,u.length,d)}static makeSegments(u){return u==""?[]:It.isNumeric(u)?[It.makeNumeric(u)]:It.isAlphanumeric(u)?[It.makeAlphanumeric(u)]:[It.makeBytes(It.toUtf8ByteArray(u))]}static makeEci(u){let d=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)n(u,8,d);else if(u<16384)n(2,2,d),n(u,14,d);else if(u<1e6)n(6,3,d),n(u,21,d);else throw new RangeError("ECI assignment value out of range");return new It(It.Mode.ECI,0,d)}static isNumeric(u){return It.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return It.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,d){let p=0;for(const f of u){const m=f.mode.numCharCountBits(d);if(f.numChars>=1<<m)return 1/0;p+=4+m+f.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let d=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?d.push(u.charCodeAt(p)):(d.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return d}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let c=l;e.QrSegment=l})(Sa||(Sa={}));(e=>{(t=>{const n=class{constructor(s,l){this.ordinal=s,this.formatBits=l}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(Sa||(Sa={}));(e=>{(t=>{const n=class{constructor(s,l){this.modeBits=s,this.numBitsCharCount=l}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(Sa||(Sa={}));var gs=Sa;var Vee={L:gs.QrCode.Ecc.LOW,M:gs.QrCode.Ecc.MEDIUM,Q:gs.QrCode.Ecc.QUARTILE,H:gs.QrCode.Ecc.HIGH},yL=128,vL="L",_L="#FFFFFF",SL="#000000",xL=!1,EL=1,Kee=4,Yee=0,Xee=.1;function wL(e,t=0){const n=[];return e.forEach(function(i,s){let l=null;i.forEach(function(c,o){if(!c&&l!==null){n.push(`M${l+t} ${s+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===i.length-1){if(!c)return;l===null?n.push(`M${o+t},${s+t} h1v1H${o+t}z`):n.push(`M${l+t},${s+t} h${o+1-l}v1H${l+t}z`);return}c&&l===null&&(l=o)})}),n.join("")}function CL(e,t){return e.slice().map((n,i)=>i<t.y||i>=t.y+t.h?n:n.map((s,l)=>l<t.x||l>=t.x+t.w?s:!1))}function Zee(e,t,n,i){if(i==null)return null;const s=e.length+n*2,l=Math.floor(t*Xee),c=s/t,o=(i.width||l)*c,u=(i.height||l)*c,d=i.x==null?e.length/2-o/2:i.x*c,p=i.y==null?e.length/2-u/2:i.y*c,f=i.opacity==null?1:i.opacity;let m=null;if(i.excavate){let w=Math.floor(d),E=Math.floor(p),b=Math.ceil(o+d-w),_=Math.ceil(u+p-E);m={x:w,y:E,w:b,h:_}}const v=i.crossOrigin;return{x:d,y:p,h:u,w:o,excavation:m,opacity:f,crossOrigin:v}}function Qee(e,t){return t!=null?Math.max(Math.floor(t),0):e?Kee:Yee}function kL({value:e,level:t,minVersion:n,includeMargin:i,marginSize:s,imageSettings:l,size:c,boostLevel:o}){let u=Je.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((E,b)=>(E.push(...gs.QrSegment.makeSegments(b)),E),[]);return gs.QrCode.encodeSegments(w,Vee[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:p,numCells:f,calculatedImageSettings:m}=Je.useMemo(()=>{let v=u.getModules();const w=Qee(i,s),E=v.length+w*2,b=Zee(v,c,w,l);return{cells:v,margin:w,numCells:E,calculatedImageSettings:b}},[u,c,l,i,s]);return{qrcode:u,margin:p,cells:d,numCells:f,calculatedImageSettings:m}}var Jee=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ete=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=yL,level:c=vL,bgColor:o=_L,fgColor:u=SL,includeMargin:d=xL,minVersion:p=EL,boostLevel:f,marginSize:m,imageSettings:v}=i,E=Ev(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=E,_=Ev(E,["style"]),x=v?.src,S=Je.useRef(null),k=Je.useRef(null),O=Je.useCallback(W=>{S.current=W,typeof n=="function"?n(W):n&&(n.current=W)},[n]),[T,A]=Je.useState(!1),{margin:R,cells:D,numCells:L,calculatedImageSettings:I}=kL({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:m,imageSettings:v,size:l});Je.useEffect(()=>{if(S.current!=null){const W=S.current,K=W.getContext("2d");if(!K)return;let V=D;const X=k.current,Y=I!=null&&X!==null&&X.complete&&X.naturalHeight!==0&&X.naturalWidth!==0;Y&&I.excavation!=null&&(V=CL(D,I.excavation));const P=window.devicePixelRatio||1;W.height=W.width=l*P;const M=l/L*P;K.scale(M,M),K.fillStyle=o,K.fillRect(0,0,L,L),K.fillStyle=u,Jee?K.fill(new Path2D(wL(V,R))):D.forEach(function(j,$){j.forEach(function(U,J){U&&K.fillRect(J+R,$+R,1,1)})}),I&&(K.globalAlpha=I.opacity),Y&&K.drawImage(X,I.x+R,I.y+R,I.w,I.h)}}),Je.useEffect(()=>{A(!1)},[x]);const H=xv({height:l,width:l},b);let B=null;return x!=null&&(B=Je.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{A(!0)},ref:k,crossOrigin:I?.crossOrigin})),Je.createElement(Je.Fragment,null,Je.createElement("canvas",xv({style:H,height:l,width:l,ref:O,role:"img"},_)),B)});ete.displayName="QRCodeCanvas";var TL=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=yL,level:c=vL,bgColor:o=_L,fgColor:u=SL,includeMargin:d=xL,minVersion:p=EL,boostLevel:f,title:m,marginSize:v,imageSettings:w}=i,E=Ev(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:_,numCells:x,calculatedImageSettings:S}=kL({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:v,imageSettings:w,size:l});let k=_,O=null;w!=null&&S!=null&&(S.excavation!=null&&(k=CL(_,S.excavation)),O=Je.createElement("image",{href:w.src,height:S.h,width:S.w,x:S.x+b,y:S.y+b,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const T=wL(k,b);return Je.createElement("svg",xv({height:l,width:l,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},E),!!m&&Je.createElement("title",null,m),Je.createElement("path",{fill:o,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),Je.createElement("path",{fill:u,d:T,shapeRendering:"crispEdges"}),O)});TL.displayName="QRCodeSVG";const Fu=q.memo(function({title:t,icon:n,children:i,action:s}){return y.jsxs("div",{className:"border-b border-border",children:[y.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 bg-muted/30",children:[n,y.jsx("span",{className:"text-sm font-medium flex-1",children:t}),s]}),y.jsx("div",{className:"px-4 py-3 space-y-3",children:i})]})}),Fy=q.memo(function({label:t,value:n}){return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsx("span",{className:"font-mono text-foreground",children:n})]})}),PN=q.memo(function({label:t,checked:n,onChange:i}){return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>i(!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${n?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${n?"translate-x-6":"translate-x-1"} ${n?"bg-primary-foreground":"bg-foreground"}`})})]})}),ju=q.memo(function({label:t,value:n,options:i,onChange:s,disabled:l}){const[c,o]=q.useState(!1),u=i.find(d=>d.id===n);return y.jsxs("div",{className:"flex items-center justify-between text-sm",children:[y.jsx("span",{className:"text-muted-foreground",children:t}),y.jsxs("div",{className:"relative",children:[y.jsxs("button",{type:"button",onClick:()=>!l&&o(!c),disabled:l,className:"flex items-center gap-1 px-2 py-1 text-xs font-mono bg-muted hover:bg-muted/80 rounded border border-border disabled:opacity-50",children:[y.jsx("span",{className:"max-w-[120px] truncate",children:u?.label||n||"Select..."}),y.jsx(xa,{className:"w-3 h-3"})]}),c&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1),role:"presentation"}),y.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-[200px] overflow-y-auto bg-popover border border-border rounded-md shadow-lg",children:i.map(d=>y.jsx("button",{type:"button",onClick:()=>{s(d.id),o(!1)},className:`w-full px-3 py-2 text-left text-xs font-mono hover:bg-muted truncate ${d.id===n?"bg-muted/50":""}`,children:d.label},d.id))})]})]})]})}),tte=q.memo(function(){const t=kr(A=>A.isExpanded),n=kr(A=>A.collapseSidebar),{data:i}=Zv(),{data:s}=Bc(),{preferences:l,updatePreferences:c}=Jo(),o=w7(),u=cn(A=>A.balance),d=cn(A=>A.walletAddress),p=cn(A=>A.usdcBalance),f=cn(A=>A.isLoading),m=i?.providers?.includes("setu"),{fetchBalance:v}=Jv(m?"setu":void 0),w=q.useMemo(()=>!i?.providers||!s?[]:i.providers.filter(A=>s[A]).map(A=>({id:A,label:s[A]?.label||A})),[i?.providers,s]),E=q.useMemo(()=>{const A=i?.defaults?.provider;return!A||!s?.[A]?[]:s[A].models.map(R=>({id:R.id,label:R.label}))},[i?.defaults?.provider,s]),b=q.useMemo(()=>i?.agents?i.agents.map(A=>({id:A,label:A})):[],[i?.agents]);if(!t)return null;const _=A=>{const R=s?.[A]?.models?.[0]?.id;o.mutate({provider:A,model:R||i?.defaults?.model})},x=A=>{o.mutate({model:A})},S=A=>{o.mutate({agent:A})},k=A=>A?`${A.slice(0,4)}...${A.slice(-4)}`:"Not configured",O=A=>A===null?"—":`$${A.toFixed(4)}`,T=A=>A===null?"—":`${A.toFixed(2)} USDC`;return y.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(jO,{className:"w-4 h-4"}),y.jsx("span",{className:"font-medium",children:"Settings"})]}),y.jsx(st,{variant:"ghost",size:"icon",onClick:n,children:y.jsx(nn,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[y.jsxs(Fu,{title:"Default Model",icon:y.jsx(SB,{className:"w-4 h-4 text-muted-foreground"}),children:[y.jsx(ju,{label:"Provider",value:i?.defaults?.provider??"",options:w,onChange:_,disabled:o.isPending}),y.jsx(ju,{label:"Model",value:i?.defaults?.model??"",options:E,onChange:x,disabled:o.isPending}),y.jsx(ju,{label:"Agent",value:i?.defaults?.agent??"",options:b,onChange:S,disabled:o.isPending})]}),y.jsxs(Fu,{title:"Preferences",icon:y.jsx(qv,{className:"w-4 h-4 text-muted-foreground"}),children:[y.jsx(PN,{label:"Vim Mode",checked:l.vimMode,onChange:A=>c({vimMode:A})}),y.jsx(PN,{label:"Show Reasoning",checked:l.reasoningEnabled,onChange:A=>c({reasoningEnabled:A})}),y.jsx(ju,{label:"Tool Approval",value:i?.defaults?.toolApproval??"auto",options:[{id:"auto",label:"Auto (no approval)"},{id:"dangerous",label:"Dangerous only"},{id:"all",label:"All tools"}],onChange:A=>o.mutate({toolApproval:A}),disabled:o.isPending})]}),i?.providers?.includes("setu")&&y.jsxs(Fu,{title:"Setu Wallet",icon:y.jsx(IF,{className:"w-4 h-4 text-muted-foreground"}),action:y.jsx("button",{type:"button",onClick:v,disabled:f,className:"p-1 hover:bg-muted rounded transition-colors disabled:opacity-50",title:"Refresh balances",children:y.jsx(Ea,{className:`w-3.5 h-3.5 text-muted-foreground ${f?"animate-spin":""}`})}),children:[d&&y.jsx("div",{className:"flex justify-center pb-3",children:y.jsx("div",{className:"p-2 bg-white rounded-lg",children:y.jsx(TL,{value:d,size:120,level:"M",includeMargin:!1})})}),y.jsx(Fy,{label:"Address",value:k(d)}),y.jsx(Fy,{label:"Balance",value:O(u)}),y.jsx(Fy,{label:"USDC",value:T(p)})]}),y.jsx(Fu,{title:"Providers",icon:y.jsx(BF,{className:"w-4 h-4 text-muted-foreground"}),children:y.jsx("div",{className:"flex flex-wrap gap-2",children:i?.providers?.map(A=>y.jsx("span",{className:"px-2 py-1 text-xs bg-muted rounded-md font-mono",children:A},A))??y.jsx("span",{className:"text-muted-foreground text-sm",children:"None"})})})]})]})}),nte=q.memo(function(){const t=kr(i=>i.isExpanded),n=kr(i=>i.toggleSidebar);return y.jsx("button",{type:"button",onClick:n,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${t?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Settings",children:y.jsx(jO,{className:"w-5 h-5 text-muted-foreground mx-auto"})})});const rte=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ite=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),UN=e=>{const t=ite(e);return t.charAt(0).toUpperCase()+t.slice(1)},RL=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),ate=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var ste={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ote=q.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:s="",children:l,iconNode:c,...o},u)=>q.createElement("svg",{ref:u,...ste,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:RL("lucide",s),...!l&&!ate(o)&&{"aria-hidden":"true"},...o},[...c.map(([d,p])=>q.createElement(d,p)),...Array.isArray(l)?l:[l]]));const dl=(e,t)=>{const n=q.forwardRef(({className:i,...s},l)=>q.createElement(ote,{ref:l,iconNode:t,className:RL(`lucide-${rte(UN(e))}`,`lucide-${e}`,i),...s}));return n.displayName=UN(e),n};const lte=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ute=dl("chevron-right",lte);const cte=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],dte=dl("moon",cte);const hte=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],HN=dl("plus",hte);const pte=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fte=dl("sun",pte);const mte=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gte=dl("x",mte),bte=q.memo(function({children:t,onNewSession:n}){const i=Tt(c=>c.isDiffOpen),s=_a(c=>c.isCollapsed),l=_a(c=>c.toggleCollapse);return q.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),s?y.jsxs("aside",{className:"w-12 md:w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out hidden md:flex",children:[y.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:n,title:"New session",className:"rounded-full touch-manipulation",children:y.jsx(HN,{className:"w-4 h-4"})})}),y.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:i?void 0:l,title:i?void 0:"Expand sidebar","aria-label":"Expand sidebar"}),y.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:y.jsx(ute,{className:"w-4 h-4"})})})]}):y.jsxs(y.Fragment,{children:[!s&&y.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:l,"aria-hidden":"true"}),y.jsxs("aside",{className:"w-full md:w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out fixed md:relative top-0 left-0 z-50 h-screen md:h-auto",children:[y.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2 md:hidden bg-background",children:[y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Close menu",className:"touch-manipulation flex-shrink-0","aria-label":"Close menu",children:y.jsx(gte,{className:"w-5 h-5"})}),y.jsx("h1",{className:"text-lg font-semibold text-foreground flex-1",children:"AGI"})]}),y.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2",children:y.jsxs(st,{variant:"primary",size:"sm",onClick:n,className:"flex-1 touch-manipulation",children:[y.jsx(HN,{className:"w-4 h-4 mr-2"}),"New Session"]})}),y.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:t}),y.jsx("div",{className:"h-12 border-t border-border px-2 flex items-center justify-end",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:y.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[y.jsx("title",{children:"Collapse sidebar"}),y.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})]})}),yte=q.memo(function({sidebar:t,children:n,onNewSession:i,theme:s,onToggleTheme:l,sessionId:c,onNavigateToSession:o}){return y.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[y.jsx(bte,{onNewSession:i,children:t}),y.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden relative w-full md:w-auto",children:[y.jsx(cee,{}),y.jsx(Fee,{}),n]}),y.jsxs("div",{className:"hidden md:flex",children:[y.jsx(aee,{}),y.jsx(Nee,{sessionId:c}),y.jsx(wee,{}),y.jsx(qee,{parentSessionId:c??null,onNavigateToSession:o}),y.jsx(tte,{}),y.jsxs("div",{className:"flex flex-col w-12 border-l border-border bg-background",children:[y.jsx(see,{}),y.jsx(Oee,{sessionId:c}),y.jsx(Cee,{}),y.jsx(Gee,{parentSessionId:c}),y.jsx("div",{className:"flex-1"}),y.jsx(nte,{}),y.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:y.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:`Switch to ${s==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${s==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:s==="dark"?y.jsx(fte,{className:"w-4 h-4"}):y.jsx(dte,{className:"w-4 h-4"})})})]})]}),y.jsx(dee,{}),y.jsx(FF,{})]})}),AL="agi-theme",zN="dark";function vte(){if(typeof window>"u")return zN;const e=window.localStorage.getItem(AL);return e==="light"||e==="dark"?e:zN}function _te(){const[e,t]=q.useState(()=>vte());q.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(AL,e)}catch(s){console.warn("Failed to persist theme preference",s)}},[e]);const n=q.useCallback(()=>{t(i=>i==="dark"?"light":"dark")},[]);return q.useMemo(()=>({theme:e,setTheme:t,toggleTheme:n}),[e,n])}function Ste(){const[e,t]=q.useState(null);return q.useEffect(()=>{(async()=>{try{const l=`${window.AGI_SERVER_URL||Ic}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",l);const c=await fetch(l);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const o=await c.json();console.log("[useWorkingDirectory] Success:",o),o.dirName&&(console.log("[useWorkingDirectory] Setting title to:",o.dirName),t(o.dirName),document.title=o.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}function xte({sessionIds:e,activeSessionId:t,gitFiles:n,onSelectSession:i,onNewSession:s,onStageFile:l,onUnstageFile:c,onRestoreFile:o,onDeleteFile:u,onStageAll:d,onUnstageAll:p,onOpenCommitModal:f,onViewDiff:m,onReturnToInput:v}){const{currentFocus:w,sessionIndex:E,gitFileIndex:b,setFocus:_,setSessionIndex:x,setGitFileIndex:S,resetGitFileIndex:k}=N1(),{setCollapsed:O,toggleCollapse:T}=_a(),{isExpanded:A,toggleSidebar:R}=Tt(),D=Tt(B=>B.closeDiff),L=jn(B=>B.toggleSidebar),I=e.indexOf(t||""),H=q.useCallback(B=>{const W=B.target,K=W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable;if((B.ctrlKey||B.metaKey)&&B.key==="h"){B.preventDefault(),w==="sessions"?(document.activeElement?.blur(),_("input"),O(!0),setTimeout(()=>v?.(),50)):w==="git"?(document.activeElement?.blur(),_("input"),R(),D(),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),_("sessions"),O(!1),I>=0&&x(I));return}if((B.ctrlKey||B.metaKey)&&B.key==="l"){B.preventDefault(),w==="git"?(document.activeElement?.blur(),_("input"),R(),D(),setTimeout(()=>v?.(),50)):w==="sessions"?(document.activeElement?.blur(),_("input"),O(!0),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),A||R(),_("git"),k());return}if((B.ctrlKey||B.metaKey)&&B.key==="/"){B.preventDefault(),T();return}if((B.ctrlKey||B.metaKey)&&B.key==="\\"){B.preventDefault(),R();return}if((B.ctrlKey||B.metaKey)&&B.shiftKey&&B.key==="r"){B.preventDefault(),L();return}if((B.ctrlKey||B.metaKey)&&B.key==="n"){B.preventDefault(),s();return}if(B.key==="Escape"||B.key==="q"&&!K&&(w==="sessions"||w==="git")){B.preventDefault(),w==="sessions"?O(!0):w==="git"&&(R(),D()),_("input"),v?.();return}if(w==="sessions"&&!K){if(B.key==="j"&&e.length>0){B.preventDefault();const V=Math.min(E+1,e.length-1);x(V);return}if(B.key==="k"&&e.length>0){B.preventDefault();const V=Math.max(E-1,0);x(V);return}if(B.key==="Enter"&&e[E]){B.preventDefault(),i(e[E]),_("input");return}}if(w==="git"&&!K){if(B.key==="j"&&n.length>0){B.preventDefault();const V=Math.min(b+1,n.length-1);S(V);return}if(B.key==="k"&&n.length>0){B.preventDefault();const V=Math.max(b-1,0);S(V);return}if(B.key===" "&&n[b]){B.preventDefault();const V=n[b];V.staged?c?.(V.path):l?.(V.path);return}if(B.key==="a"){B.preventDefault(),d?.();return}if(B.key==="u"){B.preventDefault(),p?.();return}if(B.key==="R"&&n[b]){B.preventDefault();const V=n[b];!V.staged&&V.status!=="untracked"&&V.status!=="added"&&o?.(V.path);return}if(B.shiftKey&&B.key==="D"||B.key==="Backspace"){B.preventDefault();const V=n[b];V&&!V.staged&&V.status==="untracked"&&u?.(V.path);return}if(B.key==="c"){B.preventDefault(),f?.();return}if(B.key==="Enter"&&n[b]){B.preventDefault();const V=n[b];m?.(V.path,V.staged);return}}},[w,E,b,e,n,I,A,_,x,S,k,O,R,L,T,i,s,l,c,o,u,d,p,f,m,v,D]);return q.useEffect(()=>(window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)),[H]),{currentFocus:w,sessionIndex:E,gitFileIndex:b}}function Ete(e){const t=q.useRef(null),n=q.useRef(null),i=cn(o=>o.setBalance),s=cn(o=>o.setPaymentPending),l=Cr(o=>o.removeToast),c=Cr(o=>o.updateToast);q.useEffect(()=>{if(!e)return;const o=new dL;t.current=o;const u=qe.getStreamUrl(e);o.connect(u);const d=o.on("*",p=>{const f=p.payload;switch(p.type){case"setu.payment.required":{const m=typeof f?.amountUsd=="number"?f.amountUsd:0;s(!0),n.current=Kt.loading(`💳 Payment required: $${m.toFixed(2)}`);break}case"setu.payment.signing":{n.current?c(n.current,{message:"✍️ Signing transaction..."}):n.current=Kt.loading("✍️ Signing transaction...");break}case"setu.payment.complete":{const m=f?.amountUsd,v=f?.newBalance,w=typeof f?.transactionId=="string"?f.transactionId:void 0,E=typeof m=="number"?m:typeof m=="string"?parseFloat(m):0,b=typeof v=="number"?v:typeof v=="string"?parseFloat(v):0;i(b),s(!1),n.current&&(l(n.current),n.current=null);const _=`✅ Paid $${E.toFixed(2)}`;w?Kt.successWithAction(_,{label:"View Tx",href:`https://orbmarkets.io/tx/${w}`}):Kt.success(_);break}case"setu.payment.error":{const m=typeof f?.error=="string"?f.error:"Payment failed";s(!1),n.current&&(l(n.current),n.current=null),Kt.error(`❌ ${m}`);break}}});return()=>{d(),o.disconnect()}},[e,i,s,l,c])}function NL({sessionId:e}){const t=q.useRef(null),n=x7(),{data:i}=Zv(),{theme:s,toggleTheme:l}=_te(),{openCommitModal:c,openDiff:o}=Tt(),u=Ec(),{data:d=[]}=Mc(),{data:p}=Fc(),f=jc(),m=Qv(),v=TD(),w=RD(),E=Pv(A=>A.openConfirmation);Ste(),Ete(e),Jv(i?.defaults?.provider);const b=q.useCallback(()=>{setTimeout(()=>{t.current?.focus()},100)},[]),_=q.useCallback(async()=>{try{const A=await n.mutateAsync({agent:i?.defaults.agent||"general",provider:i?.defaults.provider,model:i?.defaults.model});u({to:"/sessions/$sessionId",params:{sessionId:A.id},replace:!1}),b()}catch(A){console.error("Failed to create session:",A)}},[n,i,u,b]),x=q.useCallback(()=>{u({to:"/sessions"})},[u]),S=q.useCallback(A=>{u({to:"/sessions/$sessionId",params:{sessionId:A}}),b()},[u,b]),k=q.useMemo(()=>p?[...p.staged.map(A=>({path:A.path,staged:!0,status:A.status})),...p.unstaged.map(A=>({path:A.path,staged:!1,status:A.status})),...p.untracked.map(A=>({path:A.path,staged:!1,status:A.status}))]:[],[p]),O=q.useMemo(()=>d.map(A=>A.id),[d]);xte({sessionIds:O,activeSessionId:e,gitFiles:k,onSelectSession:S,onNewSession:_,onStageFile:A=>f.mutate([A]),onUnstageFile:A=>m.mutate([A]),onRestoreFile:A=>v.mutate([A]),onDeleteFile:A=>{E({title:"Delete File",message:`Delete ${A}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await w.mutateAsync([A])}})},onStageAll:()=>{const A=k.filter(R=>!R.staged).map(R=>R.path);A.length>0&&f.mutate(A)},onUnstageAll:()=>{const A=k.filter(R=>R.staged).map(R=>R.path);A.length>0&&m.mutate(A)},onOpenCommitModal:c,onViewDiff:o,onReturnToInput:b}),q.useEffect(()=>{e&&b()},[e,b]);const T=q.useMemo(()=>e?y.jsxs(y.Fragment,{children:[y.jsx(XJ,{sessionId:e,onSelectSession:S}),y.jsx(U7,{ref:t,sessionId:e,onNewSession:_,onDeleteSession:x})]}):y.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"}),[e,_,S,x]);return y.jsxs(y.Fragment,{children:[y.jsx(yte,{onNewSession:_,theme:s,onToggleTheme:l,sessionId:e,onNavigateToSession:S,sidebar:y.jsx(QJ,{activeSessionId:e,onSelectSession:S}),children:T}),y.jsx(HF,{})]})}const wte=$o("/sessions/")({component:Cte});function Cte(){return y.jsx(NL,{})}const OL=$o("/sessions/$sessionId")({component:kte});function kte(){const{sessionId:e}=OL.useParams();return y.jsx(NL,{sessionId:e})}const Tte=C6.update({id:"/",path:"/",getParentRoute:()=>wc}),Rte=wte.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>wc}),Ate=OL.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>wc}),Nte={IndexRoute:Tte,SessionsSessionIdRoute:Ate,SessionsIndexRoute:Rte},Ote=wc._addFileChildren(Nte)._addFileTypes(),Dte=()=>{const n=(typeof globalThis<"u"?globalThis.AGI_ROUTER_BASEPATH:void 0)??"/"??"/";if(!n||n==="/")return"/";const i=n.replace(/\/+$/,"")||"/";return i.startsWith("/")?i:`/${i}`},Ite=_6({routeTree:Ote,basepath:Dte()}),Lte=new E4({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function Mte(){return y.jsx(w4,{client:Lte,children:y.jsx(E6,{router:Ite})})}const DL=document.getElementById("root");if(!DL)throw new Error("Root element not found");J3.createRoot(DL).render(y.jsx(q.StrictMode,{children:y.jsx(Mte,{})}));