@ottocode/web-ui 0.1.250 → 0.1.251

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.
@@ -106,17 +106,17 @@ ${h.url}`).join(`
106
106
  `),maxHeight:"max-h-80",children:o.jsx("div",{className:"divide-y divide-border/50",children:C.map((h,k)=>o.jsxs("div",{className:"px-3 py-2 hover:bg-muted/20",children:[o.jsxs("a",{href:h.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:[h.title,o.jsx(vt,{className:"h-3 w-3 flex-shrink-0"})]}),o.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:h.snippet}),o.jsx("p",{className:"text-xs text-muted-foreground/60 truncate mt-0.5",children:h.url})]},`${h.url}-${k}`))})}),C.length===0&&o.jsx(rt,{title:"results",maxHeight:"",children:o.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No results found"})})]})]});const f=u&&u.length>50?`${u.slice(0,50)}...`:u;return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:"web fetch",isExpanded:t,onToggle:s,isError:a,colorVariant:"purple",canExpand:!0,children:[f&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 truncate min-w-0",title:u,children:f})]}),o.jsx(we,{}),o.jsx(Ut,{children:i})]}),t&&a&&g&&o.jsx(Ht,{error:g,stack:Q,showStack:!0}),t&&!a&&o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[o.jsx(rt,{title:"url",icon:o.jsx(eC,{className:"h-3 w-3"}),copyText:u,maxHeight:"",children:o.jsx("div",{className:"px-3 py-2 font-mono text-xs bg-muted/10 break-all",children:o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:u})})}),I.content&&o.jsx(rt,{title:"content",copyText:I.content,maxHeight:"max-h-80",children:o.jsx("div",{className:"px-3 py-2 text-xs text-foreground/80 whitespace-pre-wrap break-words",children:I.content})}),!I.content&&o.jsx(rt,{title:"content",maxHeight:"",children:o.jsx("div",{className:"px-3 py-2 text-muted-foreground/60 italic",children:"No content returned"})})]})]})}function Mf({contentJson:A,debug:e,sessionId:t,onRetry:s,onCompact:n}){const[r,i]=x.useState(!1),a=A.type==="balance_low"||A.errorType==="balance_low",g=A.type==="context_length_exceeded"||A.errorType==="context_length_exceeded";A.isRetryable;let Q,l,C,I=!1;A.error&&typeof A.error=="object"?(Q=A.error,Q.message&&typeof Q.message=="string"&&(l=Q.message),Q.type&&typeof Q.type=="string"&&(C=Q.type)):A.details&&typeof A.details=="object"?(Q=A.details,A.message&&typeof A.message=="string"&&(l=A.message),A.type&&typeof A.type=="string"&&(C=A.type),A.isAborted===!0&&(I=!0)):(A.message&&typeof A.message=="string"&&(l=A.message),A.type&&typeof A.type=="string"&&(C=A.type),A.isAborted===!0&&(I=!0),Q=A);let c;if(Q?.responseBody&&typeof Q.responseBody=="string")try{const J=JSON.parse(Q.responseBody);J.error&&typeof J.error=="object"&&(c={type:typeof J.error.type=="string"?J.error.type:void 0,message:typeof J.error.message=="string"?J.error.message:void 0,code:typeof J.error.code=="string"?J.error.code:void 0})}catch{}const u=String(Q?.url??"").includes("githubcopilot.com")||String(l??"").toLowerCase().includes("copilot model"),f=String(c?.message??l??"").toLowerCase(),h=u&&(c?.code==="model_not_supported"||f.includes("model is not supported")||f.includes("not available for this account/organization token"));if(c?.message?.toLowerCase().includes("not accessible via the /chat/completions")&&String(Q?.url??"").includes("githubcopilot.com")){const J=Q?.requestBodyValues?.model;return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Model requires Responses API"}),o.jsx("p",{className:"text-sm text-foreground",children:J?o.jsxs(o.Fragment,{children:[o.jsx("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:String(J)})," ","must be sent through the Responses API. If this persists, refresh auth and retry."]}):"This model must be sent through the Responses API. If this persists, refresh auth and retry."}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Codex models (gpt-5.1-codex, gpt-5.2-codex, etc.) require the Responses API. Try a chat-compatible model like gpt-5, claude-sonnet-4, or gpt-4.1."})]}),s&&o.jsx("div",{className:"pt-1",children:o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[o.jsx(Vt,{className:"w-3 h-3"}),"Retry"]})})]})}if(h){const J=Q?.requestBodyValues?.model;return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Model not available"}),o.jsx("p",{className:"text-sm text-foreground",children:J?o.jsxs(o.Fragment,{children:[o.jsx("code",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:String(J)})," ","is not available for the current Copilot token."]}):"The requested model is not available for the current Copilot token."}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Your org may restrict third-party OAuth apps, so OAuth and GH tokens can see different model entitlements."}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Check model settings at"," ",o.jsx("a",{href:"https://github.com/settings/copilot",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground transition-colors",onClick:V=>{V.preventDefault(),ho("https://github.com/settings/copilot")},children:"github.com/settings/copilot"}),", then reconnect Copilot with OAuth or token mode."]})]}),s&&o.jsx("div",{className:"pt-1",children:o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[o.jsx(Vt,{className:"w-3 h-3"}),"Retry"]})})]})}if(a)return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(fr,{className:"h-4 w-4 text-amber-500"}),o.jsx("span",{className:"font-medium text-foreground",children:"Balance too low"})]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Top up in the modal, then retry your request."}),s&&o.jsx("div",{className:"pt-1",children:o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[o.jsx(Vt,{className:"w-3 h-3"}),"Retry"]})})]});if(g)return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Fg,{className:"h-4 w-4 text-amber-500"}),o.jsx("span",{className:"font-medium text-foreground",children:"Context window exceeded"})]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"The conversation is too long for the model. Compact to reduce context size, then retry."}),o.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[n&&o.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[o.jsx(Fg,{className:"w-3 h-3"}),"Compact"]}),s&&o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-border text-foreground hover:bg-muted transition-colors",children:[o.jsx(Vt,{className:"w-3 h-3"}),"Retry"]})]})]});const v=J=>{if(J==null)return o.jsx("span",{className:"text-muted-foreground",children:"null"});if(typeof J=="boolean")return o.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:String(J)});if(typeof J=="number")return o.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:J});if(typeof J=="string"){if(J.startsWith("{")||J.startsWith("["))try{const V=JSON.parse(J);return o.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:o.jsx("code",{children:JSON.stringify(V,null,2)})})}catch{}return o.jsx("span",{className:"text-foreground",children:J})}return typeof J=="object"?o.jsx("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto",children:o.jsx("code",{children:JSON.stringify(J,null,2)})}):o.jsx("span",{className:"text-foreground",children:String(J)})},D=["name","statusCode","url","model","isRetryable","cause"],O=new Set;return o.jsxs("div",{className:"space-y-2 text-sm",children:[I&&o.jsx("div",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"Request aborted"}),c?.message&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"API Error:"}),o.jsx("div",{className:"text-foreground",children:c.message}),c.type&&o.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",c.type]})]}),!c?.message&&l&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),o.jsx("div",{className:"text-foreground",children:l}),C&&o.jsxs("div",{className:"text-xs text-muted-foreground",children:["Type: ",C]})]}),s&&o.jsx("div",{className:"pt-2",children:o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[o.jsx(Vt,{className:"w-3 h-3"}),"Retry"]})}),Q&&o.jsx("div",{className:"space-y-1.5",children:D.map(J=>{const V=Q[J];return V==null?null:(O.add(J),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("span",{className:"font-medium text-muted-foreground min-w-[100px]",children:[J,":"]}),v(V)]},J))})}),Q&&o.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[o.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[r?o.jsx(_t,{className:"h-3 w-3"}):o.jsx(ct,{className:"h-3 w-3"}),r?"Hide":"View"," Raw Error Details"]}),r&&o.jsx("div",{className:"mt-2",children:o.jsx("pre",{className:"p-3 bg-muted/50 rounded text-xs overflow-x-auto max-h-96 overflow-y-auto",children:o.jsx("code",{children:JSON.stringify(Q,null,2)})})})]}),e&&o.jsxs("details",{className:"mt-4 text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Debug Info"}),o.jsx("pre",{className:"mt-2 p-2 bg-muted/30 rounded overflow-x-auto",children:o.jsx("code",{children:JSON.stringify({contentJson:A,errorDetails:Q,apiError:c},null,2)})})]})]})}function Vl(A){return A?new Date(A).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}function li({session:A,onNavigate:e,compact:t}){return t?o.jsxs("button",{type:"button",onClick:()=>e?.(A.id),disabled:!e,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:[o.jsx("span",{className:"truncate text-foreground",children:A.title||"Untitled"}),e&&o.jsx(vt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):o.jsxs("button",{type:"button",onClick:()=>e?.(A.id),disabled:!e,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-medium text-sm truncate text-foreground",children:A.title||"Untitled"}),e&&o.jsx(vt,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[A.agent&&o.jsx("span",{className:"text-violet-600 dark:text-violet-400",children:A.agent}),A.agent&&A.provider&&o.jsx("span",{children:"·"}),A.provider&&o.jsx("span",{children:A.provider}),A.messageCount!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsxs("span",{children:[A.messageCount," msgs"]})]}),A.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{children:Vl(A.createdAt)})]})]})]})}function hQ({message:A,onNavigate:e,compact:t}){const s="sessionId"in A?A.sessionId:"",n="sessionTitle"in A?A.sessionTitle:null,r="content"in A?A.content:"contentPreview"in A?A.contentPreview:"matchedContent"in A?A.matchedContent:"";return t?o.jsxs("button",{type:"button",onClick:()=>e?.(s),disabled:!e||!s,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:[o.jsx("span",{className:"truncate text-foreground/80",children:r?.slice(0,50)||n||s.slice(0,8)}),e&&s&&o.jsx(vt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}):o.jsxs("button",{type:"button",onClick:()=>e?.(s),disabled:!e||!s,className:"w-full text-left p-2 rounded-md border border-border hover:bg-muted/50 transition-colors group",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:n||s.slice(0,8)}),e&&s&&o.jsx(vt,{className:"w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]}),r&&o.jsx("div",{className:"text-xs text-foreground/80 mt-1 line-clamp-2",children:r}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[A.role&&o.jsx("span",{className:"capitalize",children:A.role}),A.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{children:Vl(A.createdAt)})]})]})]})}function pQ({args:A,toolName:e}){const t=(i,a)=>a==null||typeof a=="boolean"&&!a||Array.isArray(a)&&a.length===0?null:o.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[o.jsxs("span",{className:"opacity-60",children:[i,":"]}),o.jsx("span",{className:"text-foreground/80",children:typeof a=="string"?a:JSON.stringify(a)})]},i),r=({query_sessions:["agent","sessionType","startDate","endDate"],query_messages:["sessionId","role","search","toolName"],search_history:["query"],get_session_context:["sessionId","includeMessages"],get_parent_session:["includeMessages"]}[e]||Object.keys(A).slice(0,3)).filter(i=>A[i]!==void 0&&A[i]!==null).map(i=>t(i,A[i])).filter(Boolean);return r.length===0?null:o.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-xs mb-2 pb-2 border-b border-border",children:[o.jsx(oC,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),r]})}function bf({toolName:A,contentJson:e,toolDurationMs:t,isExpanded:s,onToggle:n,onNavigateToSession:r,compact:i}){const a=e.result||{},g=e.args||{},Q=typeof a=="object"&&"ok"in a&&a.ok===!1,l=Q&&"error"in a&&typeof a.error=="string"?a.error:null,C=bt(t);if(A==="present_action"){const u=a.links||[],f=a.summary,h=a.title;return u.length===0&&!f?null:o.jsxs("div",{className:"mt-2 mb-1",children:[h&&o.jsx("div",{className:"text-sm font-medium text-foreground mb-1.5",children:h}),f&&o.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1.5",children:[o.jsx(tC,{className:"w-3.5 h-3.5 text-teal-500"}),o.jsx("span",{children:f})]}),u.length>0&&o.jsx("div",{className:"space-y-1.5",children:u.map(k=>o.jsxs("button",{type:"button",onClick:()=>r?.(k.sessionId),disabled:!r,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:[o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-sm text-foreground",children:k.title}),k.description&&o.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:k.description})]}),r&&o.jsx(vt,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 opacity-60 group-hover:opacity-100 transition-opacity flex-shrink-0"})]},k.sessionId))})]})}const I=()=>{switch(A){case"query_sessions":{const u=a.sessions||[],f=a.total;return`${u.length} session${u.length!==1?"s":""}${f?` of ${f}`:""}`}case"query_messages":{const u=a.messages||[];return`${u.length} message${u.length!==1?"s":""}`}case"search_history":{const u=g.query,f=a.results||[],h=u?`"${u.slice(0,20)}${u.length>20?"…":""}"`:"";return`${f.length} result${f.length!==1?"s":""}${h?` for ${h}`:""}`}case"get_session_context":return a.session?.title||g.sessionId?.slice(0,8)||"session";case"get_parent_session":return a.parentSession?.title||"parent session";default:return A}},c=()=>{const u=Object.keys(g).length>0&&!i;switch(A){case"query_sessions":{const f=a.sessions||[];return o.jsxs("div",{className:i?"p-1":"p-2",children:[u&&o.jsx(pQ,{args:g,toolName:A}),f.length===0?o.jsx("div",{className:"text-xs text-muted-foreground",children:"No sessions found"}):o.jsxs("div",{className:i?"space-y-0.5":"space-y-2",children:[f.slice(0,i?5:10).map(h=>o.jsx(li,{session:h,onNavigate:r,compact:i},h.id)),f.length>(i?5:10)&&o.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",f.length-(i?5:10)," more"]})]})]})}case"query_messages":{const f=a.messages||[];return o.jsxs("div",{className:i?"p-1":"p-2",children:[u&&o.jsx(pQ,{args:g,toolName:A}),f.length===0?o.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages found"}):o.jsxs("div",{className:i?"space-y-0.5":"space-y-2",children:[f.slice(0,i?5:10).map(h=>o.jsx(hQ,{message:h,onNavigate:r,compact:i},h.id)),f.length>(i?5:10)&&o.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",f.length-(i?5:10)," more"]})]})]})}case"search_history":{const f=a.results||[],h=g.query;return o.jsxs("div",{className:i?"p-1":"p-2",children:[h&&!i&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs mb-2 pb-2 border-b border-border",children:[o.jsx(Ds,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),o.jsx("span",{className:"text-muted-foreground",children:"Query:"}),o.jsxs("span",{className:"text-foreground font-medium",children:['"',h,'"']})]}),f.length===0?o.jsx("div",{className:"text-xs text-muted-foreground",children:"No results found"}):o.jsxs("div",{className:i?"space-y-0.5":"space-y-2",children:[f.slice(0,i?5:10).map((k,v)=>o.jsx(hQ,{message:k,onNavigate:r,compact:i},`${k.sessionId}-${k.messageId}-${v}`)),f.length>(i?5:10)&&o.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["+",f.length-(i?5:10)," more"]})]})]})}case"get_session_context":case"get_parent_session":{const f=A==="get_parent_session"?a.parentSession:a.session,h=a.stats,k=a.messages;return f?i?o.jsx("div",{className:"p-1",children:o.jsx(li,{session:f,onNavigate:r,compact:!0})}):o.jsxs("div",{className:"p-2 space-y-3",children:[o.jsx(li,{session:f,onNavigate:r}),h&&o.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[h.totalMessages!==void 0&&o.jsxs("span",{children:[h.totalMessages," messages"]}),h.totalToolCalls!==void 0&&o.jsxs("span",{children:[h.totalToolCalls," tool calls"]})]}),k&&k.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Recent messages:"}),o.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:k.slice(0,5).map(v=>o.jsxs("div",{className:"text-xs p-1.5 rounded bg-muted/30",children:[o.jsxs("span",{className:"font-medium capitalize text-foreground/70",children:[v.role,":"," "]}),o.jsx("span",{className:"text-foreground/60 line-clamp-2",children:v.content})]},v.id))})]})]}):o.jsx("div",{className:`text-xs text-muted-foreground ${i?"p-1":"p-2"}`,children:"Session not found"})}default:return o.jsx("pre",{className:"text-xs p-2 overflow-auto max-h-48",children:JSON.stringify(a,null,2)})}};return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:A,isExpanded:s,onToggle:n,isError:Q,colorVariant:"default",canExpand:!0,children:[!i&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 min-w-0 truncate",children:I()})]}),!Q&&!i&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx($s,{children:"Done"}),o.jsx(we,{}),o.jsx(Ut,{children:C})]}),Q&&!i&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx(Fr,{children:"Error"}),o.jsxs(Ut,{children:["· ",C]})]})]}),s&&Q&&l&&o.jsx(Ht,{error:l}),s&&!Q&&o.jsx("div",{className:i?"mt-1 ml-3":"mt-2 ml-5",children:i?o.jsx("div",{className:"border border-border rounded-md overflow-hidden max-h-48 overflow-y-auto",children:c()}):o.jsx(rt,{title:"results",maxHeight:"max-h-96",children:c()})})]})}const Ff='"JetBrainsMono NFM", monospace';let fQ=!1,Yr=null;function Gf(){return fQ?Promise.resolve():Yr||(Yr=vf().then(()=>{fQ=!0}),Yr)}async function vf(){if(typeof document>"u"||!("FontFace"in window))return;const e=[{file:"JetBrainsMonoNerdFontMono-Regular.woff2",weight:"400",style:"normal"},{file:"JetBrainsMonoNerdFontMono-Bold.woff2",weight:"700",style:"normal"},{file:"JetBrainsMonoNerdFontMono-Italic.woff2",weight:"400",style:"italic"},{file:"JetBrainsMonoNerdFontMono-BoldItalic.woff2",weight:"700",style:"italic"}].map(async t=>{try{const s=new URL(Object.assign({"../assets/fonts/JetBrainsMonoNerdFontMono-Bold.woff2":dl,"../assets/fonts/JetBrainsMonoNerdFontMono-BoldItalic.woff2":hl,"../assets/fonts/JetBrainsMonoNerdFontMono-Italic.woff2":pl,"../assets/fonts/JetBrainsMonoNerdFontMono-Regular.woff2":fl})[`../assets/fonts/${t.file}`],import.meta.url).href,r=await new FontFace("JetBrainsMono NFM",`url("${s}") format("woff2")`,{weight:t.weight,style:t.style}).load();document.fonts.add(r)}catch{}});await Promise.allSettled(e)}const Sf=/[\x1B\x9B][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nq-uy=><~]/g,Uf=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g;function Rf(A){return A.replace(Sf,"").replace(Uf,"").replace(/\\n/g,`
107
107
  `).replace(/\r\n/g,`
108
108
  `).replace(/\r/g,`
109
- `)}function Kf({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const[,r]=x.useState(!1);x.useEffect(()=>{Gf().then(()=>r(!0))},[]);const i=A.result||{},a=A.args||{},g=String(a.operation||a.command||""),Q=typeof i=="object"&&"ok"in i&&i.ok===!1,l=Q&&"error"in i&&typeof i.error=="string"?i.error:null,C=Q&&"stack"in i&&typeof i.stack=="string"?i.stack:void 0,I=bt(e),c=String(i.terminalId||a.terminalId||""),u=c.length>12?`${c.slice(0,12)}…`:c,f=String(i.purpose||a.purpose||""),h=String(i.command||a.command||""),k=()=>{const X=i.pid?`PID ${i.pid}`:"";return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-1 text-xs",children:[h&&o.jsxs("div",{className:"flex items-center gap-2 text-foreground/70",children:[o.jsx(to,{className:"h-3 w-3"}),o.jsx("code",{className:"font-mono",children:h})]}),f&&o.jsx("div",{className:"text-muted-foreground/70",children:f}),o.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground/60",children:[u&&o.jsx("span",{className:"font-mono",children:u}),X&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{children:X})]})]})]})},v=()=>{const X=String(i.text||i.output||""),K=Rf(X),W=String(i.status||""),T=i.exitCode,L=typeof i.lines=="number"?i.lines:0;return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/70",children:[u&&o.jsx("span",{className:"font-mono",children:u}),o.jsx("span",{children:"·"}),o.jsxs("span",{children:[L," lines"]}),o.jsx("span",{children:"·"}),o.jsxs("span",{className:W==="running"?"text-emerald-600 dark:text-emerald-400":"",children:[W,W==="exited"&&T!==void 0?` (${T})`:""]})]}),K.trim()&&o.jsx(rt,{title:"output",copyText:K,maxHeight:"max-h-[30rem]",children:o.jsx("pre",{className:"px-3 py-2 text-xs text-foreground/85 whitespace-pre-wrap break-words overflow-x-auto",style:{fontFamily:Ff},children:K})})]})},D=()=>{const X=Array.isArray(i.terminals)?i.terminals:[],K=typeof i.count=="number"?i.count:X.length;return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-1 text-xs",children:[o.jsxs("div",{className:"text-muted-foreground/70",children:[K," terminal",K!==1?"s":""]}),X.slice(0,8).map((W,T)=>o.jsxs("div",{className:"flex items-center gap-2 text-foreground/70 font-mono",children:[o.jsx("span",{className:`h-2 w-2 rounded-full ${W.status==="running"?"bg-emerald-500":"bg-muted-foreground/40"}`}),o.jsx("span",{className:"truncate max-w-[100px]",children:String(W.id||"").slice(0,12)}),o.jsx("span",{className:"text-muted-foreground/60 truncate",children:String(W.purpose||"")})]},String(W.id||T)))]})},O=()=>{const X=String(a.input||"");return X?o.jsx("div",{className:"mt-2 ml-5 text-xs",children:o.jsx("code",{className:"font-mono text-foreground/70 whitespace-pre-wrap",children:X})}):null},V=`terminal ${g||"terminal"}`,eA=!Q&&(g==="start"||g==="read"||g==="list"||g==="write"&&(a.input||i.message));return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:V,isExpanded:t,onToggle:s,isError:!!Q,colorVariant:"amber",canExpand:!!eA||!!Q,children:[!n&&u&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 font-mono text-[11px]",children:u})]}),!n&&f&&!u&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 text-[11px] truncate max-w-xs",children:f})]}),!Q&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx($s,{children:"ok"}),o.jsx(we,{}),o.jsx(Ut,{children:I})]}),Q&&!n&&o.jsxs(Ut,{children:["· ",I]})]}),t&&Q&&l&&o.jsx(Ht,{error:l,stack:C,showStack:!0}),t&&!Q&&g==="start"&&k(),t&&!Q&&g==="read"&&v(),t&&!Q&&g==="list"&&D(),t&&!Q&&g==="write"&&O()]})}function Jf(A){const e=A.indexOf("__");return e===-1?{server:"",tool:A}:{server:A.slice(0,e),tool:A.slice(e+2)}}function Lf(A){return A.includes("__")}function jf({toolName:A,contentJson:e,toolDurationMs:t,isExpanded:s,onToggle:n,compact:r}){const{server:i,tool:a}=Jf(A),g=e.result||{},Q=e.args||{},l=bt(t),C=document?.documentElement.classList.contains("dark")?Eo:Co,I=typeof g=="object"&&"ok"in g&&g.ok===!1,c=I&&"error"in g&&typeof g.error=="string"?g.error:typeof e.error=="string"?e.error:null,u=I&&"stack"in g&&typeof g.stack=="string"?g.stack:void 0,f=typeof g.result=="string"?g.result:g.result&&typeof g.result=="object"?JSON.stringify(g.result,null,2):null,h=Array.isArray(g.images)?g.images:[],k=h.length>0,v=!I&&(f||Object.keys(g).length>0||k),D=f||JSON.stringify(g,null,2),O=D.startsWith("{")||D.startsWith("["),J=Object.entries(Q).slice(0,3).map(([eA,X])=>{const K=typeof X=="string"?X.length>30?`${X.slice(0,27)}…`:X:JSON.stringify(X);return`${eA}=${K}`}).join(" "),V=i?`${i} › ${a}`:a;return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:V,isExpanded:s,onToggle:n,isError:!!I,colorVariant:"purple",canExpand:!!v||!!I||k,children:[!r&&J&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/60 truncate max-w-xs font-mono text-[11px]",children:J})]}),!I&&!r&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx($s,{children:"ok"}),o.jsx(we,{}),o.jsx(Ut,{children:l})]}),I&&!r&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx(Fr,{children:"error"}),o.jsx(we,{}),o.jsx(Ut,{children:l})]})]}),s&&I&&c&&o.jsx(Ht,{error:c,stack:u,showStack:!0}),s&&!I&&v&&o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[k&&o.jsx(zl,{images:h}),D&&!k&&o.jsx(rt,{title:"result",icon:o.jsx(wr,{className:"h-3 w-3"}),copyText:D,maxHeight:"max-h-[30rem]",children:o.jsx(qt,{language:O?"json":"text",style:C,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:D})})]})]})}function Tf({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const r=A.result||{},i=A.args||{},a=bt(e),g=Array.isArray(i.tools)?i.tools:[],Q=Array.isArray(r.loaded)?r.loaded:[],l=Array.isArray(r.notFound)?r.notFound:[],C=r.ok===!1,I=Q.length>0||l.length>0;return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:"load_mcp_tools",isExpanded:t,onToggle:s,isError:C,colorVariant:"purple",canExpand:I,children:[!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsxs("span",{className:"text-foreground/60 font-mono text-[11px]",children:[g.length," tool",g.length!==1?"s":""]})]}),!C&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsxs($s,{children:[Q.length," loaded"]}),o.jsx(we,{}),o.jsx(Ut,{children:a})]}),C&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx(Fr,{children:"error"}),o.jsx(we,{}),o.jsx(Ut,{children:a})]})]}),t&&I&&o.jsxs("div",{className:"mt-1.5 ml-5 flex flex-col gap-1",children:[Q.map(c=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[o.jsx(Yt,{className:"h-3 w-3 text-green-500"}),o.jsx(wr,{className:"h-3 w-3 text-purple-400"}),o.jsx("span",{className:"font-mono text-foreground/70",children:c})]},c)),l.map(c=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[o.jsx(lt,{className:"h-3 w-3 text-red-400"}),o.jsx("span",{className:"font-mono text-foreground/40 line-through",children:c})]},c))]})]})}function Of({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const r=A.result||{},i=bt(e),a=typeof r=="object"&&"ok"in r&&r.ok===!1,g=a&&"error"in r&&typeof r.error=="string"?r.error:null,Q=r.name,l=r.description,C=r.content,I=r.scope,c=r.availableFiles,u=r.securityNotices,f=l?.startsWith("Sub-file:"),h=c?.length??0,k=u?.length??0,v=!!C||a;return o.jsxs("div",{className:"text-xs",children:[o.jsxs("button",{type:"button",onClick:()=>v&&s(),className:`flex items-center gap-2 transition-colors w-full min-w-0 ${a?"text-red-700 dark:text-red-300 hover:text-red-600 dark:hover:text-red-200":v?"text-violet-700 dark:text-violet-300 hover:text-violet-600 dark:hover:text-violet-200":"text-violet-700 dark:text-violet-300"}`,children:[v?o.jsx(ct,{className:`h-3 w-3 flex-shrink-0 transition-transform ${t?"rotate-90":""}`}):o.jsx("div",{className:"w-3 flex-shrink-0"}),a&&o.jsx(wo,{className:"h-3 w-3 flex-shrink-0 text-red-600 dark:text-red-400"}),f?o.jsx(ts,{className:"h-3 w-3 flex-shrink-0"}):o.jsx(LB,{className:"h-3 w-3 flex-shrink-0"}),o.jsxs("span",{className:"font-medium flex-shrink-0",children:["skill",a?" error":""]}),Q&&!n&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),o.jsx("span",{className:"text-foreground/70 truncate",children:f?l?.replace("Sub-file: ",""):Q})]}),I&&!n&&!f&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",I]}),h>0&&!n&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",h," file",h!==1?"s":""]}),k>0&&!n&&o.jsxs("span",{className:"text-amber-600 dark:text-amber-400 flex-shrink-0 flex items-center gap-0.5",children:["· ",o.jsx(Gg,{className:"h-3 w-3 inline"})," ",k]}),i&&!n&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",i]})]}),t&&a&&g&&o.jsx(Ht,{error:g}),t&&!a&&o.jsxs("div",{className:"mt-2 ml-5 space-y-2",children:[k>0&&u&&o.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-2.5 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-700 dark:text-amber-300 font-medium text-[11px]",children:[o.jsx(Gg,{className:"h-3 w-3"}),"Security Notice",k>1?"s":""]}),u.map((D,O)=>o.jsxs("div",{className:"text-amber-600 dark:text-amber-400 text-[11px] leading-snug",children:[o.jsx("span",{className:"font-mono bg-amber-100 dark:bg-amber-900/40 rounded px-1 py-0.5",children:D.type})," ",D.description]},`${D.type}-${D.line??O}`))]}),l&&!f&&o.jsx("p",{className:"text-muted-foreground italic",children:l}),C&&o.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:o.jsx("div",{className:"p-3 whitespace-pre-wrap font-mono text-xs leading-relaxed",children:C})}),h>0&&c&&o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"text-muted-foreground cursor-pointer hover:text-foreground/80 text-[11px] select-none",children:[h," available sub-file",h!==1?"s":""]}),o.jsx("div",{className:"mt-1.5 bg-card/40 border border-border rounded-lg p-2 space-y-0.5 max-h-48 overflow-y-auto",children:c.map(D=>o.jsxs("div",{className:"flex items-center justify-between gap-2 font-mono text-[11px]",children:[o.jsx("span",{className:"text-foreground/80 truncate",children:D.relativePath}),o.jsx("span",{className:"text-muted-foreground/60 flex-shrink-0 tabular-nums",children:qf(D.size)})]},D.relativePath))})]})]})]})}function qf(A){if(A<1024)return`${A}B`;const e=A/1024;return e<1024?`${e.toFixed(1)}KB`:`${(e/1024).toFixed(1)}MB`}function Yf({part:A}){const[e,t]=x.useState(!0),s=x.useRef(null),n=x.useRef(!1);let r="";const i=A.contentJson||A.content;return i&&typeof i=="object"&&"text"in i?r=String(i.text):typeof i=="string"&&(r=i),x.useEffect(()=>{s.current&&e&&!A.completedAt&&!n.current&&(s.current.scrollTop=s.current.scrollHeight)},[r,e,A.completedAt]),!r||!r.trim()?null:o.jsxs("div",{className:"w-full",children:[o.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full",children:[e?o.jsx(_t,{className:"h-3 w-3 flex-shrink-0"}):o.jsx(ct,{className:"h-3 w-3 flex-shrink-0"}),o.jsx("span",{className:"font-medium",children:"Reasoning"}),!A.completedAt&&o.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"thinking..."})]}),e&&o.jsx("div",{ref:s,className:"mt-2 p-3 bg-muted/30 rounded-md border border-border max-h-48 overflow-y-auto",role:"log",onMouseEnter:()=>{n.current=!0},onMouseLeave:()=>{n.current=!1},children:o.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:r})})]})}const Hf={Read:"read",Edit:"edit",MultiEdit:"multiedit",Write:"write",Ls:"ls",Tree:"tree",Cd:"cd",Pwd:"pwd",Glob:"glob",Grep:"ripgrep",Shell:"shell",Bash:"shell",bash:"shell",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",LoadMcpTools:"load_mcp_tools",Skill:"skill"};function Pf(A){return Hf[A]??A}const Wf=new Set(["shell","edit","multiedit","write","apply_patch","terminal"]);function la({toolName:A,contentJson:e,toolDurationMs:t,debug:s,onNavigateToSession:n,compact:r,sessionId:i,onRetry:a,onCompact:g}){const[Q,l]=x.useState(!1),C=Pf(A),I=r&&!Wf.has(C),u={contentJson:e,toolDurationMs:t??void 0,isExpanded:Q,onToggle:()=>l(!Q),compact:I};if(s)return o.jsx(Df,{...u,toolName:A});switch(C){case"read":return o.jsx(gf,{...u});case"edit":case"multiedit":return o.jsx(dQ,{...u,toolName:C});case"write":return o.jsx(Qf,{...u});case"shell":return o.jsx(cf,{...u});case"git_status":return o.jsx(uf,{...u});case"git_diff":return o.jsx(df,{...u});case"git_commit":return o.jsx(hf,{...u});case"apply_patch":return o.jsx(dQ,{...u});case"terminal":return o.jsx(Kf,{...u});case"ls":return o.jsx(pf,{...u});case"tree":return o.jsx(ff,{...u});case"ripgrep":case"grep":case"glob":return o.jsx(mf,{...u});case"websearch":return o.jsx(kf,{...u});case"finish":return o.jsx(wf,{...u});case"update_todos":case"update_plan":return o.jsx(yf,{...u});case"progress_update":return o.jsx(Nf,{...u});case"load_mcp_tools":return o.jsx(Tf,{...u,toolName:A});case"skill":return o.jsx(Of,{...u});case"error":return o.jsx(Mf,{...u,sessionId:i,onRetry:a,onCompact:g});case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":case"present_action":return o.jsx(bf,{toolName:A,...u,onNavigateToSession:n});default:return Lf(C)?o.jsx(jf,{...u,toolName:A}):o.jsx(xf,{...u,toolName:A})}}function ca(A){const e=A.contentJson;if(e&&typeof e=="object")return e;try{if(A.content){const t=JSON.parse(A.content);if(t&&typeof t=="object"&&!Array.isArray(t))return t}}catch{}return null}function zf(A){const e=ca(A);if(!e)return;const t=e.args;if(t&&typeof t=="object"&&!Array.isArray(t))return t}function Vf(A){if(!A)return null;const e=["cmd","command","script","input"];for(const t of e){const s=A[t];if(typeof s=="string"&&s.trim().length>0)return s.trim()}return null}function Zf(A){return A.match(/^\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+)$/m)?.[1]?.trim()||null}function Zl(A){return A==="bash"?"shell":A}function Ea(A){return Zl(A)==="shell"}function _f(A,e){if(!e)return null;const t=[{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:s}of t){const n=e[s];if(typeof n=="string"&&n.trim().length>0)return{key:s,value:n.trim()}}if(Ea(A)){const s=e.command;if(typeof s=="string"&&s.trim().length>0)return{key:"command",value:s.trim()}}if(A==="apply_patch"){const s=e.patch;if(typeof s=="string"&&s.trim().length>0){const n=Zf(s);if(n)return{key:"patch",value:n}}}return null}function Xf(A,e){if(!A)return null;const t=[];for(const[n,r]of Object.entries(A))if(!(e&&n===e)){if(typeof r=="string"||typeof r=="number"){const i=`${n}=${String(r)}`;t.push(i)}if(t.length>=3)break}if(!t.length)return null;const s=t.join(" ");return s.length>120?`${s.slice(0,117)}…`:s}const mQ=x.memo(function({part:e,showLine:t,isLastToolCall:s,isLastProgressUpdate:n,onNavigateToSession:r,compact:i,pendingApproval:a,onApprove:g,onReject:Q,sessionId:l,onRetry:C,onCompact:I}){if(e.type==="tool_call"&&((e.toolName||"")==="progress_update"||!s&&!a)||e.type==="tool_result"&&e.toolName==="progress_update"&&!n)return null;if(e.type==="text"){const D=e.contentJson||e.content;let O="";if(D&&typeof D=="object"&&"text"in D?O=String(D.text):typeof D=="string"&&(O=D),!O||!O.trim())return null}if(e.type==="reasoning"){const D=e.contentJson||e.content;let O="";if(D&&typeof D=="object"&&"text"in D?O=String(D.text):typeof D=="string"&&(O=D),!O||!O.trim())return null}const c=e.type==="tool_call"||e.type==="tool_result",u=["flex-1","min-w-0","max-w-full"];c||e.type==="reasoning"?u.push(i?"pt-0.5":"pt-1"):e.type==="error"?u.push("pt-0.5"):e.type==="text"?(u.push("pt-0"),u.push("-mt-0.5")):u.push("pt-0");const f=u.join(" "),h=()=>{if(e.type==="reasoning")return o.jsx(vn,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"});if(e.type==="tool_call")return o.jsx(Le,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(e.type==="error")return ca(e)?.isAborted===!0?o.jsx(sC,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):o.jsx(wo,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(e.type==="tool_result"){const D=e.toolName||"";return D==="read"?o.jsx(ts,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):D==="write"?o.jsx(Yo,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="ls"?o.jsx(rC,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):D==="tree"?o.jsx(Cr,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):Ea(D)?o.jsx(to,{className:"h-4 w-4 text-muted-foreground"}):D==="ripgrep"||D==="grep"||D==="glob"?o.jsx(Ds,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):D==="apply_patch"?o.jsx(Hi,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):D==="git_status"?o.jsx(ao,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):D==="git_diff"?o.jsx(Hi,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):D==="git_commit"?o.jsx(Cn,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="finish"?o.jsx(Yt,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="query_sessions"||D==="query_messages"||D==="search_history"||D==="get_session_context"||D==="get_parent_session"?o.jsx(nC,{className:"h-4 w-4 text-teal-600 dark:text-teal-300"}):D==="terminal"?o.jsx(to,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):D==="skill"?o.jsx(LB,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"}):D.includes("__")?o.jsx(wr,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):o.jsx(to,{className:"h-4 w-4 text-muted-foreground"})}return o.jsx(io,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},k=()=>{const D=e.toolName||"";let O;try{e.contentJson&&typeof e.contentJson=="object"?O=e.contentJson:typeof e.content=="string"?O=JSON.parse(e.content):O={}}catch{O={result:e.content}}return o.jsx(la,{toolName:D,contentJson:O,toolDurationMs:e.toolDurationMs,debug:!1,onNavigateToSession:r,compact:i})},v=()=>{if(e.type==="reasoning")return o.jsx(Yf,{part:e});if(e.type==="text"){let D="";const O=e.contentJson||e.content;return O&&typeof O=="object"&&"text"in O?D=String(O.text):typeof O=="string"?D=O:O&&(D=JSON.stringify(O,null,2)),o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"absolute -top-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:D,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})}),o.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-x-auto",children:o.jsx(ja,{remarkPlugins:[Ta],components:{a:({href:J,children:V,...eA})=>o.jsx("a",{href:J,target:"_blank",rel:"noopener noreferrer",onClick:X=>{window.self!==window.top&&J&&(X.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:J},"*"))},...eA,children:V}),pre:({children:J,...V})=>{const eA=(()=>{if(!J)return"";const X=Array.isArray(J)?J[0]:J;if(X&&typeof X=="object"&&"props"in X){const K=X.props;if(typeof K.children=="string")return K.children}return""})();return o.jsxs("div",{className:"relative group/code my-3",children:[o.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover/code:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:eA,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"sm"})}),o.jsx("pre",{...V,className:"overflow-x-auto",children:J})]})},table:({children:J,...V})=>o.jsx("div",{className:"overflow-x-auto max-w-full min-w-0 my-3",children:o.jsx("table",{...V,children:J})})},children:D})}),D.length>500&&o.jsx("div",{className:"absolute -bottom-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:D,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})})]})}if(e.type==="error"){let D;try{e.contentJson&&typeof e.contentJson=="object"?D=e.contentJson:typeof e.content=="string"?D=JSON.parse(e.content):D={}}catch{D={message:e.content||"Unknown error"}}return o.jsx(la,{toolName:"error",contentJson:D,toolDurationMs:e.toolDurationMs,debug:!1,compact:i,sessionId:l,onRetry:C,onCompact:I})}if(e.type==="tool_call"){const D=ca(e),O=e.toolName||(typeof D?.name=="string"?D.name:"tool"),J=Zl(O),V=J.includes("__")?J.replace("__"," › "):J.replace(/_/g," "),eA=zf(e),X=a?.args,K=eA||X,W=_f(J,K),T=Xf(K,W?.key),L=Ea(J)?Vf(K):null,w=[];if(L?w.push({key:"cmd",node:o.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:L})}):W&&w.push({key:"primary",node:o.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:W.value})}),T&&w.push({key:"args",node:o.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:T})}),a&&a.callId===e.toolCallId&&g&&Q)return o.jsx(rf,{toolName:O,args:K,pendingApproval:a,onApprove:g,onReject:Q});w.length===0&&w.push({key:"running",node:o.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const d=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return e.ephemeral&&d.push("animate-pulse"),o.jsxs("div",{className:d.join(" "),children:[o.jsx("span",{className:"font-medium text-foreground",children:V}),w.map(N=>o.jsxs(x.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/65",children:"·"}),N.node]},N.key))]})}return e.type==="tool_result"?k():null};return o.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[o.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:h()}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:f,children:v()})]})},(A,e)=>A.part.id===e.part.id&&A.part.content===e.part.content&&A.part.contentJson===e.part.contentJson&&A.part.ephemeral===e.part.ephemeral&&A.part.completedAt===e.part.completedAt&&A.showLine===e.showLine&&A.isLastToolCall===e.isLastToolCall&&A.isLastProgressUpdate===e.isLastProgressUpdate&&A.compact===e.compact&&A.onNavigateToSession===e.onNavigateToSession&&A.pendingApproval?.callId===e.pendingApproval?.callId&&A.onApprove===e.onApprove&&A.onReject===e.onReject),_l=new Set(["read","ls","tree","ripgrep","grep","glob","websearch","skill","query_sessions","query_messages","search_history","get_session_context","get_parent_session"]);function ng(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{if(A.content){const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}}catch{}return null}function $f(A){const t=ng(A)?.args;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Am(A){const t=ng(A)?.result;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function gs(A,e=56){return A.length>e?`${A.slice(0,e-1)}…`:A}function em(A){const t=ng(A)?.text;return typeof t=="string"&&t.trim()?t.trim():typeof A.content=="string"?A.content.trim():""}function tm(A){return A.split(`
109
+ `)}function Kf({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const[,r]=x.useState(!1);x.useEffect(()=>{Gf().then(()=>r(!0))},[]);const i=A.result||{},a=A.args||{},g=String(a.operation||a.command||""),Q=typeof i=="object"&&"ok"in i&&i.ok===!1,l=Q&&"error"in i&&typeof i.error=="string"?i.error:null,C=Q&&"stack"in i&&typeof i.stack=="string"?i.stack:void 0,I=bt(e),c=String(i.terminalId||a.terminalId||""),u=c.length>12?`${c.slice(0,12)}…`:c,f=String(i.purpose||a.purpose||""),h=String(i.command||a.command||""),k=()=>{const X=i.pid?`PID ${i.pid}`:"";return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-1 text-xs",children:[h&&o.jsxs("div",{className:"flex items-center gap-2 text-foreground/70",children:[o.jsx(to,{className:"h-3 w-3"}),o.jsx("code",{className:"font-mono",children:h})]}),f&&o.jsx("div",{className:"text-muted-foreground/70",children:f}),o.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground/60",children:[u&&o.jsx("span",{className:"font-mono",children:u}),X&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{children:X})]})]})]})},v=()=>{const X=String(i.text||i.output||""),K=Rf(X),W=String(i.status||""),T=i.exitCode,L=typeof i.lines=="number"?i.lines:0;return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/70",children:[u&&o.jsx("span",{className:"font-mono",children:u}),o.jsx("span",{children:"·"}),o.jsxs("span",{children:[L," lines"]}),o.jsx("span",{children:"·"}),o.jsxs("span",{className:W==="running"?"text-emerald-600 dark:text-emerald-400":"",children:[W,W==="exited"&&T!==void 0?` (${T})`:""]})]}),K.trim()&&o.jsx(rt,{title:"output",copyText:K,maxHeight:"max-h-[30rem]",children:o.jsx("pre",{className:"px-3 py-2 text-xs text-foreground/85 whitespace-pre-wrap break-words overflow-x-auto",style:{fontFamily:Ff},children:K})})]})},D=()=>{const X=Array.isArray(i.terminals)?i.terminals:[],K=typeof i.count=="number"?i.count:X.length;return o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-1 text-xs",children:[o.jsxs("div",{className:"text-muted-foreground/70",children:[K," terminal",K!==1?"s":""]}),X.slice(0,8).map((W,T)=>o.jsxs("div",{className:"flex items-center gap-2 text-foreground/70 font-mono",children:[o.jsx("span",{className:`h-2 w-2 rounded-full ${W.status==="running"?"bg-emerald-500":"bg-muted-foreground/40"}`}),o.jsx("span",{className:"truncate max-w-[100px]",children:String(W.id||"").slice(0,12)}),o.jsx("span",{className:"text-muted-foreground/60 truncate",children:String(W.purpose||"")})]},String(W.id||T)))]})},O=()=>{const X=String(a.input||"");return X?o.jsx("div",{className:"mt-2 ml-5 text-xs",children:o.jsx("code",{className:"font-mono text-foreground/70 whitespace-pre-wrap",children:X})}):null},V=`terminal ${g||"terminal"}`,eA=!Q&&(g==="start"||g==="read"||g==="list"||g==="write"&&(a.input||i.message));return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:V,isExpanded:t,onToggle:s,isError:!!Q,colorVariant:"amber",canExpand:!!eA||!!Q,children:[!n&&u&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 font-mono text-[11px]",children:u})]}),!n&&f&&!u&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/70 text-[11px] truncate max-w-xs",children:f})]}),!Q&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx($s,{children:"ok"}),o.jsx(we,{}),o.jsx(Ut,{children:I})]}),Q&&!n&&o.jsxs(Ut,{children:["· ",I]})]}),t&&Q&&l&&o.jsx(Ht,{error:l,stack:C,showStack:!0}),t&&!Q&&g==="start"&&k(),t&&!Q&&g==="read"&&v(),t&&!Q&&g==="list"&&D(),t&&!Q&&g==="write"&&O()]})}function Jf(A){const e=A.indexOf("__");return e===-1?{server:"",tool:A}:{server:A.slice(0,e),tool:A.slice(e+2)}}function Lf(A){return A.includes("__")}function jf({toolName:A,contentJson:e,toolDurationMs:t,isExpanded:s,onToggle:n,compact:r}){const{server:i,tool:a}=Jf(A),g=e.result||{},Q=e.args||{},l=bt(t),C=document?.documentElement.classList.contains("dark")?Eo:Co,I=typeof g=="object"&&"ok"in g&&g.ok===!1,c=I&&"error"in g&&typeof g.error=="string"?g.error:typeof e.error=="string"?e.error:null,u=I&&"stack"in g&&typeof g.stack=="string"?g.stack:void 0,f=typeof g.result=="string"?g.result:g.result&&typeof g.result=="object"?JSON.stringify(g.result,null,2):null,h=Array.isArray(g.images)?g.images:[],k=h.length>0,v=!I&&(f||Object.keys(g).length>0||k),D=f||JSON.stringify(g,null,2),O=D.startsWith("{")||D.startsWith("["),J=Object.entries(Q).slice(0,3).map(([eA,X])=>{const K=typeof X=="string"?X.length>30?`${X.slice(0,27)}…`:X:JSON.stringify(X);return`${eA}=${K}`}).join(" "),V=i?`${i} › ${a}`:a;return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:V,isExpanded:s,onToggle:n,isError:!!I,colorVariant:"purple",canExpand:!!v||!!I||k,children:[!r&&J&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx("span",{className:"text-foreground/60 truncate max-w-xs font-mono text-[11px]",children:J})]}),!I&&!r&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx($s,{children:"ok"}),o.jsx(we,{}),o.jsx(Ut,{children:l})]}),I&&!r&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx(Fr,{children:"error"}),o.jsx(we,{}),o.jsx(Ut,{children:l})]})]}),s&&I&&c&&o.jsx(Ht,{error:c,stack:u,showStack:!0}),s&&!I&&v&&o.jsxs("div",{className:"mt-2 ml-5 flex flex-col gap-2 max-w-full",children:[k&&o.jsx(zl,{images:h}),D&&!k&&o.jsx(rt,{title:"result",icon:o.jsx(wr,{className:"h-3 w-3"}),copyText:D,maxHeight:"max-h-[30rem]",children:o.jsx(qt,{language:O?"json":"text",style:C,customStyle:{margin:0,padding:"0.75rem",fontSize:"0.75rem",lineHeight:"1.5",background:"transparent",maxWidth:"100%"},wrapLines:!0,wrapLongLines:!0,children:D})})]})]})}function Tf({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const r=A.result||{},i=A.args||{},a=bt(e),g=Array.isArray(i.tools)?i.tools:[],Q=Array.isArray(r.loaded)?r.loaded:[],l=Array.isArray(r.notFound)?r.notFound:[],C=r.ok===!1,I=Q.length>0||l.length>0;return o.jsxs("div",{className:"text-xs",children:[o.jsxs(co,{toolName:"load_mcp_tools",isExpanded:t,onToggle:s,isError:C,colorVariant:"purple",canExpand:I,children:[!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsxs("span",{className:"text-foreground/60 font-mono text-[11px]",children:[g.length," tool",g.length!==1?"s":""]})]}),!C&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsxs($s,{children:[Q.length," loaded"]}),o.jsx(we,{}),o.jsx(Ut,{children:a})]}),C&&!n&&o.jsxs(o.Fragment,{children:[o.jsx(we,{}),o.jsx(Fr,{children:"error"}),o.jsx(we,{}),o.jsx(Ut,{children:a})]})]}),t&&I&&o.jsxs("div",{className:"mt-1.5 ml-5 flex flex-col gap-1",children:[Q.map(c=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[o.jsx(Yt,{className:"h-3 w-3 text-green-500"}),o.jsx(wr,{className:"h-3 w-3 text-purple-400"}),o.jsx("span",{className:"font-mono text-foreground/70",children:c})]},c)),l.map(c=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[o.jsx(lt,{className:"h-3 w-3 text-red-400"}),o.jsx("span",{className:"font-mono text-foreground/40 line-through",children:c})]},c))]})]})}function Of({contentJson:A,toolDurationMs:e,isExpanded:t,onToggle:s,compact:n}){const r=A.result||{},i=bt(e),a=typeof r=="object"&&"ok"in r&&r.ok===!1,g=a&&"error"in r&&typeof r.error=="string"?r.error:null,Q=r.name,l=r.description,C=r.content,I=r.scope,c=r.availableFiles,u=r.securityNotices,f=l?.startsWith("Sub-file:"),h=c?.length??0,k=u?.length??0,v=!!C||a;return o.jsxs("div",{className:"text-xs",children:[o.jsxs("button",{type:"button",onClick:()=>v&&s(),className:`flex items-center gap-2 transition-colors w-full min-w-0 ${a?"text-red-700 dark:text-red-300 hover:text-red-600 dark:hover:text-red-200":v?"text-violet-700 dark:text-violet-300 hover:text-violet-600 dark:hover:text-violet-200":"text-violet-700 dark:text-violet-300"}`,children:[v?o.jsx(ct,{className:`h-3 w-3 flex-shrink-0 transition-transform ${t?"rotate-90":""}`}):o.jsx("div",{className:"w-3 flex-shrink-0"}),a&&o.jsx(wo,{className:"h-3 w-3 flex-shrink-0 text-red-600 dark:text-red-400"}),f?o.jsx(ts,{className:"h-3 w-3 flex-shrink-0"}):o.jsx(LB,{className:"h-3 w-3 flex-shrink-0"}),o.jsxs("span",{className:"font-medium flex-shrink-0",children:["skill",a?" error":""]}),Q&&!n&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/70 flex-shrink-0",children:"·"}),o.jsx("span",{className:"text-foreground/70 truncate",children:f?l?.replace("Sub-file: ",""):Q})]}),I&&!n&&!f&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",I]}),h>0&&!n&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",h," file",h!==1?"s":""]}),k>0&&!n&&o.jsxs("span",{className:"text-amber-600 dark:text-amber-400 flex-shrink-0 flex items-center gap-0.5",children:["· ",o.jsx(Gg,{className:"h-3 w-3 inline"})," ",k]}),i&&!n&&o.jsxs("span",{className:"text-muted-foreground/80 flex-shrink-0",children:["· ",i]})]}),t&&a&&g&&o.jsx(Ht,{error:g}),t&&!a&&o.jsxs("div",{className:"mt-2 ml-5 space-y-2",children:[k>0&&u&&o.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-2.5 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-700 dark:text-amber-300 font-medium text-[11px]",children:[o.jsx(Gg,{className:"h-3 w-3"}),"Security Notice",k>1?"s":""]}),u.map((D,O)=>o.jsxs("div",{className:"text-amber-600 dark:text-amber-400 text-[11px] leading-snug",children:[o.jsx("span",{className:"font-mono bg-amber-100 dark:bg-amber-900/40 rounded px-1 py-0.5",children:D.type})," ",D.description]},`${D.type}-${D.line??O}`))]}),l&&!f&&o.jsx("p",{className:"text-muted-foreground italic",children:l}),C&&o.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden max-h-96 overflow-y-auto max-w-full",children:o.jsx("div",{className:"p-3 whitespace-pre-wrap font-mono text-xs leading-relaxed",children:C})}),h>0&&c&&o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"text-muted-foreground cursor-pointer hover:text-foreground/80 text-[11px] select-none",children:[h," available sub-file",h!==1?"s":""]}),o.jsx("div",{className:"mt-1.5 bg-card/40 border border-border rounded-lg p-2 space-y-0.5 max-h-48 overflow-y-auto",children:c.map(D=>o.jsxs("div",{className:"flex items-center justify-between gap-2 font-mono text-[11px]",children:[o.jsx("span",{className:"text-foreground/80 truncate",children:D.relativePath}),o.jsx("span",{className:"text-muted-foreground/60 flex-shrink-0 tabular-nums",children:qf(D.size)})]},D.relativePath))})]})]})]})}function qf(A){if(A<1024)return`${A}B`;const e=A/1024;return e<1024?`${e.toFixed(1)}KB`:`${(e/1024).toFixed(1)}MB`}function Yf({part:A}){const[e,t]=x.useState(!0),s=x.useRef(null),n=x.useRef(!1);let r="";const i=A.contentJson||A.content;return i&&typeof i=="object"&&"text"in i?r=String(i.text):typeof i=="string"&&(r=i),x.useEffect(()=>{s.current&&e&&!A.completedAt&&!n.current&&(s.current.scrollTop=s.current.scrollHeight)},[r,e,A.completedAt]),!r||!r.trim()?null:o.jsxs("div",{className:"w-full",children:[o.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full",children:[e?o.jsx(_t,{className:"h-3 w-3 flex-shrink-0"}):o.jsx(ct,{className:"h-3 w-3 flex-shrink-0"}),o.jsx("span",{className:"font-medium",children:"Reasoning"}),!A.completedAt&&o.jsx("span",{className:"text-muted-foreground/60 animate-pulse",children:"thinking..."})]}),e&&o.jsx("div",{ref:s,className:"mt-2 p-3 bg-muted/30 rounded-md border border-border max-h-48 overflow-y-auto",role:"log",onMouseEnter:()=>{n.current=!0},onMouseLeave:()=>{n.current=!1},children:o.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:r})})]})}const Hf={Read:"read",Edit:"edit",MultiEdit:"multiedit",Write:"write",Ls:"ls",Tree:"tree",Cd:"cd",Pwd:"pwd",Glob:"glob",Grep:"ripgrep",Shell:"shell",Bash:"shell",bash:"shell",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",LoadMcpTools:"load_mcp_tools",Skill:"skill"};function Pf(A){return Hf[A]??A}const Wf=new Set(["shell","edit","multiedit","write","apply_patch","terminal"]);function la({toolName:A,contentJson:e,toolDurationMs:t,debug:s,onNavigateToSession:n,compact:r,sessionId:i,onRetry:a,onCompact:g}){const[Q,l]=x.useState(!1),C=Pf(A),I=r&&!Wf.has(C),u={contentJson:e,toolDurationMs:t??void 0,isExpanded:Q,onToggle:()=>l(!Q),compact:I};if(s)return o.jsx(Df,{...u,toolName:A});switch(C){case"read":return o.jsx(gf,{...u});case"edit":case"multiedit":return o.jsx(dQ,{...u,toolName:C});case"write":return o.jsx(Qf,{...u});case"shell":return o.jsx(cf,{...u});case"git_status":return o.jsx(uf,{...u});case"git_diff":return o.jsx(df,{...u});case"git_commit":return o.jsx(hf,{...u});case"apply_patch":return o.jsx(dQ,{...u});case"terminal":return o.jsx(Kf,{...u});case"ls":return o.jsx(pf,{...u});case"tree":return o.jsx(ff,{...u});case"ripgrep":case"grep":case"glob":return o.jsx(mf,{...u});case"websearch":return o.jsx(kf,{...u});case"finish":return o.jsx(wf,{...u});case"update_todos":case"update_plan":return o.jsx(yf,{...u});case"progress_update":return o.jsx(Nf,{...u});case"load_mcp_tools":return o.jsx(Tf,{...u,toolName:A});case"skill":return o.jsx(Of,{...u});case"error":return o.jsx(Mf,{...u,sessionId:i,onRetry:a,onCompact:g});case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":case"present_action":return o.jsx(bf,{toolName:A,...u,onNavigateToSession:n});default:return Lf(C)?o.jsx(jf,{...u,toolName:A}):o.jsx(xf,{...u,toolName:A})}}function ca(A){const e=A.contentJson;if(e&&typeof e=="object")return e;try{if(A.content){const t=JSON.parse(A.content);if(t&&typeof t=="object"&&!Array.isArray(t))return t}}catch{}return null}function zf(A){const e=ca(A);if(!e)return;const t=e.args;if(t&&typeof t=="object"&&!Array.isArray(t))return t}function Vf(A){if(!A)return null;const e=["cmd","command","script","input"];for(const t of e){const s=A[t];if(typeof s=="string"&&s.trim().length>0)return s.trim()}return null}function Zf(A){return A.match(/^\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+)$/m)?.[1]?.trim()||null}function Zl(A){return A==="bash"?"shell":A}function Ea(A){return Zl(A)==="shell"}function _f(A,e){if(!e)return null;const t=[{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:s}of t){const n=e[s];if(typeof n=="string"&&n.trim().length>0)return{key:s,value:n.trim()}}if(Ea(A)){const s=e.command;if(typeof s=="string"&&s.trim().length>0)return{key:"command",value:s.trim()}}if(A==="apply_patch"){const s=e.patch;if(typeof s=="string"&&s.trim().length>0){const n=Zf(s);if(n)return{key:"patch",value:n}}}return null}function Xf(A,e){if(!A)return null;const t=[];for(const[n,r]of Object.entries(A))if(!(e&&n===e)){if(typeof r=="string"||typeof r=="number"){const i=`${n}=${String(r)}`;t.push(i)}if(t.length>=3)break}if(!t.length)return null;const s=t.join(" ");return s.length>120?`${s.slice(0,117)}…`:s}const mQ=x.memo(function({part:e,showLine:t,isLastToolCall:s,isLastProgressUpdate:n,onNavigateToSession:r,compact:i,pendingApproval:a,onApprove:g,onReject:Q,sessionId:l,onRetry:C,onCompact:I}){if(e.type==="tool_call"&&((e.toolName||"")==="progress_update"||!s&&!a)||e.type==="tool_result"&&e.toolName==="progress_update"&&!n)return null;if(e.type==="text"){const D=e.contentJson||e.content;let O="";if(D&&typeof D=="object"&&"text"in D?O=String(D.text):typeof D=="string"&&(O=D),!O||!O.trim())return null}if(e.type==="reasoning"){const D=e.contentJson||e.content;let O="";if(D&&typeof D=="object"&&"text"in D?O=String(D.text):typeof D=="string"&&(O=D),!O||!O.trim())return null}const c=e.type==="tool_call"||e.type==="tool_result",u=["flex-1","min-w-0","max-w-full"];c||e.type==="reasoning"?u.push(i?"pt-0.5":"pt-1"):e.type==="error"?u.push("pt-0.5"):e.type==="text"?(u.push("pt-0"),u.push("-mt-0.5")):u.push("pt-0");const f=u.join(" "),h=()=>{if(e.type==="reasoning")return o.jsx(vn,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"});if(e.type==="tool_call")return o.jsx(Le,{className:"h-4 w-4 text-amber-600 dark:text-amber-300 animate-spin"});if(e.type==="error")return ca(e)?.isAborted===!0?o.jsx(sC,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}):o.jsx(wo,{className:"h-4 w-4 text-red-600 dark:text-red-400"});if(e.type==="tool_result"){const D=e.toolName||"";return D==="read"?o.jsx(ts,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):D==="write"?o.jsx(Yo,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="ls"?o.jsx(rC,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):D==="tree"?o.jsx(Cr,{className:"h-4 w-4 text-cyan-600 dark:text-cyan-300"}):Ea(D)?o.jsx(to,{className:"h-4 w-4 text-muted-foreground"}):D==="ripgrep"||D==="grep"||D==="glob"?o.jsx(Ds,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):D==="apply_patch"?o.jsx(Hi,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):D==="git_status"?o.jsx(ao,{className:"h-4 w-4 text-blue-600 dark:text-blue-300"}):D==="git_diff"?o.jsx(Hi,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):D==="git_commit"?o.jsx(Cn,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="finish"?o.jsx(Yt,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-300"}):D==="query_sessions"||D==="query_messages"||D==="search_history"||D==="get_session_context"||D==="get_parent_session"?o.jsx(nC,{className:"h-4 w-4 text-teal-600 dark:text-teal-300"}):D==="terminal"?o.jsx(to,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}):D==="skill"?o.jsx(LB,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"}):D.includes("__")?o.jsx(wr,{className:"h-4 w-4 text-purple-600 dark:text-purple-300"}):o.jsx(to,{className:"h-4 w-4 text-muted-foreground"})}return o.jsx(io,{className:"h-4 w-4 text-violet-600 dark:text-violet-300"})},k=()=>{const D=e.toolName||"";let O;try{e.contentJson&&typeof e.contentJson=="object"?O=e.contentJson:typeof e.content=="string"?O=JSON.parse(e.content):O={}}catch{O={result:e.content}}return o.jsx(la,{toolName:D,contentJson:O,toolDurationMs:e.toolDurationMs,debug:!1,onNavigateToSession:r,compact:i})},v=()=>{if(e.type==="reasoning")return o.jsx(Yf,{part:e});if(e.type==="text"){let D="";const O=e.contentJson||e.content;return O&&typeof O=="object"&&"text"in O?D=String(O.text):typeof O=="string"?D=O:O&&(D=JSON.stringify(O,null,2)),o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"absolute -top-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:D,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})}),o.jsx("div",{className:"text-base text-foreground leading-relaxed markdown-content max-w-full overflow-x-auto",children:o.jsx(ja,{remarkPlugins:[Ta],components:{a:({href:J,children:V,...eA})=>o.jsx("a",{href:J,target:"_blank",rel:"noopener noreferrer",onClick:X=>{window.self!==window.top&&J&&(X.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:J},"*"))},...eA,children:V}),pre:({children:J,...V})=>{const eA=(()=>{if(!J)return"";const X=Array.isArray(J)?J[0]:J;if(X&&typeof X=="object"&&"props"in X){const K=X.props;if(typeof K.children=="string")return K.children}return""})();return o.jsxs("div",{className:"relative group/code my-3",children:[o.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover/code:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:eA,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"sm"})}),o.jsx("pre",{...V,className:"overflow-x-auto",children:J})]})},table:({children:J,...V})=>o.jsx("div",{className:"overflow-x-auto max-w-full min-w-0 my-3",children:o.jsx("table",{...V,children:J})})},children:D})}),D.length>500&&o.jsx("div",{className:"absolute -bottom-1 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:o.jsx(Qn,{text:D,className:"bg-background/80 backdrop-blur-sm border border-border/50 shadow-sm",size:"md"})})]})}if(e.type==="error"){let D;try{e.contentJson&&typeof e.contentJson=="object"?D=e.contentJson:typeof e.content=="string"?D=JSON.parse(e.content):D={}}catch{D={message:e.content||"Unknown error"}}return o.jsx(la,{toolName:"error",contentJson:D,toolDurationMs:e.toolDurationMs,debug:!1,compact:i,sessionId:l,onRetry:C,onCompact:I})}if(e.type==="tool_call"){const D=ca(e),O=e.toolName||(typeof D?.name=="string"?D.name:"tool"),J=Zl(O),V=J.includes("__")?J.replace("__"," › "):J.replace(/_/g," "),eA=zf(e),X=a?.args,K=eA||X,W=_f(J,K),T=Xf(K,W?.key),L=Ea(J)?Vf(K):null,w=[];if(L?w.push({key:"cmd",node:o.jsx("code",{className:"font-mono text-foreground/90 truncate max-w-xs",children:L})}):W&&w.push({key:"primary",node:o.jsx("code",{className:"font-mono text-foreground/85 truncate max-w-xs",children:W.value})}),T&&w.push({key:"args",node:o.jsx("span",{className:"text-muted-foreground/80 truncate max-w-xs",children:T})}),a&&a.callId===e.toolCallId&&g&&Q)return o.jsx(rf,{toolName:O,args:K,pendingApproval:a,onApprove:g,onReject:Q});w.length===0&&w.push({key:"running",node:o.jsx("span",{className:"text-muted-foreground/75",children:"running…"})});const d=["flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-foreground/80 max-w-full"];return e.ephemeral&&d.push("animate-pulse"),o.jsxs("div",{className:d.join(" "),children:[o.jsx("span",{className:"font-medium text-foreground",children:V}),w.map(N=>o.jsxs(x.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/65",children:"·"}),N.node]},N.key))]})}return e.type==="tool_result"?k():null};return o.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[o.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:h()}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:f,children:v()})]})},(A,e)=>A.part.id===e.part.id&&A.part.content===e.part.content&&A.part.ephemeral===e.part.ephemeral&&A.part.completedAt===e.part.completedAt&&A.showLine===e.showLine&&A.isLastToolCall===e.isLastToolCall&&A.isLastProgressUpdate===e.isLastProgressUpdate&&A.compact===e.compact&&A.onNavigateToSession===e.onNavigateToSession&&A.pendingApproval?.callId===e.pendingApproval?.callId&&A.onApprove===e.onApprove&&A.onReject===e.onReject),_l=new Set(["read","ls","tree","ripgrep","grep","glob","websearch","skill","query_sessions","query_messages","search_history","get_session_context","get_parent_session"]);function ng(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{if(A.content){const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}}catch{}return null}function $f(A){const t=ng(A)?.args;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Am(A){const t=ng(A)?.result;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function gs(A,e=56){return A.length>e?`${A.slice(0,e-1)}…`:A}function em(A){const t=ng(A)?.text;return typeof t=="string"&&t.trim()?t.trim():typeof A.content=="string"?A.content.trim():""}function tm(A){return A.split(`
110
110
  `).map(t=>t.trim()).find(Boolean)||A.trim()}function om(A){return A.replace(/^Reasoning:\s*/i,"").replace(/^[-*+]\s+/,"").replace(/\[(.*?)\]\((.*?)\)/g,"$1").replace(/[*_`#>~]+/g,"").replace(/\s+/g," ").trim()}function yo(A,...e){for(const t of e){const s=A[t];if(typeof s=="string"&&s.trim())return s.trim()}}function sm(A){return A.type==="reasoning"?!0:A.type!=="tool_call"&&A.type!=="tool_result"?!1:!!(A.toolName&&_l.has(A.toolName))}function rm(A){if(A.type==="reasoning"){const s=em(A),n=om(tm(s));return{id:A.id,label:n?gs(n):"Thinking through the approach",toolName:"reasoning",fullText:s||void 0,startedAt:A.startedAt,completedAt:A.completedAt}}if(!A.toolName||!_l.has(A.toolName))return null;const e=$f(A),t=Am(A);if(A.toolName==="read"){const s=yo(t,"path")||yo(e,"path");return{id:A.id,toolName:A.toolName,path:s,label:s?`Reading ${gs(s)}`:"Reading file contents",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="ls"||A.toolName==="tree"){const s=yo(e,"path")||yo(t,"path");return{id:A.id,toolName:A.toolName,path:s,label:s?`Scanning ${gs(s)}`:"Scanning the project",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="ripgrep"||A.toolName==="grep"||A.toolName==="glob"){const s=yo(e,"query","pattern","filePattern")||yo(t,"query","pattern");return{id:A.id,toolName:A.toolName,query:s,label:s?`Searching for ${gs(s,42)}`:"Searching code",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="websearch"){const s=yo(e,"query"),n=yo(e,"url")||yo(t,"url");return{id:A.id,toolName:A.toolName,query:s,url:n,label:s?`Researching ${gs(s,42)}`:n?`Reviewing ${gs(n,42)}`:"Researching references",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="skill"){const s=yo(e,"name");return{id:A.id,toolName:A.toolName,label:s?`Loading skill ${gs(s,36)}`:"Loading a skill",startedAt:A.startedAt,completedAt:A.completedAt}}return{id:A.id,toolName:A.toolName,label:"Reviewing prior context",startedAt:A.startedAt,completedAt:A.completedAt}}function nm(A){const e=new Map;for(const s of A)s.type==="tool_result"&&s.toolCallId&&e.set(s.toolCallId,s);const t=[];for(const s of A){if(s.type==="tool_call"&&s.toolCallId&&e.has(s.toolCallId))continue;const n=rm(s);n&&t.push(n)}return t}function im(A){const e=new Set;for(const t of A)t.path&&e.add(t.path);return e}function am(A){let e=null,t=null;for(const s of A){const n=s.startedAt??null,r=s.completedAt??s.startedAt??null;n!==null&&(e===null||n<e)&&(e=n),r!==null&&(t===null||r>t)&&(t=r)}return e!==null&&t!==null&&t>e?t-e:null}function gm(A){const e=Math.round(A/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return s>0?`${t}m ${s}s`:`${t}m`}function Qm(A){const e=im(A);let t=0,s=0,n=0,r=0,i=0;for(const c of A)switch(c.toolName){case"reasoning":r+=1;break;case"read":break;case"ls":case"tree":s+=1;break;case"ripgrep":case"grep":case"glob":t+=1;break;case"websearch":n+=1;break;case"skill":case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":i+=1;break}const a=e.size>0||s>0,g=am(A),Q=g!==null?gm(g):null,l=r>0&&e.size===0&&t===0&&s===0&&n===0&&i===0,C=l?Q?`Thought for ${Q}`:"Thought through the approach":n>0?a||t>0?"Researched and reviewed the project":"Researched references":i>0&&t>0?"Reviewed context and searched code":a&&t>0?"Reviewed files and searched code":s>0?"Explored project structure":e.size>0?"Reviewed project files":i>0?"Reviewed prior context":"Thought through the approach",I=[];return!l&&Q&&I.push(Q),e.size>0&&I.push(`${e.size} ${e.size===1?"file":"files"}`),t>0&&I.push(`${t} ${t===1?"search":"searches"}`),s>0&&e.size===0&&I.push(`${s} ${s===1?"scan":"scans"}`),n>0&&I.push(`${n} ${n===1?"web lookup":"web lookups"}`),i>0&&C!=="Reviewed prior context"&&I.push("prior context"),r>0&&!l&&I.push("reasoning"),I.length===0&&r===0&&I.push(`${A.length} ${A.length===1?"step":"steps"}`),{title:C,details:I}}const No=320,ko="cubic-bezier(0.25, 1, 0.5, 1)",wQ=140;function Bm({entries:A,titleOverride:e,showLine:t,collapsed:s}){const n=s&&A.length>0,[r,i]=x.useState(n),[a,g]=x.useState(n),Q=x.useRef(null),l=x.useRef(null),C=x.useRef(null),I=x.useRef(!1),c=x.useRef(A.length),[u,f]=x.useState(0),h=x.useMemo(()=>Qm(A),[A]),v=[e||h.title,...h.details].join(" · "),D=A.some(V=>V.toolName==="reasoning"),O=A.length>0?A[A.length-1]:null;x.useEffect(()=>{if(!s&&!a){i(!1);return}if(!a&&s&&g(!0),r||A.length===0)return;const V=window.setTimeout(()=>i(!0),500);return()=>window.clearTimeout(V)},[s,r,a,A.length]),x.useLayoutEffect(()=>{if(r)return;const V=Q.current;if(!V)return;const eA=()=>{const K=Math.min(V.scrollHeight,wQ);f(W=>W===K?W:K)};eA();const X=new ResizeObserver(()=>eA());return X.observe(V),()=>X.disconnect()},[r]),x.useEffect(()=>()=>{C.current!==null&&window.cancelAnimationFrame(C.current)},[]),x.useEffect(()=>{if(r||I.current)return;const V=l.current;if(!V)return;const eA=Q.current?.scrollHeight??0,X=eA>u+1,K=X?Math.max(0,eA-u):0;if(C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),!X){V.scrollTop=0;return}const W=V.scrollTop,T=K-W;if(T<=1){V.scrollTop=K;return}const L=performance.now(),w=Math.min(360,Math.max(180,T*.9)),B=d=>{const N=Math.min(1,(d-L)/w),G=1-(1-N)**3;if(V.scrollTop=W+T*G,N<1&&!I.current){C.current=window.requestAnimationFrame(B);return}C.current=null};C.current=window.requestAnimationFrame(B)},[A.length,O?.fullText,r,u]),x.useEffect(()=>{c.current=A.length},[A.length]);const J=!r;return o.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[o.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:D?o.jsx(vn,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"}):o.jsx(Ds,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"})}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:"flex-1 min-w-0 pt-0.5",children:o.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{border:J?"1px solid hsl(var(--border) / 0.6)":"1px solid transparent",background:J?"hsl(var(--muted) / 0.2)":"transparent",padding:J?"8px 12px":"0px 0px",transition:`border ${No}ms ${ko}, background ${No}ms ${ko}, padding ${No}ms ${ko}`},children:[o.jsxs("div",{style:{overflow:"hidden",opacity:J?1:0,maxHeight:J?`${wQ+28}px`:"0px",transition:`opacity ${No}ms ${ko}, max-height ${No}ms ${ko}`},children:[o.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground/70 mb-1",children:"Exploring"}),o.jsx("div",{ref:l,className:"overflow-y-auto",style:{height:`${u}px`,transition:`height ${No}ms ${ko}`,maskImage:"linear-gradient(to bottom, transparent 0px, black 20px)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0px, black 20px)"},role:"log",onMouseEnter:()=>{I.current=!0},onMouseLeave:()=>{I.current=!1},children:o.jsx("div",{ref:Q,className:"pt-2.5",children:A.map((V,eA)=>{const X=eA===A.length-1,K=eA>=c.current;return V.toolName==="reasoning"&&V.fullText&&V.fullText.trim()?o.jsx("div",{className:"px-1 py-0.5",style:{animation:K?`ottoEntryIn ${No}ms ${ko} both`:void 0},children:o.jsx("p",{className:`text-[11px] leading-relaxed font-mono whitespace-pre-wrap ${X?"text-foreground/80":"text-muted-foreground/60"}`,children:V.fullText})},V.id):o.jsx("div",{className:`flex items-center px-1 text-xs leading-5 h-7 ${X?"text-foreground":"text-muted-foreground/70"}`,style:{animation:K?`ottoEntryIn ${No}ms ${ko} both`:void 0},children:o.jsx("span",{className:"block min-w-0 truncate",children:V.label})},V.id)})})})]}),o.jsx("div",{className:"flex items-center text-xs",style:{opacity:r?1:0,height:r?"20px":"0px",overflow:"hidden",transition:`opacity ${No}ms ${ko}, height ${No}ms ${ko}`},children:o.jsx("span",{className:"block min-w-0 truncate leading-5 text-foreground",title:v,children:v})})]})}),o.jsx("style",{children:"@keyframes ottoEntryIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }"})]})}const Ro=320,Ko="cubic-bezier(0.25, 1, 0.5, 1)",xQ=140;function ig(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{if(A.content){const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}}catch{}return{}}function lm(A){const e=ig(A);return typeof e._streamedInput=="string"?e._streamedInput:""}function cm(A){const e=ig(A);return typeof e._streamedOutput=="string"?e._streamedOutput:""}function Em(A){const t=ig(A)?.args;if(t&&typeof t=="object"&&!Array.isArray(t))return t}function Cm(A){return A.match(/^\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+)$/m)?.[1]?.trim()||null}const Im={shell:{Icon:to,color:"text-muted-foreground",label:"Running"},bash:{Icon:to,color:"text-muted-foreground",label:"Running"},write:{Icon:Yo,color:"text-emerald-600 dark:text-emerald-300",label:"Writing"},apply_patch:{Icon:Hi,color:"text-purple-600 dark:text-purple-300",label:"Patching"},edit:{Icon:Yo,color:"text-purple-600 dark:text-purple-300",label:"Editing"},multiedit:{Icon:Yo,color:"text-purple-600 dark:text-purple-300",label:"Editing"},terminal:{Icon:to,color:"text-amber-600 dark:text-amber-300",label:"Terminal"}};function Xl(A){return A==="bash"?"shell":A}function Gr(A){return Xl(A)==="shell"}function um(A,e){if(!e)return"";if(Gr(A)){const t=String(e.cmd||"");return t.length>80?`${t.slice(0,77)}…`:t}if(A==="write"||A==="edit"||A==="multiedit")return String(e.path||"");if(A==="apply_patch"){const t=String(e.patch||"");return Cm(t)||""}return""}function dm(A,e){if(Gr(A)){const t=$o(e,"cmd");if(t)return t.length>80?`${t.slice(0,77)}…`:t}if(A==="write")return $o(e,"path")||$o(e,"filePath");if(A==="edit"||A==="multiedit")return $o(e,"path");if(A==="apply_patch"){const t=e.match(/\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+?)(?:\\n|")/);return t?t[1].trim():""}return""}function hm(A){try{if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;if(typeof A.content=="string")return JSON.parse(A.content)}catch{}return{}}function pm({part:A,showLine:e}){const t=x.useRef(null),s=x.useRef(null),n=x.useRef(null),r=x.useRef(!1),i=x.useRef(0),[a,g]=x.useState(0),Q=Xl(A.toolName||""),l=A.type==="tool_result",C=Im[Q]||{Icon:to,color:"text-muted-foreground",label:Q.replace(/_/g," ")},[I,c]=x.useState(()=>l),[u,f]=x.useState(()=>l),h=Em(A),k=lm(A),v=cm(A),D=um(Q,h)||dm(Q,k),O=fm(Q,k),J=Gr(Q)?v||O||(h?DQ(Q,h):""):h?DQ(Q,h):O,V=J.trim().length>0;x.useEffect(()=>{if(!l&&!u){c(!1);return}if(!u&&l&&f(!0),I||!l)return;const K=window.setTimeout(()=>c(!0),500);return()=>window.clearTimeout(K)},[l,I,u]),x.useLayoutEffect(()=>{if(!V){g(0);return}const K=t.current;if(!K||K.textContent!==J)return;const W=Math.min(K.scrollHeight,xQ-12);g(T=>T===W?T:W)},[J,V]),x.useEffect(()=>()=>{n.current!==null&&window.cancelAnimationFrame(n.current)},[]),x.useEffect(()=>{const K=s.current;if(!K||r.current)return;const W=J.length,T=t.current?.scrollHeight??0,L=T>a+1,w=L?Math.max(0,T-a):0;if(n.current!==null&&(window.cancelAnimationFrame(n.current),n.current=null),!L){K.scrollTop=0,i.current=W;return}if(W<=i.current){K.scrollTop=w,i.current=W;return}const B=K.scrollTop,d=w-B;if(d<=1){K.scrollTop=w,i.current=W;return}const N=performance.now(),G=Math.min(360,Math.max(180,d*.9)),S=j=>{const H=Math.min(1,(j-N)/G),b=1-(1-H)**3;if(K.scrollTop=B+d*b,H<1&&!r.current){n.current=window.requestAnimationFrame(S);return}n.current=null};n.current=window.requestAnimationFrame(S),i.current=W},[J,a]);const eA=!I,X=l?hm(A):null;return o.jsxs("div",{className:"flex gap-3 pb-2 relative max-w-full overflow-hidden",children:[o.jsxs("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:o.jsx(C.Icon,{className:`h-4 w-4 ${C.color}`})}),e&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:"flex-1 min-w-0 pt-0.5",children:o.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{border:eA?"1px solid hsl(var(--border) / 0.6)":"1px solid transparent",background:eA?"hsl(var(--muted) / 0.2)":"transparent",padding:eA?"8px 12px":"0px 0px",transition:`border ${Ro}ms ${Ko}, background ${Ro}ms ${Ko}, padding ${Ro}ms ${Ko}`},children:[o.jsxs("div",{style:{overflow:"hidden",opacity:eA?1:0,maxHeight:eA?`${xQ+28}px`:"0px",transition:`opacity ${Ro}ms ${Ko}, max-height ${Ro}ms ${Ko}`},children:[o.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground/70",children:[o.jsx(Le,{className:"h-3 w-3 animate-spin flex-shrink-0"}),o.jsx("span",{className:"flex-shrink-0",children:C.label}),D&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/40 flex-shrink-0",children:"·"}),o.jsx("span",{className:"truncate text-foreground/60 lowercase tracking-normal font-normal font-mono",children:D})]}),!h&&!O&&!v&&o.jsx("span",{className:"text-muted-foreground/50 animate-pulse lowercase tracking-normal font-normal",children:"generating…"})]}),o.jsx("div",{style:{overflow:"hidden",opacity:V?1:0,height:V?`${a+6}px`:"0px",transition:`opacity ${Ro}ms ${Ko}, height ${Ro}ms ${Ko}`},children:J&&o.jsx("div",{className:"pt-1.5",children:o.jsx("section",{ref:s,className:"overflow-y-auto","aria-label":`${C.label} content`,style:{height:`${a}px`,maskImage:"linear-gradient(to bottom, transparent 0px, black 20px)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0px, black 20px)"},onMouseEnter:()=>{r.current=!0},onMouseLeave:()=>{r.current=!1},children:o.jsx("pre",{ref:t,className:"px-1 pt-2.5 pb-1 text-[11px] leading-relaxed text-foreground/60 font-mono whitespace-pre-wrap break-all",children:J})})})})]}),o.jsx("div",{className:"min-w-0 text-xs",style:{opacity:I?1:0,maxHeight:I?"1200px":"0px",overflow:"hidden",transition:`opacity ${Ro}ms ${Ko}, max-height ${Ro}ms ${Ko}`},children:X?o.jsx("div",{className:"min-w-0",children:o.jsx(la,{toolName:Q,contentJson:X,toolDurationMs:A.toolDurationMs??void 0,debug:!1,compact:!1})}):o.jsx("div",{className:"flex min-w-0 items-center",children:o.jsx("span",{className:"block min-w-0 truncate leading-5 text-foreground",title:D||C.label,children:D?`${C.label} · ${D}`:C.label})})})]})})]})}function DQ(A,e){return Gr(A)?String(e.cmd||""):A==="write"?String(e.content||""):A==="apply_patch"?String(e.patch||""):A==="edit"?String(e.oldString||""):""}function $o(A,e){const s=new RegExp(`"${e}"\\s*:\\s*"`).exec(A);if(!s)return"";const n=s.index+s[0].length;let r="",i=n;for(;i<A.length;)if(A[i]==="\\"&&i+1<A.length){const a=A[i+1];a==="n"?r+=`
111
111
  `:a==="t"?r+=" ":a==='"'?r+='"':a==="\\"?r+="\\":r+=a,i+=2}else{if(A[i]==='"')break;r+=A[i],i+=1}return r}function fm(A,e){return e?Gr(A)?$o(e,"cmd"):A==="write"?$o(e,"content"):A==="apply_patch"?$o(e,"patch"):A==="edit"?$o(e,"oldString"):"":""}const ci={currentMessageId:null,queuedMessages:[],queueLength:0};function mm(A){const{data:e}=at({queryKey:["queueState",A],queryFn:()=>ci,enabled:!!A,initialData:ci,staleTime:1/0});return e??ci}function $l(A,e){const t=mm(A);if(!A||!t)return{isQueued:!1,isRunning:!1,position:null};if(t.currentMessageId===e)return{isQueued:!1,isRunning:!0,position:null};const s=t.queuedMessages.find(n=>n.messageId===e);return s?{isQueued:!0,isRunning:!1,position:s.position}:{isQueued:!1,isRunning:!1,position:null}}function wm(A){const e=ke();return Ze({mutationFn:t=>{if(!A)throw new Error("No session ID");return mA.createBranch(A,t)},onSuccess:()=>{e.invalidateQueries({queryKey:fo}),A&&e.invalidateQueries({queryKey:["branches",A]})}})}function Ac(A){return at({queryKey:["parentSession",A],queryFn:()=>{if(!A)throw new Error("No session ID");return mA.getParentSession(A)},enabled:!!A})}function xm({isOpen:A,onClose:e,sessionId:t,message:s,onBranchCreated:n}){const r=eg(t),i=wm(t),[a,g]=x.useState(""),[Q,l]=x.useState(!0),C=x.useId(),I=x.useId(),c=s.parts?.find(h=>h.type==="text")?.content||"",u=(()=>{try{return JSON.parse(c)?.text?.slice(0,100)||""}catch{return c.slice(0,100)}})(),f=async h=>{h.preventDefault();try{const k=await i.mutateAsync({fromMessageId:s.id,title:a.trim()||void 0,provider:Q?r?.provider:void 0,model:Q?r?.model:void 0,agent:Q?r?.agent:void 0});e(),n&&k.session&&n(k.session.id)}catch(k){console.error("Failed to create branch:",k)}};return o.jsx(Po,{isOpen:A,onClose:e,title:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ao,{className:"h-5 w-5 text-primary"}),o.jsx("span",{children:"Branch Session"})]}),maxWidth:"md",children:o.jsxs("form",{onSubmit:f,className:"space-y-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.jsx("p",{children:"Creating branch from message:"}),o.jsxs("p",{className:"mt-1 p-2 bg-muted/50 rounded text-foreground italic truncate",children:['"',u,'..."']})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:C,className:"block text-sm font-medium text-foreground",children:"Branch Title (optional)"}),o.jsx("input",{id:C,type:"text",value:a,onChange:h=>g(h.target.value),placeholder:`Branch of ${r?.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"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{id:I,type:"checkbox",checked:Q,onChange:h=>l(h.target.checked),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary/50"}),o.jsx("label",{htmlFor:I,className:"text-sm text-foreground",children:"Use same provider/model/agent as parent"})]}),r&&o.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 rounded p-2",children:o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("span",{children:[o.jsx("strong",{children:"Provider:"})," ",r.provider]}),o.jsxs("span",{children:[o.jsx("strong",{children:"Model:"})," ",r.model]}),o.jsxs("span",{children:[o.jsx("strong",{children:"Agent:"})," ",r.agent]})]})}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),o.jsx("button",{type:"submit",disabled:i.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:i.isPending?o.jsxs(o.Fragment,{children:[o.jsx(Le,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ao,{className:"h-4 w-4"}),"Create Branch"]})})]}),i.isError&&o.jsx("p",{className:"text-sm text-red-500",children:i.error?.message||"Failed to create branch"})]})})}const yQ=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function Dm(A){const e=A.split("").reduce((t,s)=>t+s.charCodeAt(0),0);return yQ[e%yQ.length]}const ec=x.memo(function({sessionId:e,message:t,showHeader:s,hasNextAssistantMessage:n,onBranchCreated:r,compact:i,showBranchButton:a=!0,onNavigateToSession:g,onRetry:Q,onCompact:l}){const{isQueued:C}=$l(e,t.id),[I,c]=x.useState(!1),[u,f]=x.useState(!1),[h,k]=x.useState(!1),{pendingApprovals:v,removePendingApproval:D}=Mr(),O=x.useCallback(async E=>{if(e)try{await mA.approveToolCall(e,E,!0),D(E)}catch(p){console.error("Failed to approve tool call:",p)}},[e,D]),J=x.useCallback(async E=>{if(e)try{await mA.approveToolCall(e,E,!1),D(E)}catch(p){console.error("Failed to reject tool call:",p)}},[e,D]),V=x.useMemo(()=>v.filter(E=>E.messageId===t.id),[v,t.id]),eA=x.useCallback(async()=>{if(e)try{await Promise.all(V.map(E=>mA.approveToolCall(e,E.callId,!0)));for(const E of V)D(E.callId)}catch(E){console.error("Failed to approve all tool calls:",E)}},[e,V,D]),X=x.useMemo(()=>[...t.parts||[]].sort((p,U)=>{const R=(p.index??0)-(U.index??0);if(R!==0)return R;const _=(p.stepIndex??0)-(U.stepIndex??0);return _!==0?_:(p.startedAt??0)-(U.startedAt??0)}),[t.parts]),K=X.some(E=>E.toolName==="finish"),W=X.reduce((E,p,U)=>p.type==="tool_result"&&p.toolName==="progress_update"?U:E,-1),T=W>=0?X[W]:null,L=new Set(X.filter(E=>E.ephemeral&&["shell","bash","edit","multiedit","write","apply_patch","terminal"].includes(E.toolName||"")).map(E=>E.toolCallId).filter(E=>!!E)),w=x.useMemo(()=>{const E=[];let p=[],U=-1,R;const _=tA=>{if(p.length===0){tA&&(R=tA);return}const IA=nm(p);if(IA.length>0)E.push({kind:"group",id:`compact-${p[0].id}`,entries:IA,titleOverride:R});else for(const[iA,UA]of p.entries())E.push({kind:"part",index:U+iA,part:UA});p=[],U=-1,R=tA};for(const[tA,IA]of X.entries()){if((IA.type==="tool_result"||IA.type==="tool_call")&&IA.toolName==="progress_update"){let UA;const HA=IA.contentJson&&typeof IA.contentJson=="object"?IA.contentJson:null;if(HA){const lA=HA.args??HA.result;if(lA&&typeof lA=="object"){const qA=lA.message;typeof qA=="string"&&qA.trim()&&(UA=qA.trim())}}UA&&_(UA);continue}if(i&&sm(IA)){p.length===0&&(U=tA),p.push(IA);continue}_(),E.push({kind:"part",index:tA,part:IA})}return _(),E},[X,i]),B=w.length>0,d=X.findIndex(E=>!(E.type==="tool_result"&&E.toolName==="progress_update")),N=t.status==="pending"&&!K&&!!T,G=t.status==="pending"&&!K&&!T&&!C,S=E=>E?new Date(E).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",j=t.status==="complete",H=x.useCallback(()=>{const E=X.filter(p=>p.type==="text").map(p=>{try{return JSON.parse(p.content||"{}")?.text||""}catch{return p.content||""}}).join(`
112
- `);navigator.clipboard.writeText(E),k(!0),setTimeout(()=>k(!1),2e3)},[X]),b=x.useCallback(()=>{f(!0)},[]);return C?null:o.jsxs("div",{className:"relative group",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s&&o.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[o.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:[o.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:o.jsx(io,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),o.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:[t.agent&&o.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300 whitespace-nowrap",title:t.agent,children:t.agent}),t.provider&&o.jsxs(o.Fragment,{children:[t.agent&&o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx($t,{provider:t.provider,size:14,className:"opacity-70"})]}),t.model&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"hidden md:inline text-muted-foreground whitespace-nowrap",title:t.model,children:t.model})]}),t.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:S(t.createdAt)})]})]})]}),I&&j&&e&&a&&o.jsx("button",{type:"button",onClick:b,className:"ml-4 p-1.5 text-muted-foreground hover:text-primary transition-colors flex-shrink-0",title:"Branch from this message",children:o.jsx(ao,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"relative ml-1",children:[w.map((E,p)=>{const U=p<w.length-1||n||N;if(E.kind==="group")return o.jsx(Bm,{entries:E.entries,titleOverride:E.titleOverride,showLine:U,collapsed:t.status!=="pending"||p<w.length-1},E.id);const{part:R,index:_}=E,tA=_===X.length-1;if(R.ephemeral&&(R.type==="tool_call"||R.type==="tool_result")&&["shell","bash","edit","multiedit","write","apply_patch","terminal"].includes(R.toolName||""))return o.jsx(pm,{part:R,showLine:U},R.id);const iA=R.type==="tool_call"&&R.toolCallId?v.find(qA=>qA.callId===R.toolCallId)??null:null;if(R.type==="tool_result"&&R.toolCallId&&L.has(R.toolCallId))return null;const UA=R.type==="tool_result"&&R.toolName==="finish",HA=U&&!UA,lA=R.type==="tool_call"&&tA;return o.jsx(mQ,{part:R,showLine:HA,isFirstPart:_===d&&!s,isLastToolCall:lA,onNavigateToSession:g,compact:i,pendingApproval:iA,onApprove:O,onReject:J,sessionId:e,onRetry:Q,onCompact:l},R.id)}),V.length>1&&o.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:[o.jsx(Ra,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),o.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200 flex-1",children:[V.length," tools waiting for approval"]}),o.jsxs("button",{type:"button",onClick:eA,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:[o.jsx(SB,{className:"w-3.5 h-3.5"}),"Approve All",o.jsx("kbd",{className:"ml-1 text-[10px] opacity-70",children:"A"})]})]}),N&&T&&o.jsx(mQ,{part:T,showLine:n,isFirstPart:!B&&!s,isLastProgressUpdate:!0,compact:i},T.id),G&&o.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[o.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:o.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:o.jsx(io,{className:"h-4 w-4"})})}),o.jsx("div",{className:"flex-1 pt-0.5",children:o.jsx("div",{className:"text-base text-foreground animate-pulse",children:Dm(t.id)})})]})]}),j&&e&&o.jsx("div",{className:"grid ml-7 transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:I?"1fr":"0fr"},children:o.jsx("div",{className:"overflow-hidden",children:o.jsxs("div",{className:"flex gap-2 mt-2",children:[a&&o.jsxs("button",{type:"button",onClick:b,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:[o.jsx(ao,{className:"h-3 w-3"}),"Branch"]}),o.jsx("button",{type:"button",onClick:H,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:h?o.jsxs(o.Fragment,{children:[o.jsx(Yt,{className:"h-3 w-3 text-green-500"}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx(ps,{className:"h-3 w-3"}),"Copy"]})})]})})}),u&&e&&o.jsx(xm,{isOpen:u,onClose:()=>f(!1),sessionId:e,message:t,onBranchCreated:r})]})},(A,e)=>{const t=A.message.parts||[],s=e.message.parts||[];if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],i=s[n];if(r.id!==i.id||r.index!==i.index||r.stepIndex!==i.stepIndex||r.type!==i.type||r.content!==i.content||r.contentJson!==i.contentJson||r.toolName!==i.toolName||r.toolCallId!==i.toolCallId||r.ephemeral!==i.ephemeral||r.completedAt!==i.completedAt||r.startedAt!==i.startedAt)return!1}return A.message.id===e.message.id&&A.message.status===e.message.status&&A.message.completedAt===e.message.completedAt&&A.showHeader===e.showHeader&&A.hasNextAssistantMessage===e.hasNextAssistantMessage&&A.isLastMessage===e.isLastMessage&&A.sessionId===e.sessionId&&A.compact===e.compact&&A.onNavigateToSession===e.onNavigateToSession}),tc=x.memo(function({sessionId:e,message:t,nextAssistantMessageId:s}){const[n,r]=x.useState(null),i=t.parts||[],a=ke(),{isQueued:g,position:Q}=$l(e,s??""),l=Ba(T=>T.setPendingRestoreText),C=i.filter(T=>T.type==="text"),I=i.filter(T=>T.type==="image"),c=i.filter(T=>T.type==="file"),u=C[0];let f="";if(u){const T=u.contentJson||u.content;T&&typeof T=="object"&&"text"in T?f=String(T.text):typeof T=="string"?f=T:T&&(f=JSON.stringify(T,null,2))}const{researchContexts:h,cleanContent:k}=Wp(f),v=[];for(const T of I)try{const L=T.contentJson||JSON.parse(T.content||"{}");if(L&&typeof L=="object"&&"data"in L){const w=L,B=`data:${w.mediaType};base64,${w.data}`;v.push({id:T.id,src:B})}}catch{}const D=[];for(const T of c)try{const L=T.contentJson||JSON.parse(T.content||"{}");if(L&&typeof L=="object"&&"type"in L){const w=L;if(w.type==="image"&&w.data){const B=`data:${w.mediaType};base64,${w.data}`;v.push({id:T.id,src:B})}else D.push({id:T.id,type:w.type,name:w.name})}}catch{}const O=T=>T?new Date(T).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",J=k.trim().length>0,V=v.length>0,eA=D.length>0,X=h.length>0;if(!J&&!V&&!eA&&!X)return null;const K=async()=>{if(!(!e||!s)){l(k);try{await mA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(T){console.error("Failed to cancel queued message:",T)}}},W=async()=>{if(!(!e||!s))try{await mA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(T){console.error("Failed to delete queued message:",T)}};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative pb-8 pt-6",children:o.jsxs("div",{className:"flex gap-3 md:gap-4 justify-end",children:[o.jsxs("div",{className:"flex flex-col items-end min-w-0 flex-1 max-w-[calc(100%-3rem)] md:max-w-2xl",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[o.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),t.createdAt&&o.jsx("span",{children:"·"}),t.createdAt&&o.jsx("span",{children:O(t.createdAt)}),g&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",children:[o.jsx(Ka,{className:"h-3 w-3"}),"Queued",Q!==null&&Q>0?` #${Q+1}`:""]})]})]}),o.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:[V&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:v.map(T=>o.jsx("button",{type:"button",onClick:()=>r(T.src),className:"w-16 h-16 rounded-lg overflow-hidden bg-muted hover:ring-2 hover:ring-primary/50 transition-all",children:o.jsx("img",{src:T.src,alt:"Attachment",className:"w-full h-full object-cover"})},T.id))}),eA&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:D.map(T=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border",children:[T.type==="pdf"?o.jsx(es,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):o.jsx(ts,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs truncate max-w-[150px]",children:T.name})]},T.id))}),X&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:h.map(T=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30",children:[o.jsx(Er,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs text-teal-600 dark:text-teal-400",children:T.label})]},T.id))}),J&&o.jsx("div",{className:"prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_*]:[word-break:break-word] [&_*]:overflow-wrap-anywhere whitespace-pre-wrap",children:o.jsx(ja,{remarkPlugins:[Ta],components:{a:({href:T,children:L,...w})=>o.jsx("a",{href:T,target:"_blank",rel:"noopener noreferrer",onClick:B=>{window.self!==window.top&&T&&(B.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:T},"*"))},...w,children:L})},children:k.replace(/\n/g,`
112
+ `);navigator.clipboard.writeText(E),k(!0),setTimeout(()=>k(!1),2e3)},[X]),b=x.useCallback(()=>{f(!0)},[]);return C?null:o.jsxs("div",{className:"relative group",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s&&o.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[o.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:[o.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:o.jsx(io,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),o.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:[t.agent&&o.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300 whitespace-nowrap",title:t.agent,children:t.agent}),t.provider&&o.jsxs(o.Fragment,{children:[t.agent&&o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx($t,{provider:t.provider,size:14,className:"opacity-70"})]}),t.model&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"hidden md:inline text-muted-foreground whitespace-nowrap",title:t.model,children:t.model})]}),t.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:S(t.createdAt)})]})]})]}),I&&j&&e&&a&&o.jsx("button",{type:"button",onClick:b,className:"ml-4 p-1.5 text-muted-foreground hover:text-primary transition-colors flex-shrink-0",title:"Branch from this message",children:o.jsx(ao,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"relative ml-1",children:[w.map((E,p)=>{const U=p<w.length-1||n||N;if(E.kind==="group")return o.jsx(Bm,{entries:E.entries,titleOverride:E.titleOverride,showLine:U,collapsed:t.status!=="pending"||p<w.length-1},E.id);const{part:R,index:_}=E,tA=_===X.length-1;if(R.ephemeral&&(R.type==="tool_call"||R.type==="tool_result")&&["shell","bash","edit","multiedit","write","apply_patch","terminal"].includes(R.toolName||""))return o.jsx(pm,{part:R,showLine:U},R.id);const iA=R.type==="tool_call"&&R.toolCallId?v.find(qA=>qA.callId===R.toolCallId)??null:null;if(R.type==="tool_result"&&R.toolCallId&&L.has(R.toolCallId))return null;const UA=R.type==="tool_result"&&R.toolName==="finish",HA=U&&!UA,lA=R.type==="tool_call"&&tA;return o.jsx(mQ,{part:R,showLine:HA,isFirstPart:_===d&&!s,isLastToolCall:lA,onNavigateToSession:g,compact:i,pendingApproval:iA,onApprove:O,onReject:J,sessionId:e,onRetry:Q,onCompact:l},R.id)}),V.length>1&&o.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:[o.jsx(Ra,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),o.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200 flex-1",children:[V.length," tools waiting for approval"]}),o.jsxs("button",{type:"button",onClick:eA,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:[o.jsx(SB,{className:"w-3.5 h-3.5"}),"Approve All",o.jsx("kbd",{className:"ml-1 text-[10px] opacity-70",children:"A"})]})]}),N&&T&&o.jsx(mQ,{part:T,showLine:n,isFirstPart:!B&&!s,isLastProgressUpdate:!0,compact:i},T.id),G&&o.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[o.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:o.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:o.jsx(io,{className:"h-4 w-4"})})}),o.jsx("div",{className:"flex-1 pt-0.5",children:o.jsx("div",{className:"text-base text-foreground animate-pulse",children:Dm(t.id)})})]})]}),j&&e&&o.jsx("div",{className:"grid ml-7 transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:I?"1fr":"0fr"},children:o.jsx("div",{className:"overflow-hidden",children:o.jsxs("div",{className:"flex gap-2 mt-2",children:[a&&o.jsxs("button",{type:"button",onClick:b,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:[o.jsx(ao,{className:"h-3 w-3"}),"Branch"]}),o.jsx("button",{type:"button",onClick:H,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:h?o.jsxs(o.Fragment,{children:[o.jsx(Yt,{className:"h-3 w-3 text-green-500"}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx(ps,{className:"h-3 w-3"}),"Copy"]})})]})})}),u&&e&&o.jsx(xm,{isOpen:u,onClose:()=>f(!1),sessionId:e,message:t,onBranchCreated:r})]})},(A,e)=>{const t=A.message.parts||[],s=e.message.parts||[];if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],i=s[n];if(r.id!==i.id||r.index!==i.index||r.stepIndex!==i.stepIndex||r.type!==i.type||r.content!==i.content||r.toolName!==i.toolName||r.toolCallId!==i.toolCallId||r.ephemeral!==i.ephemeral||r.completedAt!==i.completedAt||r.startedAt!==i.startedAt)return!1}return A.message.id===e.message.id&&A.message.status===e.message.status&&A.message.completedAt===e.message.completedAt&&A.showHeader===e.showHeader&&A.hasNextAssistantMessage===e.hasNextAssistantMessage&&A.isLastMessage===e.isLastMessage&&A.sessionId===e.sessionId&&A.compact===e.compact&&A.onNavigateToSession===e.onNavigateToSession}),tc=x.memo(function({sessionId:e,message:t,nextAssistantMessageId:s}){const[n,r]=x.useState(null),i=t.parts||[],a=ke(),{isQueued:g,position:Q}=$l(e,s??""),l=Ba(T=>T.setPendingRestoreText),C=i.filter(T=>T.type==="text"),I=i.filter(T=>T.type==="image"),c=i.filter(T=>T.type==="file"),u=C[0];let f="";if(u){const T=u.contentJson||u.content;T&&typeof T=="object"&&"text"in T?f=String(T.text):typeof T=="string"?f=T:T&&(f=JSON.stringify(T,null,2))}const{researchContexts:h,cleanContent:k}=Wp(f),v=[];for(const T of I)try{const L=T.contentJson||JSON.parse(T.content||"{}");if(L&&typeof L=="object"&&"data"in L){const w=L,B=`data:${w.mediaType};base64,${w.data}`;v.push({id:T.id,src:B})}}catch{}const D=[];for(const T of c)try{const L=T.contentJson||JSON.parse(T.content||"{}");if(L&&typeof L=="object"&&"type"in L){const w=L;if(w.type==="image"&&w.data){const B=`data:${w.mediaType};base64,${w.data}`;v.push({id:T.id,src:B})}else D.push({id:T.id,type:w.type,name:w.name})}}catch{}const O=T=>T?new Date(T).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",J=k.trim().length>0,V=v.length>0,eA=D.length>0,X=h.length>0;if(!J&&!V&&!eA&&!X)return null;const K=async()=>{if(!(!e||!s)){l(k);try{await mA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(T){console.error("Failed to cancel queued message:",T)}}},W=async()=>{if(!(!e||!s))try{await mA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(T){console.error("Failed to delete queued message:",T)}};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative pb-8 pt-6",children:o.jsxs("div",{className:"flex gap-3 md:gap-4 justify-end",children:[o.jsxs("div",{className:"flex flex-col items-end min-w-0 flex-1 max-w-[calc(100%-3rem)] md:max-w-2xl",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground pb-2 justify-end",children:[o.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:"You"}),t.createdAt&&o.jsx("span",{children:"·"}),t.createdAt&&o.jsx("span",{children:O(t.createdAt)}),g&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",children:[o.jsx(Ka,{className:"h-3 w-3"}),"Queued",Q!==null&&Q>0?` #${Q+1}`:""]})]})]}),o.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:[V&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:v.map(T=>o.jsx("button",{type:"button",onClick:()=>r(T.src),className:"w-16 h-16 rounded-lg overflow-hidden bg-muted hover:ring-2 hover:ring-primary/50 transition-all",children:o.jsx("img",{src:T.src,alt:"Attachment",className:"w-full h-full object-cover"})},T.id))}),eA&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:D.map(T=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border",children:[T.type==="pdf"?o.jsx(es,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):o.jsx(ts,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs truncate max-w-[150px]",children:T.name})]},T.id))}),X&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:h.map(T=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30",children:[o.jsx(Er,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs text-teal-600 dark:text-teal-400",children:T.label})]},T.id))}),J&&o.jsx("div",{className:"prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_*]:[word-break:break-word] [&_*]:overflow-wrap-anywhere whitespace-pre-wrap",children:o.jsx(ja,{remarkPlugins:[Ta],components:{a:({href:T,children:L,...w})=>o.jsx("a",{href:T,target:"_blank",rel:"noopener noreferrer",onClick:B=>{window.self!==window.top&&T&&(B.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:T},"*"))},...w,children:L})},children:k.replace(/\n/g,`
113
113
  `)})})]}),g&&o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[o.jsxs("button",{type:"button",onClick:K,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:[o.jsx(jB,{className:"h-3 w-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:W,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:[o.jsx(mr,{className:"h-3 w-3"}),"Delete"]})]})]}),o.jsx("div",{className:"flex-shrink-0 w-8 flex items-start justify-center",children:o.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:o.jsx(Fa,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})})})]})}),n&&o.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>r(null),onKeyDown:T=>T.key==="Escape"&&r(null),tabIndex:-1,children:[o.jsx("button",{type:"button",onClick:()=>r(null),className:"absolute top-4 right-4 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:o.jsx(lt,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:n,alt:"Expanded attachment",className:"max-w-full max-h-full object-contain rounded-lg",onClick:T=>T.stopPropagation(),onKeyDown:T=>T.key==="Enter"&&T.stopPropagation()})]})]})},(A,e)=>{const t=A.message.parts?.[0],s=e.message.parts?.[0];return A.message.id===e.message.id&&t?.content===s?.content&&t?.contentJson===s?.contentJson&&A.message.createdAt===e.message.createdAt&&A.message.parts?.length===e.message.parts?.length&&A.sessionId===e.sessionId&&A.nextAssistantMessageId===e.nextAssistantMessageId}),ym={openai:{id:"openai",models:[{id:"chatgpt-image-latest",ownedBy:"openai",label:"chatgpt-image-latest",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-3.5-turbo",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",label:"GPT-4.1 mini",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",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",ownedBy:"openai",label:"GPT-4o",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",label:"GPT-4o mini",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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:"gpt-5.3-chat-latest",ownedBy:"openai",label:"GPT-5.3 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:32e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:13e4}},{id:"gpt-image-1",ownedBy:"openai",label:"gpt-image-1",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-04-24",lastUpdated:"2025-04-24",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1-mini",ownedBy:"openai",label:"gpt-image-1-mini",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-09-26",lastUpdated:"2025-09-26",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1.5",ownedBy:"openai",label:"gpt-image-1.5",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-11-25",lastUpdated:"2025-11-25",openWeights:!1,limit:{context:0,output:0}},{id:"o1",ownedBy:"openai",label:"o1",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",label:"o3",modalities:{input:["text","image","pdf"],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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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-haiku-20240307",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-sonnet-4-0",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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}},{id:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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:.03},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-image",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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:.125},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-05-06",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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-3.1-flash-image-preview",ownedBy:"google",label:"Gemini 3.1 Flash Image (Preview)",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-26",lastUpdated:"2026-02-26",openWeights:!1,cost:{input:.25,output:60},limit:{context:131072,output:32768}},{id:"gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:1},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-embedding-001",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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}},{id:"gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,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:32768,output:8192}},{id:"gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",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:131072,output:8192}},{id:"gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,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:32768,output:8192}},{id:"gemma-3n-e2b-it",ownedBy:"google",label:"Gemma 3n 2B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],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:2e3}},{id:"gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}},{id:"gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}}],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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-sonnet-4",ownedBy:"anthropic",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",ownedBy:"anthropic",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:"anthropic/claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:128e3}},{id:"arcee-ai/trinity-large-preview:free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"arcee-ai/trinity-large-thinking",label:"Trinity Large Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.22,output:.85},limit:{context:262144,output:8e4}},{id:"black-forest-labs/flux.2-flex",label:"FLUX.2 Flex",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:67344,output:67344}},{id:"black-forest-labs/flux.2-klein-4b",label:"FLUX.2 Klein 4B",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"black-forest-labs/flux.2-max",label:"FLUX.2 Max",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-16",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"black-forest-labs/flux.2-pro",label:"FLUX.2 Pro",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"bytedance-seed/seedream-4.5",label:"Seedream 4.5",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-23",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:4096,output:4096}},{id:"cognitivecomputations/dolphin-mistral-24b-venice-edition:free",label:"Uncensored (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-07-09",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{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",label:"DeepSeek: R1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-01-20",lastUpdated:"2025-01-20",openWeights:!0,cost:{input:.7,output:2.5},limit:{context:64e3,output:16e3}},{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-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}},{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}},{id:"deepseek/deepseek-v4-flash",label:"DeepSeek V4 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:.14,output:.28,cacheRead:.028},limit:{context:1048576,output:393216}},{id:"deepseek/deepseek-v4-pro",label:"DeepSeek V4 Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:1.74,output:3.48,cacheRead:.145},limit:{context:1048576,output:393216}},{id:"google/gemini-2.0-flash-001",ownedBy:"google",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.5-flash",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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:.125},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-05-06",ownedBy:"google",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",ownedBy:"google",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",ownedBy:"google",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}},{id:"google/gemini-3-pro-preview",ownedBy:"google",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}},{id:"google/gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","pdf","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:.083},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemma-2-9b-it",ownedBy:"google",label:"Gemma 2 9B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-06",releaseDate:"2024-06-28",lastUpdated:"2024-06-28",openWeights:!0,cost:{input:.03,output:.09},limit:{context:8192,output:8192}},{id:"google/gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.03,output:.1},limit:{context:131072,output:131072}},{id:"google/gemma-3-12b-it:free",ownedBy:"google",label:"Gemma 3 12B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,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:32768,output:8192}},{id:"google/gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",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:.04,output:.15},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-27b-it:free",ownedBy:"google",label:"Gemma 3 27B (free)",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:131072,output:8192}},{id:"google/gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.01703,output:.06815},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-4b-it:free",ownedBy:"google",label:"Gemma 3 4B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,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:32768,output:8192}},{id:"google/gemma-3n-e2b-it:free",ownedBy:"google",label:"Gemma 3n 2B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:.02,output:.04},limit:{context:32768,output:32768}},{id:"google/gemma-3n-e4b-it:free",ownedBy:"google",label:"Gemma 3n 4B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B A4B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.13,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-26b-a4b-it:free",ownedBy:"google",label:"Gemma 4 26B A4B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"google/gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:.14,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-31b-it:free",ownedBy:"google",label:"Gemma 4 31B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"inception/mercury-2",label:"Mercury 2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-04",lastUpdated:"2026-03-04",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:5e4}},{id:"inception/mercury-edit-2",label:"Mercury Edit 2",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:8192}},{id:"liquid/lfm-2.5-1.2b-instruct:free",label:"LFM2.5-1.2B-Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"liquid/lfm-2.5-1.2b-thinking:free",label:"LFM2.5-1.2B-Thinking (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{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.2-3b-instruct:free",label:"Llama 3.2 3B Instruct (free)",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:131072}},{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:131072,output:131072}},{id:"minimax/minimax-01",ownedBy:"minimax",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",ownedBy:"minimax",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",ownedBy:"minimax",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}},{id:"minimax/minimax-m2.1",ownedBy:"minimax",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}},{id:"minimax/minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.5:free",ownedBy:"minimax",label:"MiniMax M2.5 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{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-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-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-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-small-2603",label:"Mistral Small 4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{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:"moonshotai/kimi-k2",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",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:"moonshotai/kimi-k2.5",ownedBy:"moonshot",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}},{id:"moonshotai/kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:262144}},{id:"nousresearch/hermes-3-llama-3.1-405b:free",label:"Hermes 3 405B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2024-08-16",lastUpdated:"2024-08-16",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{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-3-nano-30b-a3b:free",label:"Nemotron 3 Nano 30B A3B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-12-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:256e3,output:256e3}},{id:"nvidia/nemotron-3-super-120b-a12b",label:"Nemotron 3 Super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:.1,output:.5},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-3-super-120b-a12b:free",label:"Nemotron 3 Super (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-nano-12b-v2-vl:free",label:"Nemotron Nano 12B 2 VL (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-10-28",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{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:"nvidia/nemotron-nano-9b-v2:free",label:"Nemotron Nano 9B V2 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-09-05",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"openai/gpt-4.1",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3}},{id:"openai/gpt-oss-120b",ownedBy:"openai",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",ownedBy:"openai",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-120b:free",ownedBy:"openai",label:"gpt-oss-120b (free)",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:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b",ownedBy:"openai",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-20b:free",ownedBy:"openai",label:"gpt-oss-20b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-safeguard-20b",ownedBy:"openai",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",ownedBy:"openai",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/elephant-alpha",label:"Elephant (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-13",lastUpdated:"2026-04-13",openWeights:!1,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"openrouter/free",label:"Free Models Router",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-01",lastUpdated:"2026-02-01",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:8e3}},{id:"prime-intellect/intellect-3",ownedBy:"zai",label:"Intellect 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:131072,output:8192}},{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-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/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-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-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-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-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/qwen3.5-397b-a17b",label:"Qwen3.5 397B A17B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!0,cost:{input:.6,output:3.6},limit:{context:262144,output:65536}},{id:"qwen/qwen3.5-flash-02-23",label:"Qwen: Qwen3.5-Flash",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-25",lastUpdated:"2026-02-25",openWeights:!1,cost:{input:.065,output:.26},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.5-plus-02-15",label:"Qwen3.5 Plus 2026-02-15",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.4,output:2.4},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.325,output:1.95},limit:{context:1e6,output:65536}},{id:"sourceful/riverflow-v2-fast-preview",label:"Riverflow V2 Fast Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-max-preview",label:"Riverflow V2 Max Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-standard-preview",label:"Riverflow V2 Standard Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"stepfun/step-3.5-flash",label:"Step 3.5 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-29",lastUpdated:"2026-01-29",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.02},limit:{context:256e3,output:256e3}},{id:"x-ai/grok-3",ownedBy:"xai",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",ownedBy:"xai",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",ownedBy:"xai",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",ownedBy:"xai",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",ownedBy:"xai",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",ownedBy:"xai",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",ownedBy:"xai",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-4.20-beta",ownedBy:"xai",label:"Grok 4.20 Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.20-multi-agent-beta",ownedBy:"xai",label:"Grok 4.20 Multi - Agent Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-code-fast-1",ownedBy:"xai",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:"xiaomi/mimo-v2-flash",label:"MiMo-V2-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2025-12-14",lastUpdated:"2025-12-14",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.01},limit:{context:262144,output:65536}},{id:"xiaomi/mimo-v2-omni",label:"MiMo-V2-Omni",modalities:{input:["text","image","video","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.4,output:2,cacheRead:.08},limit:{context:262144,output:65536}},{id:"xiaomi/mimo-v2-pro",label:"MiMo-V2-Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:1,output:3,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"z-ai/glm-4.5",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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}},{id:"z-ai/glm-4.7-flash",ownedBy:"zai",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:.07,output:.4},limit:{context:2e5,output:65535}},{id:"z-ai/glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:202752,output:131e3}},{id:"z-ai/glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:.96,output:3.2,cacheRead:.192,cacheWrite:0},limit:{context:202752,output:131072}},{id:"z-ai/glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:202752,output:131072}}],label:"OpenRouter",env:["OPENROUTER_API_KEY"],npm:"@openrouter/ai-sdk-provider",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},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-3-5-haiku",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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",ownedBy:"anthropic",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-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4",ownedBy:"anthropic",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",ownedBy:"anthropic",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:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",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",ownedBy:"google",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",ownedBy:"google",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:"gemini-3.1-pro",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"glm-4.6",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",label:"GLM-4.7 Free",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:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:204800,output:131072}},{id:"glm-5-free",ownedBy:"zai",label:"GLM-5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:204800,output:131072}},{id:"gpt-5",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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",ownedBy:"openai",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:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"grok-code",ownedBy:"xai",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:"hy3-preview-free",label:"Hy3 preview Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:256e3,output:64e3}},{id:"kimi-k2",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.08},limit:{context:262144,output:65536}},{id:"kimi-k2.5-free",ownedBy:"moonshot",label:"Kimi K2.5 Free",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:65536}},{id:"ling-2.6-flash-free",label:"Ling 2.6 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:0,output:0},limit:{context:262100,output:32800}},{id:"mimo-v2-flash-free",label:"MiMo V2 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:65536}},{id:"mimo-v2-omni-free",label:"MiMo V2 Omni Free",modalities:{input:["text","image","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:64e3}},{id:"mimo-v2-pro-free",label:"MiMo V2 Pro Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"minimax-m2.1",ownedBy:"minimax",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",ownedBy:"minimax",label:"MiniMax M2.1 Free",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:"minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"minimax-m2.5-free",ownedBy:"minimax",label:"MiniMax M2.5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"nemotron-3-super-free",label:"Nemotron 3 Super Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2026-02",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:128e3}},{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}},{id:"qwen3.5-plus",label:"Qwen3.5 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.625},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus-free",label:"Qwen3.6 Plus Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"trinity-large-preview-free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}}],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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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}},{id:"glm-4.7-flash",ownedBy:"zai",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}},{id:"glm-4.7-flashx",ownedBy:"zai",label:"GLM-4.7-FlashX",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:.07,output:.4,cacheRead:.01,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"glm-5v-turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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",ownedBy:"zai",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}},{id:"glm-4.7-flashx",ownedBy:"zai",label:"GLM-4.7-FlashX",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:.07,output:.4,cacheRead:.01,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"glm-5v-turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,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",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",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",ownedBy:"moonshot",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}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2026-01",lastUpdated:"2026-01",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},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"},minimax:{id:"minimax",models:[{id:"MiniMax-M2",ownedBy:"minimax",label:"MiniMax-M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-27",lastUpdated:"2025-10-27",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:196608,output:128e3}},{id:"MiniMax-M2.1",ownedBy:"minimax",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}},{id:"MiniMax-M2.5",ownedBy:"minimax",label:"MiniMax-M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.5-highspeed",ownedBy:"minimax",label:"MiniMax-M2.5-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-13",lastUpdated:"2026-02-13",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7",ownedBy:"minimax",label:"MiniMax-M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7-highspeed",ownedBy:"minimax",label:"MiniMax-M2.7-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}}],label:"MiniMax (minimax.io)",env:["MINIMAX_API_KEY"],npm:"@ai-sdk/anthropic",api:"https://api.minimax.io/anthropic/v1",doc:"https://platform.minimax.io/docs/guides/quickstart"},copilot:{id:"copilot",models:[{id:"claude-haiku-4.5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image"],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:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-opus-4.5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-08-01",openWeights:!1,cost:{input:0,output:0},limit:{context:16e4,output:32e3}},{id:"claude-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-41",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:0,output:0},limit:{context:8e4,output:16e3}},{id:"claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image"],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:0,output:0},limit:{context:216e3,output:16e3}},{id:"claude-sonnet-4.5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:32e3}},{id:"gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash",modalities:{input:["text","image","audio","video"],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:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video"],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:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gpt-4.1",ownedBy:"openai",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:0,output:0},limit:{context:128e3,output:16384}},{id:"gpt-4o",ownedBy:"openai",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-05-13",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:4096}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"gpt-5-mini",ownedBy:"openai",label:"GPT-5-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-08-13",lastUpdated:"2025-08-13",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1",ownedBy:"openai",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:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",ownedBy:"openai",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-12-04",lastUpdated:"2025-12-04",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1-Codex-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",ownedBy:"openai",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:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-27",lastUpdated:"2025-08-27",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}}],label:"GitHub Copilot",env:["GITHUB_TOKEN"],npm:"@ai-sdk/openai-compatible",api:"https://api.githubcopilot.com",doc:"https://docs.github.com/en/copilot"},"ollama-cloud":{id:"ollama-cloud",models:[{id:"cogito-2.1:671b",label:"cogito-2.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-11-19",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:32e3}},{id:"deepseek-v3.1:671b",label:"deepseek-v3.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-21",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:163840}},{id:"deepseek-v3.2",label:"deepseek-v3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-06-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:65536}},{id:"devstral-2:123b",label:"devstral-2:123b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"devstral-small-2:24b",label:"devstral-small-2:24b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"gemini-3-flash-preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:1048576,output:65536}},{id:"gemma3:12b",label:"gemma3:12b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:27b",label:"gemma3:27b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2025-07-27",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:4b",label:"gemma3:4b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma4:31b",label:"gemma4:31b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:262144,output:262144}},{id:"glm-4.6",ownedBy:"zai",label:"glm-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-29",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-4.7",ownedBy:"zai",label:"glm-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5",ownedBy:"zai",label:"glm-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"glm-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-27",lastUpdated:"2026-04-07",openWeights:!0,limit:{context:202752,output:131072}},{id:"gpt-oss:120b",ownedBy:"openai",label:"gpt-oss:120b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"gpt-oss:20b",ownedBy:"openai",label:"gpt-oss:20b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"kimi-k2-thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2:1t",ownedBy:"moonshot",label:"kimi-k2:1t",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"kimi-k2.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.6:cloud",ownedBy:"moonshot",label:"kimi-k2.6:cloud",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,limit:{context:262144,output:262144}},{id:"minimax-m2",ownedBy:"minimax",label:"minimax-m2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-10-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:128e3}},{id:"minimax-m2.1",ownedBy:"minimax",label:"minimax-m2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.5",ownedBy:"minimax",label:"minimax-m2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.7",ownedBy:"minimax",label:"minimax-m2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,limit:{context:204800,output:131072}},{id:"ministral-3:14b",label:"ministral-3:14b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:3b",label:"ministral-3:3b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-10-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:8b",label:"ministral-3:8b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"mistral-large-3:675b",label:"mistral-large-3:675b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-02",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"nemotron-3-nano:30b",label:"nemotron-3-nano:30b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:1048576,output:131072}},{id:"nemotron-3-super",label:"nemotron-3-super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-11",lastUpdated:"2026-03-12",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder-next",label:"qwen3-coder-next",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2026-02-02",lastUpdated:"2026-02-08",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder:480b",label:"qwen3-coder:480b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-07-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-next:80b",label:"qwen3-next:80b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b",label:"qwen3-vl:235b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b-instruct",label:"qwen3-vl:235b-instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:131072}},{id:"qwen3.5:397b",label:"qwen3.5:397b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-02-15",lastUpdated:"2026-02-17",openWeights:!0,limit:{context:262144,output:81920}},{id:"rnj-1:8b",label:"rnj-1:8b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:32768,output:4096}}],label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud"}};var Ei={},sr={},NQ;function Nm(){if(NQ)return sr;NQ=1,sr.byteLength=a,sr.toByteArray=Q,sr.fromByteArray=I;for(var A=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,r=s.length;n<r;++n)A[n]=s[n],e[s.charCodeAt(n)]=n;e[45]=62,e[95]=63;function i(c){var u=c.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=c.indexOf("=");f===-1&&(f=u);var h=f===u?0:4-f%4;return[f,h]}function a(c){var u=i(c),f=u[0],h=u[1];return(f+h)*3/4-h}function g(c,u,f){return(u+f)*3/4-f}function Q(c){var u,f=i(c),h=f[0],k=f[1],v=new t(g(c,h,k)),D=0,O=k>0?h-4:h,J;for(J=0;J<O;J+=4)u=e[c.charCodeAt(J)]<<18|e[c.charCodeAt(J+1)]<<12|e[c.charCodeAt(J+2)]<<6|e[c.charCodeAt(J+3)],v[D++]=u>>16&255,v[D++]=u>>8&255,v[D++]=u&255;return k===2&&(u=e[c.charCodeAt(J)]<<2|e[c.charCodeAt(J+1)]>>4,v[D++]=u&255),k===1&&(u=e[c.charCodeAt(J)]<<10|e[c.charCodeAt(J+1)]<<4|e[c.charCodeAt(J+2)]>>2,v[D++]=u>>8&255,v[D++]=u&255),v}function l(c){return A[c>>18&63]+A[c>>12&63]+A[c>>6&63]+A[c&63]}function C(c,u,f){for(var h,k=[],v=u;v<f;v+=3)h=(c[v]<<16&16711680)+(c[v+1]<<8&65280)+(c[v+2]&255),k.push(l(h));return k.join("")}function I(c){for(var u,f=c.length,h=f%3,k=[],v=16383,D=0,O=f-h;D<O;D+=v)k.push(C(c,D,D+v>O?O:D+v));return h===1?(u=c[f-1],k.push(A[u>>2]+A[u<<4&63]+"==")):h===2&&(u=(c[f-2]<<8)+c[f-1],k.push(A[u>>10]+A[u>>4&63]+A[u<<2&63]+"=")),k.join("")}return sr}var Hr={};var kQ;function km(){return kQ||(kQ=1,Hr.read=function(A,e,t,s,n){var r,i,a=n*8-s-1,g=(1<<a)-1,Q=g>>1,l=-7,C=t?n-1:0,I=t?-1:1,c=A[e+C];for(C+=I,r=c&(1<<-l)-1,c>>=-l,l+=a;l>0;r=r*256+A[e+C],C+=I,l-=8);for(i=r&(1<<-l)-1,r>>=-l,l+=s;l>0;i=i*256+A[e+C],C+=I,l-=8);if(r===0)r=1-Q;else{if(r===g)return i?NaN:(c?-1:1)*(1/0);i=i+Math.pow(2,s),r=r-Q}return(c?-1:1)*i*Math.pow(2,r-s)},Hr.write=function(A,e,t,s,n,r){var i,a,g,Q=r*8-n-1,l=(1<<Q)-1,C=l>>1,I=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,c=s?0:r-1,u=s?1:-1,f=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=l):(i=Math.floor(Math.log(e)/Math.LN2),e*(g=Math.pow(2,-i))<1&&(i--,g*=2),i+C>=1?e+=I/g:e+=I*Math.pow(2,1-C),e*g>=2&&(i++,g/=2),i+C>=l?(a=0,i=l):i+C>=1?(a=(e*g-1)*Math.pow(2,n),i=i+C):(a=e*Math.pow(2,C-1)*Math.pow(2,n),i=0));n>=8;A[t+c]=a&255,c+=u,a/=256,n-=8);for(i=i<<n|a,Q+=n;Q>0;A[t+c]=i&255,c+=u,i/=256,Q-=8);A[t+c-u]|=f*128}),Hr}var MQ;function ag(){return MQ||(MQ=1,(function(A){const e=Nm(),t=km(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;A.Buffer=a,A.SlowBuffer=v,A.INSPECT_MAX_BYTES=50;const n=2147483647;A.kMaxLength=n,a.TYPED_ARRAY_SUPPORT=r(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function r(){try{const q=new Uint8Array(1),y={foo:function(){return 42}};return Object.setPrototypeOf(y,Uint8Array.prototype),Object.setPrototypeOf(q,y),q.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function i(q){if(q>n)throw new RangeError('The value "'+q+'" is invalid for option "size"');const y=new Uint8Array(q);return Object.setPrototypeOf(y,a.prototype),y}function a(q,y,M){if(typeof q=="number"){if(typeof y=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(q)}return g(q,y,M)}a.poolSize=8192;function g(q,y,M){if(typeof q=="string")return I(q,y);if(ArrayBuffer.isView(q))return u(q);if(q==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q);if(nt(q,ArrayBuffer)||q&&nt(q.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(q,SharedArrayBuffer)||q&&nt(q.buffer,SharedArrayBuffer)))return f(q,y,M);if(typeof q=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Z=q.valueOf&&q.valueOf();if(Z!=null&&Z!==q)return a.from(Z,y,M);const AA=h(q);if(AA)return AA;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]=="function")return a.from(q[Symbol.toPrimitive]("string"),y,M);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q)}a.from=function(q,y,M){return g(q,y,M)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function Q(q){if(typeof q!="number")throw new TypeError('"size" argument must be of type number');if(q<0)throw new RangeError('The value "'+q+'" is invalid for option "size"')}function l(q,y,M){return Q(q),q<=0?i(q):y!==void 0?typeof M=="string"?i(q).fill(y,M):i(q).fill(y):i(q)}a.alloc=function(q,y,M){return l(q,y,M)};function C(q){return Q(q),i(q<0?0:k(q)|0)}a.allocUnsafe=function(q){return C(q)},a.allocUnsafeSlow=function(q){return C(q)};function I(q,y){if((typeof y!="string"||y==="")&&(y="utf8"),!a.isEncoding(y))throw new TypeError("Unknown encoding: "+y);const M=D(q,y)|0;let Z=i(M);const AA=Z.write(q,y);return AA!==M&&(Z=Z.slice(0,AA)),Z}function c(q){const y=q.length<0?0:k(q.length)|0,M=i(y);for(let Z=0;Z<y;Z+=1)M[Z]=q[Z]&255;return M}function u(q){if(nt(q,Uint8Array)){const y=new Uint8Array(q);return f(y.buffer,y.byteOffset,y.byteLength)}return c(q)}function f(q,y,M){if(y<0||q.byteLength<y)throw new RangeError('"offset" is outside of buffer bounds');if(q.byteLength<y+(M||0))throw new RangeError('"length" is outside of buffer bounds');let Z;return y===void 0&&M===void 0?Z=new Uint8Array(q):M===void 0?Z=new Uint8Array(q,y):Z=new Uint8Array(q,y,M),Object.setPrototypeOf(Z,a.prototype),Z}function h(q){if(a.isBuffer(q)){const y=k(q.length)|0,M=i(y);return M.length===0||q.copy(M,0,0,y),M}if(q.length!==void 0)return typeof q.length!="number"||ve(q.length)?i(0):c(q);if(q.type==="Buffer"&&Array.isArray(q.data))return c(q.data)}function k(q){if(q>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return q|0}function v(q){return+q!=q&&(q=0),a.alloc(+q)}a.isBuffer=function(y){return y!=null&&y._isBuffer===!0&&y!==a.prototype},a.compare=function(y,M){if(nt(y,Uint8Array)&&(y=a.from(y,y.offset,y.byteLength)),nt(M,Uint8Array)&&(M=a.from(M,M.offset,M.byteLength)),!a.isBuffer(y)||!a.isBuffer(M))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(y===M)return 0;let Z=y.length,AA=M.length;for(let nA=0,cA=Math.min(Z,AA);nA<cA;++nA)if(y[nA]!==M[nA]){Z=y[nA],AA=M[nA];break}return Z<AA?-1:AA<Z?1:0},a.isEncoding=function(y){switch(String(y).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(y,M){if(!Array.isArray(y))throw new TypeError('"list" argument must be an Array of Buffers');if(y.length===0)return a.alloc(0);let Z;if(M===void 0)for(M=0,Z=0;Z<y.length;++Z)M+=y[Z].length;const AA=a.allocUnsafe(M);let nA=0;for(Z=0;Z<y.length;++Z){let cA=y[Z];if(nt(cA,Uint8Array))nA+cA.length>AA.length?(a.isBuffer(cA)||(cA=a.from(cA)),cA.copy(AA,nA)):Uint8Array.prototype.set.call(AA,cA,nA);else if(a.isBuffer(cA))cA.copy(AA,nA);else throw new TypeError('"list" argument must be an Array of Buffers');nA+=cA.length}return AA};function D(q,y){if(a.isBuffer(q))return q.length;if(ArrayBuffer.isView(q)||nt(q,ArrayBuffer))return q.byteLength;if(typeof q!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof q);const M=q.length,Z=arguments.length>2&&arguments[2]===!0;if(!Z&&M===0)return 0;let AA=!1;for(;;)switch(y){case"ascii":case"latin1":case"binary":return M;case"utf8":case"utf-8":return VA(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M*2;case"hex":return M>>>1;case"base64":return le(q).length;default:if(AA)return Z?-1:VA(q).length;y=(""+y).toLowerCase(),AA=!0}}a.byteLength=D;function O(q,y,M){let Z=!1;if((y===void 0||y<0)&&(y=0),y>this.length||((M===void 0||M>this.length)&&(M=this.length),M<=0)||(M>>>=0,y>>>=0,M<=y))return"";for(q||(q="utf8");;)switch(q){case"hex":return j(this,y,M);case"utf8":case"utf-8":return B(this,y,M);case"ascii":return G(this,y,M);case"latin1":case"binary":return S(this,y,M);case"base64":return w(this,y,M);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,y,M);default:if(Z)throw new TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),Z=!0}}a.prototype._isBuffer=!0;function J(q,y,M){const Z=q[y];q[y]=q[M],q[M]=Z}a.prototype.swap16=function(){const y=this.length;if(y%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let M=0;M<y;M+=2)J(this,M,M+1);return this},a.prototype.swap32=function(){const y=this.length;if(y%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let M=0;M<y;M+=4)J(this,M,M+3),J(this,M+1,M+2);return this},a.prototype.swap64=function(){const y=this.length;if(y%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let M=0;M<y;M+=8)J(this,M,M+7),J(this,M+1,M+6),J(this,M+2,M+5),J(this,M+3,M+4);return this},a.prototype.toString=function(){const y=this.length;return y===0?"":arguments.length===0?B(this,0,y):O.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(y){if(!a.isBuffer(y))throw new TypeError("Argument must be a Buffer");return this===y?!0:a.compare(this,y)===0},a.prototype.inspect=function(){let y="";const M=A.INSPECT_MAX_BYTES;return y=this.toString("hex",0,M).replace(/(.{2})/g,"$1 ").trim(),this.length>M&&(y+=" ... "),"<Buffer "+y+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(y,M,Z,AA,nA){if(nt(y,Uint8Array)&&(y=a.from(y,y.offset,y.byteLength)),!a.isBuffer(y))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof y);if(M===void 0&&(M=0),Z===void 0&&(Z=y?y.length:0),AA===void 0&&(AA=0),nA===void 0&&(nA=this.length),M<0||Z>y.length||AA<0||nA>this.length)throw new RangeError("out of range index");if(AA>=nA&&M>=Z)return 0;if(AA>=nA)return-1;if(M>=Z)return 1;if(M>>>=0,Z>>>=0,AA>>>=0,nA>>>=0,this===y)return 0;let cA=nA-AA,zA=Z-M;const PA=Math.min(cA,zA),ZA=this.slice(AA,nA),Se=y.slice(M,Z);for(let WA=0;WA<PA;++WA)if(ZA[WA]!==Se[WA]){cA=ZA[WA],zA=Se[WA];break}return cA<zA?-1:zA<cA?1:0};function V(q,y,M,Z,AA){if(q.length===0)return-1;if(typeof M=="string"?(Z=M,M=0):M>2147483647?M=2147483647:M<-2147483648&&(M=-2147483648),M=+M,ve(M)&&(M=AA?0:q.length-1),M<0&&(M=q.length+M),M>=q.length){if(AA)return-1;M=q.length-1}else if(M<0)if(AA)M=0;else return-1;if(typeof y=="string"&&(y=a.from(y,Z)),a.isBuffer(y))return y.length===0?-1:eA(q,y,M,Z,AA);if(typeof y=="number")return y=y&255,typeof Uint8Array.prototype.indexOf=="function"?AA?Uint8Array.prototype.indexOf.call(q,y,M):Uint8Array.prototype.lastIndexOf.call(q,y,M):eA(q,[y],M,Z,AA);throw new TypeError("val must be string, number or Buffer")}function eA(q,y,M,Z,AA){let nA=1,cA=q.length,zA=y.length;if(Z!==void 0&&(Z=String(Z).toLowerCase(),Z==="ucs2"||Z==="ucs-2"||Z==="utf16le"||Z==="utf-16le")){if(q.length<2||y.length<2)return-1;nA=2,cA/=2,zA/=2,M/=2}function PA(Se,WA){return nA===1?Se[WA]:Se.readUInt16BE(WA*nA)}let ZA;if(AA){let Se=-1;for(ZA=M;ZA<cA;ZA++)if(PA(q,ZA)===PA(y,Se===-1?0:ZA-Se)){if(Se===-1&&(Se=ZA),ZA-Se+1===zA)return Se*nA}else Se!==-1&&(ZA-=ZA-Se),Se=-1}else for(M+zA>cA&&(M=cA-zA),ZA=M;ZA>=0;ZA--){let Se=!0;for(let WA=0;WA<zA;WA++)if(PA(q,ZA+WA)!==PA(y,WA)){Se=!1;break}if(Se)return ZA}return-1}a.prototype.includes=function(y,M,Z){return this.indexOf(y,M,Z)!==-1},a.prototype.indexOf=function(y,M,Z){return V(this,y,M,Z,!0)},a.prototype.lastIndexOf=function(y,M,Z){return V(this,y,M,Z,!1)};function X(q,y,M,Z){M=Number(M)||0;const AA=q.length-M;Z?(Z=Number(Z),Z>AA&&(Z=AA)):Z=AA;const nA=y.length;Z>nA/2&&(Z=nA/2);let cA;for(cA=0;cA<Z;++cA){const zA=parseInt(y.substr(cA*2,2),16);if(ve(zA))return cA;q[M+cA]=zA}return cA}function K(q,y,M,Z){return Ge(VA(y,q.length-M),q,M,Z)}function W(q,y,M,Z){return Ge(ae(y),q,M,Z)}function T(q,y,M,Z){return Ge(le(y),q,M,Z)}function L(q,y,M,Z){return Ge(He(y,q.length-M),q,M,Z)}a.prototype.write=function(y,M,Z,AA){if(M===void 0)AA="utf8",Z=this.length,M=0;else if(Z===void 0&&typeof M=="string")AA=M,Z=this.length,M=0;else if(isFinite(M))M=M>>>0,isFinite(Z)?(Z=Z>>>0,AA===void 0&&(AA="utf8")):(AA=Z,Z=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const nA=this.length-M;if((Z===void 0||Z>nA)&&(Z=nA),y.length>0&&(Z<0||M<0)||M>this.length)throw new RangeError("Attempt to write outside buffer bounds");AA||(AA="utf8");let cA=!1;for(;;)switch(AA){case"hex":return X(this,y,M,Z);case"utf8":case"utf-8":return K(this,y,M,Z);case"ascii":case"latin1":case"binary":return W(this,y,M,Z);case"base64":return T(this,y,M,Z);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,y,M,Z);default:if(cA)throw new TypeError("Unknown encoding: "+AA);AA=(""+AA).toLowerCase(),cA=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(q,y,M){return y===0&&M===q.length?e.fromByteArray(q):e.fromByteArray(q.slice(y,M))}function B(q,y,M){M=Math.min(q.length,M);const Z=[];let AA=y;for(;AA<M;){const nA=q[AA];let cA=null,zA=nA>239?4:nA>223?3:nA>191?2:1;if(AA+zA<=M){let PA,ZA,Se,WA;switch(zA){case 1:nA<128&&(cA=nA);break;case 2:PA=q[AA+1],(PA&192)===128&&(WA=(nA&31)<<6|PA&63,WA>127&&(cA=WA));break;case 3:PA=q[AA+1],ZA=q[AA+2],(PA&192)===128&&(ZA&192)===128&&(WA=(nA&15)<<12|(PA&63)<<6|ZA&63,WA>2047&&(WA<55296||WA>57343)&&(cA=WA));break;case 4:PA=q[AA+1],ZA=q[AA+2],Se=q[AA+3],(PA&192)===128&&(ZA&192)===128&&(Se&192)===128&&(WA=(nA&15)<<18|(PA&63)<<12|(ZA&63)<<6|Se&63,WA>65535&&WA<1114112&&(cA=WA))}}cA===null?(cA=65533,zA=1):cA>65535&&(cA-=65536,Z.push(cA>>>10&1023|55296),cA=56320|cA&1023),Z.push(cA),AA+=zA}return N(Z)}const d=4096;function N(q){const y=q.length;if(y<=d)return String.fromCharCode.apply(String,q);let M="",Z=0;for(;Z<y;)M+=String.fromCharCode.apply(String,q.slice(Z,Z+=d));return M}function G(q,y,M){let Z="";M=Math.min(q.length,M);for(let AA=y;AA<M;++AA)Z+=String.fromCharCode(q[AA]&127);return Z}function S(q,y,M){let Z="";M=Math.min(q.length,M);for(let AA=y;AA<M;++AA)Z+=String.fromCharCode(q[AA]);return Z}function j(q,y,M){const Z=q.length;(!y||y<0)&&(y=0),(!M||M<0||M>Z)&&(M=Z);let AA="";for(let nA=y;nA<M;++nA)AA+=yA[q[nA]];return AA}function H(q,y,M){const Z=q.slice(y,M);let AA="";for(let nA=0;nA<Z.length-1;nA+=2)AA+=String.fromCharCode(Z[nA]+Z[nA+1]*256);return AA}a.prototype.slice=function(y,M){const Z=this.length;y=~~y,M=M===void 0?Z:~~M,y<0?(y+=Z,y<0&&(y=0)):y>Z&&(y=Z),M<0?(M+=Z,M<0&&(M=0)):M>Z&&(M=Z),M<y&&(M=y);const AA=this.subarray(y,M);return Object.setPrototypeOf(AA,a.prototype),AA};function b(q,y,M){if(q%1!==0||q<0)throw new RangeError("offset is not uint");if(q+y>M)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(y,M,Z){y=y>>>0,M=M>>>0,Z||b(y,M,this.length);let AA=this[y],nA=1,cA=0;for(;++cA<M&&(nA*=256);)AA+=this[y+cA]*nA;return AA},a.prototype.readUintBE=a.prototype.readUIntBE=function(y,M,Z){y=y>>>0,M=M>>>0,Z||b(y,M,this.length);let AA=this[y+--M],nA=1;for(;M>0&&(nA*=256);)AA+=this[y+--M]*nA;return AA},a.prototype.readUint8=a.prototype.readUInt8=function(y,M){return y=y>>>0,M||b(y,1,this.length),this[y]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(y,M){return y=y>>>0,M||b(y,2,this.length),this[y]|this[y+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(y,M){return y=y>>>0,M||b(y,2,this.length),this[y]<<8|this[y+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(y,M){return y=y>>>0,M||b(y,4,this.length),(this[y]|this[y+1]<<8|this[y+2]<<16)+this[y+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(y,M){return y=y>>>0,M||b(y,4,this.length),this[y]*16777216+(this[y+1]<<16|this[y+2]<<8|this[y+3])},a.prototype.readBigUInt64LE=pe(function(y){y=y>>>0,qA(y,"offset");const M=this[y],Z=this[y+7];(M===void 0||Z===void 0)&&re(y,this.length-8);const AA=M+this[++y]*2**8+this[++y]*2**16+this[++y]*2**24,nA=this[++y]+this[++y]*2**8+this[++y]*2**16+Z*2**24;return BigInt(AA)+(BigInt(nA)<<BigInt(32))}),a.prototype.readBigUInt64BE=pe(function(y){y=y>>>0,qA(y,"offset");const M=this[y],Z=this[y+7];(M===void 0||Z===void 0)&&re(y,this.length-8);const AA=M*2**24+this[++y]*2**16+this[++y]*2**8+this[++y],nA=this[++y]*2**24+this[++y]*2**16+this[++y]*2**8+Z;return(BigInt(AA)<<BigInt(32))+BigInt(nA)}),a.prototype.readIntLE=function(y,M,Z){y=y>>>0,M=M>>>0,Z||b(y,M,this.length);let AA=this[y],nA=1,cA=0;for(;++cA<M&&(nA*=256);)AA+=this[y+cA]*nA;return nA*=128,AA>=nA&&(AA-=Math.pow(2,8*M)),AA},a.prototype.readIntBE=function(y,M,Z){y=y>>>0,M=M>>>0,Z||b(y,M,this.length);let AA=M,nA=1,cA=this[y+--AA];for(;AA>0&&(nA*=256);)cA+=this[y+--AA]*nA;return nA*=128,cA>=nA&&(cA-=Math.pow(2,8*M)),cA},a.prototype.readInt8=function(y,M){return y=y>>>0,M||b(y,1,this.length),this[y]&128?(255-this[y]+1)*-1:this[y]},a.prototype.readInt16LE=function(y,M){y=y>>>0,M||b(y,2,this.length);const Z=this[y]|this[y+1]<<8;return Z&32768?Z|4294901760:Z},a.prototype.readInt16BE=function(y,M){y=y>>>0,M||b(y,2,this.length);const Z=this[y+1]|this[y]<<8;return Z&32768?Z|4294901760:Z},a.prototype.readInt32LE=function(y,M){return y=y>>>0,M||b(y,4,this.length),this[y]|this[y+1]<<8|this[y+2]<<16|this[y+3]<<24},a.prototype.readInt32BE=function(y,M){return y=y>>>0,M||b(y,4,this.length),this[y]<<24|this[y+1]<<16|this[y+2]<<8|this[y+3]},a.prototype.readBigInt64LE=pe(function(y){y=y>>>0,qA(y,"offset");const M=this[y],Z=this[y+7];(M===void 0||Z===void 0)&&re(y,this.length-8);const AA=this[y+4]+this[y+5]*2**8+this[y+6]*2**16+(Z<<24);return(BigInt(AA)<<BigInt(32))+BigInt(M+this[++y]*2**8+this[++y]*2**16+this[++y]*2**24)}),a.prototype.readBigInt64BE=pe(function(y){y=y>>>0,qA(y,"offset");const M=this[y],Z=this[y+7];(M===void 0||Z===void 0)&&re(y,this.length-8);const AA=(M<<24)+this[++y]*2**16+this[++y]*2**8+this[++y];return(BigInt(AA)<<BigInt(32))+BigInt(this[++y]*2**24+this[++y]*2**16+this[++y]*2**8+Z)}),a.prototype.readFloatLE=function(y,M){return y=y>>>0,M||b(y,4,this.length),t.read(this,y,!0,23,4)},a.prototype.readFloatBE=function(y,M){return y=y>>>0,M||b(y,4,this.length),t.read(this,y,!1,23,4)},a.prototype.readDoubleLE=function(y,M){return y=y>>>0,M||b(y,8,this.length),t.read(this,y,!0,52,8)},a.prototype.readDoubleBE=function(y,M){return y=y>>>0,M||b(y,8,this.length),t.read(this,y,!1,52,8)};function E(q,y,M,Z,AA,nA){if(!a.isBuffer(q))throw new TypeError('"buffer" argument must be a Buffer instance');if(y>AA||y<nA)throw new RangeError('"value" argument is out of bounds');if(M+Z>q.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(y,M,Z,AA){if(y=+y,M=M>>>0,Z=Z>>>0,!AA){const zA=Math.pow(2,8*Z)-1;E(this,y,M,Z,zA,0)}let nA=1,cA=0;for(this[M]=y&255;++cA<Z&&(nA*=256);)this[M+cA]=y/nA&255;return M+Z},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(y,M,Z,AA){if(y=+y,M=M>>>0,Z=Z>>>0,!AA){const zA=Math.pow(2,8*Z)-1;E(this,y,M,Z,zA,0)}let nA=Z-1,cA=1;for(this[M+nA]=y&255;--nA>=0&&(cA*=256);)this[M+nA]=y/cA&255;return M+Z},a.prototype.writeUint8=a.prototype.writeUInt8=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,1,255,0),this[M]=y&255,M+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,2,65535,0),this[M]=y&255,this[M+1]=y>>>8,M+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,2,65535,0),this[M]=y>>>8,this[M+1]=y&255,M+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,4,4294967295,0),this[M+3]=y>>>24,this[M+2]=y>>>16,this[M+1]=y>>>8,this[M]=y&255,M+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,4,4294967295,0),this[M]=y>>>24,this[M+1]=y>>>16,this[M+2]=y>>>8,this[M+3]=y&255,M+4};function p(q,y,M,Z,AA){lA(y,Z,AA,q,M,7);let nA=Number(y&BigInt(4294967295));q[M++]=nA,nA=nA>>8,q[M++]=nA,nA=nA>>8,q[M++]=nA,nA=nA>>8,q[M++]=nA;let cA=Number(y>>BigInt(32)&BigInt(4294967295));return q[M++]=cA,cA=cA>>8,q[M++]=cA,cA=cA>>8,q[M++]=cA,cA=cA>>8,q[M++]=cA,M}function U(q,y,M,Z,AA){lA(y,Z,AA,q,M,7);let nA=Number(y&BigInt(4294967295));q[M+7]=nA,nA=nA>>8,q[M+6]=nA,nA=nA>>8,q[M+5]=nA,nA=nA>>8,q[M+4]=nA;let cA=Number(y>>BigInt(32)&BigInt(4294967295));return q[M+3]=cA,cA=cA>>8,q[M+2]=cA,cA=cA>>8,q[M+1]=cA,cA=cA>>8,q[M]=cA,M+8}a.prototype.writeBigUInt64LE=pe(function(y,M=0){return p(this,y,M,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=pe(function(y,M=0){return U(this,y,M,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(y,M,Z,AA){if(y=+y,M=M>>>0,!AA){const PA=Math.pow(2,8*Z-1);E(this,y,M,Z,PA-1,-PA)}let nA=0,cA=1,zA=0;for(this[M]=y&255;++nA<Z&&(cA*=256);)y<0&&zA===0&&this[M+nA-1]!==0&&(zA=1),this[M+nA]=(y/cA>>0)-zA&255;return M+Z},a.prototype.writeIntBE=function(y,M,Z,AA){if(y=+y,M=M>>>0,!AA){const PA=Math.pow(2,8*Z-1);E(this,y,M,Z,PA-1,-PA)}let nA=Z-1,cA=1,zA=0;for(this[M+nA]=y&255;--nA>=0&&(cA*=256);)y<0&&zA===0&&this[M+nA+1]!==0&&(zA=1),this[M+nA]=(y/cA>>0)-zA&255;return M+Z},a.prototype.writeInt8=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,1,127,-128),y<0&&(y=255+y+1),this[M]=y&255,M+1},a.prototype.writeInt16LE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,2,32767,-32768),this[M]=y&255,this[M+1]=y>>>8,M+2},a.prototype.writeInt16BE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,2,32767,-32768),this[M]=y>>>8,this[M+1]=y&255,M+2},a.prototype.writeInt32LE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,4,2147483647,-2147483648),this[M]=y&255,this[M+1]=y>>>8,this[M+2]=y>>>16,this[M+3]=y>>>24,M+4},a.prototype.writeInt32BE=function(y,M,Z){return y=+y,M=M>>>0,Z||E(this,y,M,4,2147483647,-2147483648),y<0&&(y=4294967295+y+1),this[M]=y>>>24,this[M+1]=y>>>16,this[M+2]=y>>>8,this[M+3]=y&255,M+4},a.prototype.writeBigInt64LE=pe(function(y,M=0){return p(this,y,M,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=pe(function(y,M=0){return U(this,y,M,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function R(q,y,M,Z,AA,nA){if(M+Z>q.length)throw new RangeError("Index out of range");if(M<0)throw new RangeError("Index out of range")}function _(q,y,M,Z,AA){return y=+y,M=M>>>0,AA||R(q,y,M,4),t.write(q,y,M,Z,23,4),M+4}a.prototype.writeFloatLE=function(y,M,Z){return _(this,y,M,!0,Z)},a.prototype.writeFloatBE=function(y,M,Z){return _(this,y,M,!1,Z)};function tA(q,y,M,Z,AA){return y=+y,M=M>>>0,AA||R(q,y,M,8),t.write(q,y,M,Z,52,8),M+8}a.prototype.writeDoubleLE=function(y,M,Z){return tA(this,y,M,!0,Z)},a.prototype.writeDoubleBE=function(y,M,Z){return tA(this,y,M,!1,Z)},a.prototype.copy=function(y,M,Z,AA){if(!a.isBuffer(y))throw new TypeError("argument should be a Buffer");if(Z||(Z=0),!AA&&AA!==0&&(AA=this.length),M>=y.length&&(M=y.length),M||(M=0),AA>0&&AA<Z&&(AA=Z),AA===Z||y.length===0||this.length===0)return 0;if(M<0)throw new RangeError("targetStart out of bounds");if(Z<0||Z>=this.length)throw new RangeError("Index out of range");if(AA<0)throw new RangeError("sourceEnd out of bounds");AA>this.length&&(AA=this.length),y.length-M<AA-Z&&(AA=y.length-M+Z);const nA=AA-Z;return this===y&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(M,Z,AA):Uint8Array.prototype.set.call(y,this.subarray(Z,AA),M),nA},a.prototype.fill=function(y,M,Z,AA){if(typeof y=="string"){if(typeof M=="string"?(AA=M,M=0,Z=this.length):typeof Z=="string"&&(AA=Z,Z=this.length),AA!==void 0&&typeof AA!="string")throw new TypeError("encoding must be a string");if(typeof AA=="string"&&!a.isEncoding(AA))throw new TypeError("Unknown encoding: "+AA);if(y.length===1){const cA=y.charCodeAt(0);(AA==="utf8"&&cA<128||AA==="latin1")&&(y=cA)}}else typeof y=="number"?y=y&255:typeof y=="boolean"&&(y=Number(y));if(M<0||this.length<M||this.length<Z)throw new RangeError("Out of range index");if(Z<=M)return this;M=M>>>0,Z=Z===void 0?this.length:Z>>>0,y||(y=0);let nA;if(typeof y=="number")for(nA=M;nA<Z;++nA)this[nA]=y;else{const cA=a.isBuffer(y)?y:a.from(y,AA),zA=cA.length;if(zA===0)throw new TypeError('The value "'+y+'" is invalid for argument "value"');for(nA=0;nA<Z-M;++nA)this[nA+M]=cA[nA%zA]}return this};const IA={};function iA(q,y,M){IA[q]=class extends M{constructor(){super(),Object.defineProperty(this,"message",{value:y.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${q}]`,this.stack,delete this.name}get code(){return q}set code(AA){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:AA,writable:!0})}toString(){return`${this.name} [${q}]: ${this.message}`}}}iA("ERR_BUFFER_OUT_OF_BOUNDS",function(q){return q?`${q} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),iA("ERR_INVALID_ARG_TYPE",function(q,y){return`The "${q}" argument must be of type number. Received type ${typeof y}`},TypeError),iA("ERR_OUT_OF_RANGE",function(q,y,M){let Z=`The value of "${q}" is out of range.`,AA=M;return Number.isInteger(M)&&Math.abs(M)>2**32?AA=UA(String(M)):typeof M=="bigint"&&(AA=String(M),(M>BigInt(2)**BigInt(32)||M<-(BigInt(2)**BigInt(32)))&&(AA=UA(AA)),AA+="n"),Z+=` It must be ${y}. Received ${AA}`,Z},RangeError);function UA(q){let y="",M=q.length;const Z=q[0]==="-"?1:0;for(;M>=Z+4;M-=3)y=`_${q.slice(M-3,M)}${y}`;return`${q.slice(0,M)}${y}`}function HA(q,y,M){qA(y,"offset"),(q[y]===void 0||q[y+M]===void 0)&&re(y,q.length-(M+1))}function lA(q,y,M,Z,AA,nA){if(q>M||q<y){const cA=typeof y=="bigint"?"n":"";let zA;throw y===0||y===BigInt(0)?zA=`>= 0${cA} and < 2${cA} ** ${(nA+1)*8}${cA}`:zA=`>= -(2${cA} ** ${(nA+1)*8-1}${cA}) and < 2 ** ${(nA+1)*8-1}${cA}`,new IA.ERR_OUT_OF_RANGE("value",zA,q)}HA(Z,AA,nA)}function qA(q,y){if(typeof q!="number")throw new IA.ERR_INVALID_ARG_TYPE(y,"number",q)}function re(q,y,M){throw Math.floor(q)!==q?(qA(q,M),new IA.ERR_OUT_OF_RANGE("offset","an integer",q)):y<0?new IA.ERR_BUFFER_OUT_OF_BOUNDS:new IA.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${y}`,q)}const he=/[^+/0-9A-Za-z-_]/g;function kA(q){if(q=q.split("=")[0],q=q.trim().replace(he,""),q.length<2)return"";for(;q.length%4!==0;)q=q+"=";return q}function VA(q,y){y=y||1/0;let M;const Z=q.length;let AA=null;const nA=[];for(let cA=0;cA<Z;++cA){if(M=q.charCodeAt(cA),M>55295&&M<57344){if(!AA){if(M>56319){(y-=3)>-1&&nA.push(239,191,189);continue}else if(cA+1===Z){(y-=3)>-1&&nA.push(239,191,189);continue}AA=M;continue}if(M<56320){(y-=3)>-1&&nA.push(239,191,189),AA=M;continue}M=(AA-55296<<10|M-56320)+65536}else AA&&(y-=3)>-1&&nA.push(239,191,189);if(AA=null,M<128){if((y-=1)<0)break;nA.push(M)}else if(M<2048){if((y-=2)<0)break;nA.push(M>>6|192,M&63|128)}else if(M<65536){if((y-=3)<0)break;nA.push(M>>12|224,M>>6&63|128,M&63|128)}else if(M<1114112){if((y-=4)<0)break;nA.push(M>>18|240,M>>12&63|128,M>>6&63|128,M&63|128)}else throw new Error("Invalid code point")}return nA}function ae(q){const y=[];for(let M=0;M<q.length;++M)y.push(q.charCodeAt(M)&255);return y}function He(q,y){let M,Z,AA;const nA=[];for(let cA=0;cA<q.length&&!((y-=2)<0);++cA)M=q.charCodeAt(cA),Z=M>>8,AA=M%256,nA.push(AA),nA.push(Z);return nA}function le(q){return e.toByteArray(kA(q))}function Ge(q,y,M,Z){let AA;for(AA=0;AA<Z&&!(AA+M>=y.length||AA>=q.length);++AA)y[AA+M]=q[AA];return AA}function nt(q,y){return q instanceof y||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===y.name}function ve(q){return q!==q}const yA=(function(){const q="0123456789abcdef",y=new Array(256);for(let M=0;M<16;++M){const Z=M*16;for(let AA=0;AA<16;++AA)y[Z+AA]=q[M]+q[AA]}return y})();function pe(q){return typeof BigInt>"u"?YA:q}function YA(){throw new Error("BigInt not supported")}})(Ei)),Ei}var Dt=ag();const Ss=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function vr(A){return A instanceof Uint8Array||ArrayBuffer.isView(A)&&A.constructor.name==="Uint8Array"}function Ca(A){if(!Number.isSafeInteger(A)||A<0)throw new Error("positive integer expected, got "+A)}function ys(A,...e){if(!vr(A))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(A.length))throw new Error("Uint8Array expected of length "+e+", got length="+A.length)}function oc(A){if(typeof A!="function"||typeof A.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ca(A.outputLen),Ca(A.blockLen)}function pn(A,e=!0){if(A.destroyed)throw new Error("Hash instance has been destroyed");if(e&&A.finished)throw new Error("Hash#digest() has already been called")}function Mm(A,e){ys(A);const t=e.outputLen;if(A.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function qs(...A){for(let e=0;e<A.length;e++)A[e].fill(0)}function Ci(A){return new DataView(A.buffer,A.byteOffset,A.byteLength)}function Mo(A,e){return A<<32-e|A>>>e}const sc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bm=Array.from({length:256},(A,e)=>e.toString(16).padStart(2,"0"));function hs(A){if(ys(A),sc)return A.toHex();let e="";for(let t=0;t<A.length;t++)e+=bm[A[t]];return e}const Jo={_0:48,_9:57,A:65,F:70,a:97,f:102};function bQ(A){if(A>=Jo._0&&A<=Jo._9)return A-Jo._0;if(A>=Jo.A&&A<=Jo.F)return A-(Jo.A-10);if(A>=Jo.a&&A<=Jo.f)return A-(Jo.a-10)}function fn(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);if(sc)return Uint8Array.fromHex(A);const e=A.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(t);for(let n=0,r=0;n<t;n++,r+=2){const i=bQ(A.charCodeAt(r)),a=bQ(A.charCodeAt(r+1));if(i===void 0||a===void 0){const g=A[r]+A[r+1];throw new Error('hex string expected, got non-hex character "'+g+'" at index '+r)}s[n]=i*16+a}return s}function Fm(A){if(typeof A!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(A))}function gg(A){return typeof A=="string"&&(A=Fm(A)),ys(A),A}function bo(...A){let e=0;for(let s=0;s<A.length;s++){const n=A[s];ys(n),e+=n.length}const t=new Uint8Array(e);for(let s=0,n=0;s<A.length;s++){const r=A[s];t.set(r,n),n+=r.length}return t}class rc{}function nc(A){const e=s=>A().update(gg(s)).digest(),t=A();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>A(),e}function Qg(A=32){if(Ss&&typeof Ss.getRandomValues=="function")return Ss.getRandomValues(new Uint8Array(A));if(Ss&&typeof Ss.randomBytes=="function")return Uint8Array.from(Ss.randomBytes(A));throw new Error("crypto.getRandomValues must be defined")}function Gm(A,e,t,s){if(typeof A.setBigUint64=="function")return A.setBigUint64(e,t,s);const n=BigInt(32),r=BigInt(4294967295),i=Number(t>>n&r),a=Number(t&r),g=s?4:0,Q=s?0:4;A.setUint32(e+g,i,s),A.setUint32(e+Q,a,s)}function vm(A,e,t){return A&e^~A&t}function Sm(A,e,t){return A&e^A&t^e&t}class ic extends rc{constructor(e,t,s,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Ci(this.buffer)}update(e){pn(this),e=gg(e),ys(e);const{view:t,buffer:s,blockLen:n}=this,r=e.length;for(let i=0;i<r;){const a=Math.min(n-this.pos,r-i);if(a===n){const g=Ci(e);for(;n<=r-i;i+=n)this.process(g,i);continue}s.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pn(this),Mm(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:n,isLE:r}=this;let{pos:i}=this;t[i++]=128,qs(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(s,0),i=0);for(let C=i;C<n;C++)t[C]=0;Gm(s,n-8,BigInt(this.length*8),r),this.process(s,0);const a=Ci(e),g=this.outputLen;if(g%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const Q=g/4,l=this.get();if(Q>l.length)throw new Error("_sha2: outputLen bigger than state");for(let C=0;C<Q;C++)a.setUint32(4*C,l[C],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,n%t&&e.buffer.set(s),e}clone(){return this._cloneInto()}}const Wo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Pr=BigInt(2**32-1),FQ=BigInt(32);function Um(A,e=!1){return e?{h:Number(A&Pr),l:Number(A>>FQ&Pr)}:{h:Number(A>>FQ&Pr)|0,l:Number(A&Pr)|0}}function Rm(A,e=!1){const t=A.length;let s=new Uint32Array(t),n=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=Um(A[r],e);[s[r],n[r]]=[i,a]}return[s,n]}const GQ=(A,e,t)=>A>>>t,vQ=(A,e,t)=>A<<32-t|e>>>t,Us=(A,e,t)=>A>>>t|e<<32-t,Rs=(A,e,t)=>A<<32-t|e>>>t,Wr=(A,e,t)=>A<<64-t|e>>>t-32,zr=(A,e,t)=>A>>>t-32|e<<64-t;function Lo(A,e,t,s){const n=(e>>>0)+(s>>>0);return{h:A+t+(n/2**32|0)|0,l:n|0}}const Km=(A,e,t)=>(A>>>0)+(e>>>0)+(t>>>0),Jm=(A,e,t,s)=>e+t+s+(A/2**32|0)|0,Lm=(A,e,t,s)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0),jm=(A,e,t,s,n)=>e+t+s+n+(A/2**32|0)|0,Tm=(A,e,t,s,n)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(n>>>0),Om=(A,e,t,s,n,r)=>e+t+s+n+r+(A/2**32|0)|0,qm=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zo=new Uint32Array(64);class Ym extends ic{constructor(e=32){super(64,e,8,!1),this.A=Wo[0]|0,this.B=Wo[1]|0,this.C=Wo[2]|0,this.D=Wo[3]|0,this.E=Wo[4]|0,this.F=Wo[5]|0,this.G=Wo[6]|0,this.H=Wo[7]|0}get(){const{A:e,B:t,C:s,D:n,E:r,F:i,G:a,H:g}=this;return[e,t,s,n,r,i,a,g]}set(e,t,s,n,r,i,a,g){this.A=e|0,this.B=t|0,this.C=s|0,this.D=n|0,this.E=r|0,this.F=i|0,this.G=a|0,this.H=g|0}process(e,t){for(let C=0;C<16;C++,t+=4)zo[C]=e.getUint32(t,!1);for(let C=16;C<64;C++){const I=zo[C-15],c=zo[C-2],u=Mo(I,7)^Mo(I,18)^I>>>3,f=Mo(c,17)^Mo(c,19)^c>>>10;zo[C]=f+zo[C-7]+u+zo[C-16]|0}let{A:s,B:n,C:r,D:i,E:a,F:g,G:Q,H:l}=this;for(let C=0;C<64;C++){const I=Mo(a,6)^Mo(a,11)^Mo(a,25),c=l+I+vm(a,g,Q)+qm[C]+zo[C]|0,f=(Mo(s,2)^Mo(s,13)^Mo(s,22))+Sm(s,n,r)|0;l=Q,Q=g,g=a,a=i+c|0,i=r,r=n,n=s,s=c+f|0}s=s+this.A|0,n=n+this.B|0,r=r+this.C|0,i=i+this.D|0,a=a+this.E|0,g=g+this.F|0,Q=Q+this.G|0,l=l+this.H|0,this.set(s,n,r,i,a,g,Q,l)}roundClean(){qs(zo)}destroy(){this.set(0,0,0,0,0,0,0,0),qs(this.buffer)}}const ac=Rm(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(A=>BigInt(A))),Hm=ac[0],Pm=ac[1],Vo=new Uint32Array(80),Zo=new Uint32Array(80);class Wm extends ic{constructor(e=64){super(128,e,16,!1),this.Ah=Kt[0]|0,this.Al=Kt[1]|0,this.Bh=Kt[2]|0,this.Bl=Kt[3]|0,this.Ch=Kt[4]|0,this.Cl=Kt[5]|0,this.Dh=Kt[6]|0,this.Dl=Kt[7]|0,this.Eh=Kt[8]|0,this.El=Kt[9]|0,this.Fh=Kt[10]|0,this.Fl=Kt[11]|0,this.Gh=Kt[12]|0,this.Gl=Kt[13]|0,this.Hh=Kt[14]|0,this.Hl=Kt[15]|0}get(){const{Ah:e,Al:t,Bh:s,Bl:n,Ch:r,Cl:i,Dh:a,Dl:g,Eh:Q,El:l,Fh:C,Fl:I,Gh:c,Gl:u,Hh:f,Hl:h}=this;return[e,t,s,n,r,i,a,g,Q,l,C,I,c,u,f,h]}set(e,t,s,n,r,i,a,g,Q,l,C,I,c,u,f,h){this.Ah=e|0,this.Al=t|0,this.Bh=s|0,this.Bl=n|0,this.Ch=r|0,this.Cl=i|0,this.Dh=a|0,this.Dl=g|0,this.Eh=Q|0,this.El=l|0,this.Fh=C|0,this.Fl=I|0,this.Gh=c|0,this.Gl=u|0,this.Hh=f|0,this.Hl=h|0}process(e,t){for(let D=0;D<16;D++,t+=4)Vo[D]=e.getUint32(t),Zo[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){const O=Vo[D-15]|0,J=Zo[D-15]|0,V=Us(O,J,1)^Us(O,J,8)^GQ(O,J,7),eA=Rs(O,J,1)^Rs(O,J,8)^vQ(O,J,7),X=Vo[D-2]|0,K=Zo[D-2]|0,W=Us(X,K,19)^Wr(X,K,61)^GQ(X,K,6),T=Rs(X,K,19)^zr(X,K,61)^vQ(X,K,6),L=Lm(eA,T,Zo[D-7],Zo[D-16]),w=jm(L,V,W,Vo[D-7],Vo[D-16]);Vo[D]=w|0,Zo[D]=L|0}let{Ah:s,Al:n,Bh:r,Bl:i,Ch:a,Cl:g,Dh:Q,Dl:l,Eh:C,El:I,Fh:c,Fl:u,Gh:f,Gl:h,Hh:k,Hl:v}=this;for(let D=0;D<80;D++){const O=Us(C,I,14)^Us(C,I,18)^Wr(C,I,41),J=Rs(C,I,14)^Rs(C,I,18)^zr(C,I,41),V=C&c^~C&f,eA=I&u^~I&h,X=Tm(v,J,eA,Pm[D],Zo[D]),K=Om(X,k,O,V,Hm[D],Vo[D]),W=X|0,T=Us(s,n,28)^Wr(s,n,34)^Wr(s,n,39),L=Rs(s,n,28)^zr(s,n,34)^zr(s,n,39),w=s&r^s&a^r&a,B=n&i^n&g^i&g;k=f|0,v=h|0,f=c|0,h=u|0,c=C|0,u=I|0,{h:C,l:I}=Lo(Q|0,l|0,K|0,W|0),Q=a|0,l=g|0,a=r|0,g=i|0,r=s|0,i=n|0;const d=Km(W,L,B);s=Jm(d,K,T,w),n=d|0}({h:s,l:n}=Lo(this.Ah|0,this.Al|0,s|0,n|0)),{h:r,l:i}=Lo(this.Bh|0,this.Bl|0,r|0,i|0),{h:a,l:g}=Lo(this.Ch|0,this.Cl|0,a|0,g|0),{h:Q,l}=Lo(this.Dh|0,this.Dl|0,Q|0,l|0),{h:C,l:I}=Lo(this.Eh|0,this.El|0,C|0,I|0),{h:c,l:u}=Lo(this.Fh|0,this.Fl|0,c|0,u|0),{h:f,l:h}=Lo(this.Gh|0,this.Gl|0,f|0,h|0),{h:k,l:v}=Lo(this.Hh|0,this.Hl|0,k|0,v|0),this.set(s,n,r,i,a,g,Q,l,C,I,c,u,f,h,k,v)}roundClean(){qs(Vo,Zo)}destroy(){qs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const gc=nc(()=>new Ym),zm=nc(()=>new Wm);const Bg=BigInt(0),Ia=BigInt(1);function ms(A,e=""){if(typeof A!="boolean"){const t=e&&`"${e}"`;throw new Error(t+"expected boolean, got type="+typeof A)}return A}function uo(A,e,t=""){const s=vr(A),n=A?.length,r=e!==void 0;if(!s||r&&n!==e){const i=t&&`"${t}" `,a=r?` of length ${e}`:"",g=s?`length=${n}`:`type=${typeof A}`;throw new Error(i+"expected Uint8Array"+a+", got "+g)}return A}function Vr(A){const e=A.toString(16);return e.length&1?"0"+e:e}function Qc(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);return A===""?Bg:BigInt("0x"+A)}function zn(A){return Qc(hs(A))}function dr(A){return ys(A),Qc(hs(Uint8Array.from(A).reverse()))}function lg(A,e){return fn(A.toString(16).padStart(e*2,"0"))}function Bc(A,e){return lg(A,e).reverse()}function ut(A,e,t){let s;if(typeof e=="string")try{s=fn(e)}catch(r){throw new Error(A+" must be hex string or Uint8Array, cause: "+r)}else if(vr(e))s=Uint8Array.from(e);else throw new Error(A+" must be hex string or Uint8Array");const n=s.length;if(typeof t=="number"&&n!==t)throw new Error(A+" of length "+t+" expected, got "+n);return s}function SQ(A){return Uint8Array.from(A)}const Ii=A=>typeof A=="bigint"&&Bg<=A;function Vm(A,e,t){return Ii(A)&&Ii(e)&&Ii(t)&&e<=A&&A<t}function ua(A,e,t,s){if(!Vm(e,t,s))throw new Error("expected valid "+A+": "+t+" <= n < "+s+", got "+e)}function lc(A){let e;for(e=0;A>Bg;A>>=Ia,e+=1);return e}const Sr=A=>(Ia<<BigInt(A))-Ia;function Zm(A,e,t){if(typeof A!="number"||A<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");const s=c=>new Uint8Array(c),n=c=>Uint8Array.of(c);let r=s(A),i=s(A),a=0;const g=()=>{r.fill(1),i.fill(0),a=0},Q=(...c)=>t(i,r,...c),l=(c=s(0))=>{i=Q(n(0),c),r=Q(),c.length!==0&&(i=Q(n(1),c),r=Q())},C=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let c=0;const u=[];for(;c<e;){r=Q();const f=r.slice();u.push(f),c+=r.length}return bo(...u)};return(c,u)=>{g(),l(c);let f;for(;!(f=u(C()));)l();return g(),f}}function Ur(A,e,t={}){if(!A||typeof A!="object")throw new Error("expected valid options object");function s(n,r,i){const a=A[n];if(i&&a===void 0)return;const g=typeof a;if(g!==r||a===null)throw new Error(`param "${n}" is invalid: expected ${r}, got ${g}`)}Object.entries(e).forEach(([n,r])=>s(n,r,!1)),Object.entries(t).forEach(([n,r])=>s(n,r,!0))}function mn(A){const e=new WeakMap;return(t,...s)=>{const n=e.get(t);if(n!==void 0)return n;const r=A(t,...s);return e.set(t,r),r}}const eo=BigInt(0),St=BigInt(1),Cs=BigInt(2),cc=BigInt(3),Ec=BigInt(4),Cc=BigInt(5),_m=BigInt(7),Ic=BigInt(8),Xm=BigInt(9),uc=BigInt(16);function wt(A,e){const t=A%e;return t>=eo?t:e+t}function It(A,e,t){let s=A;for(;e-- >eo;)s*=s,s%=t;return s}function UQ(A,e){if(A===eo)throw new Error("invert: expected non-zero number");if(e<=eo)throw new Error("invert: expected positive modulus, got "+e);let t=wt(A,e),s=e,n=eo,r=St;for(;t!==eo;){const a=s/t,g=s%t,Q=n-r*a;s=t,t=g,n=r,r=Q}if(s!==St)throw new Error("invert: does not exist");return wt(n,e)}function cg(A,e,t){if(!A.eql(A.sqr(e),t))throw new Error("Cannot find square root")}function dc(A,e){const t=(A.ORDER+St)/Ec,s=A.pow(e,t);return cg(A,s,e),s}function $m(A,e){const t=(A.ORDER-Cc)/Ic,s=A.mul(e,Cs),n=A.pow(s,t),r=A.mul(e,n),i=A.mul(A.mul(r,Cs),n),a=A.mul(r,A.sub(i,A.ONE));return cg(A,a,e),a}function Aw(A){const e=Ns(A),t=hc(A),s=t(e,e.neg(e.ONE)),n=t(e,s),r=t(e,e.neg(s)),i=(A+_m)/uc;return(a,g)=>{let Q=a.pow(g,i),l=a.mul(Q,s);const C=a.mul(Q,n),I=a.mul(Q,r),c=a.eql(a.sqr(l),g),u=a.eql(a.sqr(C),g);Q=a.cmov(Q,l,c),l=a.cmov(I,C,u);const f=a.eql(a.sqr(l),g),h=a.cmov(Q,l,f);return cg(a,h,g),h}}function hc(A){if(A<cc)throw new Error("sqrt is not defined for small field");let e=A-St,t=0;for(;e%Cs===eo;)e/=Cs,t++;let s=Cs;const n=Ns(A);for(;RQ(n,s)===1;)if(s++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return dc;let r=n.pow(s,e);const i=(e+St)/Cs;return function(g,Q){if(g.is0(Q))return Q;if(RQ(g,Q)!==1)throw new Error("Cannot find square root");let l=t,C=g.mul(g.ONE,r),I=g.pow(Q,e),c=g.pow(Q,i);for(;!g.eql(I,g.ONE);){if(g.is0(I))return g.ZERO;let u=1,f=g.sqr(I);for(;!g.eql(f,g.ONE);)if(u++,f=g.sqr(f),u===l)throw new Error("Cannot find square root");const h=St<<BigInt(l-u-1),k=g.pow(C,h);l=u,C=g.sqr(k),I=g.mul(I,C),c=g.mul(c,k)}return c}}function ew(A){return A%Ec===cc?dc:A%Ic===Cc?$m:A%uc===Xm?Aw(A):hc(A)}const tw=(A,e)=>(wt(A,e)&St)===St,ow=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sw(A){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},t=ow.reduce((s,n)=>(s[n]="function",s),e);return Ur(A,t),A}function rw(A,e,t){if(t<eo)throw new Error("invalid exponent, negatives unsupported");if(t===eo)return A.ONE;if(t===St)return e;let s=A.ONE,n=e;for(;t>eo;)t&St&&(s=A.mul(s,n)),n=A.sqr(n),t>>=St;return s}function pc(A,e,t=!1){const s=new Array(e.length).fill(t?A.ZERO:void 0),n=e.reduce((i,a,g)=>A.is0(a)?i:(s[g]=i,A.mul(i,a)),A.ONE),r=A.inv(n);return e.reduceRight((i,a,g)=>A.is0(a)?i:(s[g]=A.mul(i,s[g]),A.mul(i,a)),r),s}function RQ(A,e){const t=(A.ORDER-St)/Cs,s=A.pow(e,t),n=A.eql(s,A.ONE),r=A.eql(s,A.ZERO),i=A.eql(s,A.neg(A.ONE));if(!n&&!r&&!i)throw new Error("invalid Legendre symbol result");return n?1:r?0:-1}function fc(A,e){e!==void 0&&Ca(e);const t=e!==void 0?e:A.toString(2).length,s=Math.ceil(t/8);return{nBitLength:t,nByteLength:s}}function Ns(A,e,t=!1,s={}){if(A<=eo)throw new Error("invalid field: expected ORDER > 0, got "+A);let n,r,i=!1,a;if(typeof e=="object"&&e!=null){if(s.sqrt||t)throw new Error("cannot specify opts in two arguments");const I=e;I.BITS&&(n=I.BITS),I.sqrt&&(r=I.sqrt),typeof I.isLE=="boolean"&&(t=I.isLE),typeof I.modFromBytes=="boolean"&&(i=I.modFromBytes),a=I.allowedLengths}else typeof e=="number"&&(n=e),s.sqrt&&(r=s.sqrt);const{nBitLength:g,nByteLength:Q}=fc(A,n);if(Q>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const C=Object.freeze({ORDER:A,isLE:t,BITS:g,BYTES:Q,MASK:Sr(g),ZERO:eo,ONE:St,allowedLengths:a,create:I=>wt(I,A),isValid:I=>{if(typeof I!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof I);return eo<=I&&I<A},is0:I=>I===eo,isValidNot0:I=>!C.is0(I)&&C.isValid(I),isOdd:I=>(I&St)===St,neg:I=>wt(-I,A),eql:(I,c)=>I===c,sqr:I=>wt(I*I,A),add:(I,c)=>wt(I+c,A),sub:(I,c)=>wt(I-c,A),mul:(I,c)=>wt(I*c,A),pow:(I,c)=>rw(C,I,c),div:(I,c)=>wt(I*UQ(c,A),A),sqrN:I=>I*I,addN:(I,c)=>I+c,subN:(I,c)=>I-c,mulN:(I,c)=>I*c,inv:I=>UQ(I,A),sqrt:r||(I=>(l||(l=ew(A)),l(C,I))),toBytes:I=>t?Bc(I,Q):lg(I,Q),fromBytes:(I,c=!0)=>{if(a){if(!a.includes(I.length)||I.length>Q)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+I.length);const f=new Uint8Array(Q);f.set(I,t?0:f.length-I.length),I=f}if(I.length!==Q)throw new Error("Field.fromBytes: expected "+Q+" bytes, got "+I.length);let u=t?dr(I):zn(I);if(i&&(u=wt(u,A)),!c&&!C.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u},invertBatch:I=>pc(C,I),cmov:(I,c,u)=>u?c:I});return Object.freeze(C)}function mc(A){if(typeof A!="bigint")throw new Error("field order must be bigint");const e=A.toString(2).length;return Math.ceil(e/8)}function wc(A){const e=mc(A);return e+Math.ceil(e/2)}function nw(A,e,t=!1){const s=A.length,n=mc(e),r=wc(e);if(s<16||s<r||s>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+s);const i=t?dr(A):zn(A),a=wt(i,e-St)+St;return t?Bc(a,n):lg(a,n)}const Ys=BigInt(0),Is=BigInt(1);function wn(A,e){const t=e.negate();return A?t:e}function us(A,e){const t=pc(A.Fp,e.map(s=>s.Z));return e.map((s,n)=>A.fromAffine(s.toAffine(t[n])))}function xc(A,e){if(!Number.isSafeInteger(A)||A<=0||A>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+A)}function ui(A,e){xc(A,e);const t=Math.ceil(e/A)+1,s=2**(A-1),n=2**A,r=Sr(A),i=BigInt(A);return{windows:t,windowSize:s,mask:r,maxNumber:n,shiftBy:i}}function KQ(A,e,t){const{windowSize:s,mask:n,maxNumber:r,shiftBy:i}=t;let a=Number(A&n),g=A>>i;a>s&&(a-=r,g+=Is);const Q=e*s,l=Q+Math.abs(a)-1,C=a===0,I=a<0,c=e%2!==0;return{nextN:g,offset:l,isZero:C,isNeg:I,isNegF:c,offsetF:Q}}function iw(A,e){if(!Array.isArray(A))throw new Error("array expected");A.forEach((t,s)=>{if(!(t instanceof e))throw new Error("invalid point at index "+s)})}function aw(A,e){if(!Array.isArray(A))throw new Error("array of scalars expected");A.forEach((t,s)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+s)})}const di=new WeakMap,Dc=new WeakMap;function hi(A){return Dc.get(A)||1}function JQ(A){if(A!==Ys)throw new Error("invalid wNAF")}class yc{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,s=this.ZERO){let n=e;for(;t>Ys;)t&Is&&(s=s.add(n)),n=n.double(),t>>=Is;return s}precomputeWindow(e,t){const{windows:s,windowSize:n}=ui(t,this.bits),r=[];let i=e,a=i;for(let g=0;g<s;g++){a=i,r.push(a);for(let Q=1;Q<n;Q++)a=a.add(i),r.push(a);i=a.double()}return r}wNAF(e,t,s){if(!this.Fn.isValid(s))throw new Error("invalid scalar");let n=this.ZERO,r=this.BASE;const i=ui(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:g,offset:Q,isZero:l,isNeg:C,isNegF:I,offsetF:c}=KQ(s,a,i);s=g,l?r=r.add(wn(I,t[c])):n=n.add(wn(C,t[Q]))}return JQ(s),{p:n,f:r}}wNAFUnsafe(e,t,s,n=this.ZERO){const r=ui(e,this.bits);for(let i=0;i<r.windows&&s!==Ys;i++){const{nextN:a,offset:g,isZero:Q,isNeg:l}=KQ(s,i,r);if(s=a,!Q){const C=t[g];n=n.add(l?C.negate():C)}}return JQ(s),n}getPrecomputes(e,t,s){let n=di.get(t);return n||(n=this.precomputeWindow(t,e),e!==1&&(typeof s=="function"&&(n=s(n)),di.set(t,n))),n}cached(e,t,s){const n=hi(e);return this.wNAF(n,this.getPrecomputes(n,e,s),t)}unsafe(e,t,s,n){const r=hi(e);return r===1?this._unsafeLadder(e,t,n):this.wNAFUnsafe(r,this.getPrecomputes(r,e,s),t,n)}createCache(e,t){xc(t,this.bits),Dc.set(e,t),di.delete(e)}hasCache(e){return hi(e)!==1}}function gw(A,e,t,s){let n=e,r=A.ZERO,i=A.ZERO;for(;t>Ys||s>Ys;)t&Is&&(r=r.add(n)),s&Is&&(i=i.add(n)),n=n.double(),t>>=Is,s>>=Is;return{p1:r,p2:i}}function Nc(A,e,t,s){iw(t,A),aw(s,e);const n=t.length,r=s.length;if(n!==r)throw new Error("arrays of points and scalars must have equal length");const i=A.ZERO,a=lc(BigInt(n));let g=1;a>12?g=a-3:a>4?g=a-2:a>0&&(g=2);const Q=Sr(g),l=new Array(Number(Q)+1).fill(i),C=Math.floor((e.BITS-1)/g)*g;let I=i;for(let c=C;c>=0;c-=g){l.fill(i);for(let f=0;f<r;f++){const h=s[f],k=Number(h>>BigInt(c)&Q);l[k]=l[k].add(t[f])}let u=i;for(let f=l.length-1,h=i;f>0;f--)h=h.add(l[f]),u=u.add(h);if(I=I.add(u),c!==0)for(let f=0;f<g;f++)I=I.double()}return I}function LQ(A,e,t){if(e){if(e.ORDER!==A)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return sw(e),e}else return Ns(A,{isLE:t})}function kc(A,e,t={},s){if(s===void 0&&(s=A==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${A} CURVE object`);for(const g of["p","n","h"]){const Q=e[g];if(!(typeof Q=="bigint"&&Q>Ys))throw new Error(`CURVE.${g} must be positive bigint`)}const n=LQ(e.p,t.Fp,s),r=LQ(e.n,t.Fn,s),a=["Gx","Gy","a",A==="weierstrass"?"b":"d"];for(const g of a)if(!n.isValid(e[g]))throw new Error(`CURVE.${g} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:n,Fn:r}}const _o=BigInt(0),Nt=BigInt(1),pi=BigInt(2),Qw=BigInt(8);function Bw(A,e,t,s){const n=A.sqr(t),r=A.sqr(s),i=A.add(A.mul(e.a,n),r),a=A.add(A.ONE,A.mul(e.d,A.mul(n,r)));return A.eql(i,a)}function lw(A,e={}){const t=kc("edwards",A,e,e.FpFnLE),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i}=r;Ur(e,{},{uvRatio:"function"});const a=pi<<BigInt(n.BYTES*8)-Nt,g=h=>s.create(h),Q=e.uvRatio||((h,k)=>{try{return{isValid:!0,value:s.sqrt(s.div(h,k))}}catch{return{isValid:!1,value:_o}}});if(!Bw(s,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function l(h,k,v=!1){const D=v?Nt:_o;return ua("coordinate "+h,k,D,a),k}function C(h){if(!(h instanceof u))throw new Error("ExtendedPoint expected")}const I=mn((h,k)=>{const{X:v,Y:D,Z:O}=h,J=h.is0();k==null&&(k=J?Qw:s.inv(O));const V=g(v*k),eA=g(D*k),X=s.mul(O,k);if(J)return{x:_o,y:Nt};if(X!==Nt)throw new Error("invZ was invalid");return{x:V,y:eA}}),c=mn(h=>{const{a:k,d:v}=r;if(h.is0())throw new Error("bad point: ZERO");const{X:D,Y:O,Z:J,T:V}=h,eA=g(D*D),X=g(O*O),K=g(J*J),W=g(K*K),T=g(eA*k),L=g(K*g(T+X)),w=g(W+g(v*g(eA*X)));if(L!==w)throw new Error("bad point: equation left != right (1)");const B=g(D*O),d=g(J*V);if(B!==d)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(k,v,D,O){this.X=l("x",k),this.Y=l("y",v),this.Z=l("z",D,!0),this.T=l("t",O),Object.freeze(this)}static CURVE(){return r}static fromAffine(k){if(k instanceof u)throw new Error("extended point not allowed");const{x:v,y:D}=k||{};return l("x",v),l("y",D),new u(v,D,Nt,g(v*D))}static fromBytes(k,v=!1){const D=s.BYTES,{a:O,d:J}=r;k=SQ(uo(k,D,"point")),ms(v,"zip215");const V=SQ(k),eA=k[D-1];V[D-1]=eA&-129;const X=dr(V),K=v?a:s.ORDER;ua("point.y",X,_o,K);const W=g(X*X),T=g(W-Nt),L=g(J*W-O);let{isValid:w,value:B}=Q(T,L);if(!w)throw new Error("bad point: invalid y coordinate");const d=(B&Nt)===Nt,N=(eA&128)!==0;if(!v&&B===_o&&N)throw new Error("bad point: x=0 and x_0=1");return N!==d&&(B=g(-B)),u.fromAffine({x:B,y:X})}static fromHex(k,v=!1){return u.fromBytes(ut("point",k),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(k=8,v=!0){return f.createCache(this,k),v||this.multiply(pi),this}assertValidity(){c(this)}equals(k){C(k);const{X:v,Y:D,Z:O}=this,{X:J,Y:V,Z:eA}=k,X=g(v*eA),K=g(J*O),W=g(D*eA),T=g(V*O);return X===K&&W===T}is0(){return this.equals(u.ZERO)}negate(){return new u(g(-this.X),this.Y,this.Z,g(-this.T))}double(){const{a:k}=r,{X:v,Y:D,Z:O}=this,J=g(v*v),V=g(D*D),eA=g(pi*g(O*O)),X=g(k*J),K=v+D,W=g(g(K*K)-J-V),T=X+V,L=T-eA,w=X-V,B=g(W*L),d=g(T*w),N=g(W*w),G=g(L*T);return new u(B,d,G,N)}add(k){C(k);const{a:v,d:D}=r,{X:O,Y:J,Z:V,T:eA}=this,{X,Y:K,Z:W,T}=k,L=g(O*X),w=g(J*K),B=g(eA*D*T),d=g(V*W),N=g((O+J)*(X+K)-L-w),G=d-B,S=d+B,j=g(w-v*L),H=g(N*G),b=g(S*j),E=g(N*j),p=g(G*S);return new u(H,b,p,E)}subtract(k){return this.add(k.negate())}multiply(k){if(!n.isValidNot0(k))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:v,f:D}=f.cached(this,k,O=>us(u,O));return us(u,[v,D])[0]}multiplyUnsafe(k,v=u.ZERO){if(!n.isValid(k))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return k===_o?u.ZERO:this.is0()||k===Nt?this:f.unsafe(this,k,D=>us(u,D),v)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return f.unsafe(this,r.n).is0()}toAffine(k){return I(this,k)}clearCofactor(){return i===Nt?this:this.multiplyUnsafe(i)}toBytes(){const{x:k,y:v}=this.toAffine(),D=s.toBytes(v);return D[D.length-1]|=k&Nt?128:0,D}toHex(){return hs(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(k){return us(u,k)}static msm(k,v){return Nc(u,n,k,v)}_setWindowSize(k){this.precompute(k)}toRawBytes(){return this.toBytes()}}u.BASE=new u(r.Gx,r.Gy,Nt,g(r.Gx*r.Gy)),u.ZERO=new u(_o,Nt,Nt,_o),u.Fp=s,u.Fn=n;const f=new yc(u,n.BITS);return u.BASE.precompute(8),u}function cw(A,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Ur(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:s}=t,{BASE:n,Fp:r,Fn:i}=A,a=t.randomBytes||Qg,g=t.adjustScalarBytes||(K=>K),Q=t.domain||((K,W,T)=>{if(ms(T,"phflag"),W.length||T)throw new Error("Contexts/pre-hash are not supported");return K});function l(K){return i.create(dr(K))}function C(K){const W=D.secretKey;K=ut("private key",K,W);const T=ut("hashed private key",e(K),2*W),L=g(T.slice(0,W)),w=T.slice(W,2*W),B=l(L);return{head:L,prefix:w,scalar:B}}function I(K){const{head:W,prefix:T,scalar:L}=C(K),w=n.multiply(L),B=w.toBytes();return{head:W,prefix:T,scalar:L,point:w,pointBytes:B}}function c(K){return I(K).pointBytes}function u(K=Uint8Array.of(),...W){const T=bo(...W);return l(e(Q(T,ut("context",K),!!s)))}function f(K,W,T={}){K=ut("message",K),s&&(K=s(K));const{prefix:L,scalar:w,pointBytes:B}=I(W),d=u(T.context,L,K),N=n.multiply(d).toBytes(),G=u(T.context,N,B,K),S=i.create(d+G*w);if(!i.isValid(S))throw new Error("sign failed: invalid s");const j=bo(N,i.toBytes(S));return uo(j,D.signature,"result")}const h={zip215:!0};function k(K,W,T,L=h){const{context:w,zip215:B}=L,d=D.signature;K=ut("signature",K,d),W=ut("message",W),T=ut("publicKey",T,D.publicKey),B!==void 0&&ms(B,"zip215"),s&&(W=s(W));const N=d/2,G=K.subarray(0,N),S=dr(K.subarray(N,d));let j,H,b;try{j=A.fromBytes(T,B),H=A.fromBytes(G,B),b=n.multiplyUnsafe(S)}catch{return!1}if(!B&&j.isSmallOrder())return!1;const E=u(w,H.toBytes(),j.toBytes(),W);return H.add(j.multiplyUnsafe(E)).subtract(b).clearCofactor().is0()}const v=r.BYTES,D={secretKey:v,publicKey:v,signature:2*v,seed:v};function O(K=a(D.seed)){return uo(K,D.seed,"seed")}function J(K){const W=X.randomSecretKey(K);return{secretKey:W,publicKey:c(W)}}function V(K){return vr(K)&&K.length===i.BYTES}function eA(K,W){try{return!!A.fromBytes(K,W)}catch{return!1}}const X={getExtendedPublicKey:I,randomSecretKey:O,isValidSecretKey:V,isValidPublicKey:eA,toMontgomery(K){const{y:W}=A.fromBytes(K),T=D.publicKey,L=T===32;if(!L&&T!==57)throw new Error("only defined for 25519 and 448");const w=L?r.div(Nt+W,Nt-W):r.div(W-Nt,W+Nt);return r.toBytes(w)},toMontgomerySecret(K){const W=D.secretKey;uo(K,W);const T=e(K.subarray(0,W));return g(T).subarray(0,W)},randomPrivateKey:O,precompute(K=8,W=A.BASE){return W.precompute(K,!1)}};return Object.freeze({keygen:J,getPublicKey:c,sign:f,verify:k,utils:X,Point:A,lengths:D})}function Ew(A){const e={a:A.a,d:A.d,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp,s=Ns(e.n,A.nBitLength,!0),n={Fp:t,Fn:s,uvRatio:A.uvRatio},r={randomBytes:A.randomBytes,adjustScalarBytes:A.adjustScalarBytes,domain:A.domain,prehash:A.prehash,mapToCurve:A.mapToCurve};return{CURVE:e,curveOpts:n,hash:A.hash,eddsaOpts:r}}function Cw(A,e){const t=e.Point;return Object.assign({},e,{ExtendedPoint:t,CURVE:A,nBitLength:t.Fn.BITS,nByteLength:t.Fn.BYTES})}function Iw(A){const{CURVE:e,curveOpts:t,hash:s,eddsaOpts:n}=Ew(A),r=lw(e,t),i=cw(r,s,n);return Cw(A,i)}const uw=BigInt(1),jQ=BigInt(2);BigInt(3);const dw=BigInt(5),hw=BigInt(8),Eg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Mc={p:Eg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:hw,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function pw(A){const e=BigInt(10),t=BigInt(20),s=BigInt(40),n=BigInt(80),r=Eg,a=A*A%r*A%r,g=It(a,jQ,r)*a%r,Q=It(g,uw,r)*A%r,l=It(Q,dw,r)*Q%r,C=It(l,e,r)*l%r,I=It(C,t,r)*C%r,c=It(I,s,r)*I%r,u=It(c,n,r)*c%r,f=It(u,n,r)*c%r,h=It(f,e,r)*l%r;return{pow_p_5_8:It(h,jQ,r)*A%r,b2:a}}function fw(A){return A[0]&=248,A[31]&=127,A[31]|=64,A}const TQ=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function mw(A,e){const t=Eg,s=wt(e*e*e,t),n=wt(s*s*e,t),r=pw(A*n).pow_p_5_8;let i=wt(A*s*r,t);const a=wt(e*i*i,t),g=i,Q=wt(i*TQ,t),l=a===A,C=a===wt(-A,t),I=a===wt(-A*TQ,t);return l&&(i=g),(C||I)&&(i=Q),tw(i,t)&&(i=wt(-i,t)),{isValid:l||C,value:i}}const ww=Ns(Mc.p,{isLE:!0}),xw={...Mc,Fp:ww,hash:zm,adjustScalarBytes:fw,uvRatio:mw},Vn=Iw(xw);var Bn={exports:{}};const Dw={},yw=Object.freeze(Object.defineProperty({__proto__:null,default:Dw},Symbol.toStringTag,{value:"Module"})),bc=Ma(yw);var Nw=Bn.exports,OQ;function Fc(){return OQ||(OQ=1,(function(A){(function(e,t){function s(w,B){if(!w)throw new Error(B||"Assertion failed")}function n(w,B){w.super_=B;var d=function(){};d.prototype=B.prototype,w.prototype=new d,w.prototype.constructor=w}function r(w,B,d){if(r.isBN(w))return w;this.negative=0,this.words=null,this.length=0,this.red=null,w!==null&&((B==="le"||B==="be")&&(d=B,B=10),this._init(w||0,B||10,d||"be"))}typeof e=="object"?e.exports=r:t.BN=r,r.BN=r,r.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=bc.Buffer}catch{}r.isBN=function(B){return B instanceof r?!0:B!==null&&typeof B=="object"&&B.constructor.wordSize===r.wordSize&&Array.isArray(B.words)},r.max=function(B,d){return B.cmp(d)>0?B:d},r.min=function(B,d){return B.cmp(d)<0?B:d},r.prototype._init=function(B,d,N){if(typeof B=="number")return this._initNumber(B,d,N);if(typeof B=="object")return this._initArray(B,d,N);d==="hex"&&(d=16),s(d===(d|0)&&d>=2&&d<=36),B=B.toString().replace(/\s+/g,"");var G=0;B[0]==="-"&&(G++,this.negative=1),G<B.length&&(d===16?this._parseHex(B,G,N):(this._parseBase(B,d,G),N==="le"&&this._initArray(this.toArray(),d,N)))},r.prototype._initNumber=function(B,d,N){B<0&&(this.negative=1,B=-B),B<67108864?(this.words=[B&67108863],this.length=1):B<4503599627370496?(this.words=[B&67108863,B/67108864&67108863],this.length=2):(s(B<9007199254740992),this.words=[B&67108863,B/67108864&67108863,1],this.length=3),N==="le"&&this._initArray(this.toArray(),d,N)},r.prototype._initArray=function(B,d,N){if(s(typeof B.length=="number"),B.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(B.length/3),this.words=new Array(this.length);for(var G=0;G<this.length;G++)this.words[G]=0;var S,j,H=0;if(N==="be")for(G=B.length-1,S=0;G>=0;G-=3)j=B[G]|B[G-1]<<8|B[G-2]<<16,this.words[S]|=j<<H&67108863,this.words[S+1]=j>>>26-H&67108863,H+=24,H>=26&&(H-=26,S++);else if(N==="le")for(G=0,S=0;G<B.length;G+=3)j=B[G]|B[G+1]<<8|B[G+2]<<16,this.words[S]|=j<<H&67108863,this.words[S+1]=j>>>26-H&67108863,H+=24,H>=26&&(H-=26,S++);return this._strip()};function a(w,B){var d=w.charCodeAt(B);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;s(!1,"Invalid character in "+w)}function g(w,B,d){var N=a(w,d);return d-1>=B&&(N|=a(w,d-1)<<4),N}r.prototype._parseHex=function(B,d,N){this.length=Math.ceil((B.length-d)/6),this.words=new Array(this.length);for(var G=0;G<this.length;G++)this.words[G]=0;var S=0,j=0,H;if(N==="be")for(G=B.length-1;G>=d;G-=2)H=g(B,d,G)<<S,this.words[j]|=H&67108863,S>=18?(S-=18,j+=1,this.words[j]|=H>>>26):S+=8;else{var b=B.length-d;for(G=b%2===0?d+1:d;G<B.length;G+=2)H=g(B,d,G)<<S,this.words[j]|=H&67108863,S>=18?(S-=18,j+=1,this.words[j]|=H>>>26):S+=8}this._strip()};function Q(w,B,d,N){for(var G=0,S=0,j=Math.min(w.length,d),H=B;H<j;H++){var b=w.charCodeAt(H)-48;G*=N,b>=49?S=b-49+10:b>=17?S=b-17+10:S=b,s(b>=0&&S<N,"Invalid character"),G+=S}return G}r.prototype._parseBase=function(B,d,N){this.words=[0],this.length=1;for(var G=0,S=1;S<=67108863;S*=d)G++;G--,S=S/d|0;for(var j=B.length-N,H=j%G,b=Math.min(j,j-H)+N,E=0,p=N;p<b;p+=G)E=Q(B,p,p+G,d),this.imuln(S),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E);if(H!==0){var U=1;for(E=Q(B,p,B.length,d),p=0;p<H;p++)U*=d;this.imuln(U),this.words[0]+E<67108864?this.words[0]+=E:this._iaddn(E)}this._strip()},r.prototype.copy=function(B){B.words=new Array(this.length);for(var d=0;d<this.length;d++)B.words[d]=this.words[d];B.length=this.length,B.negative=this.negative,B.red=this.red};function l(w,B){w.words=B.words,w.length=B.length,w.negative=B.negative,w.red=B.red}if(r.prototype._move=function(B){l(B,this)},r.prototype.clone=function(){var B=new r(null);return this.copy(B),B},r.prototype._expand=function(B){for(;this.length<B;)this.words[this.length++]=0;return this},r.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},r.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=C}catch{r.prototype.inspect=C}else r.prototype.inspect=C;function C(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];r.prototype.toString=function(B,d){B=B||10,d=d|0||1;var N;if(B===16||B==="hex"){N="";for(var G=0,S=0,j=0;j<this.length;j++){var H=this.words[j],b=((H<<G|S)&16777215).toString(16);S=H>>>24-G&16777215,G+=2,G>=26&&(G-=26,j--),S!==0||j!==this.length-1?N=I[6-b.length]+b+N:N=b+N}for(S!==0&&(N=S.toString(16)+N);N.length%d!==0;)N="0"+N;return this.negative!==0&&(N="-"+N),N}if(B===(B|0)&&B>=2&&B<=36){var E=c[B],p=u[B];N="";var U=this.clone();for(U.negative=0;!U.isZero();){var R=U.modrn(p).toString(B);U=U.idivn(p),U.isZero()?N=R+N:N=I[E-R.length]+R+N}for(this.isZero()&&(N="0"+N);N.length%d!==0;)N="0"+N;return this.negative!==0&&(N="-"+N),N}s(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var B=this.words[0];return this.length===2?B+=this.words[1]*67108864:this.length===3&&this.words[2]===1?B+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-B:B},r.prototype.toJSON=function(){return this.toString(16,2)},i&&(r.prototype.toBuffer=function(B,d){return this.toArrayLike(i,B,d)}),r.prototype.toArray=function(B,d){return this.toArrayLike(Array,B,d)};var f=function(B,d){return B.allocUnsafe?B.allocUnsafe(d):new B(d)};r.prototype.toArrayLike=function(B,d,N){this._strip();var G=this.byteLength(),S=N||Math.max(1,G);s(G<=S,"byte array longer than desired length"),s(S>0,"Requested array length <= 0");var j=f(B,S),H=d==="le"?"LE":"BE";return this["_toArrayLike"+H](j,G),j},r.prototype._toArrayLikeLE=function(B,d){for(var N=0,G=0,S=0,j=0;S<this.length;S++){var H=this.words[S]<<j|G;B[N++]=H&255,N<B.length&&(B[N++]=H>>8&255),N<B.length&&(B[N++]=H>>16&255),j===6?(N<B.length&&(B[N++]=H>>24&255),G=0,j=0):(G=H>>>24,j+=2)}if(N<B.length)for(B[N++]=G;N<B.length;)B[N++]=0},r.prototype._toArrayLikeBE=function(B,d){for(var N=B.length-1,G=0,S=0,j=0;S<this.length;S++){var H=this.words[S]<<j|G;B[N--]=H&255,N>=0&&(B[N--]=H>>8&255),N>=0&&(B[N--]=H>>16&255),j===6?(N>=0&&(B[N--]=H>>24&255),G=0,j=0):(G=H>>>24,j+=2)}if(N>=0)for(B[N--]=G;N>=0;)B[N--]=0},Math.clz32?r.prototype._countBits=function(B){return 32-Math.clz32(B)}:r.prototype._countBits=function(B){var d=B,N=0;return d>=4096&&(N+=13,d>>>=13),d>=64&&(N+=7,d>>>=7),d>=8&&(N+=4,d>>>=4),d>=2&&(N+=2,d>>>=2),N+d},r.prototype._zeroBits=function(B){if(B===0)return 26;var d=B,N=0;return(d&8191)===0&&(N+=13,d>>>=13),(d&127)===0&&(N+=7,d>>>=7),(d&15)===0&&(N+=4,d>>>=4),(d&3)===0&&(N+=2,d>>>=2),(d&1)===0&&N++,N},r.prototype.bitLength=function(){var B=this.words[this.length-1],d=this._countBits(B);return(this.length-1)*26+d};function h(w){for(var B=new Array(w.bitLength()),d=0;d<B.length;d++){var N=d/26|0,G=d%26;B[d]=w.words[N]>>>G&1}return B}r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var B=0,d=0;d<this.length;d++){var N=this._zeroBits(this.words[d]);if(B+=N,N!==26)break}return B},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(B){return this.negative!==0?this.abs().inotn(B).iaddn(1):this.clone()},r.prototype.fromTwos=function(B){return this.testn(B-1)?this.notn(B).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return this.negative!==0},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(B){for(;this.length<B.length;)this.words[this.length++]=0;for(var d=0;d<B.length;d++)this.words[d]=this.words[d]|B.words[d];return this._strip()},r.prototype.ior=function(B){return s((this.negative|B.negative)===0),this.iuor(B)},r.prototype.or=function(B){return this.length>B.length?this.clone().ior(B):B.clone().ior(this)},r.prototype.uor=function(B){return this.length>B.length?this.clone().iuor(B):B.clone().iuor(this)},r.prototype.iuand=function(B){var d;this.length>B.length?d=B:d=this;for(var N=0;N<d.length;N++)this.words[N]=this.words[N]&B.words[N];return this.length=d.length,this._strip()},r.prototype.iand=function(B){return s((this.negative|B.negative)===0),this.iuand(B)},r.prototype.and=function(B){return this.length>B.length?this.clone().iand(B):B.clone().iand(this)},r.prototype.uand=function(B){return this.length>B.length?this.clone().iuand(B):B.clone().iuand(this)},r.prototype.iuxor=function(B){var d,N;this.length>B.length?(d=this,N=B):(d=B,N=this);for(var G=0;G<N.length;G++)this.words[G]=d.words[G]^N.words[G];if(this!==d)for(;G<d.length;G++)this.words[G]=d.words[G];return this.length=d.length,this._strip()},r.prototype.ixor=function(B){return s((this.negative|B.negative)===0),this.iuxor(B)},r.prototype.xor=function(B){return this.length>B.length?this.clone().ixor(B):B.clone().ixor(this)},r.prototype.uxor=function(B){return this.length>B.length?this.clone().iuxor(B):B.clone().iuxor(this)},r.prototype.inotn=function(B){s(typeof B=="number"&&B>=0);var d=Math.ceil(B/26)|0,N=B%26;this._expand(d),N>0&&d--;for(var G=0;G<d;G++)this.words[G]=~this.words[G]&67108863;return N>0&&(this.words[G]=~this.words[G]&67108863>>26-N),this._strip()},r.prototype.notn=function(B){return this.clone().inotn(B)},r.prototype.setn=function(B,d){s(typeof B=="number"&&B>=0);var N=B/26|0,G=B%26;return this._expand(N+1),d?this.words[N]=this.words[N]|1<<G:this.words[N]=this.words[N]&~(1<<G),this._strip()},r.prototype.iadd=function(B){var d;if(this.negative!==0&&B.negative===0)return this.negative=0,d=this.isub(B),this.negative^=1,this._normSign();if(this.negative===0&&B.negative!==0)return B.negative=0,d=this.isub(B),B.negative=1,d._normSign();var N,G;this.length>B.length?(N=this,G=B):(N=B,G=this);for(var S=0,j=0;j<G.length;j++)d=(N.words[j]|0)+(G.words[j]|0)+S,this.words[j]=d&67108863,S=d>>>26;for(;S!==0&&j<N.length;j++)d=(N.words[j]|0)+S,this.words[j]=d&67108863,S=d>>>26;if(this.length=N.length,S!==0)this.words[this.length]=S,this.length++;else if(N!==this)for(;j<N.length;j++)this.words[j]=N.words[j];return this},r.prototype.add=function(B){var d;return B.negative!==0&&this.negative===0?(B.negative=0,d=this.sub(B),B.negative^=1,d):B.negative===0&&this.negative!==0?(this.negative=0,d=B.sub(this),this.negative=1,d):this.length>B.length?this.clone().iadd(B):B.clone().iadd(this)},r.prototype.isub=function(B){if(B.negative!==0){B.negative=0;var d=this.iadd(B);return B.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(B),this.negative=1,this._normSign();var N=this.cmp(B);if(N===0)return this.negative=0,this.length=1,this.words[0]=0,this;var G,S;N>0?(G=this,S=B):(G=B,S=this);for(var j=0,H=0;H<S.length;H++)d=(G.words[H]|0)-(S.words[H]|0)+j,j=d>>26,this.words[H]=d&67108863;for(;j!==0&&H<G.length;H++)d=(G.words[H]|0)+j,j=d>>26,this.words[H]=d&67108863;if(j===0&&H<G.length&&G!==this)for(;H<G.length;H++)this.words[H]=G.words[H];return this.length=Math.max(this.length,H),G!==this&&(this.negative=1),this._strip()},r.prototype.sub=function(B){return this.clone().isub(B)};function k(w,B,d){d.negative=B.negative^w.negative;var N=w.length+B.length|0;d.length=N,N=N-1|0;var G=w.words[0]|0,S=B.words[0]|0,j=G*S,H=j&67108863,b=j/67108864|0;d.words[0]=H;for(var E=1;E<N;E++){for(var p=b>>>26,U=b&67108863,R=Math.min(E,B.length-1),_=Math.max(0,E-w.length+1);_<=R;_++){var tA=E-_|0;G=w.words[tA]|0,S=B.words[_]|0,j=G*S+U,p+=j/67108864|0,U=j&67108863}d.words[E]=U|0,b=p|0}return b!==0?d.words[E]=b|0:d.length--,d._strip()}var v=function(B,d,N){var G=B.words,S=d.words,j=N.words,H=0,b,E,p,U=G[0]|0,R=U&8191,_=U>>>13,tA=G[1]|0,IA=tA&8191,iA=tA>>>13,UA=G[2]|0,HA=UA&8191,lA=UA>>>13,qA=G[3]|0,re=qA&8191,he=qA>>>13,kA=G[4]|0,VA=kA&8191,ae=kA>>>13,He=G[5]|0,le=He&8191,Ge=He>>>13,nt=G[6]|0,ve=nt&8191,yA=nt>>>13,pe=G[7]|0,YA=pe&8191,q=pe>>>13,y=G[8]|0,M=y&8191,Z=y>>>13,AA=G[9]|0,nA=AA&8191,cA=AA>>>13,zA=S[0]|0,PA=zA&8191,ZA=zA>>>13,Se=S[1]|0,WA=Se&8191,De=Se>>>13,Pt=S[2]|0,Je=Pt&8191,Pe=Pt>>>13,So=S[3]|0,ce=So&8191,Ue=So>>>13,Wt=S[4]|0,Oe=Wt&8191,_e=Wt>>>13,_A=S[5]|0,ye=_A&8191,fe=_A>>>13,Uo=S[6]|0,F=Uo&8191,Y=Uo>>>13,P=S[7]|0,m=P&8191,z=P>>>13,sA=S[8]|0,oA=sA&8191,uA=sA>>>13,DA=S[9]|0,bA=DA&8191,xA=DA>>>13;N.negative=B.negative^d.negative,N.length=19,b=Math.imul(R,PA),E=Math.imul(R,ZA),E=E+Math.imul(_,PA)|0,p=Math.imul(_,ZA);var Ie=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,b=Math.imul(IA,PA),E=Math.imul(IA,ZA),E=E+Math.imul(iA,PA)|0,p=Math.imul(iA,ZA),b=b+Math.imul(R,WA)|0,E=E+Math.imul(R,De)|0,E=E+Math.imul(_,WA)|0,p=p+Math.imul(_,De)|0;var SA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(SA>>>26)|0,SA&=67108863,b=Math.imul(HA,PA),E=Math.imul(HA,ZA),E=E+Math.imul(lA,PA)|0,p=Math.imul(lA,ZA),b=b+Math.imul(IA,WA)|0,E=E+Math.imul(IA,De)|0,E=E+Math.imul(iA,WA)|0,p=p+Math.imul(iA,De)|0,b=b+Math.imul(R,Je)|0,E=E+Math.imul(R,Pe)|0,E=E+Math.imul(_,Je)|0,p=p+Math.imul(_,Pe)|0;var XA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(XA>>>26)|0,XA&=67108863,b=Math.imul(re,PA),E=Math.imul(re,ZA),E=E+Math.imul(he,PA)|0,p=Math.imul(he,ZA),b=b+Math.imul(HA,WA)|0,E=E+Math.imul(HA,De)|0,E=E+Math.imul(lA,WA)|0,p=p+Math.imul(lA,De)|0,b=b+Math.imul(IA,Je)|0,E=E+Math.imul(IA,Pe)|0,E=E+Math.imul(iA,Je)|0,p=p+Math.imul(iA,Pe)|0,b=b+Math.imul(R,ce)|0,E=E+Math.imul(R,Ue)|0,E=E+Math.imul(_,ce)|0,p=p+Math.imul(_,Ue)|0;var se=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(se>>>26)|0,se&=67108863,b=Math.imul(VA,PA),E=Math.imul(VA,ZA),E=E+Math.imul(ae,PA)|0,p=Math.imul(ae,ZA),b=b+Math.imul(re,WA)|0,E=E+Math.imul(re,De)|0,E=E+Math.imul(he,WA)|0,p=p+Math.imul(he,De)|0,b=b+Math.imul(HA,Je)|0,E=E+Math.imul(HA,Pe)|0,E=E+Math.imul(lA,Je)|0,p=p+Math.imul(lA,Pe)|0,b=b+Math.imul(IA,ce)|0,E=E+Math.imul(IA,Ue)|0,E=E+Math.imul(iA,ce)|0,p=p+Math.imul(iA,Ue)|0,b=b+Math.imul(R,Oe)|0,E=E+Math.imul(R,_e)|0,E=E+Math.imul(_,Oe)|0,p=p+Math.imul(_,_e)|0;var ge=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(ge>>>26)|0,ge&=67108863,b=Math.imul(le,PA),E=Math.imul(le,ZA),E=E+Math.imul(Ge,PA)|0,p=Math.imul(Ge,ZA),b=b+Math.imul(VA,WA)|0,E=E+Math.imul(VA,De)|0,E=E+Math.imul(ae,WA)|0,p=p+Math.imul(ae,De)|0,b=b+Math.imul(re,Je)|0,E=E+Math.imul(re,Pe)|0,E=E+Math.imul(he,Je)|0,p=p+Math.imul(he,Pe)|0,b=b+Math.imul(HA,ce)|0,E=E+Math.imul(HA,Ue)|0,E=E+Math.imul(lA,ce)|0,p=p+Math.imul(lA,Ue)|0,b=b+Math.imul(IA,Oe)|0,E=E+Math.imul(IA,_e)|0,E=E+Math.imul(iA,Oe)|0,p=p+Math.imul(iA,_e)|0,b=b+Math.imul(R,ye)|0,E=E+Math.imul(R,fe)|0,E=E+Math.imul(_,ye)|0,p=p+Math.imul(_,fe)|0;var ie=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(ie>>>26)|0,ie&=67108863,b=Math.imul(ve,PA),E=Math.imul(ve,ZA),E=E+Math.imul(yA,PA)|0,p=Math.imul(yA,ZA),b=b+Math.imul(le,WA)|0,E=E+Math.imul(le,De)|0,E=E+Math.imul(Ge,WA)|0,p=p+Math.imul(Ge,De)|0,b=b+Math.imul(VA,Je)|0,E=E+Math.imul(VA,Pe)|0,E=E+Math.imul(ae,Je)|0,p=p+Math.imul(ae,Pe)|0,b=b+Math.imul(re,ce)|0,E=E+Math.imul(re,Ue)|0,E=E+Math.imul(he,ce)|0,p=p+Math.imul(he,Ue)|0,b=b+Math.imul(HA,Oe)|0,E=E+Math.imul(HA,_e)|0,E=E+Math.imul(lA,Oe)|0,p=p+Math.imul(lA,_e)|0,b=b+Math.imul(IA,ye)|0,E=E+Math.imul(IA,fe)|0,E=E+Math.imul(iA,ye)|0,p=p+Math.imul(iA,fe)|0,b=b+Math.imul(R,F)|0,E=E+Math.imul(R,Y)|0,E=E+Math.imul(_,F)|0,p=p+Math.imul(_,Y)|0;var te=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(te>>>26)|0,te&=67108863,b=Math.imul(YA,PA),E=Math.imul(YA,ZA),E=E+Math.imul(q,PA)|0,p=Math.imul(q,ZA),b=b+Math.imul(ve,WA)|0,E=E+Math.imul(ve,De)|0,E=E+Math.imul(yA,WA)|0,p=p+Math.imul(yA,De)|0,b=b+Math.imul(le,Je)|0,E=E+Math.imul(le,Pe)|0,E=E+Math.imul(Ge,Je)|0,p=p+Math.imul(Ge,Pe)|0,b=b+Math.imul(VA,ce)|0,E=E+Math.imul(VA,Ue)|0,E=E+Math.imul(ae,ce)|0,p=p+Math.imul(ae,Ue)|0,b=b+Math.imul(re,Oe)|0,E=E+Math.imul(re,_e)|0,E=E+Math.imul(he,Oe)|0,p=p+Math.imul(he,_e)|0,b=b+Math.imul(HA,ye)|0,E=E+Math.imul(HA,fe)|0,E=E+Math.imul(lA,ye)|0,p=p+Math.imul(lA,fe)|0,b=b+Math.imul(IA,F)|0,E=E+Math.imul(IA,Y)|0,E=E+Math.imul(iA,F)|0,p=p+Math.imul(iA,Y)|0,b=b+Math.imul(R,m)|0,E=E+Math.imul(R,z)|0,E=E+Math.imul(_,m)|0,p=p+Math.imul(_,z)|0;var oe=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(oe>>>26)|0,oe&=67108863,b=Math.imul(M,PA),E=Math.imul(M,ZA),E=E+Math.imul(Z,PA)|0,p=Math.imul(Z,ZA),b=b+Math.imul(YA,WA)|0,E=E+Math.imul(YA,De)|0,E=E+Math.imul(q,WA)|0,p=p+Math.imul(q,De)|0,b=b+Math.imul(ve,Je)|0,E=E+Math.imul(ve,Pe)|0,E=E+Math.imul(yA,Je)|0,p=p+Math.imul(yA,Pe)|0,b=b+Math.imul(le,ce)|0,E=E+Math.imul(le,Ue)|0,E=E+Math.imul(Ge,ce)|0,p=p+Math.imul(Ge,Ue)|0,b=b+Math.imul(VA,Oe)|0,E=E+Math.imul(VA,_e)|0,E=E+Math.imul(ae,Oe)|0,p=p+Math.imul(ae,_e)|0,b=b+Math.imul(re,ye)|0,E=E+Math.imul(re,fe)|0,E=E+Math.imul(he,ye)|0,p=p+Math.imul(he,fe)|0,b=b+Math.imul(HA,F)|0,E=E+Math.imul(HA,Y)|0,E=E+Math.imul(lA,F)|0,p=p+Math.imul(lA,Y)|0,b=b+Math.imul(IA,m)|0,E=E+Math.imul(IA,z)|0,E=E+Math.imul(iA,m)|0,p=p+Math.imul(iA,z)|0,b=b+Math.imul(R,oA)|0,E=E+Math.imul(R,uA)|0,E=E+Math.imul(_,oA)|0,p=p+Math.imul(_,uA)|0;var $A=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+($A>>>26)|0,$A&=67108863,b=Math.imul(nA,PA),E=Math.imul(nA,ZA),E=E+Math.imul(cA,PA)|0,p=Math.imul(cA,ZA),b=b+Math.imul(M,WA)|0,E=E+Math.imul(M,De)|0,E=E+Math.imul(Z,WA)|0,p=p+Math.imul(Z,De)|0,b=b+Math.imul(YA,Je)|0,E=E+Math.imul(YA,Pe)|0,E=E+Math.imul(q,Je)|0,p=p+Math.imul(q,Pe)|0,b=b+Math.imul(ve,ce)|0,E=E+Math.imul(ve,Ue)|0,E=E+Math.imul(yA,ce)|0,p=p+Math.imul(yA,Ue)|0,b=b+Math.imul(le,Oe)|0,E=E+Math.imul(le,_e)|0,E=E+Math.imul(Ge,Oe)|0,p=p+Math.imul(Ge,_e)|0,b=b+Math.imul(VA,ye)|0,E=E+Math.imul(VA,fe)|0,E=E+Math.imul(ae,ye)|0,p=p+Math.imul(ae,fe)|0,b=b+Math.imul(re,F)|0,E=E+Math.imul(re,Y)|0,E=E+Math.imul(he,F)|0,p=p+Math.imul(he,Y)|0,b=b+Math.imul(HA,m)|0,E=E+Math.imul(HA,z)|0,E=E+Math.imul(lA,m)|0,p=p+Math.imul(lA,z)|0,b=b+Math.imul(IA,oA)|0,E=E+Math.imul(IA,uA)|0,E=E+Math.imul(iA,oA)|0,p=p+Math.imul(iA,uA)|0,b=b+Math.imul(R,bA)|0,E=E+Math.imul(R,xA)|0,E=E+Math.imul(_,bA)|0,p=p+Math.imul(_,xA)|0;var RA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(RA>>>26)|0,RA&=67108863,b=Math.imul(nA,WA),E=Math.imul(nA,De),E=E+Math.imul(cA,WA)|0,p=Math.imul(cA,De),b=b+Math.imul(M,Je)|0,E=E+Math.imul(M,Pe)|0,E=E+Math.imul(Z,Je)|0,p=p+Math.imul(Z,Pe)|0,b=b+Math.imul(YA,ce)|0,E=E+Math.imul(YA,Ue)|0,E=E+Math.imul(q,ce)|0,p=p+Math.imul(q,Ue)|0,b=b+Math.imul(ve,Oe)|0,E=E+Math.imul(ve,_e)|0,E=E+Math.imul(yA,Oe)|0,p=p+Math.imul(yA,_e)|0,b=b+Math.imul(le,ye)|0,E=E+Math.imul(le,fe)|0,E=E+Math.imul(Ge,ye)|0,p=p+Math.imul(Ge,fe)|0,b=b+Math.imul(VA,F)|0,E=E+Math.imul(VA,Y)|0,E=E+Math.imul(ae,F)|0,p=p+Math.imul(ae,Y)|0,b=b+Math.imul(re,m)|0,E=E+Math.imul(re,z)|0,E=E+Math.imul(he,m)|0,p=p+Math.imul(he,z)|0,b=b+Math.imul(HA,oA)|0,E=E+Math.imul(HA,uA)|0,E=E+Math.imul(lA,oA)|0,p=p+Math.imul(lA,uA)|0,b=b+Math.imul(IA,bA)|0,E=E+Math.imul(IA,xA)|0,E=E+Math.imul(iA,bA)|0,p=p+Math.imul(iA,xA)|0;var OA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(OA>>>26)|0,OA&=67108863,b=Math.imul(nA,Je),E=Math.imul(nA,Pe),E=E+Math.imul(cA,Je)|0,p=Math.imul(cA,Pe),b=b+Math.imul(M,ce)|0,E=E+Math.imul(M,Ue)|0,E=E+Math.imul(Z,ce)|0,p=p+Math.imul(Z,Ue)|0,b=b+Math.imul(YA,Oe)|0,E=E+Math.imul(YA,_e)|0,E=E+Math.imul(q,Oe)|0,p=p+Math.imul(q,_e)|0,b=b+Math.imul(ve,ye)|0,E=E+Math.imul(ve,fe)|0,E=E+Math.imul(yA,ye)|0,p=p+Math.imul(yA,fe)|0,b=b+Math.imul(le,F)|0,E=E+Math.imul(le,Y)|0,E=E+Math.imul(Ge,F)|0,p=p+Math.imul(Ge,Y)|0,b=b+Math.imul(VA,m)|0,E=E+Math.imul(VA,z)|0,E=E+Math.imul(ae,m)|0,p=p+Math.imul(ae,z)|0,b=b+Math.imul(re,oA)|0,E=E+Math.imul(re,uA)|0,E=E+Math.imul(he,oA)|0,p=p+Math.imul(he,uA)|0,b=b+Math.imul(HA,bA)|0,E=E+Math.imul(HA,xA)|0,E=E+Math.imul(lA,bA)|0,p=p+Math.imul(lA,xA)|0;var vA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(vA>>>26)|0,vA&=67108863,b=Math.imul(nA,ce),E=Math.imul(nA,Ue),E=E+Math.imul(cA,ce)|0,p=Math.imul(cA,Ue),b=b+Math.imul(M,Oe)|0,E=E+Math.imul(M,_e)|0,E=E+Math.imul(Z,Oe)|0,p=p+Math.imul(Z,_e)|0,b=b+Math.imul(YA,ye)|0,E=E+Math.imul(YA,fe)|0,E=E+Math.imul(q,ye)|0,p=p+Math.imul(q,fe)|0,b=b+Math.imul(ve,F)|0,E=E+Math.imul(ve,Y)|0,E=E+Math.imul(yA,F)|0,p=p+Math.imul(yA,Y)|0,b=b+Math.imul(le,m)|0,E=E+Math.imul(le,z)|0,E=E+Math.imul(Ge,m)|0,p=p+Math.imul(Ge,z)|0,b=b+Math.imul(VA,oA)|0,E=E+Math.imul(VA,uA)|0,E=E+Math.imul(ae,oA)|0,p=p+Math.imul(ae,uA)|0,b=b+Math.imul(re,bA)|0,E=E+Math.imul(re,xA)|0,E=E+Math.imul(he,bA)|0,p=p+Math.imul(he,xA)|0;var KA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(KA>>>26)|0,KA&=67108863,b=Math.imul(nA,Oe),E=Math.imul(nA,_e),E=E+Math.imul(cA,Oe)|0,p=Math.imul(cA,_e),b=b+Math.imul(M,ye)|0,E=E+Math.imul(M,fe)|0,E=E+Math.imul(Z,ye)|0,p=p+Math.imul(Z,fe)|0,b=b+Math.imul(YA,F)|0,E=E+Math.imul(YA,Y)|0,E=E+Math.imul(q,F)|0,p=p+Math.imul(q,Y)|0,b=b+Math.imul(ve,m)|0,E=E+Math.imul(ve,z)|0,E=E+Math.imul(yA,m)|0,p=p+Math.imul(yA,z)|0,b=b+Math.imul(le,oA)|0,E=E+Math.imul(le,uA)|0,E=E+Math.imul(Ge,oA)|0,p=p+Math.imul(Ge,uA)|0,b=b+Math.imul(VA,bA)|0,E=E+Math.imul(VA,xA)|0,E=E+Math.imul(ae,bA)|0,p=p+Math.imul(ae,xA)|0;var JA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(JA>>>26)|0,JA&=67108863,b=Math.imul(nA,ye),E=Math.imul(nA,fe),E=E+Math.imul(cA,ye)|0,p=Math.imul(cA,fe),b=b+Math.imul(M,F)|0,E=E+Math.imul(M,Y)|0,E=E+Math.imul(Z,F)|0,p=p+Math.imul(Z,Y)|0,b=b+Math.imul(YA,m)|0,E=E+Math.imul(YA,z)|0,E=E+Math.imul(q,m)|0,p=p+Math.imul(q,z)|0,b=b+Math.imul(ve,oA)|0,E=E+Math.imul(ve,uA)|0,E=E+Math.imul(yA,oA)|0,p=p+Math.imul(yA,uA)|0,b=b+Math.imul(le,bA)|0,E=E+Math.imul(le,xA)|0,E=E+Math.imul(Ge,bA)|0,p=p+Math.imul(Ge,xA)|0;var GA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(GA>>>26)|0,GA&=67108863,b=Math.imul(nA,F),E=Math.imul(nA,Y),E=E+Math.imul(cA,F)|0,p=Math.imul(cA,Y),b=b+Math.imul(M,m)|0,E=E+Math.imul(M,z)|0,E=E+Math.imul(Z,m)|0,p=p+Math.imul(Z,z)|0,b=b+Math.imul(YA,oA)|0,E=E+Math.imul(YA,uA)|0,E=E+Math.imul(q,oA)|0,p=p+Math.imul(q,uA)|0,b=b+Math.imul(ve,bA)|0,E=E+Math.imul(ve,xA)|0,E=E+Math.imul(yA,bA)|0,p=p+Math.imul(yA,xA)|0;var EA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(EA>>>26)|0,EA&=67108863,b=Math.imul(nA,m),E=Math.imul(nA,z),E=E+Math.imul(cA,m)|0,p=Math.imul(cA,z),b=b+Math.imul(M,oA)|0,E=E+Math.imul(M,uA)|0,E=E+Math.imul(Z,oA)|0,p=p+Math.imul(Z,uA)|0,b=b+Math.imul(YA,bA)|0,E=E+Math.imul(YA,xA)|0,E=E+Math.imul(q,bA)|0,p=p+Math.imul(q,xA)|0;var CA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(CA>>>26)|0,CA&=67108863,b=Math.imul(nA,oA),E=Math.imul(nA,uA),E=E+Math.imul(cA,oA)|0,p=Math.imul(cA,uA),b=b+Math.imul(M,bA)|0,E=E+Math.imul(M,xA)|0,E=E+Math.imul(Z,bA)|0,p=p+Math.imul(Z,xA)|0;var fA=(H+b|0)+((E&8191)<<13)|0;H=(p+(E>>>13)|0)+(fA>>>26)|0,fA&=67108863,b=Math.imul(nA,bA),E=Math.imul(nA,xA),E=E+Math.imul(cA,bA)|0,p=Math.imul(cA,xA);var hA=(H+b|0)+((E&8191)<<13)|0;return H=(p+(E>>>13)|0)+(hA>>>26)|0,hA&=67108863,j[0]=Ie,j[1]=SA,j[2]=XA,j[3]=se,j[4]=ge,j[5]=ie,j[6]=te,j[7]=oe,j[8]=$A,j[9]=RA,j[10]=OA,j[11]=vA,j[12]=KA,j[13]=JA,j[14]=GA,j[15]=EA,j[16]=CA,j[17]=fA,j[18]=hA,H!==0&&(j[19]=H,N.length++),N};Math.imul||(v=k);function D(w,B,d){d.negative=B.negative^w.negative,d.length=w.length+B.length;for(var N=0,G=0,S=0;S<d.length-1;S++){var j=G;G=0;for(var H=N&67108863,b=Math.min(S,B.length-1),E=Math.max(0,S-w.length+1);E<=b;E++){var p=S-E,U=w.words[p]|0,R=B.words[E]|0,_=U*R,tA=_&67108863;j=j+(_/67108864|0)|0,tA=tA+H|0,H=tA&67108863,j=j+(tA>>>26)|0,G+=j>>>26,j&=67108863}d.words[S]=H,N=j,j=G}return N!==0?d.words[S]=N:d.length--,d._strip()}function O(w,B,d){return D(w,B,d)}r.prototype.mulTo=function(B,d){var N,G=this.length+B.length;return this.length===10&&B.length===10?N=v(this,B,d):G<63?N=k(this,B,d):G<1024?N=D(this,B,d):N=O(this,B,d),N},r.prototype.mul=function(B){var d=new r(null);return d.words=new Array(this.length+B.length),this.mulTo(B,d)},r.prototype.mulf=function(B){var d=new r(null);return d.words=new Array(this.length+B.length),O(this,B,d)},r.prototype.imul=function(B){return this.clone().mulTo(B,this)},r.prototype.imuln=function(B){var d=B<0;d&&(B=-B),s(typeof B=="number"),s(B<67108864);for(var N=0,G=0;G<this.length;G++){var S=(this.words[G]|0)*B,j=(S&67108863)+(N&67108863);N>>=26,N+=S/67108864|0,N+=j>>>26,this.words[G]=j&67108863}return N!==0&&(this.words[G]=N,this.length++),this.length=B===0?1:this.length,d?this.ineg():this},r.prototype.muln=function(B){return this.clone().imuln(B)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(B){var d=h(B);if(d.length===0)return new r(1);for(var N=this,G=0;G<d.length&&d[G]===0;G++,N=N.sqr());if(++G<d.length)for(var S=N.sqr();G<d.length;G++,S=S.sqr())d[G]!==0&&(N=N.mul(S));return N},r.prototype.iushln=function(B){s(typeof B=="number"&&B>=0);var d=B%26,N=(B-d)/26,G=67108863>>>26-d<<26-d,S;if(d!==0){var j=0;for(S=0;S<this.length;S++){var H=this.words[S]&G,b=(this.words[S]|0)-H<<d;this.words[S]=b|j,j=H>>>26-d}j&&(this.words[S]=j,this.length++)}if(N!==0){for(S=this.length-1;S>=0;S--)this.words[S+N]=this.words[S];for(S=0;S<N;S++)this.words[S]=0;this.length+=N}return this._strip()},r.prototype.ishln=function(B){return s(this.negative===0),this.iushln(B)},r.prototype.iushrn=function(B,d,N){s(typeof B=="number"&&B>=0);var G;d?G=(d-d%26)/26:G=0;var S=B%26,j=Math.min((B-S)/26,this.length),H=67108863^67108863>>>S<<S,b=N;if(G-=j,G=Math.max(0,G),b){for(var E=0;E<j;E++)b.words[E]=this.words[E];b.length=j}if(j!==0)if(this.length>j)for(this.length-=j,E=0;E<this.length;E++)this.words[E]=this.words[E+j];else this.words[0]=0,this.length=1;var p=0;for(E=this.length-1;E>=0&&(p!==0||E>=G);E--){var U=this.words[E]|0;this.words[E]=p<<26-S|U>>>S,p=U&H}return b&&p!==0&&(b.words[b.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(B,d,N){return s(this.negative===0),this.iushrn(B,d,N)},r.prototype.shln=function(B){return this.clone().ishln(B)},r.prototype.ushln=function(B){return this.clone().iushln(B)},r.prototype.shrn=function(B){return this.clone().ishrn(B)},r.prototype.ushrn=function(B){return this.clone().iushrn(B)},r.prototype.testn=function(B){s(typeof B=="number"&&B>=0);var d=B%26,N=(B-d)/26,G=1<<d;if(this.length<=N)return!1;var S=this.words[N];return!!(S&G)},r.prototype.imaskn=function(B){s(typeof B=="number"&&B>=0);var d=B%26,N=(B-d)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=N)return this;if(d!==0&&N++,this.length=Math.min(N,this.length),d!==0){var G=67108863^67108863>>>d<<d;this.words[this.length-1]&=G}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.maskn=function(B){return this.clone().imaskn(B)},r.prototype.iaddn=function(B){return s(typeof B=="number"),s(B<67108864),B<0?this.isubn(-B):this.negative!==0?this.length===1&&(this.words[0]|0)<=B?(this.words[0]=B-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(B),this.negative=1,this):this._iaddn(B)},r.prototype._iaddn=function(B){this.words[0]+=B;for(var d=0;d<this.length&&this.words[d]>=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},r.prototype.isubn=function(B){if(s(typeof B=="number"),s(B<67108864),B<0)return this.iaddn(-B);if(this.negative!==0)return this.negative=0,this.iaddn(B),this.negative=1,this;if(this.words[0]-=B,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d<this.length&&this.words[d]<0;d++)this.words[d]+=67108864,this.words[d+1]-=1;return this._strip()},r.prototype.addn=function(B){return this.clone().iaddn(B)},r.prototype.subn=function(B){return this.clone().isubn(B)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(B,d,N){var G=B.length+N,S;this._expand(G);var j,H=0;for(S=0;S<B.length;S++){j=(this.words[S+N]|0)+H;var b=(B.words[S]|0)*d;j-=b&67108863,H=(j>>26)-(b/67108864|0),this.words[S+N]=j&67108863}for(;S<this.length-N;S++)j=(this.words[S+N]|0)+H,H=j>>26,this.words[S+N]=j&67108863;if(H===0)return this._strip();for(s(H===-1),H=0,S=0;S<this.length;S++)j=-(this.words[S]|0)+H,H=j>>26,this.words[S]=j&67108863;return this.negative=1,this._strip()},r.prototype._wordDiv=function(B,d){var N=this.length-B.length,G=this.clone(),S=B,j=S.words[S.length-1]|0,H=this._countBits(j);N=26-H,N!==0&&(S=S.ushln(N),G.iushln(N),j=S.words[S.length-1]|0);var b=G.length-S.length,E;if(d!=="mod"){E=new r(null),E.length=b+1,E.words=new Array(E.length);for(var p=0;p<E.length;p++)E.words[p]=0}var U=G.clone()._ishlnsubmul(S,1,b);U.negative===0&&(G=U,E&&(E.words[b]=1));for(var R=b-1;R>=0;R--){var _=(G.words[S.length+R]|0)*67108864+(G.words[S.length+R-1]|0);for(_=Math.min(_/j|0,67108863),G._ishlnsubmul(S,_,R);G.negative!==0;)_--,G.negative=0,G._ishlnsubmul(S,1,R),G.isZero()||(G.negative^=1);E&&(E.words[R]=_)}return E&&E._strip(),G._strip(),d!=="div"&&N!==0&&G.iushrn(N),{div:E||null,mod:G}},r.prototype.divmod=function(B,d,N){if(s(!B.isZero()),this.isZero())return{div:new r(0),mod:new r(0)};var G,S,j;return this.negative!==0&&B.negative===0?(j=this.neg().divmod(B,d),d!=="mod"&&(G=j.div.neg()),d!=="div"&&(S=j.mod.neg(),N&&S.negative!==0&&S.iadd(B)),{div:G,mod:S}):this.negative===0&&B.negative!==0?(j=this.divmod(B.neg(),d),d!=="mod"&&(G=j.div.neg()),{div:G,mod:j.mod}):(this.negative&B.negative)!==0?(j=this.neg().divmod(B.neg(),d),d!=="div"&&(S=j.mod.neg(),N&&S.negative!==0&&S.isub(B)),{div:j.div,mod:S}):B.length>this.length||this.cmp(B)<0?{div:new r(0),mod:this}:B.length===1?d==="div"?{div:this.divn(B.words[0]),mod:null}:d==="mod"?{div:null,mod:new r(this.modrn(B.words[0]))}:{div:this.divn(B.words[0]),mod:new r(this.modrn(B.words[0]))}:this._wordDiv(B,d)},r.prototype.div=function(B){return this.divmod(B,"div",!1).div},r.prototype.mod=function(B){return this.divmod(B,"mod",!1).mod},r.prototype.umod=function(B){return this.divmod(B,"mod",!0).mod},r.prototype.divRound=function(B){var d=this.divmod(B);if(d.mod.isZero())return d.div;var N=d.div.negative!==0?d.mod.isub(B):d.mod,G=B.ushrn(1),S=B.andln(1),j=N.cmp(G);return j<0||S===1&&j===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},r.prototype.modrn=function(B){var d=B<0;d&&(B=-B),s(B<=67108863);for(var N=(1<<26)%B,G=0,S=this.length-1;S>=0;S--)G=(N*G+(this.words[S]|0))%B;return d?-G:G},r.prototype.modn=function(B){return this.modrn(B)},r.prototype.idivn=function(B){var d=B<0;d&&(B=-B),s(B<=67108863);for(var N=0,G=this.length-1;G>=0;G--){var S=(this.words[G]|0)+N*67108864;this.words[G]=S/B|0,N=S%B}return this._strip(),d?this.ineg():this},r.prototype.divn=function(B){return this.clone().idivn(B)},r.prototype.egcd=function(B){s(B.negative===0),s(!B.isZero());var d=this,N=B.clone();d.negative!==0?d=d.umod(B):d=d.clone();for(var G=new r(1),S=new r(0),j=new r(0),H=new r(1),b=0;d.isEven()&&N.isEven();)d.iushrn(1),N.iushrn(1),++b;for(var E=N.clone(),p=d.clone();!d.isZero();){for(var U=0,R=1;(d.words[0]&R)===0&&U<26;++U,R<<=1);if(U>0)for(d.iushrn(U);U-- >0;)(G.isOdd()||S.isOdd())&&(G.iadd(E),S.isub(p)),G.iushrn(1),S.iushrn(1);for(var _=0,tA=1;(N.words[0]&tA)===0&&_<26;++_,tA<<=1);if(_>0)for(N.iushrn(_);_-- >0;)(j.isOdd()||H.isOdd())&&(j.iadd(E),H.isub(p)),j.iushrn(1),H.iushrn(1);d.cmp(N)>=0?(d.isub(N),G.isub(j),S.isub(H)):(N.isub(d),j.isub(G),H.isub(S))}return{a:j,b:H,gcd:N.iushln(b)}},r.prototype._invmp=function(B){s(B.negative===0),s(!B.isZero());var d=this,N=B.clone();d.negative!==0?d=d.umod(B):d=d.clone();for(var G=new r(1),S=new r(0),j=N.clone();d.cmpn(1)>0&&N.cmpn(1)>0;){for(var H=0,b=1;(d.words[0]&b)===0&&H<26;++H,b<<=1);if(H>0)for(d.iushrn(H);H-- >0;)G.isOdd()&&G.iadd(j),G.iushrn(1);for(var E=0,p=1;(N.words[0]&p)===0&&E<26;++E,p<<=1);if(E>0)for(N.iushrn(E);E-- >0;)S.isOdd()&&S.iadd(j),S.iushrn(1);d.cmp(N)>=0?(d.isub(N),G.isub(S)):(N.isub(d),S.isub(G))}var U;return d.cmpn(1)===0?U=G:U=S,U.cmpn(0)<0&&U.iadd(B),U},r.prototype.gcd=function(B){if(this.isZero())return B.abs();if(B.isZero())return this.abs();var d=this.clone(),N=B.clone();d.negative=0,N.negative=0;for(var G=0;d.isEven()&&N.isEven();G++)d.iushrn(1),N.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;N.isEven();)N.iushrn(1);var S=d.cmp(N);if(S<0){var j=d;d=N,N=j}else if(S===0||N.cmpn(1)===0)break;d.isub(N)}while(!0);return N.iushln(G)},r.prototype.invm=function(B){return this.egcd(B).a.umod(B)},r.prototype.isEven=function(){return(this.words[0]&1)===0},r.prototype.isOdd=function(){return(this.words[0]&1)===1},r.prototype.andln=function(B){return this.words[0]&B},r.prototype.bincn=function(B){s(typeof B=="number");var d=B%26,N=(B-d)/26,G=1<<d;if(this.length<=N)return this._expand(N+1),this.words[N]|=G,this;for(var S=G,j=N;S!==0&&j<this.length;j++){var H=this.words[j]|0;H+=S,S=H>>>26,H&=67108863,this.words[j]=H}return S!==0&&(this.words[j]=S,this.length++),this},r.prototype.isZero=function(){return this.length===1&&this.words[0]===0},r.prototype.cmpn=function(B){var d=B<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var N;if(this.length>1)N=1;else{d&&(B=-B),s(B<=67108863,"Number is too big");var G=this.words[0]|0;N=G===B?0:G<B?-1:1}return this.negative!==0?-N|0:N},r.prototype.cmp=function(B){if(this.negative!==0&&B.negative===0)return-1;if(this.negative===0&&B.negative!==0)return 1;var d=this.ucmp(B);return this.negative!==0?-d|0:d},r.prototype.ucmp=function(B){if(this.length>B.length)return 1;if(this.length<B.length)return-1;for(var d=0,N=this.length-1;N>=0;N--){var G=this.words[N]|0,S=B.words[N]|0;if(G!==S){G<S?d=-1:G>S&&(d=1);break}}return d},r.prototype.gtn=function(B){return this.cmpn(B)===1},r.prototype.gt=function(B){return this.cmp(B)===1},r.prototype.gten=function(B){return this.cmpn(B)>=0},r.prototype.gte=function(B){return this.cmp(B)>=0},r.prototype.ltn=function(B){return this.cmpn(B)===-1},r.prototype.lt=function(B){return this.cmp(B)===-1},r.prototype.lten=function(B){return this.cmpn(B)<=0},r.prototype.lte=function(B){return this.cmp(B)<=0},r.prototype.eqn=function(B){return this.cmpn(B)===0},r.prototype.eq=function(B){return this.cmp(B)===0},r.red=function(B){return new T(B)},r.prototype.toRed=function(B){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),B.convertTo(this)._forceRed(B)},r.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(B){return this.red=B,this},r.prototype.forceRed=function(B){return s(!this.red,"Already a number in reduction context"),this._forceRed(B)},r.prototype.redAdd=function(B){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,B)},r.prototype.redIAdd=function(B){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,B)},r.prototype.redSub=function(B){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,B)},r.prototype.redISub=function(B){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,B)},r.prototype.redShl=function(B){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,B)},r.prototype.redMul=function(B){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.mul(this,B)},r.prototype.redIMul=function(B){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,B),this.red.imul(this,B)},r.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(B){return s(this.red&&!B.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,B)};var J={k256:null,p224:null,p192:null,p25519:null};function V(w,B){this.name=w,this.p=new r(B,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var B=new r(null);return B.words=new Array(Math.ceil(this.n/13)),B},V.prototype.ireduce=function(B){var d=B,N;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),N=d.bitLength();while(N>this.n);var G=N<this.n?-1:d.ucmp(this.p);return G===0?(d.words[0]=0,d.length=1):G>0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(B,d){B.iushrn(this.n,0,d)},V.prototype.imulK=function(B){return B.imul(this.k)};function eA(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(eA,V),eA.prototype.split=function(B,d){for(var N=4194303,G=Math.min(B.length,9),S=0;S<G;S++)d.words[S]=B.words[S];if(d.length=G,B.length<=9){B.words[0]=0,B.length=1;return}var j=B.words[9];for(d.words[d.length++]=j&N,S=10;S<B.length;S++){var H=B.words[S]|0;B.words[S-10]=(H&N)<<4|j>>>22,j=H}j>>>=22,B.words[S-10]=j,j===0&&B.length>10?B.length-=10:B.length-=9},eA.prototype.imulK=function(B){B.words[B.length]=0,B.words[B.length+1]=0,B.length+=2;for(var d=0,N=0;N<B.length;N++){var G=B.words[N]|0;d+=G*977,B.words[N]=d&67108863,d=G*64+(d/67108864|0)}return B.words[B.length-1]===0&&(B.length--,B.words[B.length-1]===0&&B.length--),B};function X(){V.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(X,V);function K(){V.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(K,V);function W(){V.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(W,V),W.prototype.imulK=function(B){for(var d=0,N=0;N<B.length;N++){var G=(B.words[N]|0)*19+d,S=G&67108863;G>>>=26,B.words[N]=S,d=G}return d!==0&&(B.words[B.length++]=d),B},r._prime=function(B){if(J[B])return J[B];var d;if(B==="k256")d=new eA;else if(B==="p224")d=new X;else if(B==="p192")d=new K;else if(B==="p25519")d=new W;else throw new Error("Unknown prime "+B);return J[B]=d,d};function T(w){if(typeof w=="string"){var B=r._prime(w);this.m=B.p,this.prime=B}else s(w.gtn(1),"modulus must be greater than 1"),this.m=w,this.prime=null}T.prototype._verify1=function(B){s(B.negative===0,"red works only with positives"),s(B.red,"red works only with red numbers")},T.prototype._verify2=function(B,d){s((B.negative|d.negative)===0,"red works only with positives"),s(B.red&&B.red===d.red,"red works only with red numbers")},T.prototype.imod=function(B){return this.prime?this.prime.ireduce(B)._forceRed(this):(l(B,B.umod(this.m)._forceRed(this)),B)},T.prototype.neg=function(B){return B.isZero()?B.clone():this.m.sub(B)._forceRed(this)},T.prototype.add=function(B,d){this._verify2(B,d);var N=B.add(d);return N.cmp(this.m)>=0&&N.isub(this.m),N._forceRed(this)},T.prototype.iadd=function(B,d){this._verify2(B,d);var N=B.iadd(d);return N.cmp(this.m)>=0&&N.isub(this.m),N},T.prototype.sub=function(B,d){this._verify2(B,d);var N=B.sub(d);return N.cmpn(0)<0&&N.iadd(this.m),N._forceRed(this)},T.prototype.isub=function(B,d){this._verify2(B,d);var N=B.isub(d);return N.cmpn(0)<0&&N.iadd(this.m),N},T.prototype.shl=function(B,d){return this._verify1(B),this.imod(B.ushln(d))},T.prototype.imul=function(B,d){return this._verify2(B,d),this.imod(B.imul(d))},T.prototype.mul=function(B,d){return this._verify2(B,d),this.imod(B.mul(d))},T.prototype.isqr=function(B){return this.imul(B,B.clone())},T.prototype.sqr=function(B){return this.mul(B,B)},T.prototype.sqrt=function(B){if(B.isZero())return B.clone();var d=this.m.andln(3);if(s(d%2===1),d===3){var N=this.m.add(new r(1)).iushrn(2);return this.pow(B,N)}for(var G=this.m.subn(1),S=0;!G.isZero()&&G.andln(1)===0;)S++,G.iushrn(1);s(!G.isZero());var j=new r(1).toRed(this),H=j.redNeg(),b=this.m.subn(1).iushrn(1),E=this.m.bitLength();for(E=new r(2*E*E).toRed(this);this.pow(E,b).cmp(H)!==0;)E.redIAdd(H);for(var p=this.pow(E,G),U=this.pow(B,G.addn(1).iushrn(1)),R=this.pow(B,G),_=S;R.cmp(j)!==0;){for(var tA=R,IA=0;tA.cmp(j)!==0;IA++)tA=tA.redSqr();s(IA<_);var iA=this.pow(p,new r(1).iushln(_-IA-1));U=U.redMul(iA),p=iA.redSqr(),R=R.redMul(p),_=IA}return U},T.prototype.invm=function(B){var d=B._invmp(this.m);return d.negative!==0?(d.negative=0,this.imod(d).redNeg()):this.imod(d)},T.prototype.pow=function(B,d){if(d.isZero())return new r(1).toRed(this);if(d.cmpn(1)===0)return B.clone();var N=4,G=new Array(1<<N);G[0]=new r(1).toRed(this),G[1]=B;for(var S=2;S<G.length;S++)G[S]=this.mul(G[S-1],B);var j=G[0],H=0,b=0,E=d.bitLength()%26;for(E===0&&(E=26),S=d.length-1;S>=0;S--){for(var p=d.words[S],U=E-1;U>=0;U--){var R=p>>U&1;if(j!==G[0]&&(j=this.sqr(j)),R===0&&H===0){b=0;continue}H<<=1,H|=R,b++,!(b!==N&&(S!==0||U!==0))&&(j=this.mul(j,G[H]),b=0,H=0)}E=26}return j},T.prototype.convertTo=function(B){var d=B.umod(this.m);return d===B?d.clone():d},T.prototype.convertFrom=function(B){var d=B.clone();return d.red=null,d},r.mont=function(B){return new L(B)};function L(w){T.call(this,w),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(L,T),L.prototype.convertTo=function(B){return this.imod(B.ushln(this.shift))},L.prototype.convertFrom=function(B){var d=this.imod(B.mul(this.rinv));return d.red=null,d},L.prototype.imul=function(B,d){if(B.isZero()||d.isZero())return B.words[0]=0,B.length=1,B;var N=B.imul(d),G=N.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=N.isub(G).iushrn(this.shift),j=S;return S.cmp(this.m)>=0?j=S.isub(this.m):S.cmpn(0)<0&&(j=S.iadd(this.m)),j._forceRed(this)},L.prototype.mul=function(B,d){if(B.isZero()||d.isZero())return new r(0)._forceRed(this);var N=B.mul(d),G=N.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=N.isub(G).iushrn(this.shift),j=S;return S.cmp(this.m)>=0?j=S.isub(this.m):S.cmpn(0)<0&&(j=S.iadd(this.m)),j._forceRed(this)},L.prototype.invm=function(B){var d=this.imod(B._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(A,Nw)})(Bn)),Bn.exports}var kw=Fc();const qQ=MB(kw);var Zr={exports:{}};var YQ;function Gc(){return YQ||(YQ=1,(function(A,e){var t=ag(),s=t.Buffer;function n(i,a){for(var g in i)a[g]=i[g]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?A.exports=t:(n(t,e),e.Buffer=r);function r(i,a,g){return s(i,a,g)}r.prototype=Object.create(s.prototype),n(s,r),r.from=function(i,a,g){if(typeof i=="number")throw new TypeError("Argument must not be a number");return s(i,a,g)},r.alloc=function(i,a,g){if(typeof i!="number")throw new TypeError("Argument must be a number");var Q=s(i);return a!==void 0?typeof g=="string"?Q.fill(a,g):Q.fill(a):Q.fill(0),Q},r.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return s(i)},r.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(i)}})(Zr,Zr.exports)),Zr.exports}var fi,HQ;function Mw(){if(HQ)return fi;HQ=1;var A=Gc().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),l=Math.log(g)/Math.log(256),C=Math.log(256)/Math.log(g);function I(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var h=0,k=0,v=0,D=f.length;v!==D&&f[v]===0;)v++,h++;for(var O=(D-v)*C+1>>>0,J=new Uint8Array(O);v!==D;){for(var V=f[v],eA=0,X=O-1;(V!==0||eA<k)&&X!==-1;X--,eA++)V+=256*J[X]>>>0,J[X]=V%g>>>0,V=V/g>>>0;if(V!==0)throw new Error("Non-zero carry");k=eA,v++}for(var K=O-k;K!==O&&J[K]===0;)K++;for(var W=Q.repeat(h);K<O;++K)W+=t.charAt(J[K]);return W}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var h=0,k=0,v=0;f[h]===Q;)k++,h++;for(var D=(f.length-h)*l+1>>>0,O=new Uint8Array(D);h<f.length;){var J=f.charCodeAt(h);if(J>255)return;var V=s[J];if(V===255)return;for(var eA=0,X=D-1;(V!==0||eA<v)&&X!==-1;X--,eA++)V+=g*O[X]>>>0,O[X]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");v=eA,h++}for(var K=D-v;K!==D&&O[K]===0;)K++;var W=A.allocUnsafe(k+(D-K));W.fill(0,0,k);for(var T=k;K!==D;)W[T++]=O[K++];return W}function u(f){var h=c(f);if(h)return h;throw new Error("Non-base"+g+" character")}return{encode:I,decodeUnsafe:c,decode:u}}return fi=e,fi}var mi,PQ;function bw(){if(PQ)return mi;PQ=1;var A=Mw(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return mi=A(e),mi}var Fw=bw();const WQ=MB(Fw),zQ=gc;var Xe={},wi,VQ;function Gw(){if(VQ)return wi;VQ=1;var A=Gc().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),l=Math.log(g)/Math.log(256),C=Math.log(256)/Math.log(g);function I(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var h=0,k=0,v=0,D=f.length;v!==D&&f[v]===0;)v++,h++;for(var O=(D-v)*C+1>>>0,J=new Uint8Array(O);v!==D;){for(var V=f[v],eA=0,X=O-1;(V!==0||eA<k)&&X!==-1;X--,eA++)V+=256*J[X]>>>0,J[X]=V%g>>>0,V=V/g>>>0;if(V!==0)throw new Error("Non-zero carry");k=eA,v++}for(var K=O-k;K!==O&&J[K]===0;)K++;for(var W=Q.repeat(h);K<O;++K)W+=t.charAt(J[K]);return W}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var h=0,k=0,v=0;f[h]===Q;)k++,h++;for(var D=(f.length-h)*l+1>>>0,O=new Uint8Array(D);h<f.length;){var J=f.charCodeAt(h);if(J>255)return;var V=s[J];if(V===255)return;for(var eA=0,X=D-1;(V!==0||eA<v)&&X!==-1;X--,eA++)V+=g*O[X]>>>0,O[X]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");v=eA,h++}for(var K=D-v;K!==D&&O[K]===0;)K++;var W=A.allocUnsafe(k+(D-K));W.fill(0,0,k);for(var T=k;K!==D;)W[T++]=O[K++];return W}function u(f){var h=c(f);if(h)return h;throw new Error("Non-base"+g+" character")}return{encode:I,decodeUnsafe:c,decode:u}}return wi=e,wi}var xi,ZQ;function vw(){if(ZQ)return xi;ZQ=1;var A=Gw(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return xi=A(e),xi}function Oo(A,e,t){return e<=A&&A<=t}function Zn(A){if(A===void 0)return{};if(A===Object(A))return A;throw TypeError("Could not convert argument to dictionary")}function Sw(A){for(var e=String(A),t=e.length,s=0,n=[];s<t;){var r=e.charCodeAt(s);if(r<55296||r>57343)n.push(r);else if(56320<=r&&r<=57343)n.push(65533);else if(55296<=r&&r<=56319)if(s===t-1)n.push(65533);else{var i=A.charCodeAt(s+1);if(56320<=i&&i<=57343){var a=r&1023,g=i&1023;n.push(65536+(a<<10)+g),s+=1}else n.push(65533)}s+=1}return n}function Uw(A){for(var e="",t=0;t<A.length;++t){var s=A[t];s<=65535?e+=String.fromCharCode(s):(s-=65536,e+=String.fromCharCode((s>>10)+55296,(s&1023)+56320))}return e}var xn=-1;function Cg(A){this.tokens=[].slice.call(A)}Cg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():xn},prepend:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(A)},push:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.push(e.shift());else this.tokens.push(A)}};var Hs=-1;function Di(A,e){if(A)throw TypeError("Decoder error");return e||65533}var Dn="utf-8";function yn(A,e){if(!(this instanceof yn))return new yn(A,e);if(A=A!==void 0?String(A).toLowerCase():Dn,A!==Dn)throw new Error("Encoding not supported. Only utf-8 is supported");e=Zn(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}yn.prototype={decode:function(e,t){var s;typeof e=="object"&&e instanceof ArrayBuffer?s=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):s=new Uint8Array(0),t=Zn(t),this._streaming||(this._decoder=new Rw({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var n=new Cg(s),r=[],i;!n.endOfStream()&&(i=this._decoder.handler(n,n.read()),i!==Hs);)i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i));if(!this._streaming){do{if(i=this._decoder.handler(n,n.read()),i===Hs)break;i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i))}while(!n.endOfStream());this._decoder=null}return r.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(r[0]===65279?(this._BOMseen=!0,r.shift()):this._BOMseen=!0),Uw(r)}};function Nn(A,e){if(!(this instanceof Nn))return new Nn(A,e);if(A=A!==void 0?String(A).toLowerCase():Dn,A!==Dn)throw new Error("Encoding not supported. Only utf-8 is supported");e=Zn(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Nn.prototype={encode:function(e,t){e=e?String(e):"",t=Zn(t),this._streaming||(this._encoder=new Kw(this._options)),this._streaming=!!t.stream;for(var s=[],n=new Cg(Sw(e)),r;!n.endOfStream()&&(r=this._encoder.handler(n,n.read()),r!==Hs);)Array.isArray(r)?s.push.apply(s,r):s.push(r);if(!this._streaming){for(;r=this._encoder.handler(n,n.read()),r!==Hs;)Array.isArray(r)?s.push.apply(s,r):s.push(r);this._encoder=null}return new Uint8Array(s)}};function Rw(A){var e=A.fatal,t=0,s=0,n=0,r=128,i=191;this.handler=function(a,g){if(g===xn&&n!==0)return n=0,Di(e);if(g===xn)return Hs;if(n===0){if(Oo(g,0,127))return g;if(Oo(g,194,223))n=1,t=g-192;else if(Oo(g,224,239))g===224&&(r=160),g===237&&(i=159),n=2,t=g-224;else if(Oo(g,240,244))g===240&&(r=144),g===244&&(i=143),n=3,t=g-240;else return Di(e);return t=t<<6*n,null}if(!Oo(g,r,i))return t=n=s=0,r=128,i=191,a.prepend(g),Di(e);if(r=128,i=191,s+=1,t+=g-128<<6*(n-s),s!==n)return null;var Q=t;return t=n=s=0,Q}}function Kw(A){A.fatal,this.handler=function(e,t){if(t===xn)return Hs;if(Oo(t,0,127))return t;var s,n;Oo(t,128,2047)?(s=1,n=192):Oo(t,2048,65535)?(s=2,n=224):Oo(t,65536,1114111)&&(s=3,n=240);for(var r=[(t>>6*s)+n];s>0;){var i=t>>6*(s-1);r.push(128|i&63),s-=1}return r}}const Jw=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:yn,TextEncoder:Nn},Symbol.toStringTag,{value:"Module"})),Lw=Ma(Jw);var _Q;function jw(){if(_Q)return Xe;_Q=1;var A=Xe&&Xe.__createBinding||(Object.create?(function(K,W,T,L){L===void 0&&(L=T),Object.defineProperty(K,L,{enumerable:!0,get:function(){return W[T]}})}):(function(K,W,T,L){L===void 0&&(L=T),K[L]=W[T]})),e=Xe&&Xe.__setModuleDefault||(Object.create?(function(K,W){Object.defineProperty(K,"default",{enumerable:!0,value:W})}):function(K,W){K.default=W}),t=Xe&&Xe.__decorate||function(K,W,T,L){var w=arguments.length,B=w<3?W:L===null?L=Object.getOwnPropertyDescriptor(W,T):L,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(K,W,T,L);else for(var N=K.length-1;N>=0;N--)(d=K[N])&&(B=(w<3?d(B):w>3?d(W,T,B):d(W,T))||B);return w>3&&B&&Object.defineProperty(W,T,B),B},s=Xe&&Xe.__importStar||function(K){if(K&&K.__esModule)return K;var W={};if(K!=null)for(var T in K)T!=="default"&&Object.hasOwnProperty.call(K,T)&&A(W,K,T);return e(W,K),W},n=Xe&&Xe.__importDefault||function(K){return K&&K.__esModule?K:{default:K}};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.deserializeUnchecked=Xe.deserialize=Xe.serialize=Xe.BinaryReader=Xe.BinaryWriter=Xe.BorshError=Xe.baseDecode=Xe.baseEncode=void 0;const r=n(Fc()),i=n(vw()),a=s(Lw),g=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,Q=new g("utf-8",{fatal:!0});function l(K){return typeof K=="string"&&(K=Buffer.from(K,"utf8")),i.default.encode(Buffer.from(K))}Xe.baseEncode=l;function C(K){return Buffer.from(i.default.decode(K))}Xe.baseDecode=C;const I=1024;class c extends Error{constructor(W){super(W),this.fieldPath=[],this.originalMessage=W}addToFieldPath(W){this.fieldPath.splice(0,0,W),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Xe.BorshError=c;class u{constructor(){this.buf=Buffer.alloc(I),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(I)]))}writeU8(W){this.maybeResize(),this.buf.writeUInt8(W,this.length),this.length+=1}writeU16(W){this.maybeResize(),this.buf.writeUInt16LE(W,this.length),this.length+=2}writeU32(W){this.maybeResize(),this.buf.writeUInt32LE(W,this.length),this.length+=4}writeU64(W){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(W).toArray("le",8)))}writeU128(W){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(W).toArray("le",16)))}writeU256(W){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(W).toArray("le",32)))}writeU512(W){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(W).toArray("le",64)))}writeBuffer(W){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),W,Buffer.alloc(I)]),this.length+=W.length}writeString(W){this.maybeResize();const T=Buffer.from(W,"utf8");this.writeU32(T.length),this.writeBuffer(T)}writeFixedArray(W){this.writeBuffer(Buffer.from(W))}writeArray(W,T){this.maybeResize(),this.writeU32(W.length);for(const L of W)this.maybeResize(),T(L)}toArray(){return this.buf.subarray(0,this.length)}}Xe.BinaryWriter=u;function f(K,W,T){const L=T.value;T.value=function(...w){try{return L.apply(this,w)}catch(B){if(B instanceof RangeError){const d=B.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(d)>=0)throw new c("Reached the end of buffer when deserializing")}throw B}}}class h{constructor(W){this.buf=W,this.offset=0}readU8(){const W=this.buf.readUInt8(this.offset);return this.offset+=1,W}readU16(){const W=this.buf.readUInt16LE(this.offset);return this.offset+=2,W}readU32(){const W=this.buf.readUInt32LE(this.offset);return this.offset+=4,W}readU64(){const W=this.readBuffer(8);return new r.default(W,"le")}readU128(){const W=this.readBuffer(16);return new r.default(W,"le")}readU256(){const W=this.readBuffer(32);return new r.default(W,"le")}readU512(){const W=this.readBuffer(64);return new r.default(W,"le")}readBuffer(W){if(this.offset+W>this.buf.length)throw new c(`Expected buffer length ${W} isn't within bounds`);const T=this.buf.slice(this.offset,this.offset+W);return this.offset+=W,T}readString(){const W=this.readU32(),T=this.readBuffer(W);try{return Q.decode(T)}catch(L){throw new c(`Error decoding UTF-8 string: ${L}`)}}readFixedArray(W){return new Uint8Array(this.readBuffer(W))}readArray(W){const T=this.readU32(),L=Array();for(let w=0;w<T;++w)L.push(W());return L}}t([f],h.prototype,"readU8",null),t([f],h.prototype,"readU16",null),t([f],h.prototype,"readU32",null),t([f],h.prototype,"readU64",null),t([f],h.prototype,"readU128",null),t([f],h.prototype,"readU256",null),t([f],h.prototype,"readU512",null),t([f],h.prototype,"readString",null),t([f],h.prototype,"readFixedArray",null),t([f],h.prototype,"readArray",null),Xe.BinaryReader=h;function k(K){return K.charAt(0).toUpperCase()+K.slice(1)}function v(K,W,T,L,w){try{if(typeof L=="string")w[`write${k(L)}`](T);else if(L instanceof Array)if(typeof L[0]=="number"){if(T.length!==L[0])throw new c(`Expecting byte array of length ${L[0]}, but got ${T.length} bytes`);w.writeFixedArray(T)}else if(L.length===2&&typeof L[1]=="number"){if(T.length!==L[1])throw new c(`Expecting byte array of length ${L[1]}, but got ${T.length} bytes`);for(let B=0;B<L[1];B++)v(K,null,T[B],L[0],w)}else w.writeArray(T,B=>{v(K,W,B,L[0],w)});else if(L.kind!==void 0)switch(L.kind){case"option":{T==null?w.writeU8(0):(w.writeU8(1),v(K,W,T,L.type,w));break}case"map":{w.writeU32(T.size),T.forEach((B,d)=>{v(K,W,d,L.key,w),v(K,W,B,L.value,w)});break}default:throw new c(`FieldType ${L} unrecognized`)}else D(K,T,w)}catch(B){throw B instanceof c&&B.addToFieldPath(W),B}}function D(K,W,T){if(typeof W.borshSerialize=="function"){W.borshSerialize(T);return}const L=K.get(W.constructor);if(!L)throw new c(`Class ${W.constructor.name} is missing in schema`);if(L.kind==="struct")L.fields.map(([w,B])=>{v(K,w,W[w],B,T)});else if(L.kind==="enum"){const w=W[L.field];for(let B=0;B<L.values.length;++B){const[d,N]=L.values[B];if(d===w){T.writeU8(B),v(K,d,W[d],N,T);break}}}else throw new c(`Unexpected schema kind: ${L.kind} for ${W.constructor.name}`)}function O(K,W,T=u){const L=new T;return D(K,W,L),L.toArray()}Xe.serialize=O;function J(K,W,T,L){try{if(typeof T=="string")return L[`read${k(T)}`]();if(T instanceof Array){if(typeof T[0]=="number")return L.readFixedArray(T[0]);if(typeof T[1]=="number"){const w=[];for(let B=0;B<T[1];B++)w.push(J(K,null,T[0],L));return w}else return L.readArray(()=>J(K,W,T[0],L))}if(T.kind==="option")return L.readU8()?J(K,W,T.type,L):void 0;if(T.kind==="map"){let w=new Map;const B=L.readU32();for(let d=0;d<B;d++){const N=J(K,W,T.key,L),G=J(K,W,T.value,L);w.set(N,G)}return w}return V(K,T,L)}catch(w){throw w instanceof c&&w.addToFieldPath(W),w}}function V(K,W,T){if(typeof W.borshDeserialize=="function")return W.borshDeserialize(T);const L=K.get(W);if(!L)throw new c(`Class ${W.name} is missing in schema`);if(L.kind==="struct"){const w={};for(const[B,d]of K.get(W).fields)w[B]=J(K,B,d,T);return new W(w)}if(L.kind==="enum"){const w=T.readU8();if(w>=L.values.length)throw new c(`Enum index: ${w} is out of range`);const[B,d]=L.values[w],N=J(K,B,d,T);return new W({[B]:N})}throw new c(`Unexpected schema kind: ${L.kind} for ${W.constructor.name}`)}function eA(K,W,T,L=h){const w=new L(T),B=V(K,W,w);if(w.offset<T.length)throw new c(`Unexpected ${T.length-w.offset} bytes after deserialized data`);return B}Xe.deserialize=eA;function X(K,W,T,L=h){const w=new L(T);return V(K,W,w)}return Xe.deserializeUnchecked=X,Xe}var yi=jw(),QA={},XQ;function Tw(){if(XQ)return QA;XQ=1,Object.defineProperty(QA,"__esModule",{value:!0}),QA.s16=QA.s8=QA.nu64be=QA.u48be=QA.u40be=QA.u32be=QA.u24be=QA.u16be=QA.nu64=QA.u48=QA.u40=QA.u32=QA.u24=QA.u16=QA.u8=QA.offset=QA.greedy=QA.Constant=QA.UTF8=QA.CString=QA.Blob=QA.Boolean=QA.BitField=QA.BitStructure=QA.VariantLayout=QA.Union=QA.UnionLayoutDiscriminator=QA.UnionDiscriminator=QA.Structure=QA.Sequence=QA.DoubleBE=QA.Double=QA.FloatBE=QA.Float=QA.NearInt64BE=QA.NearInt64=QA.NearUInt64BE=QA.NearUInt64=QA.IntBE=QA.Int=QA.UIntBE=QA.UInt=QA.OffsetLayout=QA.GreedyCount=QA.ExternalLayout=QA.bindConstructorLayout=QA.nameWithProperty=QA.Layout=QA.uint8ArrayToBuffer=QA.checkUint8Array=void 0,QA.constant=QA.utf8=QA.cstr=QA.blob=QA.unionLayoutDiscriminator=QA.union=QA.seq=QA.bits=QA.struct=QA.f64be=QA.f64=QA.f32be=QA.f32=QA.ns64be=QA.s48be=QA.s40be=QA.s32be=QA.s24be=QA.s16be=QA.ns64=QA.s48=QA.s40=QA.s32=QA.s24=void 0;const A=ag();function e(E){if(!(E instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}QA.checkUint8Array=e;function t(E){return e(E),A.Buffer.from(E.buffer,E.byteOffset,E.length)}QA.uint8ArrayToBuffer=t;let s=class{constructor(p,U){if(!Number.isInteger(p))throw new TypeError("span must be an integer");this.span=p,this.property=U}makeDestinationObject(){return{}}getSpan(p,U){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(p){const U=Object.create(this.constructor.prototype);return Object.assign(U,this),U.property=p,U}fromArray(p){}};QA.Layout=s;function n(E,p){return p.property?E+"["+p.property+"]":E}QA.nameWithProperty=n;function r(E,p){if(typeof E!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(E,"layout_"))throw new Error("Class is already bound to a layout");if(!(p&&p instanceof s))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(p,"boundConstructor_"))throw new Error("layout is already bound to a constructor");E.layout_=p,p.boundConstructor_=E,p.makeDestinationObject=(()=>new E),Object.defineProperty(E.prototype,"encode",{value(U,R){return p.encode(this,U,R)},writable:!0}),Object.defineProperty(E,"decode",{value(U,R){return p.decode(U,R)},writable:!0})}QA.bindConstructorLayout=r;class i extends s{isCount(){throw new Error("ExternalLayout is abstract")}}QA.ExternalLayout=i;class a extends i{constructor(p=1,U){if(!Number.isInteger(p)||0>=p)throw new TypeError("elementSpan must be a (positive) integer");super(-1,U),this.elementSpan=p}isCount(){return!0}decode(p,U=0){e(p);const R=p.length-U;return Math.floor(R/this.elementSpan)}encode(p,U,R){return 0}}QA.GreedyCount=a;class g extends i{constructor(p,U=0,R){if(!(p instanceof s))throw new TypeError("layout must be a Layout");if(!Number.isInteger(U))throw new TypeError("offset must be integer or undefined");super(p.span,R||p.property),this.layout=p,this.offset=U}isCount(){return this.layout instanceof Q||this.layout instanceof l}decode(p,U=0){return this.layout.decode(p,U+this.offset)}encode(p,U,R=0){return this.layout.encode(p,U,R+this.offset)}}QA.OffsetLayout=g;class Q extends s{constructor(p,U){if(super(p,U),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,U=0){return t(p).readUIntLE(U,this.span)}encode(p,U,R=0){return t(U).writeUIntLE(p,R,this.span),this.span}}QA.UInt=Q;class l extends s{constructor(p,U){if(super(p,U),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,U=0){return t(p).readUIntBE(U,this.span)}encode(p,U,R=0){return t(U).writeUIntBE(p,R,this.span),this.span}}QA.UIntBE=l;class C extends s{constructor(p,U){if(super(p,U),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,U=0){return t(p).readIntLE(U,this.span)}encode(p,U,R=0){return t(U).writeIntLE(p,R,this.span),this.span}}QA.Int=C;class I extends s{constructor(p,U){if(super(p,U),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,U=0){return t(p).readIntBE(U,this.span)}encode(p,U,R=0){return t(U).writeIntBE(p,R,this.span),this.span}}QA.IntBE=I;const c=Math.pow(2,32);function u(E){const p=Math.floor(E/c),U=E-p*c;return{hi32:p,lo32:U}}function f(E,p){return E*c+p}class h extends s{constructor(p){super(8,p)}decode(p,U=0){const R=t(p),_=R.readUInt32LE(U),tA=R.readUInt32LE(U+4);return f(tA,_)}encode(p,U,R=0){const _=u(p),tA=t(U);return tA.writeUInt32LE(_.lo32,R),tA.writeUInt32LE(_.hi32,R+4),8}}QA.NearUInt64=h;class k extends s{constructor(p){super(8,p)}decode(p,U=0){const R=t(p),_=R.readUInt32BE(U),tA=R.readUInt32BE(U+4);return f(_,tA)}encode(p,U,R=0){const _=u(p),tA=t(U);return tA.writeUInt32BE(_.hi32,R),tA.writeUInt32BE(_.lo32,R+4),8}}QA.NearUInt64BE=k;class v extends s{constructor(p){super(8,p)}decode(p,U=0){const R=t(p),_=R.readUInt32LE(U),tA=R.readInt32LE(U+4);return f(tA,_)}encode(p,U,R=0){const _=u(p),tA=t(U);return tA.writeUInt32LE(_.lo32,R),tA.writeInt32LE(_.hi32,R+4),8}}QA.NearInt64=v;class D extends s{constructor(p){super(8,p)}decode(p,U=0){const R=t(p),_=R.readInt32BE(U),tA=R.readUInt32BE(U+4);return f(_,tA)}encode(p,U,R=0){const _=u(p),tA=t(U);return tA.writeInt32BE(_.hi32,R),tA.writeUInt32BE(_.lo32,R+4),8}}QA.NearInt64BE=D;class O extends s{constructor(p){super(4,p)}decode(p,U=0){return t(p).readFloatLE(U)}encode(p,U,R=0){return t(U).writeFloatLE(p,R),4}}QA.Float=O;class J extends s{constructor(p){super(4,p)}decode(p,U=0){return t(p).readFloatBE(U)}encode(p,U,R=0){return t(U).writeFloatBE(p,R),4}}QA.FloatBE=J;class V extends s{constructor(p){super(8,p)}decode(p,U=0){return t(p).readDoubleLE(U)}encode(p,U,R=0){return t(U).writeDoubleLE(p,R),8}}QA.Double=V;class eA extends s{constructor(p){super(8,p)}decode(p,U=0){return t(p).readDoubleBE(U)}encode(p,U,R=0){return t(U).writeDoubleBE(p,R),8}}QA.DoubleBE=eA;class X extends s{constructor(p,U,R){if(!(p instanceof s))throw new TypeError("elementLayout must be a Layout");if(!(U instanceof i&&U.isCount()||Number.isInteger(U)&&0<=U))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let _=-1;!(U instanceof i)&&0<p.span&&(_=U*p.span),super(_,R),this.elementLayout=p,this.count=U}getSpan(p,U=0){if(0<=this.span)return this.span;let R=0,_=this.count;if(_ instanceof i&&(_=_.decode(p,U)),0<this.elementLayout.span)R=_*this.elementLayout.span;else{let tA=0;for(;tA<_;)R+=this.elementLayout.getSpan(p,U+R),++tA}return R}decode(p,U=0){const R=[];let _=0,tA=this.count;for(tA instanceof i&&(tA=tA.decode(p,U));_<tA;)R.push(this.elementLayout.decode(p,U)),U+=this.elementLayout.getSpan(p,U),_+=1;return R}encode(p,U,R=0){const _=this.elementLayout,tA=p.reduce((IA,iA)=>IA+_.encode(iA,U,R+IA),0);return this.count instanceof i&&this.count.encode(p.length,U,R),tA}}QA.Sequence=X;class K extends s{constructor(p,U,R){if(!(Array.isArray(p)&&p.reduce((tA,IA)=>tA&&IA instanceof s,!0)))throw new TypeError("fields must be array of Layout instances");typeof U=="boolean"&&R===void 0&&(R=U,U=void 0);for(const tA of p)if(0>tA.span&&tA.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let _=-1;try{_=p.reduce((tA,IA)=>tA+IA.getSpan(),0)}catch{}super(_,U),this.fields=p,this.decodePrefixes=!!R}getSpan(p,U=0){if(0<=this.span)return this.span;let R=0;try{R=this.fields.reduce((_,tA)=>{const IA=tA.getSpan(p,U);return U+=IA,_+IA},0)}catch{throw new RangeError("indeterminate span")}return R}decode(p,U=0){e(p);const R=this.makeDestinationObject();for(const _ of this.fields)if(_.property!==void 0&&(R[_.property]=_.decode(p,U)),U+=_.getSpan(p,U),this.decodePrefixes&&p.length===U)break;return R}encode(p,U,R=0){const _=R;let tA=0,IA=0;for(const iA of this.fields){let UA=iA.span;if(IA=0<UA?UA:0,iA.property!==void 0){const HA=p[iA.property];HA!==void 0&&(IA=iA.encode(HA,U,R),0>UA&&(UA=iA.getSpan(U,R)))}tA=R,R+=UA}return tA+IA-_}fromArray(p){const U=this.makeDestinationObject();for(const R of this.fields)R.property!==void 0&&0<p.length&&(U[R.property]=p.shift());return U}layoutFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const U of this.fields)if(U.property===p)return U}offsetOf(p){if(typeof p!="string")throw new TypeError("property must be string");let U=0;for(const R of this.fields){if(R.property===p)return U;0>R.span?U=-1:0<=U&&(U+=R.span)}}}QA.Structure=K;class W{constructor(p){this.property=p}decode(p,U){throw new Error("UnionDiscriminator is abstract")}encode(p,U,R){throw new Error("UnionDiscriminator is abstract")}}QA.UnionDiscriminator=W;class T extends W{constructor(p,U){if(!(p instanceof i&&p.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(U||p.property||"variant"),this.layout=p}decode(p,U){return this.layout.decode(p,U)}encode(p,U,R){return this.layout.encode(p,U,R)}}QA.UnionLayoutDiscriminator=T;class L extends s{constructor(p,U,R){let _;if(p instanceof Q||p instanceof l)_=new T(new g(p));else if(p instanceof i&&p.isCount())_=new T(p);else if(p instanceof W)_=p;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(U===void 0&&(U=null),!(U===null||U instanceof s))throw new TypeError("defaultLayout must be null or a Layout");if(U!==null){if(0>U.span)throw new Error("defaultLayout must have constant span");U.property===void 0&&(U=U.replicate("content"))}let tA=-1;U&&(tA=U.span,0<=tA&&(p instanceof Q||p instanceof l)&&(tA+=_.layout.span)),super(tA,R),this.discriminator=_,this.usesPrefixDiscriminator=p instanceof Q||p instanceof l,this.defaultLayout=U,this.registry={};let IA=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(iA){return IA(iA)},this.configGetSourceVariant=function(iA){IA=iA.bind(this)}}getSpan(p,U=0){if(0<=this.span)return this.span;const R=this.getVariant(p,U);if(!R)throw new Error("unable to determine span for unrecognized variant");return R.getSpan(p,U)}defaultGetSourceVariant(p){if(Object.prototype.hasOwnProperty.call(p,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(p,this.defaultLayout.property))return;const U=this.registry[p[this.discriminator.property]];if(U&&(!U.layout||U.property&&Object.prototype.hasOwnProperty.call(p,U.property)))return U}else for(const U in this.registry){const R=this.registry[U];if(R.property&&Object.prototype.hasOwnProperty.call(p,R.property))return R}throw new Error("unable to infer src variant")}decode(p,U=0){let R;const _=this.discriminator,tA=_.decode(p,U),IA=this.registry[tA];if(IA===void 0){const iA=this.defaultLayout;let UA=0;this.usesPrefixDiscriminator&&(UA=_.layout.span),R=this.makeDestinationObject(),R[_.property]=tA,R[iA.property]=iA.decode(p,U+UA)}else R=IA.decode(p,U);return R}encode(p,U,R=0){const _=this.getSourceVariant(p);if(_===void 0){const tA=this.discriminator,IA=this.defaultLayout;let iA=0;return this.usesPrefixDiscriminator&&(iA=tA.layout.span),tA.encode(p[tA.property],U,R),iA+IA.encode(p[IA.property],U,R+iA)}return _.encode(p,U,R)}addVariant(p,U,R){const _=new w(this,p,U,R);return this.registry[p]=_,_}getVariant(p,U=0){let R;return p instanceof Uint8Array?R=this.discriminator.decode(p,U):R=p,this.registry[R]}}QA.Union=L;class w extends s{constructor(p,U,R,_){if(!(p instanceof L))throw new TypeError("union must be a Union");if(!Number.isInteger(U)||0>U)throw new TypeError("variant must be a (non-negative) integer");if(typeof R=="string"&&_===void 0&&(_=R,R=null),R){if(!(R instanceof s))throw new TypeError("layout must be a Layout");if(p.defaultLayout!==null&&0<=R.span&&R.span>p.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof _!="string")throw new TypeError("variant must have a String property")}let tA=p.span;0>p.span&&(tA=R?R.span:0,0<=tA&&p.usesPrefixDiscriminator&&(tA+=p.discriminator.layout.span)),super(tA,_),this.union=p,this.variant=U,this.layout=R||null}getSpan(p,U=0){if(0<=this.span)return this.span;let R=0;this.union.usesPrefixDiscriminator&&(R=this.union.discriminator.layout.span);let _=0;return this.layout&&(_=this.layout.getSpan(p,U+R)),R+_}decode(p,U=0){const R=this.makeDestinationObject();if(this!==this.union.getVariant(p,U))throw new Error("variant mismatch");let _=0;return this.union.usesPrefixDiscriminator&&(_=this.union.discriminator.layout.span),this.layout?R[this.property]=this.layout.decode(p,U+_):this.property?R[this.property]=!0:this.union.usesPrefixDiscriminator&&(R[this.union.discriminator.property]=this.variant),R}encode(p,U,R=0){let _=0;if(this.union.usesPrefixDiscriminator&&(_=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(p,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,U,R);let tA=_;if(this.layout&&(this.layout.encode(p[this.property],U,R+_),tA+=this.layout.getSpan(U,R+_),0<=this.union.span&&tA>this.union.span))throw new Error("encoded variant overruns containing union");return tA}fromArray(p){if(this.layout)return this.layout.fromArray(p)}}QA.VariantLayout=w;function B(E){return 0>E&&(E+=4294967296),E}class d extends s{constructor(p,U,R){if(!(p instanceof Q||p instanceof l))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof U=="string"&&R===void 0&&(R=U,U=!1),4<p.span)throw new RangeError("word cannot exceed 32 bits");super(p.span,R),this.word=p,this.msb=!!U,this.fields=[];let _=0;this._packedSetValue=function(tA){return _=B(tA),this},this._packedGetValue=function(){return _}}decode(p,U=0){const R=this.makeDestinationObject(),_=this.word.decode(p,U);this._packedSetValue(_);for(const tA of this.fields)tA.property!==void 0&&(R[tA.property]=tA.decode(p));return R}encode(p,U,R=0){const _=this.word.decode(U,R);this._packedSetValue(_);for(const tA of this.fields)if(tA.property!==void 0){const IA=p[tA.property];IA!==void 0&&tA.encode(IA)}return this.word.encode(this._packedGetValue(),U,R)}addField(p,U){const R=new N(this,p,U);return this.fields.push(R),R}addBoolean(p){const U=new G(this,p);return this.fields.push(U),U}fieldFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const U of this.fields)if(U.property===p)return U}}QA.BitStructure=d;class N{constructor(p,U,R){if(!(p instanceof d))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(U)||0>=U)throw new TypeError("bits must be positive integer");const _=8*p.span,tA=p.fields.reduce((IA,iA)=>IA+iA.bits,0);if(U+tA>_)throw new Error("bits too long for span remainder ("+(_-tA)+" of "+_+" remain)");this.container=p,this.bits=U,this.valueMask=(1<<U)-1,U===32&&(this.valueMask=4294967295),this.start=tA,this.container.msb&&(this.start=_-tA-U),this.wordMask=B(this.valueMask<<this.start),this.property=R}decode(p,U){const R=this.container._packedGetValue();return B(R&this.wordMask)>>>this.start}encode(p){if(typeof p!="number"||!Number.isInteger(p)||p!==B(p&this.valueMask))throw new TypeError(n("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const U=this.container._packedGetValue(),R=B(p<<this.start);this.container._packedSetValue(B(U&~this.wordMask)|R)}}QA.BitField=N;class G extends N{constructor(p,U){super(p,1,U)}decode(p,U){return!!super.decode(p,U)}encode(p){typeof p=="boolean"&&(p=+p),super.encode(p)}}QA.Boolean=G;class S extends s{constructor(p,U){if(!(p instanceof i&&p.isCount()||Number.isInteger(p)&&0<=p))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let R=-1;p instanceof i||(R=p),super(R,U),this.length=p}getSpan(p,U){let R=this.span;return 0>R&&(R=this.length.decode(p,U)),R}decode(p,U=0){let R=this.span;return 0>R&&(R=this.length.decode(p,U)),t(p).slice(U,U+R)}encode(p,U,R){let _=this.length;if(this.length instanceof i&&(_=p.length),!(p instanceof Uint8Array&&_===p.length))throw new TypeError(n("Blob.encode",this)+" requires (length "+_+") Uint8Array as src");if(R+_>U.length)throw new RangeError("encoding overruns Uint8Array");const tA=t(p);return t(U).write(tA.toString("hex"),R,_,"hex"),this.length instanceof i&&this.length.encode(_,U,R),_}}QA.Blob=S;class j extends s{constructor(p){super(-1,p)}getSpan(p,U=0){e(p);let R=U;for(;R<p.length&&p[R]!==0;)R+=1;return 1+R-U}decode(p,U=0){const R=this.getSpan(p,U);return t(p).slice(U,U+R-1).toString("utf-8")}encode(p,U,R=0){typeof p!="string"&&(p=String(p));const _=A.Buffer.from(p,"utf8"),tA=_.length;if(R+tA>U.length)throw new RangeError("encoding overruns Buffer");const IA=t(U);return _.copy(IA,R),IA[R+tA]=0,tA+1}}QA.CString=j;class H extends s{constructor(p,U){if(typeof p=="string"&&U===void 0&&(U=p,p=void 0),p===void 0)p=-1;else if(!Number.isInteger(p))throw new TypeError("maxSpan must be an integer");super(-1,U),this.maxSpan=p}getSpan(p,U=0){return e(p),p.length-U}decode(p,U=0){const R=this.getSpan(p,U);if(0<=this.maxSpan&&this.maxSpan<R)throw new RangeError("text length exceeds maxSpan");return t(p).slice(U,U+R).toString("utf-8")}encode(p,U,R=0){typeof p!="string"&&(p=String(p));const _=A.Buffer.from(p,"utf8"),tA=_.length;if(0<=this.maxSpan&&this.maxSpan<tA)throw new RangeError("text length exceeds maxSpan");if(R+tA>U.length)throw new RangeError("encoding overruns Buffer");return _.copy(t(U),R),tA}}QA.UTF8=H;class b extends s{constructor(p,U){super(0,U),this.value=p}decode(p,U){return this.value}encode(p,U,R){return 0}}return QA.Constant=b,QA.greedy=((E,p)=>new a(E,p)),QA.offset=((E,p,U)=>new g(E,p,U)),QA.u8=(E=>new Q(1,E)),QA.u16=(E=>new Q(2,E)),QA.u24=(E=>new Q(3,E)),QA.u32=(E=>new Q(4,E)),QA.u40=(E=>new Q(5,E)),QA.u48=(E=>new Q(6,E)),QA.nu64=(E=>new h(E)),QA.u16be=(E=>new l(2,E)),QA.u24be=(E=>new l(3,E)),QA.u32be=(E=>new l(4,E)),QA.u40be=(E=>new l(5,E)),QA.u48be=(E=>new l(6,E)),QA.nu64be=(E=>new k(E)),QA.s8=(E=>new C(1,E)),QA.s16=(E=>new C(2,E)),QA.s24=(E=>new C(3,E)),QA.s32=(E=>new C(4,E)),QA.s40=(E=>new C(5,E)),QA.s48=(E=>new C(6,E)),QA.ns64=(E=>new v(E)),QA.s16be=(E=>new I(2,E)),QA.s24be=(E=>new I(3,E)),QA.s32be=(E=>new I(4,E)),QA.s40be=(E=>new I(5,E)),QA.s48be=(E=>new I(6,E)),QA.ns64be=(E=>new D(E)),QA.f32=(E=>new O(E)),QA.f32be=(E=>new J(E)),QA.f64=(E=>new V(E)),QA.f64be=(E=>new eA(E)),QA.struct=((E,p,U)=>new K(E,p,U)),QA.bits=((E,p,U)=>new d(E,p,U)),QA.seq=((E,p,U)=>new X(E,p,U)),QA.union=((E,p,U)=>new L(E,p,U)),QA.unionLayoutDiscriminator=((E,p)=>new T(E,p)),QA.blob=((E,p)=>new S(E,p)),QA.cstr=(E=>new j(E)),QA.utf8=((E,p)=>new H(E,p)),QA.constant=((E,p)=>new b(E,p)),QA}var rA=Tw(),Ow=8078011;function vc(A){return Array.isArray(A)?"%5B"+A.map(vc).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function qw([A,e]){return`${A}=${vc(e)}`}function Yw(A){const e=Object.entries(A).map(qw).join("&");return btoa(e)}function Hw(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${Yw(e)}'`),`${t}\``}}var Pw=class extends Error{cause=this.cause;context;constructor(...[e,t]){let s,n;if(t){const{cause:i,...a}=t;i&&(n={cause:i}),Object.keys(a).length>0&&(s=a)}const r=Hw(e,s);super(r,n),this.context={__code:e,...s},this.name="SolanaError"}},Ww=8078e3,zw=8078001,Vw=8078004,Zw=8078005,_w=8078006;function Sc(A){return Array.isArray(A)?"%5B"+A.map(Sc).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function Xw([A,e]){return`${A}=${Sc(e)}`}function $w(A){const e=Object.entries(A).map(Xw).join("&");return btoa(e)}function Ax(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${$w(e)}'`),`${t}\``}}var cr=class extends Error{cause=this.cause;context;constructor(...[A,e]){let t,s;if(e){const{cause:r,...i}=e;r&&(s={cause:r}),Object.keys(i).length>0&&(t=i)}const n=Ax(A,t);super(n,s),this.context={__code:A,...t},this.name="SolanaError"}};function ex(A,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(A)}function tx(A){return Object.freeze({...A,encode:e=>{const t=new Uint8Array(ex(e,A));return A.write(e,t,0),t}})}function ox(A){return Object.freeze({...A,decode:(e,t=0)=>A.read(e,t)[0]})}function Ks(A){return"fixedSize"in A&&typeof A.fixedSize=="number"}function sx(A,e){if(Ks(A)!==Ks(e))throw new cr(Vw);if(Ks(A)&&Ks(e)&&A.fixedSize!==e.fixedSize)throw new cr(Zw,{decoderFixedSize:e.fixedSize,encoderFixedSize:A.fixedSize});if(!Ks(A)&&!Ks(e)&&A.maxSize!==e.maxSize)throw new cr(_w,{decoderMaxSize:e.maxSize,encoderMaxSize:A.maxSize});return{...e,...A,decode:e.decode,encode:A.encode,read:e.read,write:A.write}}function rx(A,e,t=0){if(e.length-t<=0)throw new cr(Ww,{codecDescription:A})}function nx(A,e,t,s=0){const n=t.length-s;if(n<e)throw new cr(zw,{bytesLength:n,codecDescription:A,expected:e})}function ix(A,e,t,s){if(s<e||s>t)throw new Pw(Ow,{codecDescription:A,max:t,min:e,value:s})}function Uc(A){return A?.endian!==1}function ax(A){return tx({fixedSize:A.size,write(e,t,s){A.range&&ix(A.name,A.range[0],A.range[1],e);const n=new ArrayBuffer(A.size);return A.set(new DataView(n),e,Uc(A.config)),t.set(new Uint8Array(n),s),s+A.size}})}function gx(A){return ox({fixedSize:A.size,read(e,t=0){rx(A.name,e,t),nx(A.name,A.size,e,t);const s=new DataView(Qx(e,t,A.size));return[A.get(s,Uc(A.config)),t+A.size]}})}function Qx(A,e,t){const s=A.byteOffset+(e??0),n=t??A.byteLength;return A.buffer.slice(s,s+n)}var Bx=(A={})=>ax({config:A,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,s)=>e.setBigUint64(0,BigInt(t),s),size:8}),lx=(A={})=>gx({config:A,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),cx=(A={})=>sx(Bx(A),lx(A));class Ex extends TypeError{constructor(e,t){let s;const{message:n,explanation:r,...i}=e,{path:a}=e,g=a.length===0?n:`At path: ${a.join(".")} -- ${n}`;super(r??g),r!=null&&(this.cause=g),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>s??(s=[e,...t()])}}function Cx(A){return Rr(A)&&typeof A[Symbol.iterator]=="function"}function Rr(A){return typeof A=="object"&&A!=null}function kn(A){return Rr(A)&&!Array.isArray(A)}function mo(A){return typeof A=="symbol"?A.toString():typeof A=="string"?JSON.stringify(A):`${A}`}function Ix(A){const{done:e,value:t}=A.next();return e?void 0:t}function ux(A,e,t,s){if(A===!0)return;A===!1?A={}:typeof A=="string"&&(A={message:A});const{path:n,branch:r}=e,{type:i}=t,{refinement:a,message:g=`Expected a value of type \`${i}\`${a?` with refinement \`${a}\``:""}, but received: \`${mo(s)}\``}=A;return{value:s,type:i,refinement:a,key:n[n.length-1],path:n,branch:r,...A,message:g}}function*$Q(A,e,t,s){Cx(A)||(A=[A]);for(const n of A){const r=ux(n,e,t,s);r&&(yield r)}}function*Ig(A,e,t={}){const{path:s=[],branch:n=[A],coerce:r=!1,mask:i=!1}=t,a={path:s,branch:n,mask:i};r&&(A=e.coercer(A,a));let g="valid";for(const Q of e.validator(A,a))Q.explanation=t.message,g="not_valid",yield[Q,void 0];for(let[Q,l,C]of e.entries(A,a)){const I=Ig(l,C,{path:Q===void 0?s:[...s,Q],branch:Q===void 0?n:[...n,l],coerce:r,mask:i,message:t.message});for(const c of I)c[0]?(g=c[0].refinement!=null?"not_refined":"not_valid",yield[c[0],void 0]):r&&(l=c[1],Q===void 0?A=l:A instanceof Map?A.set(Q,l):A instanceof Set?A.add(l):Rr(A)&&(l!==void 0||Q in A)&&(A[Q]=l))}if(g!=="not_valid")for(const Q of e.refiner(A,a))Q.explanation=t.message,g="not_refined",yield[Q,void 0];g==="valid"&&(yield[void 0,A])}let vo=class{constructor(e){const{type:t,schema:s,validator:n,refiner:r,coercer:i=g=>g,entries:a=function*(){}}=e;this.type=t,this.schema=s,this.entries=a,this.coercer=i,n?this.validator=(g,Q)=>{const l=n(g,Q);return $Q(l,Q,this,g)}:this.validator=()=>[],r?this.refiner=(g,Q)=>{const l=r(g,Q);return $Q(l,Q,this,g)}:this.refiner=()=>[]}assert(e,t){return dx(e,this,t)}create(e,t){return hr(e,this,t)}is(e){return Rc(e,this)}mask(e,t){return hx(e,this,t)}validate(e,t={}){return Kr(e,this,t)}};function dx(A,e,t){const s=Kr(A,e,{message:t});if(s[0])throw s[0]}function hr(A,e,t){const s=Kr(A,e,{coerce:!0,message:t});if(s[0])throw s[0];return s[1]}function hx(A,e,t){const s=Kr(A,e,{coerce:!0,mask:!0,message:t});if(s[0])throw s[0];return s[1]}function Rc(A,e){return!Kr(A,e)[0]}function Kr(A,e,t={}){const s=Ig(A,e,t),n=Ix(s);return n[0]?[new Ex(n[0],function*(){for(const i of s)i[0]&&(yield i[0])}),void 0]:[void 0,n[1]]}function ks(A,e){return new vo({type:A,schema:null,validator:e})}function px(){return ks("any",()=>!0)}function LA(A){return new vo({type:"array",schema:A,*entries(e){if(A&&Array.isArray(e))for(const[t,s]of e.entries())yield[t,s,A]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${mo(e)}`}})}function Fo(){return ks("boolean",A=>typeof A=="boolean")}function ug(A){return ks("instance",e=>e instanceof A||`Expected a \`${A.name}\` instance, but received: ${mo(e)}`)}function Bt(A){const e=mo(A),t=typeof A;return new vo({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?A:null,validator(s){return s===A||`Expected the literal \`${e}\`, but received: ${mo(s)}`}})}function fx(){return ks("never",()=>!1)}function jA(A){return new vo({...A,validator:(e,t)=>e===null||A.validator(e,t),refiner:(e,t)=>e===null||A.refiner(e,t)})}function gA(){return ks("number",A=>typeof A=="number"&&!isNaN(A)||`Expected a number, but received: ${mo(A)}`)}function ee(A){return new vo({...A,validator:(e,t)=>e===void 0||A.validator(e,t),refiner:(e,t)=>e===void 0||A.refiner(e,t)})}function Kc(A,e){return new vo({type:"record",schema:null,*entries(t){if(Rr(t))for(const s in t){const n=t[s];yield[s,s,A],yield[s,n,e]}},validator(t){return kn(t)||`Expected an object, but received: ${mo(t)}`},coercer(t){return kn(t)?{...t}:t}})}function FA(){return ks("string",A=>typeof A=="string"||`Expected a string, but received: ${mo(A)}`)}function dg(A){const e=fx();return new vo({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const s=Math.max(A.length,t.length);for(let n=0;n<s;n++)yield[n,t[n],A[n]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${mo(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function wA(A){const e=Object.keys(A);return new vo({type:"type",schema:A,*entries(t){if(Rr(t))for(const s of e)yield[s,t[s],A[s]]},validator(t){return kn(t)||`Expected an object, but received: ${mo(t)}`},coercer(t){return kn(t)?{...t}:t}})}function Xt(A){const e=A.map(t=>t.type).join(" | ");return new vo({type:"union",schema:null,coercer(t,s){for(const n of A){const[r,i]=n.validate(t,{coerce:!0,mask:s.mask});if(!r)return i}return t},validator(t,s){const n=[];for(const r of A){const[...i]=Ig(t,r,s),[a]=i;if(a[0])for(const[g]of i)g&&n.push(g);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${mo(t)}`,...n]}})}function Ar(){return ks("unknown",()=>!0)}function Jr(A,e,t){return new vo({...A,coercer:(s,n)=>Rc(s,e)?A.coercer(t(s,n),n):A.coercer(s,n)})}var _r,mx=new Uint8Array(16);function Jc(){if(!_r&&(_r=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!_r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _r(mx)}const wx=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function _n(A){return typeof A=="string"&&wx.test(A)}var Gt=[];for(var Ni=0;Ni<256;++Ni)Gt.push((Ni+256).toString(16).substr(1));function Xn(A){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Gt[A[e+0]]+Gt[A[e+1]]+Gt[A[e+2]]+Gt[A[e+3]]+"-"+Gt[A[e+4]]+Gt[A[e+5]]+"-"+Gt[A[e+6]]+Gt[A[e+7]]+"-"+Gt[A[e+8]]+Gt[A[e+9]]+"-"+Gt[A[e+10]]+Gt[A[e+11]]+Gt[A[e+12]]+Gt[A[e+13]]+Gt[A[e+14]]+Gt[A[e+15]]).toLowerCase();if(!_n(t))throw TypeError("Stringified UUID is invalid");return t}var AB,ki,Mi=0,bi=0;function xx(A,e,t){var s=e&&t||0,n=e||new Array(16);A=A||{};var r=A.node||AB,i=A.clockseq!==void 0?A.clockseq:ki;if(r==null||i==null){var a=A.random||(A.rng||Jc)();r==null&&(r=AB=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),i==null&&(i=ki=(a[6]<<8|a[7])&16383)}var g=A.msecs!==void 0?A.msecs:Date.now(),Q=A.nsecs!==void 0?A.nsecs:bi+1,l=g-Mi+(Q-bi)/1e4;if(l<0&&A.clockseq===void 0&&(i=i+1&16383),(l<0||g>Mi)&&A.nsecs===void 0&&(Q=0),Q>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Mi=g,bi=Q,ki=i,g+=122192928e5;var C=((g&268435455)*1e4+Q)%4294967296;n[s++]=C>>>24&255,n[s++]=C>>>16&255,n[s++]=C>>>8&255,n[s++]=C&255;var I=g/4294967296*1e4&268435455;n[s++]=I>>>8&255,n[s++]=I&255,n[s++]=I>>>24&15|16,n[s++]=I>>>16&255,n[s++]=i>>>8|128,n[s++]=i&255;for(var c=0;c<6;++c)n[s+c]=r[c];return e||Xn(n)}function Lc(A){if(!_n(A))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(A.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(A.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(A.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(A.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(A.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function Dx(A){A=unescape(encodeURIComponent(A));for(var e=[],t=0;t<A.length;++t)e.push(A.charCodeAt(t));return e}var yx="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Nx="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function jc(A,e,t){function s(n,r,i,a){if(typeof n=="string"&&(n=Dx(n)),typeof r=="string"&&(r=Lc(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var g=new Uint8Array(16+n.length);if(g.set(r),g.set(n,r.length),g=t(g),g[6]=g[6]&15|e,g[8]=g[8]&63|128,i){a=a||0;for(var Q=0;Q<16;++Q)i[a+Q]=g[Q];return i}return Xn(g)}try{s.name=A}catch{}return s.DNS=yx,s.URL=Nx,s}function kx(A){if(typeof A=="string"){var e=unescape(encodeURIComponent(A));A=new Uint8Array(e.length);for(var t=0;t<e.length;++t)A[t]=e.charCodeAt(t)}return Mx(bx(Fx(A),A.length*8))}function Mx(A){for(var e=[],t=A.length*32,s="0123456789abcdef",n=0;n<t;n+=8){var r=A[n>>5]>>>n%32&255,i=parseInt(s.charAt(r>>>4&15)+s.charAt(r&15),16);e.push(i)}return e}function Tc(A){return(A+64>>>9<<4)+14+1}function bx(A,e){A[e>>5]|=128<<e%32,A[Tc(e)-1]=e;for(var t=1732584193,s=-271733879,n=-1732584194,r=271733878,i=0;i<A.length;i+=16){var a=t,g=s,Q=n,l=r;t=Jt(t,s,n,r,A[i],7,-680876936),r=Jt(r,t,s,n,A[i+1],12,-389564586),n=Jt(n,r,t,s,A[i+2],17,606105819),s=Jt(s,n,r,t,A[i+3],22,-1044525330),t=Jt(t,s,n,r,A[i+4],7,-176418897),r=Jt(r,t,s,n,A[i+5],12,1200080426),n=Jt(n,r,t,s,A[i+6],17,-1473231341),s=Jt(s,n,r,t,A[i+7],22,-45705983),t=Jt(t,s,n,r,A[i+8],7,1770035416),r=Jt(r,t,s,n,A[i+9],12,-1958414417),n=Jt(n,r,t,s,A[i+10],17,-42063),s=Jt(s,n,r,t,A[i+11],22,-1990404162),t=Jt(t,s,n,r,A[i+12],7,1804603682),r=Jt(r,t,s,n,A[i+13],12,-40341101),n=Jt(n,r,t,s,A[i+14],17,-1502002290),s=Jt(s,n,r,t,A[i+15],22,1236535329),t=Lt(t,s,n,r,A[i+1],5,-165796510),r=Lt(r,t,s,n,A[i+6],9,-1069501632),n=Lt(n,r,t,s,A[i+11],14,643717713),s=Lt(s,n,r,t,A[i],20,-373897302),t=Lt(t,s,n,r,A[i+5],5,-701558691),r=Lt(r,t,s,n,A[i+10],9,38016083),n=Lt(n,r,t,s,A[i+15],14,-660478335),s=Lt(s,n,r,t,A[i+4],20,-405537848),t=Lt(t,s,n,r,A[i+9],5,568446438),r=Lt(r,t,s,n,A[i+14],9,-1019803690),n=Lt(n,r,t,s,A[i+3],14,-187363961),s=Lt(s,n,r,t,A[i+8],20,1163531501),t=Lt(t,s,n,r,A[i+13],5,-1444681467),r=Lt(r,t,s,n,A[i+2],9,-51403784),n=Lt(n,r,t,s,A[i+7],14,1735328473),s=Lt(s,n,r,t,A[i+12],20,-1926607734),t=jt(t,s,n,r,A[i+5],4,-378558),r=jt(r,t,s,n,A[i+8],11,-2022574463),n=jt(n,r,t,s,A[i+11],16,1839030562),s=jt(s,n,r,t,A[i+14],23,-35309556),t=jt(t,s,n,r,A[i+1],4,-1530992060),r=jt(r,t,s,n,A[i+4],11,1272893353),n=jt(n,r,t,s,A[i+7],16,-155497632),s=jt(s,n,r,t,A[i+10],23,-1094730640),t=jt(t,s,n,r,A[i+13],4,681279174),r=jt(r,t,s,n,A[i],11,-358537222),n=jt(n,r,t,s,A[i+3],16,-722521979),s=jt(s,n,r,t,A[i+6],23,76029189),t=jt(t,s,n,r,A[i+9],4,-640364487),r=jt(r,t,s,n,A[i+12],11,-421815835),n=jt(n,r,t,s,A[i+15],16,530742520),s=jt(s,n,r,t,A[i+2],23,-995338651),t=Tt(t,s,n,r,A[i],6,-198630844),r=Tt(r,t,s,n,A[i+7],10,1126891415),n=Tt(n,r,t,s,A[i+14],15,-1416354905),s=Tt(s,n,r,t,A[i+5],21,-57434055),t=Tt(t,s,n,r,A[i+12],6,1700485571),r=Tt(r,t,s,n,A[i+3],10,-1894986606),n=Tt(n,r,t,s,A[i+10],15,-1051523),s=Tt(s,n,r,t,A[i+1],21,-2054922799),t=Tt(t,s,n,r,A[i+8],6,1873313359),r=Tt(r,t,s,n,A[i+15],10,-30611744),n=Tt(n,r,t,s,A[i+6],15,-1560198380),s=Tt(s,n,r,t,A[i+13],21,1309151649),t=Tt(t,s,n,r,A[i+4],6,-145523070),r=Tt(r,t,s,n,A[i+11],10,-1120210379),n=Tt(n,r,t,s,A[i+2],15,718787259),s=Tt(s,n,r,t,A[i+9],21,-343485551),t=As(t,a),s=As(s,g),n=As(n,Q),r=As(r,l)}return[t,s,n,r]}function Fx(A){if(A.length===0)return[];for(var e=A.length*8,t=new Uint32Array(Tc(e)),s=0;s<e;s+=8)t[s>>5]|=(A[s/8]&255)<<s%32;return t}function As(A,e){var t=(A&65535)+(e&65535),s=(A>>16)+(e>>16)+(t>>16);return s<<16|t&65535}function Gx(A,e){return A<<e|A>>>32-e}function $n(A,e,t,s,n,r){return As(Gx(As(As(e,A),As(s,r)),n),t)}function Jt(A,e,t,s,n,r,i){return $n(e&t|~e&s,A,e,n,r,i)}function Lt(A,e,t,s,n,r,i){return $n(e&s|t&~s,A,e,n,r,i)}function jt(A,e,t,s,n,r,i){return $n(e^t^s,A,e,n,r,i)}function Tt(A,e,t,s,n,r,i){return $n(t^(e|~s),A,e,n,r,i)}var vx=jc("v3",48,kx);function Sx(A,e,t){A=A||{};var s=A.random||(A.rng||Jc)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var n=0;n<16;++n)e[t+n]=s[n];return e}return Xn(s)}function Ux(A,e,t,s){switch(A){case 0:return e&t^~e&s;case 1:return e^t^s;case 2:return e&t^e&s^t&s;case 3:return e^t^s}}function Fi(A,e){return A<<e|A>>>32-e}function Rx(A){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof A=="string"){var s=unescape(encodeURIComponent(A));A=[];for(var n=0;n<s.length;++n)A.push(s.charCodeAt(n))}else Array.isArray(A)||(A=Array.prototype.slice.call(A));A.push(128);for(var r=A.length/4+2,i=Math.ceil(r/16),a=new Array(i),g=0;g<i;++g){for(var Q=new Uint32Array(16),l=0;l<16;++l)Q[l]=A[g*64+l*4]<<24|A[g*64+l*4+1]<<16|A[g*64+l*4+2]<<8|A[g*64+l*4+3];a[g]=Q}a[i-1][14]=(A.length-1)*8/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=(A.length-1)*8&4294967295;for(var C=0;C<i;++C){for(var I=new Uint32Array(80),c=0;c<16;++c)I[c]=a[C][c];for(var u=16;u<80;++u)I[u]=Fi(I[u-3]^I[u-8]^I[u-14]^I[u-16],1);for(var f=t[0],h=t[1],k=t[2],v=t[3],D=t[4],O=0;O<80;++O){var J=Math.floor(O/20),V=Fi(f,5)+Ux(J,h,k,v)+D+e[J]+I[O]>>>0;D=v,v=k,k=Fi(h,30)>>>0,h=f,f=V}t[0]=t[0]+f>>>0,t[1]=t[1]+h>>>0,t[2]=t[2]+k>>>0,t[3]=t[3]+v>>>0,t[4]=t[4]+D>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var Kx=jc("v5",80,Rx);const Jx="00000000-0000-0000-0000-000000000000";function Lx(A){if(!_n(A))throw TypeError("Invalid UUID");return parseInt(A.substr(14,1),16)}const jx=Object.freeze(Object.defineProperty({__proto__:null,NIL:Jx,parse:Lc,stringify:Xn,v1:xx,v3:vx,v4:Sx,v5:Kx,validate:_n,version:Lx},Symbol.toStringTag,{value:"Module"})),Oc=Ma(jx);var Gi,eB;function Tx(){if(eB)return Gi;eB=1;const A=Oc.v4;return Gi=function(t,s,n,r){if(typeof t!="string")throw new TypeError(t+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const a={method:t};if(i===2&&(a.jsonrpc="2.0"),s){if(typeof s!="object"&&!Array.isArray(s))throw new TypeError(s+" must be an object, array or omitted");a.params=s}if(typeof n>"u"){const g=typeof r.generator=="function"?r.generator:function(){return A()};a.id=g(a,r)}else i===2&&n===null?r.notificationIdNull&&(a.id=null):a.id=n;return a},Gi}var vi,tB;function Ox(){if(tB)return vi;tB=1;const A=Oc.v4,e=Tx(),t=function(s,n){if(!(this instanceof t))return new t(s,n);n||(n={}),this.options={reviver:typeof n.reviver<"u"?n.reviver:null,replacer:typeof n.replacer<"u"?n.replacer:null,generator:typeof n.generator<"u"?n.generator:function(){return A()},version:typeof n.version<"u"?n.version:2,notificationIdNull:typeof n.notificationIdNull=="boolean"?n.notificationIdNull:!1},this.callServer=s};return vi=t,t.prototype.request=function(s,n,r,i){const a=this;let g=null;const Q=Array.isArray(s)&&typeof n=="function";if(this.options.version===1&&Q)throw new TypeError("JSON-RPC 1.0 does not support batching");if(Q||!Q&&s&&typeof s=="object"&&typeof n=="function")i=n,g=s;else{typeof r=="function"&&(i=r,r=void 0);const I=typeof i=="function";try{g=e(s,n,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(c){if(I){i(c);return}throw c}if(!I)return g}let C;try{C=JSON.stringify(g,this.options.replacer)}catch(I){i(I);return}return this.callServer(C,function(I,c){a._parseResponse(I,c,i)}),g},t.prototype._parseResponse=function(s,n,r){if(s){r(s);return}if(!n){r();return}let i;try{i=JSON.parse(n,this.options.reviver)}catch(a){r(a);return}if(r.length===3)if(Array.isArray(i)){const a=function(Q){return typeof Q.error<"u"},g=function(Q){return!a(Q)};r(null,i.filter(a),i.filter(g));return}else{r(null,i.error,i.result);return}r(null,i)},vi}Ox();var Si={exports:{}},oB;function qx(){return oB||(oB=1,(function(A){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function n(g,Q,l){this.fn=g,this.context=Q,this.once=l||!1}function r(g,Q,l,C,I){if(typeof l!="function")throw new TypeError("The listener must be a function");var c=new n(l,C||g,I),u=t?t+Q:Q;return g._events[u]?g._events[u].fn?g._events[u]=[g._events[u],c]:g._events[u].push(c):(g._events[u]=c,g._eventsCount++),g}function i(g,Q){--g._eventsCount===0?g._events=new s:delete g._events[Q]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var Q=[],l,C;if(this._eventsCount===0)return Q;for(C in l=this._events)e.call(l,C)&&Q.push(t?C.slice(1):C);return Object.getOwnPropertySymbols?Q.concat(Object.getOwnPropertySymbols(l)):Q},a.prototype.listeners=function(Q){var l=t?t+Q:Q,C=this._events[l];if(!C)return[];if(C.fn)return[C.fn];for(var I=0,c=C.length,u=new Array(c);I<c;I++)u[I]=C[I].fn;return u},a.prototype.listenerCount=function(Q){var l=t?t+Q:Q,C=this._events[l];return C?C.fn?1:C.length:0},a.prototype.emit=function(Q,l,C,I,c,u){var f=t?t+Q:Q;if(!this._events[f])return!1;var h=this._events[f],k=arguments.length,v,D;if(h.fn){switch(h.once&&this.removeListener(Q,h.fn,void 0,!0),k){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,l),!0;case 3:return h.fn.call(h.context,l,C),!0;case 4:return h.fn.call(h.context,l,C,I),!0;case 5:return h.fn.call(h.context,l,C,I,c),!0;case 6:return h.fn.call(h.context,l,C,I,c,u),!0}for(D=1,v=new Array(k-1);D<k;D++)v[D-1]=arguments[D];h.fn.apply(h.context,v)}else{var O=h.length,J;for(D=0;D<O;D++)switch(h[D].once&&this.removeListener(Q,h[D].fn,void 0,!0),k){case 1:h[D].fn.call(h[D].context);break;case 2:h[D].fn.call(h[D].context,l);break;case 3:h[D].fn.call(h[D].context,l,C);break;case 4:h[D].fn.call(h[D].context,l,C,I);break;default:if(!v)for(J=1,v=new Array(k-1);J<k;J++)v[J-1]=arguments[J];h[D].fn.apply(h[D].context,v)}}return!0},a.prototype.on=function(Q,l,C){return r(this,Q,l,C,!1)},a.prototype.once=function(Q,l,C){return r(this,Q,l,C,!0)},a.prototype.removeListener=function(Q,l,C,I){var c=t?t+Q:Q;if(!this._events[c])return this;if(!l)return i(this,c),this;var u=this._events[c];if(u.fn)u.fn===l&&(!I||u.once)&&(!C||u.context===C)&&i(this,c);else{for(var f=0,h=[],k=u.length;f<k;f++)(u[f].fn!==l||I&&!u[f].once||C&&u[f].context!==C)&&h.push(u[f]);h.length?this._events[c]=h.length===1?h[0]:h:i(this,c)}return this},a.prototype.removeAllListeners=function(Q){var l;return Q?(l=t?t+Q:Q,this._events[l]&&i(this,l)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,A.exports=a})(Si)),Si.exports}qx();class qc extends rc{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,oc(e);const s=gg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,r=new Uint8Array(n);r.set(s.length>n?e.create().update(s).digest():s);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),qs(r)}update(e){return pn(this),this.iHash.update(e),this}digestInto(e){pn(this),ys(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:n,destroyed:r,blockLen:i,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=r,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Yc=(A,e,t)=>new qc(A,e).update(t).digest();Yc.create=(A,e)=>new qc(A,e);const sB=(A,e)=>(A+(A>=0?e:-e)/Hc)/e;function Yx(A,e,t){const[[s,n],[r,i]]=e,a=sB(i*A,t),g=sB(-n*A,t);let Q=A-a*s-g*r,l=-a*n-g*i;const C=Q<qo,I=l<qo;C&&(Q=-Q),I&&(l=-l);const c=Sr(Math.ceil(lc(t)/2))+Ts;if(Q<qo||Q>=c||l<qo||l>=c)throw new Error("splitScalar (endomorphism): failed, k="+A);return{k1neg:C,k1:Q,k2neg:I,k2:l}}function da(A){if(!["compact","recovered","der"].includes(A))throw new Error('Signature format must be "compact", "recovered", or "der"');return A}function Ui(A,e){const t={};for(let s of Object.keys(e))t[s]=A[s]===void 0?e[s]:A[s];return ms(t.lowS,"lowS"),ms(t.prehash,"prehash"),t.format!==void 0&&da(t.format),t}class Hx extends Error{constructor(e=""){super(e)}}const To={Err:Hx,_tlv:{encode:(A,e)=>{const{Err:t}=To;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const s=e.length/2,n=Vr(s);if(n.length/2&128)throw new t("tlv.encode: long form length too big");const r=s>127?Vr(n.length/2|128):"";return Vr(A)+r+n+e},decode(A,e){const{Err:t}=To;let s=0;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[s++]!==A)throw new t("tlv.decode: wrong tlv");const n=e[s++],r=!!(n&128);let i=0;if(!r)i=n;else{const g=n&127;if(!g)throw new t("tlv.decode(long): indefinite length not supported");if(g>4)throw new t("tlv.decode(long): byte length is too big");const Q=e.subarray(s,s+g);if(Q.length!==g)throw new t("tlv.decode: length bytes not complete");if(Q[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const l of Q)i=i<<8|l;if(s+=g,i<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(s,s+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(s+i)}}},_int:{encode(A){const{Err:e}=To;if(A<qo)throw new e("integer: negative integers are not allowed");let t=Vr(A);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(A){const{Err:e}=To;if(A[0]&128)throw new e("invalid signature integer: negative");if(A[0]===0&&!(A[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return zn(A)}},toSig(A){const{Err:e,_int:t,_tlv:s}=To,n=ut("signature",A),{v:r,l:i}=s.decode(48,n);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:g}=s.decode(2,r),{v:Q,l}=s.decode(2,g);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(Q)}},hexFromSig(A){const{_tlv:e,_int:t}=To,s=e.encode(2,t.encode(A.r)),n=e.encode(2,t.encode(A.s)),r=s+n;return e.encode(48,r)}},qo=BigInt(0),Ts=BigInt(1),Hc=BigInt(2),Xr=BigInt(3),Px=BigInt(4);function Js(A,e){const{BYTES:t}=A;let s;if(typeof e=="bigint")s=e;else{let n=ut("private key",e);try{s=A.fromBytes(n)}catch{throw new Error(`invalid private key: expected ui8a of size ${t}, got ${typeof e}`)}}if(!A.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}function Wx(A,e={}){const t=kc("weierstrass",A,e),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i,n:a}=r;Ur(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:g}=e;if(g&&(!s.is0(r.a)||typeof g.beta!="bigint"||!Array.isArray(g.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const Q=Wc(s,n);function l(){if(!s.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function C(L,w,B){const{x:d,y:N}=w.toAffine(),G=s.toBytes(d);if(ms(B,"isCompressed"),B){l();const S=!s.isOdd(N);return bo(Pc(S),G)}else return bo(Uint8Array.of(4),G,s.toBytes(N))}function I(L){uo(L,void 0,"Point");const{publicKey:w,publicKeyUncompressed:B}=Q,d=L.length,N=L[0],G=L.subarray(1);if(d===w&&(N===2||N===3)){const S=s.fromBytes(G);if(!s.isValid(S))throw new Error("bad point: is not on curve, wrong x");const j=f(S);let H;try{H=s.sqrt(j)}catch(p){const U=p instanceof Error?": "+p.message:"";throw new Error("bad point: is not on curve, sqrt error"+U)}l();const b=s.isOdd(H);return(N&1)===1!==b&&(H=s.neg(H)),{x:S,y:H}}else if(d===B&&N===4){const S=s.BYTES,j=s.fromBytes(G.subarray(0,S)),H=s.fromBytes(G.subarray(S,S*2));if(!h(j,H))throw new Error("bad point: is not on curve");return{x:j,y:H}}else throw new Error(`bad point: got length ${d}, expected compressed=${w} or uncompressed=${B}`)}const c=e.toBytes||C,u=e.fromBytes||I;function f(L){const w=s.sqr(L),B=s.mul(w,L);return s.add(s.add(B,s.mul(L,r.a)),r.b)}function h(L,w){const B=s.sqr(w),d=f(L);return s.eql(B,d)}if(!h(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const k=s.mul(s.pow(r.a,Xr),Px),v=s.mul(s.sqr(r.b),BigInt(27));if(s.is0(s.add(k,v)))throw new Error("bad curve params: a or b");function D(L,w,B=!1){if(!s.isValid(w)||B&&s.is0(w))throw new Error(`bad point coordinate ${L}`);return w}function O(L){if(!(L instanceof K))throw new Error("ProjectivePoint expected")}function J(L){if(!g||!g.basises)throw new Error("no endo");return Yx(L,g.basises,n.ORDER)}const V=mn((L,w)=>{const{X:B,Y:d,Z:N}=L;if(s.eql(N,s.ONE))return{x:B,y:d};const G=L.is0();w==null&&(w=G?s.ONE:s.inv(N));const S=s.mul(B,w),j=s.mul(d,w),H=s.mul(N,w);if(G)return{x:s.ZERO,y:s.ZERO};if(!s.eql(H,s.ONE))throw new Error("invZ was invalid");return{x:S,y:j}}),eA=mn(L=>{if(L.is0()){if(e.allowInfinityPoint&&!s.is0(L.Y))return;throw new Error("bad point: ZERO")}const{x:w,y:B}=L.toAffine();if(!s.isValid(w)||!s.isValid(B))throw new Error("bad point: x or y not field elements");if(!h(w,B))throw new Error("bad point: equation left != right");if(!L.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function X(L,w,B,d,N){return B=new K(s.mul(B.X,L),B.Y,B.Z),w=wn(d,w),B=wn(N,B),w.add(B)}class K{constructor(w,B,d){this.X=D("x",w),this.Y=D("y",B,!0),this.Z=D("z",d),Object.freeze(this)}static CURVE(){return r}static fromAffine(w){const{x:B,y:d}=w||{};if(!w||!s.isValid(B)||!s.isValid(d))throw new Error("invalid affine point");if(w instanceof K)throw new Error("projective point not allowed");return s.is0(B)&&s.is0(d)?K.ZERO:new K(B,d,s.ONE)}static fromBytes(w){const B=K.fromAffine(u(uo(w,void 0,"point")));return B.assertValidity(),B}static fromHex(w){return K.fromBytes(ut("pointHex",w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,B=!0){return T.createCache(this,w),B||this.multiply(Xr),this}assertValidity(){eA(this)}hasEvenY(){const{y:w}=this.toAffine();if(!s.isOdd)throw new Error("Field doesn't support isOdd");return!s.isOdd(w)}equals(w){O(w);const{X:B,Y:d,Z:N}=this,{X:G,Y:S,Z:j}=w,H=s.eql(s.mul(B,j),s.mul(G,N)),b=s.eql(s.mul(d,j),s.mul(S,N));return H&&b}negate(){return new K(this.X,s.neg(this.Y),this.Z)}double(){const{a:w,b:B}=r,d=s.mul(B,Xr),{X:N,Y:G,Z:S}=this;let j=s.ZERO,H=s.ZERO,b=s.ZERO,E=s.mul(N,N),p=s.mul(G,G),U=s.mul(S,S),R=s.mul(N,G);return R=s.add(R,R),b=s.mul(N,S),b=s.add(b,b),j=s.mul(w,b),H=s.mul(d,U),H=s.add(j,H),j=s.sub(p,H),H=s.add(p,H),H=s.mul(j,H),j=s.mul(R,j),b=s.mul(d,b),U=s.mul(w,U),R=s.sub(E,U),R=s.mul(w,R),R=s.add(R,b),b=s.add(E,E),E=s.add(b,E),E=s.add(E,U),E=s.mul(E,R),H=s.add(H,E),U=s.mul(G,S),U=s.add(U,U),E=s.mul(U,R),j=s.sub(j,E),b=s.mul(U,p),b=s.add(b,b),b=s.add(b,b),new K(j,H,b)}add(w){O(w);const{X:B,Y:d,Z:N}=this,{X:G,Y:S,Z:j}=w;let H=s.ZERO,b=s.ZERO,E=s.ZERO;const p=r.a,U=s.mul(r.b,Xr);let R=s.mul(B,G),_=s.mul(d,S),tA=s.mul(N,j),IA=s.add(B,d),iA=s.add(G,S);IA=s.mul(IA,iA),iA=s.add(R,_),IA=s.sub(IA,iA),iA=s.add(B,N);let UA=s.add(G,j);return iA=s.mul(iA,UA),UA=s.add(R,tA),iA=s.sub(iA,UA),UA=s.add(d,N),H=s.add(S,j),UA=s.mul(UA,H),H=s.add(_,tA),UA=s.sub(UA,H),E=s.mul(p,iA),H=s.mul(U,tA),E=s.add(H,E),H=s.sub(_,E),E=s.add(_,E),b=s.mul(H,E),_=s.add(R,R),_=s.add(_,R),tA=s.mul(p,tA),iA=s.mul(U,iA),_=s.add(_,tA),tA=s.sub(R,tA),tA=s.mul(p,tA),iA=s.add(iA,tA),R=s.mul(_,iA),b=s.add(b,R),R=s.mul(UA,iA),H=s.mul(IA,H),H=s.sub(H,R),R=s.mul(IA,_),E=s.mul(UA,E),E=s.add(E,R),new K(H,b,E)}subtract(w){return this.add(w.negate())}is0(){return this.equals(K.ZERO)}multiply(w){const{endo:B}=e;if(!n.isValidNot0(w))throw new Error("invalid scalar: out of range");let d,N;const G=S=>T.cached(this,S,j=>us(K,j));if(B){const{k1neg:S,k1:j,k2neg:H,k2:b}=J(w),{p:E,f:p}=G(j),{p:U,f:R}=G(b);N=p.add(R),d=X(B.beta,E,U,S,H)}else{const{p:S,f:j}=G(w);d=S,N=j}return us(K,[d,N])[0]}multiplyUnsafe(w){const{endo:B}=e,d=this;if(!n.isValid(w))throw new Error("invalid scalar: out of range");if(w===qo||d.is0())return K.ZERO;if(w===Ts)return d;if(T.hasCache(this))return this.multiply(w);if(B){const{k1neg:N,k1:G,k2neg:S,k2:j}=J(w),{p1:H,p2:b}=gw(K,d,G,j);return X(B.beta,H,b,N,S)}else return T.unsafe(d,w)}multiplyAndAddUnsafe(w,B,d){const N=this.multiplyUnsafe(B).add(w.multiplyUnsafe(d));return N.is0()?void 0:N}toAffine(w){return V(this,w)}isTorsionFree(){const{isTorsionFree:w}=e;return i===Ts?!0:w?w(K,this):T.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:w}=e;return i===Ts?this:w?w(K,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(w=!0){return ms(w,"isCompressed"),this.assertValidity(),c(K,this,w)}toHex(w=!0){return hs(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(w=!0){return this.toBytes(w)}_setWindowSize(w){this.precompute(w)}static normalizeZ(w){return us(K,w)}static msm(w,B){return Nc(K,n,w,B)}static fromPrivateKey(w){return K.BASE.multiply(Js(n,w))}}K.BASE=new K(r.Gx,r.Gy,s.ONE),K.ZERO=new K(s.ZERO,s.ONE,s.ZERO),K.Fp=s,K.Fn=n;const W=n.BITS,T=new yc(K,e.endo?Math.ceil(W/2):W);return K.BASE.precompute(8),K}function Pc(A){return Uint8Array.of(A?2:3)}function Wc(A,e){return{secretKey:e.BYTES,publicKey:1+A.BYTES,publicKeyUncompressed:1+2*A.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function zx(A,e={}){const{Fn:t}=A,s=e.randomBytes||Qg,n=Object.assign(Wc(A.Fp,t),{seed:wc(t.ORDER)});function r(c){try{return!!Js(t,c)}catch{return!1}}function i(c,u){const{publicKey:f,publicKeyUncompressed:h}=n;try{const k=c.length;return u===!0&&k!==f||u===!1&&k!==h?!1:!!A.fromBytes(c)}catch{return!1}}function a(c=s(n.seed)){return nw(uo(c,n.seed,"seed"),t.ORDER)}function g(c,u=!0){return A.BASE.multiply(Js(t,c)).toBytes(u)}function Q(c){const u=a(c);return{secretKey:u,publicKey:g(u)}}function l(c){if(typeof c=="bigint")return!1;if(c instanceof A)return!0;const{secretKey:u,publicKey:f,publicKeyUncompressed:h}=n;if(t.allowedLengths||u===f)return;const k=ut("key",c).length;return k===f||k===h}function C(c,u,f=!0){if(l(c)===!0)throw new Error("first arg must be private key");if(l(u)===!1)throw new Error("second arg must be public key");const h=Js(t,c);return A.fromHex(u).multiply(h).toBytes(f)}return Object.freeze({getPublicKey:g,getSharedSecret:C,keygen:Q,Point:A,utils:{isValidSecretKey:r,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:r,randomPrivateKey:a,normPrivateKeyToScalar:c=>Js(t,c),precompute(c=8,u=A.BASE){return u.precompute(c,!1)}},lengths:n})}function Vx(A,e,t={}){oc(e),Ur(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const s=t.randomBytes||Qg,n=t.hmac||((B,...d)=>Yc(e,B,bo(...d))),{Fp:r,Fn:i}=A,{ORDER:a,BITS:g}=i,{keygen:Q,getPublicKey:l,getSharedSecret:C,utils:I,lengths:c}=zx(A,t),u={prehash:!1,lowS:typeof t.lowS=="boolean"?t.lowS:!1,format:void 0,extraEntropy:!1},f="compact";function h(B){const d=a>>Ts;return B>d}function k(B,d){if(!i.isValidNot0(d))throw new Error(`invalid signature ${B}: out of range 1..Point.Fn.ORDER`);return d}function v(B,d){da(d);const N=c.signature,G=d==="compact"?N:d==="recovered"?N+1:void 0;return uo(B,G,`${d} signature`)}class D{constructor(d,N,G){this.r=k("r",d),this.s=k("s",N),G!=null&&(this.recovery=G),Object.freeze(this)}static fromBytes(d,N=f){v(d,N);let G;if(N==="der"){const{r:b,s:E}=To.toSig(uo(d));return new D(b,E)}N==="recovered"&&(G=d[0],N="compact",d=d.subarray(1));const S=i.BYTES,j=d.subarray(0,S),H=d.subarray(S,S*2);return new D(i.fromBytes(j),i.fromBytes(H),G)}static fromHex(d,N){return this.fromBytes(fn(d),N)}addRecoveryBit(d){return new D(this.r,this.s,d)}recoverPublicKey(d){const N=r.ORDER,{r:G,s:S,recovery:j}=this;if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");if(a*Hc<N&&j>1)throw new Error("recovery id is ambiguous for h>1 curve");const b=j===2||j===3?G+a:G;if(!r.isValid(b))throw new Error("recovery id 2 or 3 invalid");const E=r.toBytes(b),p=A.fromBytes(bo(Pc((j&1)===0),E)),U=i.inv(b),R=J(ut("msgHash",d)),_=i.create(-R*U),tA=i.create(S*U),IA=A.BASE.multiplyUnsafe(_).add(p.multiplyUnsafe(tA));if(IA.is0())throw new Error("point at infinify");return IA.assertValidity(),IA}hasHighS(){return h(this.s)}toBytes(d=f){if(da(d),d==="der")return fn(To.hexFromSig(this));const N=i.toBytes(this.r),G=i.toBytes(this.s);if(d==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return bo(Uint8Array.of(this.recovery),N,G)}return bo(N,G)}toHex(d){return hs(this.toBytes(d))}assertValidity(){}static fromCompact(d){return D.fromBytes(ut("sig",d),"compact")}static fromDER(d){return D.fromBytes(ut("sig",d),"der")}normalizeS(){return this.hasHighS()?new D(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return hs(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return hs(this.toBytes("compact"))}}const O=t.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const N=zn(d),G=d.length*8-g;return G>0?N>>BigInt(G):N},J=t.bits2int_modN||function(d){return i.create(O(d))},V=Sr(g);function eA(B){return ua("num < 2^"+g,B,qo,V),i.toBytes(B)}function X(B,d){return uo(B,void 0,"message"),d?uo(e(B),void 0,"prehashed message"):B}function K(B,d,N){if(["recovered","canonical"].some(_=>_ in N))throw new Error("sign() legacy options not supported");const{lowS:G,prehash:S,extraEntropy:j}=Ui(N,u);B=X(B,S);const H=J(B),b=Js(i,d),E=[eA(b),eA(H)];if(j!=null&&j!==!1){const _=j===!0?s(c.secretKey):j;E.push(ut("extraEntropy",_))}const p=bo(...E),U=H;function R(_){const tA=O(_);if(!i.isValidNot0(tA))return;const IA=i.inv(tA),iA=A.BASE.multiply(tA).toAffine(),UA=i.create(iA.x);if(UA===qo)return;const HA=i.create(IA*i.create(U+UA*b));if(HA===qo)return;let lA=(iA.x===UA?0:2)|Number(iA.y&Ts),qA=HA;return G&&h(HA)&&(qA=i.neg(HA),lA^=1),new D(UA,qA,lA)}return{seed:p,k2sig:R}}function W(B,d,N={}){B=ut("message",B);const{seed:G,k2sig:S}=K(B,d,N);return Zm(e.outputLen,i.BYTES,n)(G,S)}function T(B){let d;const N=typeof B=="string"||vr(B),G=!N&&B!==null&&typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!N&&!G)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(G)d=new D(B.r,B.s);else if(N){try{d=D.fromBytes(ut("sig",B),"der")}catch(S){if(!(S instanceof To.Err))throw S}if(!d)try{d=D.fromBytes(ut("sig",B),"compact")}catch{return!1}}return d||!1}function L(B,d,N,G={}){const{lowS:S,prehash:j,format:H}=Ui(G,u);if(N=ut("publicKey",N),d=X(ut("message",d),j),"strict"in G)throw new Error("options.strict was renamed to lowS");const b=H===void 0?T(B):D.fromBytes(ut("sig",B),H);if(b===!1)return!1;try{const E=A.fromBytes(N);if(S&&b.hasHighS())return!1;const{r:p,s:U}=b,R=J(d),_=i.inv(U),tA=i.create(R*_),IA=i.create(p*_),iA=A.BASE.multiplyUnsafe(tA).add(E.multiplyUnsafe(IA));return iA.is0()?!1:i.create(iA.x)===p}catch{return!1}}function w(B,d,N={}){const{prehash:G}=Ui(N,u);return d=X(d,G),D.fromBytes(B,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:Q,getPublicKey:l,getSharedSecret:C,utils:I,lengths:c,Point:A,sign:W,verify:L,recoverPublicKey:w,Signature:D,hash:e})}function Zx(A){const e={a:A.a,b:A.b,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp;let s=A.allowedPrivateKeyLengths?Array.from(new Set(A.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const n=Ns(e.n,{BITS:A.nBitLength,allowedLengths:s,modFromBytes:A.wrapPrivateKey}),r={Fp:t,Fn:n,allowInfinityPoint:A.allowInfinityPoint,endo:A.endo,isTorsionFree:A.isTorsionFree,clearCofactor:A.clearCofactor,fromBytes:A.fromBytes,toBytes:A.toBytes};return{CURVE:e,curveOpts:r}}function _x(A){const{CURVE:e,curveOpts:t}=Zx(A),s={hmac:A.hmac,randomBytes:A.randomBytes,lowS:A.lowS,bits2int:A.bits2int,bits2int_modN:A.bits2int_modN};return{CURVE:e,curveOpts:t,hash:A.hash,ecdsaOpts:s}}function Xx(A,e){const t=e.Point;return Object.assign({},e,{ProjectivePoint:t,CURVE:Object.assign({},A,fc(t.Fn.ORDER,t.Fn.BITS))})}function $x(A){const{CURVE:e,curveOpts:t,hash:s,ecdsaOpts:n}=_x(A),r=Wx(e,t),i=Vx(r,s,n);return Xx(A,i)}function AD(A,e){const t=s=>$x({...A,hash:s});return{...t(e),create:t}}const hg={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},eD={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},rB=BigInt(2);function tD(A){const e=hg.p,t=BigInt(3),s=BigInt(6),n=BigInt(11),r=BigInt(22),i=BigInt(23),a=BigInt(44),g=BigInt(88),Q=A*A*A%e,l=Q*Q*A%e,C=It(l,t,e)*l%e,I=It(C,t,e)*l%e,c=It(I,rB,e)*Q%e,u=It(c,n,e)*c%e,f=It(u,r,e)*u%e,h=It(f,a,e)*f%e,k=It(h,g,e)*h%e,v=It(k,a,e)*f%e,D=It(v,t,e)*l%e,O=It(D,i,e)*u%e,J=It(O,s,e)*Q%e,V=It(J,rB,e);if(!ha.eql(ha.sqr(V),A))throw new Error("Cannot find square root");return V}const ha=Ns(hg.p,{sqrt:tD}),oD=AD({...hg,Fp:ha,lowS:!0,endo:eD},gc);Vn.utils.randomPrivateKey;Vn.getPublicKey;function nB(A){try{return Vn.ExtendedPoint.fromHex(A),!0}catch{return!1}}Vn.verify;const sD=A=>Dt.Buffer.isBuffer(A)?A:A instanceof Uint8Array?Dt.Buffer.from(A.buffer,A.byteOffset,A.byteLength):Dt.Buffer.from(A);class rD{constructor(e){Object.assign(this,e)}encode(){return Dt.Buffer.from(yi.serialize(ln,this))}static decode(e){return yi.deserialize(ln,this,e)}static decodeUnchecked(e){return yi.deserializeUnchecked(ln,this,e)}}const ln=new Map;var zc;const nD=32,Ri=32;function iD(A){return A._bn!==void 0}let iB=1;class Ye extends rD{constructor(e){if(super({}),this._bn=void 0,iD(e))this._bn=e._bn;else{if(typeof e=="string"){const t=WQ.decode(e);if(t.length!=Ri)throw new Error("Invalid public key input");this._bn=new qQ(t)}else this._bn=new qQ(e);if(this._bn.byteLength()>Ri)throw new Error("Invalid public key input")}}static unique(){const e=new Ye(iB);return iB+=1,new Ye(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return WQ.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Dt.Buffer);if(e.length===Ri)return e;const t=Dt.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,s){const n=Dt.Buffer.concat([e.toBuffer(),Dt.Buffer.from(t),s.toBuffer()]),r=zQ(n);return new Ye(r)}static createProgramAddressSync(e,t){let s=Dt.Buffer.alloc(0);e.forEach(function(r){if(r.length>nD)throw new TypeError("Max seed length exceeded");s=Dt.Buffer.concat([s,sD(r)])}),s=Dt.Buffer.concat([s,t.toBuffer(),Dt.Buffer.from("ProgramDerivedAddress")]);const n=zQ(s);if(nB(n))throw new Error("Invalid seeds, address must fall off the curve");return new Ye(n)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let s=255,n;for(;s!=0;){try{const r=e.concat(Dt.Buffer.from([s]));n=this.createProgramAddressSync(r,t)}catch(r){if(r instanceof TypeError)throw r;s--;continue}return[n,s]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new Ye(e);return nB(t.toBytes())}}zc=Ye;Ye.default=new zc("11111111111111111111111111111111");ln.set(Ye,{kind:"struct",fields:[["_bn","u256"]]});new Ye("BPFLoader1111111111111111111111111111111111");const aD=64,ze=(A="publicKey")=>rA.blob(32,A),Ls=(A="string")=>{const e=rA.struct([rA.u32("length"),rA.u32("lengthPadding"),rA.blob(rA.offset(rA.u32(),-8),"chars")],A),t=e.decode.bind(e),s=e.encode.bind(e),n=e;return n.decode=(r,i)=>t(r,i).chars.toString(),n.encode=(r,i,a)=>{const g={chars:Dt.Buffer.from(r,"utf8")};return s(g,i,a)},n.alloc=r=>rA.u32().span+rA.u32().span+Dt.Buffer.from(r,"utf8").length,n},gD=(A="authorized")=>rA.struct([ze("staker"),ze("withdrawer")],A),QD=(A="lockup")=>rA.struct([rA.ns64("unixTimestamp"),rA.ns64("epoch"),ze("custodian")],A),BD=(A="voteInit")=>rA.struct([ze("nodePubkey"),ze("authorizedVoter"),ze("authorizedWithdrawer"),rA.u8("commission")],A),lD=(A="voteAuthorizeWithSeedArgs")=>rA.struct([rA.u32("voteAuthorizationType"),ze("currentAuthorityDerivedKeyOwnerPubkey"),Ls("currentAuthorityDerivedKeySeed"),ze("newAuthorized")],A);Dt.Buffer.alloc(aD).fill(0);new Ye("SysvarC1ock11111111111111111111111111111111");new Ye("SysvarEpochSchedu1e111111111111111111111111");new Ye("Sysvar1nstructions1111111111111111111111111");new Ye("SysvarRecentB1ockHashes11111111111111111111");new Ye("SysvarRent111111111111111111111111111111111");new Ye("SysvarRewards111111111111111111111111111111");new Ye("SysvarS1otHashes111111111111111111111111111");new Ye("SysvarS1otHistory11111111111111111111111111");new Ye("SysvarStakeHistory1111111111111111111111111");const cD=rA.nu64("lamportsPerSignature"),ED=rA.struct([rA.u32("version"),rA.u32("state"),ze("authorizedPubkey"),ze("nonce"),rA.struct([cD],"feeCalculator")]);ED.span;function Ps(A){const e=rA.blob(8,A),t=e.decode.bind(e),s=e.encode.bind(e),n=e,r=cx();return n.decode=(i,a)=>{const g=t(i,a);return r.decode(g)},n.encode=(i,a,g)=>{const Q=r.encode(i);return s(Q,a,g)},n}Object.freeze({Create:{index:0,layout:rA.struct([rA.u32("instruction"),rA.ns64("lamports"),rA.ns64("space"),ze("programId")])},Assign:{index:1,layout:rA.struct([rA.u32("instruction"),ze("programId")])},Transfer:{index:2,layout:rA.struct([rA.u32("instruction"),Ps("lamports")])},CreateWithSeed:{index:3,layout:rA.struct([rA.u32("instruction"),ze("base"),Ls("seed"),rA.ns64("lamports"),rA.ns64("space"),ze("programId")])},AdvanceNonceAccount:{index:4,layout:rA.struct([rA.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:rA.struct([rA.u32("instruction"),rA.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:rA.struct([rA.u32("instruction"),ze("authorized")])},AuthorizeNonceAccount:{index:7,layout:rA.struct([rA.u32("instruction"),ze("authorized")])},Allocate:{index:8,layout:rA.struct([rA.u32("instruction"),rA.ns64("space")])},AllocateWithSeed:{index:9,layout:rA.struct([rA.u32("instruction"),ze("base"),Ls("seed"),rA.ns64("space"),ze("programId")])},AssignWithSeed:{index:10,layout:rA.struct([rA.u32("instruction"),ze("base"),Ls("seed"),ze("programId")])},TransferWithSeed:{index:11,layout:rA.struct([rA.u32("instruction"),Ps("lamports"),Ls("seed"),ze("programId")])},UpgradeNonceAccount:{index:12,layout:rA.struct([rA.u32("instruction")])}});new Ye("11111111111111111111111111111111");new Ye("BPFLoader2111111111111111111111111111111111");rA.struct([rA.u32("typeIndex"),Ps("deactivationSlot"),rA.nu64("lastExtendedSlot"),rA.u8("lastExtendedStartIndex"),rA.u8(),rA.seq(ze(),rA.offset(rA.u8(),-1),"authority")]);const dt=Jr(ug(Ye),FA(),A=>new Ye(A)),Vc=dg([FA(),Bt("base64")]),pg=Jr(ug(Dt.Buffer),Vc,A=>Dt.Buffer.from(A[0],"base64"));function Zc(A){return Xt([wA({jsonrpc:Bt("2.0"),id:FA(),result:A}),wA({jsonrpc:Bt("2.0"),id:FA(),error:wA({code:Ar(),message:FA(),data:ee(px())})})])}const CD=Zc(Ar());function ot(A){return Jr(Zc(A),CD,e=>"error"in e?e:{...e,result:hr(e.result,A)})}function Do(A){return ot(wA({context:wA({slot:gA()}),value:A}))}function Ai(A){return wA({context:wA({slot:gA()}),value:A})}const ID=wA({foundation:gA(),foundationTerm:gA(),initial:gA(),taper:gA(),terminal:gA()});ot(LA(jA(wA({epoch:gA(),effectiveSlot:gA(),amount:gA(),postBalance:gA(),commission:ee(jA(gA()))}))));const uD=LA(wA({slot:gA(),prioritizationFee:gA()})),dD=wA({total:gA(),validator:gA(),foundation:gA(),epoch:gA()}),hD=wA({epoch:gA(),slotIndex:gA(),slotsInEpoch:gA(),absoluteSlot:gA(),blockHeight:ee(gA()),transactionCount:ee(gA())}),pD=wA({slotsPerEpoch:gA(),leaderScheduleSlotOffset:gA(),warmup:Fo(),firstNormalEpoch:gA(),firstNormalSlot:gA()}),fD=Kc(FA(),LA(gA())),Ms=jA(Xt([wA({}),FA()])),mD=wA({err:Ms}),wD=Bt("receivedSignature");wA({"solana-core":FA(),"feature-set":ee(gA())});const xD=wA({program:FA(),programId:dt,parsed:Ar()}),DD=wA({programId:dt,accounts:LA(dt),data:FA()});Do(wA({err:jA(Xt([wA({}),FA()])),logs:jA(LA(FA())),accounts:ee(jA(LA(jA(wA({executable:Fo(),owner:FA(),lamports:gA(),data:LA(FA()),rentEpoch:ee(gA())}))))),unitsConsumed:ee(gA()),returnData:ee(jA(wA({programId:FA(),data:dg([FA(),Bt("base64")])}))),innerInstructions:ee(jA(LA(wA({index:gA(),instructions:LA(Xt([xD,DD]))}))))}));Do(wA({byIdentity:Kc(FA(),LA(gA())),range:wA({firstSlot:gA(),lastSlot:gA()})}));ot(ID);ot(dD);ot(uD);ot(hD);ot(pD);ot(fD);ot(gA());Do(wA({total:gA(),circulating:gA(),nonCirculating:gA(),nonCirculatingAccounts:LA(dt)}));const yD=wA({amount:FA(),uiAmount:jA(gA()),decimals:gA(),uiAmountString:ee(FA())});Do(LA(wA({address:dt,amount:FA(),uiAmount:jA(gA()),decimals:gA(),uiAmountString:ee(FA())})));Do(LA(wA({pubkey:dt,account:wA({executable:Fo(),owner:dt,lamports:gA(),data:pg,rentEpoch:gA()})})));const pa=wA({program:FA(),parsed:Ar(),space:gA()});Do(LA(wA({pubkey:dt,account:wA({executable:Fo(),owner:dt,lamports:gA(),data:pa,rentEpoch:gA()})})));Do(LA(wA({lamports:gA(),address:dt})));const fg=wA({executable:Fo(),owner:dt,lamports:gA(),data:pg,rentEpoch:gA()});wA({pubkey:dt,account:fg});const ND=Jr(Xt([ug(Dt.Buffer),pa]),Xt([Vc,pa]),A=>Array.isArray(A)?hr(A,pg):A),kD=wA({executable:Fo(),owner:dt,lamports:gA(),data:ND,rentEpoch:gA()});wA({pubkey:dt,account:kD});wA({state:Xt([Bt("active"),Bt("inactive"),Bt("activating"),Bt("deactivating")]),active:gA(),inactive:gA()});ot(LA(wA({signature:FA(),slot:gA(),err:Ms,memo:jA(FA()),blockTime:ee(jA(gA()))})));ot(LA(wA({signature:FA(),slot:gA(),err:Ms,memo:jA(FA()),blockTime:ee(jA(gA()))})));wA({subscription:gA(),result:Ai(fg)});const MD=wA({pubkey:dt,account:fg});wA({subscription:gA(),result:Ai(MD)});const bD=wA({parent:gA(),slot:gA(),root:gA()});wA({subscription:gA(),result:bD});const FD=Xt([wA({type:Xt([Bt("firstShredReceived"),Bt("completed"),Bt("optimisticConfirmation"),Bt("root")]),slot:gA(),timestamp:gA()}),wA({type:Bt("createdBank"),parent:gA(),slot:gA(),timestamp:gA()}),wA({type:Bt("frozen"),slot:gA(),timestamp:gA(),stats:wA({numTransactionEntries:gA(),numSuccessfulTransactions:gA(),numFailedTransactions:gA(),maxTransactionsPerEntry:gA()})}),wA({type:Bt("dead"),slot:gA(),timestamp:gA(),err:FA()})]);wA({subscription:gA(),result:FD});wA({subscription:gA(),result:Ai(Xt([mD,wD]))});wA({subscription:gA(),result:gA()});wA({pubkey:FA(),gossip:jA(FA()),tpu:jA(FA()),rpc:jA(FA()),version:jA(FA())});const aB=wA({votePubkey:FA(),nodePubkey:FA(),activatedStake:gA(),epochVoteAccount:Fo(),epochCredits:LA(dg([gA(),gA(),gA()])),commission:gA(),lastVote:gA(),rootSlot:jA(gA())});ot(wA({current:LA(aB),delinquent:LA(aB)}));const GD=Xt([Bt("processed"),Bt("confirmed"),Bt("finalized")]),vD=wA({slot:gA(),confirmations:jA(gA()),err:Ms,confirmationStatus:ee(GD)});Do(LA(jA(vD)));ot(gA());const _c=wA({accountKey:dt,writableIndexes:LA(gA()),readonlyIndexes:LA(gA())}),mg=wA({signatures:LA(FA()),message:wA({accountKeys:LA(FA()),header:wA({numRequiredSignatures:gA(),numReadonlySignedAccounts:gA(),numReadonlyUnsignedAccounts:gA()}),instructions:LA(wA({accounts:LA(gA()),data:FA(),programIdIndex:gA()})),recentBlockhash:FA(),addressTableLookups:ee(LA(_c))})}),Xc=wA({pubkey:dt,signer:Fo(),writable:Fo(),source:ee(Xt([Bt("transaction"),Bt("lookupTable")]))}),$c=wA({accountKeys:LA(Xc),signatures:LA(FA())}),AE=wA({parsed:Ar(),program:FA(),programId:dt}),eE=wA({accounts:LA(dt),data:FA(),programId:dt}),SD=Xt([eE,AE]),UD=Xt([wA({parsed:Ar(),program:FA(),programId:FA()}),wA({accounts:LA(FA()),data:FA(),programId:FA()})]),tE=Jr(SD,UD,A=>"accounts"in A?hr(A,eE):hr(A,AE)),oE=wA({signatures:LA(FA()),message:wA({accountKeys:LA(Xc),instructions:LA(tE),recentBlockhash:FA(),addressTableLookups:ee(jA(LA(_c)))})}),Mn=wA({accountIndex:gA(),mint:FA(),owner:ee(FA()),programId:ee(FA()),uiTokenAmount:yD}),sE=wA({writable:LA(dt),readonly:LA(dt)}),ei=wA({err:Ms,fee:gA(),innerInstructions:ee(jA(LA(wA({index:gA(),instructions:LA(wA({accounts:LA(gA()),data:FA(),programIdIndex:gA()}))})))),preBalances:LA(gA()),postBalances:LA(gA()),logMessages:ee(jA(LA(FA()))),preTokenBalances:ee(jA(LA(Mn))),postTokenBalances:ee(jA(LA(Mn))),loadedAddresses:ee(sE),computeUnitsConsumed:ee(gA()),costUnits:ee(gA())}),wg=wA({err:Ms,fee:gA(),innerInstructions:ee(jA(LA(wA({index:gA(),instructions:LA(tE)})))),preBalances:LA(gA()),postBalances:LA(gA()),logMessages:ee(jA(LA(FA()))),preTokenBalances:ee(jA(LA(Mn))),postTokenBalances:ee(jA(LA(Mn))),loadedAddresses:ee(sE),computeUnitsConsumed:ee(gA()),costUnits:ee(gA())}),er=Xt([Bt(0),Bt("legacy")]),bs=wA({pubkey:FA(),lamports:gA(),postBalance:jA(gA()),rewardType:jA(FA()),commission:ee(jA(gA()))});ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),transactions:LA(wA({transaction:mg,meta:jA(ei),version:ee(er)})),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),transactions:LA(wA({transaction:$c,meta:jA(ei),version:ee(er)})),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),transactions:LA(wA({transaction:oE,meta:jA(wg),version:ee(er)})),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),transactions:LA(wA({transaction:$c,meta:jA(wg),version:ee(er)})),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),rewards:ee(LA(bs)),blockTime:jA(gA()),blockHeight:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),transactions:LA(wA({transaction:mg,meta:jA(ei)})),rewards:ee(LA(bs)),blockTime:jA(gA())})));ot(jA(wA({blockhash:FA(),previousBlockhash:FA(),parentSlot:gA(),signatures:LA(FA()),blockTime:jA(gA())})));ot(jA(wA({slot:gA(),meta:jA(ei),blockTime:ee(jA(gA())),transaction:mg,version:ee(er)})));ot(jA(wA({slot:gA(),transaction:oE,meta:jA(wg),blockTime:ee(jA(gA())),version:ee(er)})));Do(wA({blockhash:FA(),lastValidBlockHeight:gA()}));Do(Fo());const RD=wA({slot:gA(),numTransactions:gA(),numSlots:gA(),samplePeriodSecs:gA()});ot(LA(RD));Do(jA(wA({feeCalculator:wA({lamportsPerSignature:gA()})})));ot(FA());ot(FA());const KD=wA({err:Ms,logs:LA(FA()),signature:FA()});wA({result:Ai(KD),subscription:gA()});Object.freeze({CreateLookupTable:{index:0,layout:rA.struct([rA.u32("instruction"),Ps("recentSlot"),rA.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:rA.struct([rA.u32("instruction")])},ExtendLookupTable:{index:2,layout:rA.struct([rA.u32("instruction"),Ps(),rA.seq(ze(),rA.offset(rA.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:rA.struct([rA.u32("instruction")])},CloseLookupTable:{index:4,layout:rA.struct([rA.u32("instruction")])}});new Ye("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:rA.struct([rA.u8("instruction"),rA.u32("units"),rA.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:rA.struct([rA.u8("instruction"),rA.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:rA.struct([rA.u8("instruction"),rA.u32("units")])},SetComputeUnitPrice:{index:3,layout:rA.struct([rA.u8("instruction"),Ps("microLamports")])}});new Ye("ComputeBudget111111111111111111111111111111");rA.struct([rA.u8("numSignatures"),rA.u8("padding"),rA.u16("signatureOffset"),rA.u16("signatureInstructionIndex"),rA.u16("publicKeyOffset"),rA.u16("publicKeyInstructionIndex"),rA.u16("messageDataOffset"),rA.u16("messageDataSize"),rA.u16("messageInstructionIndex")]);new Ye("Ed25519SigVerify111111111111111111111111111");oD.utils.isValidPrivateKey;rA.struct([rA.u8("numSignatures"),rA.u16("signatureOffset"),rA.u8("signatureInstructionIndex"),rA.u16("ethAddressOffset"),rA.u8("ethAddressInstructionIndex"),rA.u16("messageDataOffset"),rA.u16("messageDataSize"),rA.u8("messageInstructionIndex"),rA.blob(20,"ethAddress"),rA.blob(64,"signature"),rA.u8("recoveryId")]);new Ye("KeccakSecp256k11111111111111111111111111111");var rE;new Ye("StakeConfig11111111111111111111111111111111");class nE{constructor(e,t,s){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=s}}rE=nE;nE.default=new rE(0,0,Ye.default);Object.freeze({Initialize:{index:0,layout:rA.struct([rA.u32("instruction"),gD(),QD()])},Authorize:{index:1,layout:rA.struct([rA.u32("instruction"),ze("newAuthorized"),rA.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:rA.struct([rA.u32("instruction")])},Split:{index:3,layout:rA.struct([rA.u32("instruction"),rA.ns64("lamports")])},Withdraw:{index:4,layout:rA.struct([rA.u32("instruction"),rA.ns64("lamports")])},Deactivate:{index:5,layout:rA.struct([rA.u32("instruction")])},Merge:{index:7,layout:rA.struct([rA.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:rA.struct([rA.u32("instruction"),ze("newAuthorized"),rA.u32("stakeAuthorizationType"),Ls("authoritySeed"),ze("authorityOwner")])}});new Ye("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:rA.struct([rA.u32("instruction"),BD()])},Authorize:{index:1,layout:rA.struct([rA.u32("instruction"),ze("newAuthorized"),rA.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:rA.struct([rA.u32("instruction"),rA.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:rA.struct([rA.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:rA.struct([rA.u32("instruction"),lD()])}});new Ye("Vote111111111111111111111111111111111111111");new Ye("Va1idator1nfo111111111111111111111111111111");wA({name:FA(),website:ee(FA()),details:ee(FA()),iconUrl:ee(FA()),keybaseUsername:ee(FA())});new Ye("Vote111111111111111111111111111111111111111");rA.struct([ze("nodePubkey"),ze("authorizedWithdrawer"),rA.u8("commission"),rA.nu64(),rA.seq(rA.struct([rA.nu64("slot"),rA.u32("confirmationCount")]),rA.offset(rA.u32(),-8),"votes"),rA.u8("rootSlotValid"),rA.nu64("rootSlot"),rA.nu64(),rA.seq(rA.struct([rA.nu64("epoch"),ze("authorizedVoter")]),rA.offset(rA.u32(),-8),"authorizedVoters"),rA.struct([rA.seq(rA.struct([ze("authorizedPubkey"),rA.nu64("epochOfLastAuthorizedSwitch"),rA.nu64("targetEpoch")]),32,"buf"),rA.nu64("idx"),rA.u8("isEmpty")],"priorVoters"),rA.nu64(),rA.seq(rA.struct([rA.nu64("epoch"),rA.nu64("credits"),rA.nu64("prevCredits")]),rA.offset(rA.u32(),-8),"epochCredits"),rA.struct([rA.nu64("slot"),rA.nu64("timestamp")],"lastTimestamp")]);function JD(A){if(A.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let Q=0;Q<e.length;Q++)e[Q]=255;for(let Q=0;Q<A.length;Q++){const l=A.charAt(Q),C=l.charCodeAt(0);if(e[C]!==255)throw new TypeError(l+" is ambiguous");e[C]=Q}const t=A.length,s=A.charAt(0),n=Math.log(t)/Math.log(256),r=Math.log(256)/Math.log(t);function i(Q){if(Q instanceof Uint8Array||(ArrayBuffer.isView(Q)?Q=new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength):Array.isArray(Q)&&(Q=Uint8Array.from(Q))),!(Q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Q.length===0)return"";let l=0,C=0,I=0;const c=Q.length;for(;I!==c&&Q[I]===0;)I++,l++;const u=(c-I)*r+1>>>0,f=new Uint8Array(u);for(;I!==c;){let v=Q[I],D=0;for(let O=u-1;(v!==0||D<C)&&O!==-1;O--,D++)v+=256*f[O]>>>0,f[O]=v%t>>>0,v=v/t>>>0;if(v!==0)throw new Error("Non-zero carry");C=D,I++}let h=u-C;for(;h!==u&&f[h]===0;)h++;let k=s.repeat(l);for(;h<u;++h)k+=A.charAt(f[h]);return k}function a(Q){if(typeof Q!="string")throw new TypeError("Expected String");if(Q.length===0)return new Uint8Array;let l=0,C=0,I=0;for(;Q[l]===s;)C++,l++;const c=(Q.length-l)*n+1>>>0,u=new Uint8Array(c);for(;l<Q.length;){const v=Q.charCodeAt(l);if(v>255)return;let D=e[v];if(D===255)return;let O=0;for(let J=c-1;(D!==0||O<I)&&J!==-1;J--,O++)D+=t*u[J]>>>0,u[J]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");I=O,l++}let f=c-I;for(;f!==c&&u[f]===0;)f++;const h=new Uint8Array(C+(c-f));let k=C;for(;f!==c;)h[k++]=u[f++];return h}function g(Q){const l=a(Q);if(l)return l;throw new Error("Non-base"+t+" character")}return{encode:i,decodeUnsafe:a,decode:g}}var LD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";JD(LD);function jD(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ki={exports:{}},gB;function TD(){return gB||(gB=1,(function(A){(function(e){var t=function(F){var Y,P=new Float64Array(16);if(F)for(Y=0;Y<F.length;Y++)P[Y]=F[Y];return P},s=function(){throw new Error("no PRNG")},n=new Uint8Array(16),r=new Uint8Array(32);r[0]=9;var i=t(),a=t([1]),g=t([56129,1]),Q=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),C=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),I=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),c=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function u(F,Y,P,m){F[Y]=P>>24&255,F[Y+1]=P>>16&255,F[Y+2]=P>>8&255,F[Y+3]=P&255,F[Y+4]=m>>24&255,F[Y+5]=m>>16&255,F[Y+6]=m>>8&255,F[Y+7]=m&255}function f(F,Y,P,m,z){var sA,oA=0;for(sA=0;sA<z;sA++)oA|=F[Y+sA]^P[m+sA];return(1&oA-1>>>8)-1}function h(F,Y,P,m){return f(F,Y,P,m,16)}function k(F,Y,P,m){return f(F,Y,P,m,32)}function v(F,Y,P,m){for(var z=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,sA=P[0]&255|(P[1]&255)<<8|(P[2]&255)<<16|(P[3]&255)<<24,oA=P[4]&255|(P[5]&255)<<8|(P[6]&255)<<16|(P[7]&255)<<24,uA=P[8]&255|(P[9]&255)<<8|(P[10]&255)<<16|(P[11]&255)<<24,DA=P[12]&255|(P[13]&255)<<8|(P[14]&255)<<16|(P[15]&255)<<24,bA=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,xA=Y[0]&255|(Y[1]&255)<<8|(Y[2]&255)<<16|(Y[3]&255)<<24,Ie=Y[4]&255|(Y[5]&255)<<8|(Y[6]&255)<<16|(Y[7]&255)<<24,SA=Y[8]&255|(Y[9]&255)<<8|(Y[10]&255)<<16|(Y[11]&255)<<24,XA=Y[12]&255|(Y[13]&255)<<8|(Y[14]&255)<<16|(Y[15]&255)<<24,se=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ge=P[16]&255|(P[17]&255)<<8|(P[18]&255)<<16|(P[19]&255)<<24,ie=P[20]&255|(P[21]&255)<<8|(P[22]&255)<<16|(P[23]&255)<<24,te=P[24]&255|(P[25]&255)<<8|(P[26]&255)<<16|(P[27]&255)<<24,oe=P[28]&255|(P[29]&255)<<8|(P[30]&255)<<16|(P[31]&255)<<24,$A=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,RA=z,OA=sA,vA=oA,KA=uA,JA=DA,GA=bA,EA=xA,CA=Ie,fA=SA,hA=XA,pA=se,NA=ge,Ae=ie,Ee=te,ue=oe,Ce=$A,$,xe=0;xe<20;xe+=2)$=RA+Ae|0,JA^=$<<7|$>>>25,$=JA+RA|0,fA^=$<<9|$>>>23,$=fA+JA|0,Ae^=$<<13|$>>>19,$=Ae+fA|0,RA^=$<<18|$>>>14,$=GA+OA|0,hA^=$<<7|$>>>25,$=hA+GA|0,Ee^=$<<9|$>>>23,$=Ee+hA|0,OA^=$<<13|$>>>19,$=OA+Ee|0,GA^=$<<18|$>>>14,$=pA+EA|0,ue^=$<<7|$>>>25,$=ue+pA|0,vA^=$<<9|$>>>23,$=vA+ue|0,EA^=$<<13|$>>>19,$=EA+vA|0,pA^=$<<18|$>>>14,$=Ce+NA|0,KA^=$<<7|$>>>25,$=KA+Ce|0,CA^=$<<9|$>>>23,$=CA+KA|0,NA^=$<<13|$>>>19,$=NA+CA|0,Ce^=$<<18|$>>>14,$=RA+KA|0,OA^=$<<7|$>>>25,$=OA+RA|0,vA^=$<<9|$>>>23,$=vA+OA|0,KA^=$<<13|$>>>19,$=KA+vA|0,RA^=$<<18|$>>>14,$=GA+JA|0,EA^=$<<7|$>>>25,$=EA+GA|0,CA^=$<<9|$>>>23,$=CA+EA|0,JA^=$<<13|$>>>19,$=JA+CA|0,GA^=$<<18|$>>>14,$=pA+hA|0,NA^=$<<7|$>>>25,$=NA+pA|0,fA^=$<<9|$>>>23,$=fA+NA|0,hA^=$<<13|$>>>19,$=hA+fA|0,pA^=$<<18|$>>>14,$=Ce+ue|0,Ae^=$<<7|$>>>25,$=Ae+Ce|0,Ee^=$<<9|$>>>23,$=Ee+Ae|0,ue^=$<<13|$>>>19,$=ue+Ee|0,Ce^=$<<18|$>>>14;RA=RA+z|0,OA=OA+sA|0,vA=vA+oA|0,KA=KA+uA|0,JA=JA+DA|0,GA=GA+bA|0,EA=EA+xA|0,CA=CA+Ie|0,fA=fA+SA|0,hA=hA+XA|0,pA=pA+se|0,NA=NA+ge|0,Ae=Ae+ie|0,Ee=Ee+te|0,ue=ue+oe|0,Ce=Ce+$A|0,F[0]=RA>>>0&255,F[1]=RA>>>8&255,F[2]=RA>>>16&255,F[3]=RA>>>24&255,F[4]=OA>>>0&255,F[5]=OA>>>8&255,F[6]=OA>>>16&255,F[7]=OA>>>24&255,F[8]=vA>>>0&255,F[9]=vA>>>8&255,F[10]=vA>>>16&255,F[11]=vA>>>24&255,F[12]=KA>>>0&255,F[13]=KA>>>8&255,F[14]=KA>>>16&255,F[15]=KA>>>24&255,F[16]=JA>>>0&255,F[17]=JA>>>8&255,F[18]=JA>>>16&255,F[19]=JA>>>24&255,F[20]=GA>>>0&255,F[21]=GA>>>8&255,F[22]=GA>>>16&255,F[23]=GA>>>24&255,F[24]=EA>>>0&255,F[25]=EA>>>8&255,F[26]=EA>>>16&255,F[27]=EA>>>24&255,F[28]=CA>>>0&255,F[29]=CA>>>8&255,F[30]=CA>>>16&255,F[31]=CA>>>24&255,F[32]=fA>>>0&255,F[33]=fA>>>8&255,F[34]=fA>>>16&255,F[35]=fA>>>24&255,F[36]=hA>>>0&255,F[37]=hA>>>8&255,F[38]=hA>>>16&255,F[39]=hA>>>24&255,F[40]=pA>>>0&255,F[41]=pA>>>8&255,F[42]=pA>>>16&255,F[43]=pA>>>24&255,F[44]=NA>>>0&255,F[45]=NA>>>8&255,F[46]=NA>>>16&255,F[47]=NA>>>24&255,F[48]=Ae>>>0&255,F[49]=Ae>>>8&255,F[50]=Ae>>>16&255,F[51]=Ae>>>24&255,F[52]=Ee>>>0&255,F[53]=Ee>>>8&255,F[54]=Ee>>>16&255,F[55]=Ee>>>24&255,F[56]=ue>>>0&255,F[57]=ue>>>8&255,F[58]=ue>>>16&255,F[59]=ue>>>24&255,F[60]=Ce>>>0&255,F[61]=Ce>>>8&255,F[62]=Ce>>>16&255,F[63]=Ce>>>24&255}function D(F,Y,P,m){for(var z=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,sA=P[0]&255|(P[1]&255)<<8|(P[2]&255)<<16|(P[3]&255)<<24,oA=P[4]&255|(P[5]&255)<<8|(P[6]&255)<<16|(P[7]&255)<<24,uA=P[8]&255|(P[9]&255)<<8|(P[10]&255)<<16|(P[11]&255)<<24,DA=P[12]&255|(P[13]&255)<<8|(P[14]&255)<<16|(P[15]&255)<<24,bA=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,xA=Y[0]&255|(Y[1]&255)<<8|(Y[2]&255)<<16|(Y[3]&255)<<24,Ie=Y[4]&255|(Y[5]&255)<<8|(Y[6]&255)<<16|(Y[7]&255)<<24,SA=Y[8]&255|(Y[9]&255)<<8|(Y[10]&255)<<16|(Y[11]&255)<<24,XA=Y[12]&255|(Y[13]&255)<<8|(Y[14]&255)<<16|(Y[15]&255)<<24,se=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ge=P[16]&255|(P[17]&255)<<8|(P[18]&255)<<16|(P[19]&255)<<24,ie=P[20]&255|(P[21]&255)<<8|(P[22]&255)<<16|(P[23]&255)<<24,te=P[24]&255|(P[25]&255)<<8|(P[26]&255)<<16|(P[27]&255)<<24,oe=P[28]&255|(P[29]&255)<<8|(P[30]&255)<<16|(P[31]&255)<<24,$A=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,RA=z,OA=sA,vA=oA,KA=uA,JA=DA,GA=bA,EA=xA,CA=Ie,fA=SA,hA=XA,pA=se,NA=ge,Ae=ie,Ee=te,ue=oe,Ce=$A,$,xe=0;xe<20;xe+=2)$=RA+Ae|0,JA^=$<<7|$>>>25,$=JA+RA|0,fA^=$<<9|$>>>23,$=fA+JA|0,Ae^=$<<13|$>>>19,$=Ae+fA|0,RA^=$<<18|$>>>14,$=GA+OA|0,hA^=$<<7|$>>>25,$=hA+GA|0,Ee^=$<<9|$>>>23,$=Ee+hA|0,OA^=$<<13|$>>>19,$=OA+Ee|0,GA^=$<<18|$>>>14,$=pA+EA|0,ue^=$<<7|$>>>25,$=ue+pA|0,vA^=$<<9|$>>>23,$=vA+ue|0,EA^=$<<13|$>>>19,$=EA+vA|0,pA^=$<<18|$>>>14,$=Ce+NA|0,KA^=$<<7|$>>>25,$=KA+Ce|0,CA^=$<<9|$>>>23,$=CA+KA|0,NA^=$<<13|$>>>19,$=NA+CA|0,Ce^=$<<18|$>>>14,$=RA+KA|0,OA^=$<<7|$>>>25,$=OA+RA|0,vA^=$<<9|$>>>23,$=vA+OA|0,KA^=$<<13|$>>>19,$=KA+vA|0,RA^=$<<18|$>>>14,$=GA+JA|0,EA^=$<<7|$>>>25,$=EA+GA|0,CA^=$<<9|$>>>23,$=CA+EA|0,JA^=$<<13|$>>>19,$=JA+CA|0,GA^=$<<18|$>>>14,$=pA+hA|0,NA^=$<<7|$>>>25,$=NA+pA|0,fA^=$<<9|$>>>23,$=fA+NA|0,hA^=$<<13|$>>>19,$=hA+fA|0,pA^=$<<18|$>>>14,$=Ce+ue|0,Ae^=$<<7|$>>>25,$=Ae+Ce|0,Ee^=$<<9|$>>>23,$=Ee+Ae|0,ue^=$<<13|$>>>19,$=ue+Ee|0,Ce^=$<<18|$>>>14;F[0]=RA>>>0&255,F[1]=RA>>>8&255,F[2]=RA>>>16&255,F[3]=RA>>>24&255,F[4]=GA>>>0&255,F[5]=GA>>>8&255,F[6]=GA>>>16&255,F[7]=GA>>>24&255,F[8]=pA>>>0&255,F[9]=pA>>>8&255,F[10]=pA>>>16&255,F[11]=pA>>>24&255,F[12]=Ce>>>0&255,F[13]=Ce>>>8&255,F[14]=Ce>>>16&255,F[15]=Ce>>>24&255,F[16]=EA>>>0&255,F[17]=EA>>>8&255,F[18]=EA>>>16&255,F[19]=EA>>>24&255,F[20]=CA>>>0&255,F[21]=CA>>>8&255,F[22]=CA>>>16&255,F[23]=CA>>>24&255,F[24]=fA>>>0&255,F[25]=fA>>>8&255,F[26]=fA>>>16&255,F[27]=fA>>>24&255,F[28]=hA>>>0&255,F[29]=hA>>>8&255,F[30]=hA>>>16&255,F[31]=hA>>>24&255}function O(F,Y,P,m){v(F,Y,P,m)}function J(F,Y,P,m){D(F,Y,P,m)}var V=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function eA(F,Y,P,m,z,sA,oA){var uA=new Uint8Array(16),DA=new Uint8Array(64),bA,xA;for(xA=0;xA<16;xA++)uA[xA]=0;for(xA=0;xA<8;xA++)uA[xA]=sA[xA];for(;z>=64;){for(O(DA,uA,oA,V),xA=0;xA<64;xA++)F[Y+xA]=P[m+xA]^DA[xA];for(bA=1,xA=8;xA<16;xA++)bA=bA+(uA[xA]&255)|0,uA[xA]=bA&255,bA>>>=8;z-=64,Y+=64,m+=64}if(z>0)for(O(DA,uA,oA,V),xA=0;xA<z;xA++)F[Y+xA]=P[m+xA]^DA[xA];return 0}function X(F,Y,P,m,z){var sA=new Uint8Array(16),oA=new Uint8Array(64),uA,DA;for(DA=0;DA<16;DA++)sA[DA]=0;for(DA=0;DA<8;DA++)sA[DA]=m[DA];for(;P>=64;){for(O(oA,sA,z,V),DA=0;DA<64;DA++)F[Y+DA]=oA[DA];for(uA=1,DA=8;DA<16;DA++)uA=uA+(sA[DA]&255)|0,sA[DA]=uA&255,uA>>>=8;P-=64,Y+=64}if(P>0)for(O(oA,sA,z,V),DA=0;DA<P;DA++)F[Y+DA]=oA[DA];return 0}function K(F,Y,P,m,z){var sA=new Uint8Array(32);J(sA,m,z,V);for(var oA=new Uint8Array(8),uA=0;uA<8;uA++)oA[uA]=m[uA+16];return X(F,Y,P,oA,sA)}function W(F,Y,P,m,z,sA,oA){var uA=new Uint8Array(32);J(uA,sA,oA,V);for(var DA=new Uint8Array(8),bA=0;bA<8;bA++)DA[bA]=sA[bA+16];return eA(F,Y,P,m,z,DA,uA)}var T=function(F){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var Y,P,m,z,sA,oA,uA,DA;Y=F[0]&255|(F[1]&255)<<8,this.r[0]=Y&8191,P=F[2]&255|(F[3]&255)<<8,this.r[1]=(Y>>>13|P<<3)&8191,m=F[4]&255|(F[5]&255)<<8,this.r[2]=(P>>>10|m<<6)&7939,z=F[6]&255|(F[7]&255)<<8,this.r[3]=(m>>>7|z<<9)&8191,sA=F[8]&255|(F[9]&255)<<8,this.r[4]=(z>>>4|sA<<12)&255,this.r[5]=sA>>>1&8190,oA=F[10]&255|(F[11]&255)<<8,this.r[6]=(sA>>>14|oA<<2)&8191,uA=F[12]&255|(F[13]&255)<<8,this.r[7]=(oA>>>11|uA<<5)&8065,DA=F[14]&255|(F[15]&255)<<8,this.r[8]=(uA>>>8|DA<<8)&8191,this.r[9]=DA>>>5&127,this.pad[0]=F[16]&255|(F[17]&255)<<8,this.pad[1]=F[18]&255|(F[19]&255)<<8,this.pad[2]=F[20]&255|(F[21]&255)<<8,this.pad[3]=F[22]&255|(F[23]&255)<<8,this.pad[4]=F[24]&255|(F[25]&255)<<8,this.pad[5]=F[26]&255|(F[27]&255)<<8,this.pad[6]=F[28]&255|(F[29]&255)<<8,this.pad[7]=F[30]&255|(F[31]&255)<<8};T.prototype.blocks=function(F,Y,P){for(var m=this.fin?0:2048,z,sA,oA,uA,DA,bA,xA,Ie,SA,XA,se,ge,ie,te,oe,$A,RA,OA,vA,KA=this.h[0],JA=this.h[1],GA=this.h[2],EA=this.h[3],CA=this.h[4],fA=this.h[5],hA=this.h[6],pA=this.h[7],NA=this.h[8],Ae=this.h[9],Ee=this.r[0],ue=this.r[1],Ce=this.r[2],$=this.r[3],xe=this.r[4],Re=this.r[5],Me=this.r[6],me=this.r[7],be=this.r[8],Ke=this.r[9];P>=16;)z=F[Y+0]&255|(F[Y+1]&255)<<8,KA+=z&8191,sA=F[Y+2]&255|(F[Y+3]&255)<<8,JA+=(z>>>13|sA<<3)&8191,oA=F[Y+4]&255|(F[Y+5]&255)<<8,GA+=(sA>>>10|oA<<6)&8191,uA=F[Y+6]&255|(F[Y+7]&255)<<8,EA+=(oA>>>7|uA<<9)&8191,DA=F[Y+8]&255|(F[Y+9]&255)<<8,CA+=(uA>>>4|DA<<12)&8191,fA+=DA>>>1&8191,bA=F[Y+10]&255|(F[Y+11]&255)<<8,hA+=(DA>>>14|bA<<2)&8191,xA=F[Y+12]&255|(F[Y+13]&255)<<8,pA+=(bA>>>11|xA<<5)&8191,Ie=F[Y+14]&255|(F[Y+15]&255)<<8,NA+=(xA>>>8|Ie<<8)&8191,Ae+=Ie>>>5|m,SA=0,XA=SA,XA+=KA*Ee,XA+=JA*(5*Ke),XA+=GA*(5*be),XA+=EA*(5*me),XA+=CA*(5*Me),SA=XA>>>13,XA&=8191,XA+=fA*(5*Re),XA+=hA*(5*xe),XA+=pA*(5*$),XA+=NA*(5*Ce),XA+=Ae*(5*ue),SA+=XA>>>13,XA&=8191,se=SA,se+=KA*ue,se+=JA*Ee,se+=GA*(5*Ke),se+=EA*(5*be),se+=CA*(5*me),SA=se>>>13,se&=8191,se+=fA*(5*Me),se+=hA*(5*Re),se+=pA*(5*xe),se+=NA*(5*$),se+=Ae*(5*Ce),SA+=se>>>13,se&=8191,ge=SA,ge+=KA*Ce,ge+=JA*ue,ge+=GA*Ee,ge+=EA*(5*Ke),ge+=CA*(5*be),SA=ge>>>13,ge&=8191,ge+=fA*(5*me),ge+=hA*(5*Me),ge+=pA*(5*Re),ge+=NA*(5*xe),ge+=Ae*(5*$),SA+=ge>>>13,ge&=8191,ie=SA,ie+=KA*$,ie+=JA*Ce,ie+=GA*ue,ie+=EA*Ee,ie+=CA*(5*Ke),SA=ie>>>13,ie&=8191,ie+=fA*(5*be),ie+=hA*(5*me),ie+=pA*(5*Me),ie+=NA*(5*Re),ie+=Ae*(5*xe),SA+=ie>>>13,ie&=8191,te=SA,te+=KA*xe,te+=JA*$,te+=GA*Ce,te+=EA*ue,te+=CA*Ee,SA=te>>>13,te&=8191,te+=fA*(5*Ke),te+=hA*(5*be),te+=pA*(5*me),te+=NA*(5*Me),te+=Ae*(5*Re),SA+=te>>>13,te&=8191,oe=SA,oe+=KA*Re,oe+=JA*xe,oe+=GA*$,oe+=EA*Ce,oe+=CA*ue,SA=oe>>>13,oe&=8191,oe+=fA*Ee,oe+=hA*(5*Ke),oe+=pA*(5*be),oe+=NA*(5*me),oe+=Ae*(5*Me),SA+=oe>>>13,oe&=8191,$A=SA,$A+=KA*Me,$A+=JA*Re,$A+=GA*xe,$A+=EA*$,$A+=CA*Ce,SA=$A>>>13,$A&=8191,$A+=fA*ue,$A+=hA*Ee,$A+=pA*(5*Ke),$A+=NA*(5*be),$A+=Ae*(5*me),SA+=$A>>>13,$A&=8191,RA=SA,RA+=KA*me,RA+=JA*Me,RA+=GA*Re,RA+=EA*xe,RA+=CA*$,SA=RA>>>13,RA&=8191,RA+=fA*Ce,RA+=hA*ue,RA+=pA*Ee,RA+=NA*(5*Ke),RA+=Ae*(5*be),SA+=RA>>>13,RA&=8191,OA=SA,OA+=KA*be,OA+=JA*me,OA+=GA*Me,OA+=EA*Re,OA+=CA*xe,SA=OA>>>13,OA&=8191,OA+=fA*$,OA+=hA*Ce,OA+=pA*ue,OA+=NA*Ee,OA+=Ae*(5*Ke),SA+=OA>>>13,OA&=8191,vA=SA,vA+=KA*Ke,vA+=JA*be,vA+=GA*me,vA+=EA*Me,vA+=CA*Re,SA=vA>>>13,vA&=8191,vA+=fA*xe,vA+=hA*$,vA+=pA*Ce,vA+=NA*ue,vA+=Ae*Ee,SA+=vA>>>13,vA&=8191,SA=(SA<<2)+SA|0,SA=SA+XA|0,XA=SA&8191,SA=SA>>>13,se+=SA,KA=XA,JA=se,GA=ge,EA=ie,CA=te,fA=oe,hA=$A,pA=RA,NA=OA,Ae=vA,Y+=16,P-=16;this.h[0]=KA,this.h[1]=JA,this.h[2]=GA,this.h[3]=EA,this.h[4]=CA,this.h[5]=fA,this.h[6]=hA,this.h[7]=pA,this.h[8]=NA,this.h[9]=Ae},T.prototype.finish=function(F,Y){var P=new Uint16Array(10),m,z,sA,oA;if(this.leftover){for(oA=this.leftover,this.buffer[oA++]=1;oA<16;oA++)this.buffer[oA]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(m=this.h[1]>>>13,this.h[1]&=8191,oA=2;oA<10;oA++)this.h[oA]+=m,m=this.h[oA]>>>13,this.h[oA]&=8191;for(this.h[0]+=m*5,m=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=m,m=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=m,P[0]=this.h[0]+5,m=P[0]>>>13,P[0]&=8191,oA=1;oA<10;oA++)P[oA]=this.h[oA]+m,m=P[oA]>>>13,P[oA]&=8191;for(P[9]-=8192,z=(m^1)-1,oA=0;oA<10;oA++)P[oA]&=z;for(z=~z,oA=0;oA<10;oA++)this.h[oA]=this.h[oA]&z|P[oA];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,sA=this.h[0]+this.pad[0],this.h[0]=sA&65535,oA=1;oA<8;oA++)sA=(this.h[oA]+this.pad[oA]|0)+(sA>>>16)|0,this.h[oA]=sA&65535;F[Y+0]=this.h[0]>>>0&255,F[Y+1]=this.h[0]>>>8&255,F[Y+2]=this.h[1]>>>0&255,F[Y+3]=this.h[1]>>>8&255,F[Y+4]=this.h[2]>>>0&255,F[Y+5]=this.h[2]>>>8&255,F[Y+6]=this.h[3]>>>0&255,F[Y+7]=this.h[3]>>>8&255,F[Y+8]=this.h[4]>>>0&255,F[Y+9]=this.h[4]>>>8&255,F[Y+10]=this.h[5]>>>0&255,F[Y+11]=this.h[5]>>>8&255,F[Y+12]=this.h[6]>>>0&255,F[Y+13]=this.h[6]>>>8&255,F[Y+14]=this.h[7]>>>0&255,F[Y+15]=this.h[7]>>>8&255},T.prototype.update=function(F,Y,P){var m,z;if(this.leftover){for(z=16-this.leftover,z>P&&(z=P),m=0;m<z;m++)this.buffer[this.leftover+m]=F[Y+m];if(P-=z,Y+=z,this.leftover+=z,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(P>=16&&(z=P-P%16,this.blocks(F,Y,z),Y+=z,P-=z),P){for(m=0;m<P;m++)this.buffer[this.leftover+m]=F[Y+m];this.leftover+=P}};function L(F,Y,P,m,z,sA){var oA=new T(sA);return oA.update(P,m,z),oA.finish(F,Y),0}function w(F,Y,P,m,z,sA){var oA=new Uint8Array(16);return L(oA,0,P,m,z,sA),h(F,Y,oA,0)}function B(F,Y,P,m,z){var sA;if(P<32)return-1;for(W(F,0,Y,0,P,m,z),L(F,16,F,32,P-32,F),sA=0;sA<16;sA++)F[sA]=0;return 0}function d(F,Y,P,m,z){var sA,oA=new Uint8Array(32);if(P<32||(K(oA,0,32,m,z),w(Y,16,Y,32,P-32,oA)!==0))return-1;for(W(F,0,Y,0,P,m,z),sA=0;sA<32;sA++)F[sA]=0;return 0}function N(F,Y){var P;for(P=0;P<16;P++)F[P]=Y[P]|0}function G(F){var Y,P,m=1;for(Y=0;Y<16;Y++)P=F[Y]+m+65535,m=Math.floor(P/65536),F[Y]=P-m*65536;F[0]+=m-1+37*(m-1)}function S(F,Y,P){for(var m,z=~(P-1),sA=0;sA<16;sA++)m=z&(F[sA]^Y[sA]),F[sA]^=m,Y[sA]^=m}function j(F,Y){var P,m,z,sA=t(),oA=t();for(P=0;P<16;P++)oA[P]=Y[P];for(G(oA),G(oA),G(oA),m=0;m<2;m++){for(sA[0]=oA[0]-65517,P=1;P<15;P++)sA[P]=oA[P]-65535-(sA[P-1]>>16&1),sA[P-1]&=65535;sA[15]=oA[15]-32767-(sA[14]>>16&1),z=sA[15]>>16&1,sA[14]&=65535,S(oA,sA,1-z)}for(P=0;P<16;P++)F[2*P]=oA[P]&255,F[2*P+1]=oA[P]>>8}function H(F,Y){var P=new Uint8Array(32),m=new Uint8Array(32);return j(P,F),j(m,Y),k(P,0,m,0)}function b(F){var Y=new Uint8Array(32);return j(Y,F),Y[0]&1}function E(F,Y){var P;for(P=0;P<16;P++)F[P]=Y[2*P]+(Y[2*P+1]<<8);F[15]&=32767}function p(F,Y,P){for(var m=0;m<16;m++)F[m]=Y[m]+P[m]}function U(F,Y,P){for(var m=0;m<16;m++)F[m]=Y[m]-P[m]}function R(F,Y,P){var m,z,sA=0,oA=0,uA=0,DA=0,bA=0,xA=0,Ie=0,SA=0,XA=0,se=0,ge=0,ie=0,te=0,oe=0,$A=0,RA=0,OA=0,vA=0,KA=0,JA=0,GA=0,EA=0,CA=0,fA=0,hA=0,pA=0,NA=0,Ae=0,Ee=0,ue=0,Ce=0,$=P[0],xe=P[1],Re=P[2],Me=P[3],me=P[4],be=P[5],Ke=P[6],gt=P[7],We=P[8],et=P[9],it=P[10],st=P[11],Et=P[12],pt=P[13],yt=P[14],aA=P[15];m=Y[0],sA+=m*$,oA+=m*xe,uA+=m*Re,DA+=m*Me,bA+=m*me,xA+=m*be,Ie+=m*Ke,SA+=m*gt,XA+=m*We,se+=m*et,ge+=m*it,ie+=m*st,te+=m*Et,oe+=m*pt,$A+=m*yt,RA+=m*aA,m=Y[1],oA+=m*$,uA+=m*xe,DA+=m*Re,bA+=m*Me,xA+=m*me,Ie+=m*be,SA+=m*Ke,XA+=m*gt,se+=m*We,ge+=m*et,ie+=m*it,te+=m*st,oe+=m*Et,$A+=m*pt,RA+=m*yt,OA+=m*aA,m=Y[2],uA+=m*$,DA+=m*xe,bA+=m*Re,xA+=m*Me,Ie+=m*me,SA+=m*be,XA+=m*Ke,se+=m*gt,ge+=m*We,ie+=m*et,te+=m*it,oe+=m*st,$A+=m*Et,RA+=m*pt,OA+=m*yt,vA+=m*aA,m=Y[3],DA+=m*$,bA+=m*xe,xA+=m*Re,Ie+=m*Me,SA+=m*me,XA+=m*be,se+=m*Ke,ge+=m*gt,ie+=m*We,te+=m*et,oe+=m*it,$A+=m*st,RA+=m*Et,OA+=m*pt,vA+=m*yt,KA+=m*aA,m=Y[4],bA+=m*$,xA+=m*xe,Ie+=m*Re,SA+=m*Me,XA+=m*me,se+=m*be,ge+=m*Ke,ie+=m*gt,te+=m*We,oe+=m*et,$A+=m*it,RA+=m*st,OA+=m*Et,vA+=m*pt,KA+=m*yt,JA+=m*aA,m=Y[5],xA+=m*$,Ie+=m*xe,SA+=m*Re,XA+=m*Me,se+=m*me,ge+=m*be,ie+=m*Ke,te+=m*gt,oe+=m*We,$A+=m*et,RA+=m*it,OA+=m*st,vA+=m*Et,KA+=m*pt,JA+=m*yt,GA+=m*aA,m=Y[6],Ie+=m*$,SA+=m*xe,XA+=m*Re,se+=m*Me,ge+=m*me,ie+=m*be,te+=m*Ke,oe+=m*gt,$A+=m*We,RA+=m*et,OA+=m*it,vA+=m*st,KA+=m*Et,JA+=m*pt,GA+=m*yt,EA+=m*aA,m=Y[7],SA+=m*$,XA+=m*xe,se+=m*Re,ge+=m*Me,ie+=m*me,te+=m*be,oe+=m*Ke,$A+=m*gt,RA+=m*We,OA+=m*et,vA+=m*it,KA+=m*st,JA+=m*Et,GA+=m*pt,EA+=m*yt,CA+=m*aA,m=Y[8],XA+=m*$,se+=m*xe,ge+=m*Re,ie+=m*Me,te+=m*me,oe+=m*be,$A+=m*Ke,RA+=m*gt,OA+=m*We,vA+=m*et,KA+=m*it,JA+=m*st,GA+=m*Et,EA+=m*pt,CA+=m*yt,fA+=m*aA,m=Y[9],se+=m*$,ge+=m*xe,ie+=m*Re,te+=m*Me,oe+=m*me,$A+=m*be,RA+=m*Ke,OA+=m*gt,vA+=m*We,KA+=m*et,JA+=m*it,GA+=m*st,EA+=m*Et,CA+=m*pt,fA+=m*yt,hA+=m*aA,m=Y[10],ge+=m*$,ie+=m*xe,te+=m*Re,oe+=m*Me,$A+=m*me,RA+=m*be,OA+=m*Ke,vA+=m*gt,KA+=m*We,JA+=m*et,GA+=m*it,EA+=m*st,CA+=m*Et,fA+=m*pt,hA+=m*yt,pA+=m*aA,m=Y[11],ie+=m*$,te+=m*xe,oe+=m*Re,$A+=m*Me,RA+=m*me,OA+=m*be,vA+=m*Ke,KA+=m*gt,JA+=m*We,GA+=m*et,EA+=m*it,CA+=m*st,fA+=m*Et,hA+=m*pt,pA+=m*yt,NA+=m*aA,m=Y[12],te+=m*$,oe+=m*xe,$A+=m*Re,RA+=m*Me,OA+=m*me,vA+=m*be,KA+=m*Ke,JA+=m*gt,GA+=m*We,EA+=m*et,CA+=m*it,fA+=m*st,hA+=m*Et,pA+=m*pt,NA+=m*yt,Ae+=m*aA,m=Y[13],oe+=m*$,$A+=m*xe,RA+=m*Re,OA+=m*Me,vA+=m*me,KA+=m*be,JA+=m*Ke,GA+=m*gt,EA+=m*We,CA+=m*et,fA+=m*it,hA+=m*st,pA+=m*Et,NA+=m*pt,Ae+=m*yt,Ee+=m*aA,m=Y[14],$A+=m*$,RA+=m*xe,OA+=m*Re,vA+=m*Me,KA+=m*me,JA+=m*be,GA+=m*Ke,EA+=m*gt,CA+=m*We,fA+=m*et,hA+=m*it,pA+=m*st,NA+=m*Et,Ae+=m*pt,Ee+=m*yt,ue+=m*aA,m=Y[15],RA+=m*$,OA+=m*xe,vA+=m*Re,KA+=m*Me,JA+=m*me,GA+=m*be,EA+=m*Ke,CA+=m*gt,fA+=m*We,hA+=m*et,pA+=m*it,NA+=m*st,Ae+=m*Et,Ee+=m*pt,ue+=m*yt,Ce+=m*aA,sA+=38*OA,oA+=38*vA,uA+=38*KA,DA+=38*JA,bA+=38*GA,xA+=38*EA,Ie+=38*CA,SA+=38*fA,XA+=38*hA,se+=38*pA,ge+=38*NA,ie+=38*Ae,te+=38*Ee,oe+=38*ue,$A+=38*Ce,z=1,m=sA+z+65535,z=Math.floor(m/65536),sA=m-z*65536,m=oA+z+65535,z=Math.floor(m/65536),oA=m-z*65536,m=uA+z+65535,z=Math.floor(m/65536),uA=m-z*65536,m=DA+z+65535,z=Math.floor(m/65536),DA=m-z*65536,m=bA+z+65535,z=Math.floor(m/65536),bA=m-z*65536,m=xA+z+65535,z=Math.floor(m/65536),xA=m-z*65536,m=Ie+z+65535,z=Math.floor(m/65536),Ie=m-z*65536,m=SA+z+65535,z=Math.floor(m/65536),SA=m-z*65536,m=XA+z+65535,z=Math.floor(m/65536),XA=m-z*65536,m=se+z+65535,z=Math.floor(m/65536),se=m-z*65536,m=ge+z+65535,z=Math.floor(m/65536),ge=m-z*65536,m=ie+z+65535,z=Math.floor(m/65536),ie=m-z*65536,m=te+z+65535,z=Math.floor(m/65536),te=m-z*65536,m=oe+z+65535,z=Math.floor(m/65536),oe=m-z*65536,m=$A+z+65535,z=Math.floor(m/65536),$A=m-z*65536,m=RA+z+65535,z=Math.floor(m/65536),RA=m-z*65536,sA+=z-1+37*(z-1),z=1,m=sA+z+65535,z=Math.floor(m/65536),sA=m-z*65536,m=oA+z+65535,z=Math.floor(m/65536),oA=m-z*65536,m=uA+z+65535,z=Math.floor(m/65536),uA=m-z*65536,m=DA+z+65535,z=Math.floor(m/65536),DA=m-z*65536,m=bA+z+65535,z=Math.floor(m/65536),bA=m-z*65536,m=xA+z+65535,z=Math.floor(m/65536),xA=m-z*65536,m=Ie+z+65535,z=Math.floor(m/65536),Ie=m-z*65536,m=SA+z+65535,z=Math.floor(m/65536),SA=m-z*65536,m=XA+z+65535,z=Math.floor(m/65536),XA=m-z*65536,m=se+z+65535,z=Math.floor(m/65536),se=m-z*65536,m=ge+z+65535,z=Math.floor(m/65536),ge=m-z*65536,m=ie+z+65535,z=Math.floor(m/65536),ie=m-z*65536,m=te+z+65535,z=Math.floor(m/65536),te=m-z*65536,m=oe+z+65535,z=Math.floor(m/65536),oe=m-z*65536,m=$A+z+65535,z=Math.floor(m/65536),$A=m-z*65536,m=RA+z+65535,z=Math.floor(m/65536),RA=m-z*65536,sA+=z-1+37*(z-1),F[0]=sA,F[1]=oA,F[2]=uA,F[3]=DA,F[4]=bA,F[5]=xA,F[6]=Ie,F[7]=SA,F[8]=XA,F[9]=se,F[10]=ge,F[11]=ie,F[12]=te,F[13]=oe,F[14]=$A,F[15]=RA}function _(F,Y){R(F,Y,Y)}function tA(F,Y){var P=t(),m;for(m=0;m<16;m++)P[m]=Y[m];for(m=253;m>=0;m--)_(P,P),m!==2&&m!==4&&R(P,P,Y);for(m=0;m<16;m++)F[m]=P[m]}function IA(F,Y){var P=t(),m;for(m=0;m<16;m++)P[m]=Y[m];for(m=250;m>=0;m--)_(P,P),m!==1&&R(P,P,Y);for(m=0;m<16;m++)F[m]=P[m]}function iA(F,Y,P){var m=new Uint8Array(32),z=new Float64Array(80),sA,oA,uA=t(),DA=t(),bA=t(),xA=t(),Ie=t(),SA=t();for(oA=0;oA<31;oA++)m[oA]=Y[oA];for(m[31]=Y[31]&127|64,m[0]&=248,E(z,P),oA=0;oA<16;oA++)DA[oA]=z[oA],xA[oA]=uA[oA]=bA[oA]=0;for(uA[0]=xA[0]=1,oA=254;oA>=0;--oA)sA=m[oA>>>3]>>>(oA&7)&1,S(uA,DA,sA),S(bA,xA,sA),p(Ie,uA,bA),U(uA,uA,bA),p(bA,DA,xA),U(DA,DA,xA),_(xA,Ie),_(SA,uA),R(uA,bA,uA),R(bA,DA,Ie),p(Ie,uA,bA),U(uA,uA,bA),_(DA,uA),U(bA,xA,SA),R(uA,bA,g),p(uA,uA,xA),R(bA,bA,uA),R(uA,xA,SA),R(xA,DA,z),_(DA,Ie),S(uA,DA,sA),S(bA,xA,sA);for(oA=0;oA<16;oA++)z[oA+16]=uA[oA],z[oA+32]=bA[oA],z[oA+48]=DA[oA],z[oA+64]=xA[oA];var XA=z.subarray(32),se=z.subarray(16);return tA(XA,XA),R(se,se,XA),j(F,se),0}function UA(F,Y){return iA(F,Y,r)}function HA(F,Y){return s(Y,32),UA(F,Y)}function lA(F,Y,P){var m=new Uint8Array(32);return iA(m,P,Y),J(F,n,m,V)}var qA=B,re=d;function he(F,Y,P,m,z,sA){var oA=new Uint8Array(32);return lA(oA,z,sA),qA(F,Y,P,m,oA)}function kA(F,Y,P,m,z,sA){var oA=new Uint8Array(32);return lA(oA,z,sA),re(F,Y,P,m,oA)}var VA=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ae(F,Y,P,m){for(var z=new Int32Array(16),sA=new Int32Array(16),oA,uA,DA,bA,xA,Ie,SA,XA,se,ge,ie,te,oe,$A,RA,OA,vA,KA,JA,GA,EA,CA,fA,hA,pA,NA,Ae=F[0],Ee=F[1],ue=F[2],Ce=F[3],$=F[4],xe=F[5],Re=F[6],Me=F[7],me=Y[0],be=Y[1],Ke=Y[2],gt=Y[3],We=Y[4],et=Y[5],it=Y[6],st=Y[7],Et=0;m>=128;){for(JA=0;JA<16;JA++)GA=8*JA+Et,z[JA]=P[GA+0]<<24|P[GA+1]<<16|P[GA+2]<<8|P[GA+3],sA[JA]=P[GA+4]<<24|P[GA+5]<<16|P[GA+6]<<8|P[GA+7];for(JA=0;JA<80;JA++)if(oA=Ae,uA=Ee,DA=ue,bA=Ce,xA=$,Ie=xe,SA=Re,XA=Me,se=me,ge=be,ie=Ke,te=gt,oe=We,$A=et,RA=it,OA=st,EA=Me,CA=st,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=($>>>14|We<<18)^($>>>18|We<<14)^(We>>>9|$<<23),CA=(We>>>14|$<<18)^(We>>>18|$<<14)^($>>>9|We<<23),fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,EA=$&xe^~$&Re,CA=We&et^~We&it,fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,EA=VA[JA*2],CA=VA[JA*2+1],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,EA=z[JA%16],CA=sA[JA%16],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,vA=pA&65535|NA<<16,KA=fA&65535|hA<<16,EA=vA,CA=KA,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=(Ae>>>28|me<<4)^(me>>>2|Ae<<30)^(me>>>7|Ae<<25),CA=(me>>>28|Ae<<4)^(Ae>>>2|me<<30)^(Ae>>>7|me<<25),fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,EA=Ae&Ee^Ae&ue^Ee&ue,CA=me&be^me&Ke^be&Ke,fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,XA=pA&65535|NA<<16,OA=fA&65535|hA<<16,EA=bA,CA=te,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=vA,CA=KA,fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,bA=pA&65535|NA<<16,te=fA&65535|hA<<16,Ee=oA,ue=uA,Ce=DA,$=bA,xe=xA,Re=Ie,Me=SA,Ae=XA,be=se,Ke=ge,gt=ie,We=te,et=oe,it=$A,st=RA,me=OA,JA%16===15)for(GA=0;GA<16;GA++)EA=z[GA],CA=sA[GA],fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=z[(GA+9)%16],CA=sA[(GA+9)%16],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,vA=z[(GA+1)%16],KA=sA[(GA+1)%16],EA=(vA>>>1|KA<<31)^(vA>>>8|KA<<24)^vA>>>7,CA=(KA>>>1|vA<<31)^(KA>>>8|vA<<24)^(KA>>>7|vA<<25),fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,vA=z[(GA+14)%16],KA=sA[(GA+14)%16],EA=(vA>>>19|KA<<13)^(KA>>>29|vA<<3)^vA>>>6,CA=(KA>>>19|vA<<13)^(vA>>>29|KA<<3)^(KA>>>6|vA<<26),fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,z[GA]=pA&65535|NA<<16,sA[GA]=fA&65535|hA<<16;EA=Ae,CA=me,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[0],CA=Y[0],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[0]=Ae=pA&65535|NA<<16,Y[0]=me=fA&65535|hA<<16,EA=Ee,CA=be,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[1],CA=Y[1],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[1]=Ee=pA&65535|NA<<16,Y[1]=be=fA&65535|hA<<16,EA=ue,CA=Ke,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[2],CA=Y[2],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[2]=ue=pA&65535|NA<<16,Y[2]=Ke=fA&65535|hA<<16,EA=Ce,CA=gt,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[3],CA=Y[3],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[3]=Ce=pA&65535|NA<<16,Y[3]=gt=fA&65535|hA<<16,EA=$,CA=We,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[4],CA=Y[4],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[4]=$=pA&65535|NA<<16,Y[4]=We=fA&65535|hA<<16,EA=xe,CA=et,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[5],CA=Y[5],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[5]=xe=pA&65535|NA<<16,Y[5]=et=fA&65535|hA<<16,EA=Re,CA=it,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[6],CA=Y[6],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[6]=Re=pA&65535|NA<<16,Y[6]=it=fA&65535|hA<<16,EA=Me,CA=st,fA=CA&65535,hA=CA>>>16,pA=EA&65535,NA=EA>>>16,EA=F[7],CA=Y[7],fA+=CA&65535,hA+=CA>>>16,pA+=EA&65535,NA+=EA>>>16,hA+=fA>>>16,pA+=hA>>>16,NA+=pA>>>16,F[7]=Me=pA&65535|NA<<16,Y[7]=st=fA&65535|hA<<16,Et+=128,m-=128}return m}function He(F,Y,P){var m=new Int32Array(8),z=new Int32Array(8),sA=new Uint8Array(256),oA,uA=P;for(m[0]=1779033703,m[1]=3144134277,m[2]=1013904242,m[3]=2773480762,m[4]=1359893119,m[5]=2600822924,m[6]=528734635,m[7]=1541459225,z[0]=4089235720,z[1]=2227873595,z[2]=4271175723,z[3]=1595750129,z[4]=2917565137,z[5]=725511199,z[6]=4215389547,z[7]=327033209,ae(m,z,Y,P),P%=128,oA=0;oA<P;oA++)sA[oA]=Y[uA-P+oA];for(sA[P]=128,P=256-128*(P<112?1:0),sA[P-9]=0,u(sA,P-8,uA/536870912|0,uA<<3),ae(m,z,sA,P),oA=0;oA<8;oA++)u(F,8*oA,m[oA],z[oA]);return 0}function le(F,Y){var P=t(),m=t(),z=t(),sA=t(),oA=t(),uA=t(),DA=t(),bA=t(),xA=t();U(P,F[1],F[0]),U(xA,Y[1],Y[0]),R(P,P,xA),p(m,F[0],F[1]),p(xA,Y[0],Y[1]),R(m,m,xA),R(z,F[3],Y[3]),R(z,z,l),R(sA,F[2],Y[2]),p(sA,sA,sA),U(oA,m,P),U(uA,sA,z),p(DA,sA,z),p(bA,m,P),R(F[0],oA,uA),R(F[1],bA,DA),R(F[2],DA,uA),R(F[3],oA,bA)}function Ge(F,Y,P){var m;for(m=0;m<4;m++)S(F[m],Y[m],P)}function nt(F,Y){var P=t(),m=t(),z=t();tA(z,Y[2]),R(P,Y[0],z),R(m,Y[1],z),j(F,m),F[31]^=b(P)<<7}function ve(F,Y,P){var m,z;for(N(F[0],i),N(F[1],a),N(F[2],a),N(F[3],i),z=255;z>=0;--z)m=P[z/8|0]>>(z&7)&1,Ge(F,Y,m),le(Y,F),le(F,F),Ge(F,Y,m)}function yA(F,Y){var P=[t(),t(),t(),t()];N(P[0],C),N(P[1],I),N(P[2],a),R(P[3],C,I),ve(F,P,Y)}function pe(F,Y,P){var m=new Uint8Array(64),z=[t(),t(),t(),t()],sA;for(P||s(Y,32),He(m,Y,32),m[0]&=248,m[31]&=127,m[31]|=64,yA(z,m),nt(F,z),sA=0;sA<32;sA++)Y[sA+32]=F[sA];return 0}var YA=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function q(F,Y){var P,m,z,sA;for(m=63;m>=32;--m){for(P=0,z=m-32,sA=m-12;z<sA;++z)Y[z]+=P-16*Y[m]*YA[z-(m-32)],P=Math.floor((Y[z]+128)/256),Y[z]-=P*256;Y[z]+=P,Y[m]=0}for(P=0,z=0;z<32;z++)Y[z]+=P-(Y[31]>>4)*YA[z],P=Y[z]>>8,Y[z]&=255;for(z=0;z<32;z++)Y[z]-=P*YA[z];for(m=0;m<32;m++)Y[m+1]+=Y[m]>>8,F[m]=Y[m]&255}function y(F){var Y=new Float64Array(64),P;for(P=0;P<64;P++)Y[P]=F[P];for(P=0;P<64;P++)F[P]=0;q(F,Y)}function M(F,Y,P,m){var z=new Uint8Array(64),sA=new Uint8Array(64),oA=new Uint8Array(64),uA,DA,bA=new Float64Array(64),xA=[t(),t(),t(),t()];He(z,m,32),z[0]&=248,z[31]&=127,z[31]|=64;var Ie=P+64;for(uA=0;uA<P;uA++)F[64+uA]=Y[uA];for(uA=0;uA<32;uA++)F[32+uA]=z[32+uA];for(He(oA,F.subarray(32),P+32),y(oA),yA(xA,oA),nt(F,xA),uA=32;uA<64;uA++)F[uA]=m[uA];for(He(sA,F,P+64),y(sA),uA=0;uA<64;uA++)bA[uA]=0;for(uA=0;uA<32;uA++)bA[uA]=oA[uA];for(uA=0;uA<32;uA++)for(DA=0;DA<32;DA++)bA[uA+DA]+=sA[uA]*z[DA];return q(F.subarray(32),bA),Ie}function Z(F,Y){var P=t(),m=t(),z=t(),sA=t(),oA=t(),uA=t(),DA=t();return N(F[2],a),E(F[1],Y),_(z,F[1]),R(sA,z,Q),U(z,z,F[2]),p(sA,F[2],sA),_(oA,sA),_(uA,oA),R(DA,uA,oA),R(P,DA,z),R(P,P,sA),IA(P,P),R(P,P,z),R(P,P,sA),R(P,P,sA),R(F[0],P,sA),_(m,F[0]),R(m,m,sA),H(m,z)&&R(F[0],F[0],c),_(m,F[0]),R(m,m,sA),H(m,z)?-1:(b(F[0])===Y[31]>>7&&U(F[0],i,F[0]),R(F[3],F[0],F[1]),0)}function AA(F,Y,P,m){var z,sA=new Uint8Array(32),oA=new Uint8Array(64),uA=[t(),t(),t(),t()],DA=[t(),t(),t(),t()];if(P<64||Z(DA,m))return-1;for(z=0;z<P;z++)F[z]=Y[z];for(z=0;z<32;z++)F[z+32]=m[z];if(He(oA,F,P),y(oA),ve(uA,DA,oA),yA(DA,Y.subarray(32)),le(uA,DA),nt(sA,uA),P-=64,k(Y,0,sA,0)){for(z=0;z<P;z++)F[z]=0;return-1}for(z=0;z<P;z++)F[z]=Y[z+64];return P}var nA=32,cA=24,zA=32,PA=16,ZA=32,Se=32,WA=32,De=32,Pt=32,Je=cA,Pe=zA,So=PA,ce=64,Ue=32,Wt=64,Oe=32,_e=64;e.lowlevel={crypto_core_hsalsa20:J,crypto_stream_xor:W,crypto_stream:K,crypto_stream_salsa20_xor:eA,crypto_stream_salsa20:X,crypto_onetimeauth:L,crypto_onetimeauth_verify:w,crypto_verify_16:h,crypto_verify_32:k,crypto_secretbox:B,crypto_secretbox_open:d,crypto_scalarmult:iA,crypto_scalarmult_base:UA,crypto_box_beforenm:lA,crypto_box_afternm:qA,crypto_box:he,crypto_box_open:kA,crypto_box_keypair:HA,crypto_hash:He,crypto_sign:M,crypto_sign_keypair:pe,crypto_sign_open:AA,crypto_secretbox_KEYBYTES:nA,crypto_secretbox_NONCEBYTES:cA,crypto_secretbox_ZEROBYTES:zA,crypto_secretbox_BOXZEROBYTES:PA,crypto_scalarmult_BYTES:ZA,crypto_scalarmult_SCALARBYTES:Se,crypto_box_PUBLICKEYBYTES:WA,crypto_box_SECRETKEYBYTES:De,crypto_box_BEFORENMBYTES:Pt,crypto_box_NONCEBYTES:Je,crypto_box_ZEROBYTES:Pe,crypto_box_BOXZEROBYTES:So,crypto_sign_BYTES:ce,crypto_sign_PUBLICKEYBYTES:Ue,crypto_sign_SECRETKEYBYTES:Wt,crypto_sign_SEEDBYTES:Oe,crypto_hash_BYTES:_e,gf:t,D:Q,L:YA,pack25519:j,unpack25519:E,M:R,A:p,S:_,Z:U,pow2523:IA,add:le,set25519:N,modL:q,scalarmult:ve,scalarbase:yA};function _A(F,Y){if(F.length!==nA)throw new Error("bad key size");if(Y.length!==cA)throw new Error("bad nonce size")}function ye(F,Y){if(F.length!==WA)throw new Error("bad public key size");if(Y.length!==De)throw new Error("bad secret key size")}function fe(){for(var F=0;F<arguments.length;F++)if(!(arguments[F]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Uo(F){for(var Y=0;Y<F.length;Y++)F[Y]=0}e.randomBytes=function(F){var Y=new Uint8Array(F);return s(Y,F),Y},e.secretbox=function(F,Y,P){fe(F,Y,P),_A(P,Y);for(var m=new Uint8Array(zA+F.length),z=new Uint8Array(m.length),sA=0;sA<F.length;sA++)m[sA+zA]=F[sA];return B(z,m,m.length,Y,P),z.subarray(PA)},e.secretbox.open=function(F,Y,P){fe(F,Y,P),_A(P,Y);for(var m=new Uint8Array(PA+F.length),z=new Uint8Array(m.length),sA=0;sA<F.length;sA++)m[sA+PA]=F[sA];return m.length<32||d(z,m,m.length,Y,P)!==0?null:z.subarray(zA)},e.secretbox.keyLength=nA,e.secretbox.nonceLength=cA,e.secretbox.overheadLength=PA,e.scalarMult=function(F,Y){if(fe(F,Y),F.length!==Se)throw new Error("bad n size");if(Y.length!==ZA)throw new Error("bad p size");var P=new Uint8Array(ZA);return iA(P,F,Y),P},e.scalarMult.base=function(F){if(fe(F),F.length!==Se)throw new Error("bad n size");var Y=new Uint8Array(ZA);return UA(Y,F),Y},e.scalarMult.scalarLength=Se,e.scalarMult.groupElementLength=ZA,e.box=function(F,Y,P,m){var z=e.box.before(P,m);return e.secretbox(F,Y,z)},e.box.before=function(F,Y){fe(F,Y),ye(F,Y);var P=new Uint8Array(Pt);return lA(P,F,Y),P},e.box.after=e.secretbox,e.box.open=function(F,Y,P,m){var z=e.box.before(P,m);return e.secretbox.open(F,Y,z)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var F=new Uint8Array(WA),Y=new Uint8Array(De);return HA(F,Y),{publicKey:F,secretKey:Y}},e.box.keyPair.fromSecretKey=function(F){if(fe(F),F.length!==De)throw new Error("bad secret key size");var Y=new Uint8Array(WA);return UA(Y,F),{publicKey:Y,secretKey:new Uint8Array(F)}},e.box.publicKeyLength=WA,e.box.secretKeyLength=De,e.box.sharedKeyLength=Pt,e.box.nonceLength=Je,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(F,Y){if(fe(F,Y),Y.length!==Wt)throw new Error("bad secret key size");var P=new Uint8Array(ce+F.length);return M(P,F,F.length,Y),P},e.sign.open=function(F,Y){if(fe(F,Y),Y.length!==Ue)throw new Error("bad public key size");var P=new Uint8Array(F.length),m=AA(P,F,F.length,Y);if(m<0)return null;for(var z=new Uint8Array(m),sA=0;sA<z.length;sA++)z[sA]=P[sA];return z},e.sign.detached=function(F,Y){for(var P=e.sign(F,Y),m=new Uint8Array(ce),z=0;z<m.length;z++)m[z]=P[z];return m},e.sign.detached.verify=function(F,Y,P){if(fe(F,Y,P),Y.length!==ce)throw new Error("bad signature size");if(P.length!==Ue)throw new Error("bad public key size");var m=new Uint8Array(ce+F.length),z=new Uint8Array(ce+F.length),sA;for(sA=0;sA<ce;sA++)m[sA]=Y[sA];for(sA=0;sA<F.length;sA++)m[sA+ce]=F[sA];return AA(z,m,m.length,P)>=0},e.sign.keyPair=function(){var F=new Uint8Array(Ue),Y=new Uint8Array(Wt);return pe(F,Y),{publicKey:F,secretKey:Y}},e.sign.keyPair.fromSecretKey=function(F){if(fe(F),F.length!==Wt)throw new Error("bad secret key size");for(var Y=new Uint8Array(Ue),P=0;P<Y.length;P++)Y[P]=F[32+P];return{publicKey:Y,secretKey:new Uint8Array(F)}},e.sign.keyPair.fromSeed=function(F){if(fe(F),F.length!==Oe)throw new Error("bad seed size");for(var Y=new Uint8Array(Ue),P=new Uint8Array(Wt),m=0;m<32;m++)P[m]=F[m];return pe(Y,P,!0),{publicKey:Y,secretKey:P}},e.sign.publicKeyLength=Ue,e.sign.secretKeyLength=Wt,e.sign.seedLength=Oe,e.sign.signatureLength=ce,e.hash=function(F){fe(F);var Y=new Uint8Array(_e);return He(Y,F,F.length),Y},e.hash.hashLength=_e,e.verify=function(F,Y){return fe(F,Y),F.length===0||Y.length===0||F.length!==Y.length?!1:f(F,0,Y,0,F.length)===0},e.setPRNG=function(F){s=F},(function(){var F=typeof self<"u"?self.crypto||self.msCrypto:null;if(F&&F.getRandomValues){var Y=65536;e.setPRNG(function(P,m){var z,sA=new Uint8Array(m);for(z=0;z<m;z+=Y)F.getRandomValues(sA.subarray(z,z+Math.min(m-z,Y)));for(z=0;z<m;z++)P[z]=sA[z];Uo(sA)})}else typeof jD<"u"&&(F=bc,F&&F.randomBytes&&e.setPRNG(function(P,m){var z,sA=F.randomBytes(m);for(z=0;z<m;z++)P[z]=sA[z];Uo(sA)}))})()})(A.exports?A.exports:self.nacl=self.nacl||{})})(Ki)),Ki.exports}TD();const OD={models:[{id:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-06-20",last_updated:"2024-06-20",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-opus-4-0",name:"Claude Opus 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-20250514",name:"Claude Opus 4",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-24",last_updated:"2025-11-24",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-01",last_updated:"2025-11-01",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-6",name:"Claude Opus 4.6",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",release_date:"2026-02-05",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-7",name:"Claude Opus 4.7",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",release_date:"2026-04-16",last_updated:"2026-04-16",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",owned_by:"anthropic",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-02-17",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"deepseek-chat",name:"DeepSeek Chat",owned_by:"deepseek",context_length:131072,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.2814,output:.4220999999999999,cache_read:.02814}},{id:"deepseek-reasoner",name:"DeepSeek Reasoner",owned_by:"deepseek",context_length:128e3,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.2814,output:.4220999999999999,cache_read:.02814}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.7486999999999997,output:3.4973999999999994,cache_read:.14572499999999997}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-12-17",last_updated:"2025-12-17",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.5025,output:3.0149999999999997,cache_read:.050249999999999996}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",owned_by:"google",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-11-18",last_updated:"2025-11-18",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-flash-image-preview",name:"Gemini 3.1 Flash Image (Preview)",owned_by:"google",context_length:131072,max_output:32768,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-26",last_updated:"2026-02-26",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text","image"]},pricing:{input:.25125,output:60.3}},{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.25125,output:1.5074999999999998,cache_read:.025124999999999998,cache_write:1.005}},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"MiniMax-M2.1",name:"MiniMax-M2.1",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2025-12-23",last_updated:"2025-12-23",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997}},{id:"MiniMax-M2.5",name:"MiniMax-M2.5",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-12",last_updated:"2026-02-12",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.030149999999999996,cache_write:.37687499999999996}},{id:"MiniMax-M2.7",name:"MiniMax-M2.7",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-18",last_updated:"2026-03-18",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.06029999999999999,cache_write:.37687499999999996}},{id:"kimi-k2-0711-preview",name:"Kimi K2 0711",owned_by:"moonshot",context_length:131072,max_output:16384,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-07-14",last_updated:"2025-07-14",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-0905-preview",name:"Kimi K2 0905",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.1557499999999998,output:8.04,cache_read:.15074999999999997}},{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:2.4119999999999995,output:10.049999999999999,cache_read:.6029999999999999}},{id:"kimi-k2.5",name:"Kimi K2.5",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2025-01",release_date:"2026-01",last_updated:"2026-01",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.6029999999999999,output:3.0149999999999997,cache_read:.10049999999999999,cache_write:.6029999999999999}},{id:"kimi-k2.6",name:"Kimi K2.6",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-04-21",last_updated:"2026-04-21",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.9547499999999999,output:4.02,cache_read:.1608}},{id:"gpt-5",name:"GPT-5",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-chat-latest",name:"GPT-5 Chat (latest)",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999}},{id:"gpt-5-codex",name:"GPT-5-Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",release_date:"2025-09-15",last_updated:"2025-09-15",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-mini",name:"GPT-5 Mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5-nano",name:"GPT-5 Nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.050249999999999996,output:.40199999999999997,cache_read:.005025}},{id:"gpt-5-pro",name:"GPT-5 Pro",owned_by:"openai",context_length:4e5,max_output:272e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-10-06",last_updated:"2025-10-06",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:15.075,output:120.6}},{id:"gpt-5.1",name:"GPT-5.1",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.13065}},{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5.2",name:"GPT-5.2",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:21.104999999999997,output:168.83999999999997}},{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",owned_by:"openai",context_length:128e3,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.4",name:"GPT-5.4",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:2.5124999999999997,output:15.075,cache_read:.25125}},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.7537499999999999,output:4.522499999999999,cache_read:.07537499999999998}},{id:"gpt-5.4-nano",name:"GPT-5.4 nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.20099999999999998,output:1.2562499999999999,cache_read:.0201}},{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:30.15,output:180.89999999999998}},{id:"gpt-5.5",name:"GPT-5.5",owned_by:"openai",context_length:105e4,max_output:13e4,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",release_date:"2026-04-23",last_updated:"2026-04-23",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:30.15,cache_read:.5025}},{id:"glm-4.7",name:"GLM-4.7",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2025-12-22",last_updated:"2025-12-22",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.211,cache_read:.11055}},{id:"glm-4.7-flash",name:"GLM-4.7-Flash",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:0,output:0}},{id:"glm-4.7-flashx",name:"GLM-4.7-FlashX",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.07035,output:.40199999999999997,cache_read:.01005}},{id:"glm-5",name:"GLM-5",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-11",last_updated:"2026-02-11",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.005,output:3.2159999999999997,cache_read:.20099999999999998}},{id:"glm-5-turbo",name:"GLM-5-Turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-16",last_updated:"2026-03-16",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}},{id:"glm-5.1",name:"GLM-5.1",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-27",last_updated:"2026-03-27",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.4069999999999998,output:4.422,cache_read:.2613}},{id:"glm-5v-turbo",name:"glm-5v-turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-04-01",last_updated:"2026-04-01",open_weights:!1,modalities:{input:["text","image","video","pdf"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}}]},fa="ollama-cloud",iE="ottorouter",qD={openai:"@ai-sdk/openai",anthropic:"@ai-sdk/anthropic",google:"@ai-sdk/google",openrouter:"@openrouter/ai-sdk-provider",xai:"@ai-sdk/xai",moonshot:"@ai-sdk/openai-compatible",zai:"@ai-sdk/openai-compatible",minimax:"@ai-sdk/anthropic"};function YD(A){const e=A.owned_by;return{id:A.id,ownedBy:e,label:A.name,modalities:A.modalities,toolCall:A.tool_call,reasoningText:A.reasoning,attachment:A.attachment,temperature:A.temperature,knowledge:A.knowledge,releaseDate:A.release_date,lastUpdated:A.last_updated,openWeights:A.open_weights,cost:{input:A.pricing.input,output:A.pricing.output,cacheRead:A.pricing.cache_read,cacheWrite:A.pricing.cache_write},limit:{context:A.context_length,output:A.max_output},provider:{npm:qD[e]}}}function HD(){const A=OD.models.map(YD);if(!A.length)return null;A.sort((s,n)=>{const r=s.ownedBy??"",i=n.ownedBy??"";return r===i?s.id.localeCompare(n.id):r==="openai"?-1:i==="openai"?1:r.localeCompare(i)});const e="gpt-5-codex",t=A.findIndex(s=>s.id===e);if(t>0){const[s]=A.splice(t,1);A.unshift(s)}return{id:iE,label:"OttoRouter",env:["OTTOROUTER_PRIVATE_KEY"],api:"https://api.ottorouter.org/v1",doc:"https://ottorouter.org/docs",models:A}}function PD(){return{id:fa,label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud",models:[]}}function WD(A){const e=A[fa]??PD(),t=HD(),s={...A};return s[fa]=e,t&&(s[iE]=t),s}const xg=WD(ym),zD={openai:[{match:A=>A.includes("gpt-4o-mini"),inputPerMillion:.15,outputPerMillion:.6},{match:A=>A.includes("gpt-4o"),inputPerMillion:5,outputPerMillion:15},{match:A=>A.includes("gpt-4.1-mini"),inputPerMillion:1,outputPerMillion:4},{match:A=>A.includes("gpt-4.1"),inputPerMillion:5,outputPerMillion:15}],anthropic:[{match:A=>A.includes("claude-3-haiku"),inputPerMillion:.25,outputPerMillion:1.25},{match:A=>A.includes("claude-3-sonnet"),inputPerMillion:3,outputPerMillion:15},{match:A=>A.includes("claude-3-opus"),inputPerMillion:15,outputPerMillion:75}],google:[{match:A=>A.includes("gemini-1.5-flash"),inputPerMillion:.35,outputPerMillion:1.05},{match:A=>A.includes("gemini-1.5-pro"),inputPerMillion:3.5,outputPerMillion:10.5}],"ollama-cloud":[],openrouter:[],opencode:[],ottorouter:[],zai:[],"zai-coding":[],moonshot:[],minimax:[],copilot:[]};function VD(A,e){const t=zD[A];if(t)return t.find(s=>{try{return s.match(e)}catch{return!1}})}function ZD(A,e){const t=xg[A];if(!t)return;const s=e.toLowerCase();return t.models.find(n=>n.id?.toLowerCase()===s)}function aE(A,e,t){const s=typeof t.inputTokens=="number"?t.inputTokens:0,n=typeof t.outputTokens=="number"?t.outputTokens:0,r=typeof t.cachedInputTokens=="number"?t.cachedInputTokens:0,i=typeof t.cacheCreationInputTokens=="number"?t.cacheCreationInputTokens:0;if(!s&&!n&&!r&&!i)return;const a=ZD(A,e);if(a?.cost?.input!=null||a?.cost?.output!=null){const c=typeof a.cost?.input=="number"?a.cost.input:0,u=typeof a.cost?.output=="number"?a.cost.output:0,f=typeof a.cost?.cacheRead=="number"?a.cost.cacheRead:0,h=typeof a.cost?.cacheWrite=="number"?a.cost.cacheWrite:0,v=Math.max(0,s-r-i)*c/1e6,D=n*u/1e6,O=r*f/1e6,J=i*h/1e6,V=v+D+O+J;return Number.isFinite(V)?Number(V.toFixed(6)):void 0}const g=VD(A,e.toLowerCase());if(!g)return;const l=Math.max(0,s-r-i)*g.inputPerMillion/1e6,C=n*g.outputPerMillion/1e6,I=l+C;return Number.isFinite(I)?Number(I.toFixed(6)):void 0}var ma={};function Dg(...A){return A.filter(Boolean).map(e=>e.replace(/\\/g,"/")).join("/").replace(/\/+\/+/g,"/")}function _D(){return(ma.HOME||ma.USERPROFILE||"").replace(/\\/g,"/")}function XD(){const A=ma.XDG_CONFIG_HOME;return A?.trim()?A.replace(/\\/g,"/"):Dg(_D(),".config")}function $D(){return Dg(XD(),"otto")}function A2(){return Dg($D(),"models-catalog.json")}function pr(A){return typeof A=="object"&&A!==null&&!Array.isArray(A)}function e2(A){try{return Function('return typeof require === "function" ? require : null')()?.("node:fs").readFileSync(A,"utf8")??null}catch{return null}}function t2(A,e){if(!pr(e))return null;const t=Array.isArray(e.models)?e.models.filter(s=>pr(s)&&typeof s.id=="string"):[];return{id:typeof e.id=="string"?e.id:A,label:typeof e.label=="string"?e.label:void 0,models:t}}function o2(A){if(!pr(A))return{};const e=pr(A.providers)?A.providers:A,t={};for(const[s,n]of Object.entries(e)){const r=t2(s,n);r&&(t[s]=r)}return t}function s2(){try{const A=e2(A2());if(!A)return null;const e=JSON.parse(A),t=o2(e);return{version:1,updatedAt:pr(e)&&typeof e.updatedAt=="string"?e.updatedAt:new Date(0).toISOString(),providers:t}}catch{return null}}function r2(A){return s2()?.providers[A]}function gE(A,e){if(xg[A])return n2(A).find(s=>s.id===e)}function n2(A){return r2(A)?.models??xg[A]?.models??[]}function QE({sessionId:A,title:e,className:t=""}){const[s,n]=x.useState(!1),[r,i]=x.useState(e||""),a=x.useRef(null),{mutate:g}=tg(A);x.useEffect(()=>{s&&a.current&&(a.current.focus(),a.current.select())},[s]),x.useEffect(()=>{i(e||"")},[e]);const Q=x.useCallback(()=>{const C=r.trim();C&&C!==(e||"")&&g({title:C}),n(!1)},[r,e,g]),l=x.useCallback(()=>{i(e||""),n(!1)},[e]);return s?o.jsx("input",{ref:a,type:"text",value:r,onChange:C=>i(C.target.value),onBlur:Q,onKeyDown:C=>{C.key==="Enter"&&Q(),C.key==="Escape"&&l()},className:`w-full bg-muted/30 text-foreground rounded px-2 py-1 outline-none ring-1 ring-primary/50 focus:ring-primary ${t}`}):o.jsxs("button",{type:"button",onClick:()=>n(!0),className:`group flex items-center gap-2 hover:opacity-80 transition-opacity truncate text-left ${t}`,title:"Click to edit title",children:[o.jsx("span",{className:"truncate",children:e||"Untitled Session"}),o.jsx(En,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-50 flex-shrink-0 transition-opacity"})]})}function i2({session:A,onNavigateToSession:e}){const{data:t}=Ac(A.sessionType==="branch"?A.id:void 0),{preferences:s}=Zs(),{data:n}=Ag(A.id),r=x.useMemo(()=>{const k=A.totalInputTokens||0,v=A.totalOutputTokens||0,D=A.totalCachedTokens||0,O=A.totalCacheCreationTokens||0;return aE(A.provider,A.model,{inputTokens:k,outputTokens:v,cachedInputTokens:D,cacheCreationInputTokens:O})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),i=k=>{if(!k)return"0s";const v=Math.floor(k/1e3),D=Math.floor(v/60),O=Math.floor(D/60);return O>0?`${O}h ${D%60}m`:D>0?`${D}m ${v%60}s`:`${v}s`},a=k=>k.toLocaleString("en-US"),g=k=>k>=1e6?`${(k/1e6).toFixed(1)}M`:k>=1e3?`${(k/1e3).toFixed(1)}K`:k.toString(),Q=A.currentContextTokens||0,l=A.totalOutputTokens||0,C=A.sessionType==="branch",I=t?.parent,c=x.useMemo(()=>gE(A.provider,A.model)?.limit?.context,[A.provider,A.model]),u=c?Q/c*100:0,f=()=>u>=90?"text-red-600 dark:text-red-400":u>=70?"text-amber-600 dark:text-amber-400":"text-foreground",h=s.fullWidthContent?"w-full px-6 py-6":"max-w-3xl mx-auto px-6 py-6";return o.jsx("div",{className:"border-b border-border bg-background/95 backdrop-blur-sm",children:o.jsxs("div",{className:h,children:[C&&o.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm",children:[o.jsx(ao,{className:"h-4 w-4 text-violet-500"}),o.jsx("span",{className:"text-violet-600 dark:text-violet-400 font-medium",children:"Branch"}),I&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>e?.(I.id),className:"text-primary hover:underline flex items-center gap-1",children:[I.title||`Session ${I.id.slice(0,8)}`,o.jsx(TB,{className:"h-3 w-3"})]})]}),!I&&A.parentSessionId&&o.jsx("span",{className:"text-muted-foreground italic text-xs",children:"(parent deleted)"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(QE,{sessionId:A.id,title:A.title,className:"text-2xl font-semibold text-foreground leading-tight"}),n?.shared&&o.jsxs("button",{type:"button",onClick:()=>ho(n.url),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:[o.jsx(Ua,{className:"h-3 w-3"}),o.jsx("span",{children:"Shared"}),n.pendingMessages&&n.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Vt,{className:"h-2.5 w-2.5"}),n.pendingMessages]}):o.jsx(vt,{className:"h-2.5 w-2.5 opacity-60"})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 mt-4 text-sm text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-1.5",title:`Current context window: ${a(Q)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${f()}`,children:g(Q)})]}),o.jsxs("div",{className:"flex items-center gap-1.5",title:`Total output: ${a(l)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"out"}),o.jsx("span",{className:"font-medium text-foreground",children:g(l)})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ka,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:i(A.totalToolTimeMs)})]}),r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(OB,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:r.toFixed(4)})]}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[o.jsx($t,{provider:A.provider,size:18}),o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})})}const lo=ht(A=>({usage:{},isLoading:{},lastFetched:{},isModalOpen:!1,modalProvider:null,setUsage:(e,t)=>A(s=>({usage:{...s.usage,[e]:t}})),setLoading:(e,t)=>A(s=>({isLoading:{...s.isLoading,[e]:t}})),setLastFetched:(e,t)=>A(s=>({lastFetched:{...s.lastFetched,[e]:t}})),openModal:e=>A({isModalOpen:!0,modalProvider:e}),closeModal:()=>A({isModalOpen:!1,modalProvider:null})})),Bs=22,wa=2.5,xa=(Bs-wa)/2,Ji=2*Math.PI*xa;function a2(A){return A>=90?"#ef4444":A>=70?"#f59e0b":"#3b82f6"}const QB=x.memo(function({usage:e,provider:t}){const s=lo(a=>a.openModal),n=e.primaryWindow?.usedPercent??0,r=Ji-n/100*Ji,i=a2(n);return o.jsxs("button",{type:"button",onClick:()=>s(t),className:"relative flex items-center hover:opacity-80 transition-opacity cursor-pointer",title:`Usage: ${Math.round(n)}% (5h window) — Click for details`,children:[o.jsxs("svg",{width:Bs,height:Bs,className:"-rotate-90",role:"img","aria-label":"Usage ring",children:[o.jsx("circle",{cx:Bs/2,cy:Bs/2,r:xa,fill:"none",stroke:"hsl(var(--muted))",strokeWidth:wa}),o.jsx("circle",{cx:Bs/2,cy:Bs/2,r:xa,fill:"none",stroke:i,strokeWidth:wa,strokeDasharray:Ji,strokeDashoffset:r,strokeLinecap:"round",className:"transition-all duration-500"})]}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center rotate-0 font-medium text-muted-foreground",style:{fontSize:7},children:"5h"})]})});function g2(A){if(!A)return"Unknown";const e=Date.now(),s=new Date(A).getTime()-e;if(s<=0)return"Now";const n=Math.floor(s/864e5),r=Math.floor(s%864e5/36e5),i=Math.floor(s%36e5/6e4);return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m`}function BB(A){return A<=18e3?"5 Hour":A<=86400?"24 Hour":"7 Day"}function Li({label:A,window:e}){const t=Math.min(e.usedPercent,100),s=t>=90?"bg-red-500":t>=70?"bg-amber-500":"bg-blue-500";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:A}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(t),"%"]}),e.resetsAt&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["resets in ",g2(e.resetsAt)]})]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${s}`,style:{width:`${t}%`}})})]})}const Q2=x.memo(function(){const e=lo(i=>i.isModalOpen),t=lo(i=>i.modalProvider),s=lo(i=>i.closeModal),n=lo(i=>t?i.usage[t]:void 0),r=x.useMemo(()=>o.jsxs("div",{className:"flex items-center gap-2",children:[t&&o.jsx($t,{provider:t,size:20}),o.jsx("span",{children:"Usage & Limits"})]}),[t]);return n?o.jsx(Po,{isOpen:e,onClose:s,title:r,maxWidth:"sm",children:o.jsxs("div",{className:"space-y-5",children:[n.limitReached&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md bg-red-500/10 border border-red-500/20",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 flex-shrink-0"}),o.jsx("span",{className:"text-sm text-red-600 dark:text-red-400 font-medium",children:"Rate limit reached"})]}),n.primaryWindow&&o.jsx(Li,{label:`${BB(n.primaryWindow.windowSeconds)} Window`,window:n.primaryWindow}),n.secondaryWindow&&o.jsx(Li,{label:`${BB(n.secondaryWindow.windowSeconds)} Window`,window:n.secondaryWindow}),n.sonnetWindow&&n.sonnetWindow.usedPercent>0&&o.jsx(Li,{label:"Sonnet (7 Day)",window:{usedPercent:n.sonnetWindow.usedPercent,windowSeconds:604800,resetsAt:n.sonnetWindow.resetsAt}}),n.extraUsage?.is_enabled&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Extra Credits"}),o.jsxs("span",{className:"font-medium text-foreground",children:["$",n.extraUsage.used_credits.toFixed(2)," / $",n.extraUsage.monthly_limit]})]})}),n.credits?.has_credits&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Credits"}),o.jsx("span",{className:"font-medium text-foreground",children:n.credits.balance!==null?`$${n.credits.balance.toFixed(2)}`:"Available"})]})}),n.planType&&o.jsx("div",{className:"pt-2 border-t border-border",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Plan"}),o.jsx("span",{className:"font-medium text-foreground capitalize",children:n.planType})]})})]})}):null}),B2=6e4,l2=3e4,ji=new Set;function c2(A,e){const t=lo(Q=>Q.setUsage),s=lo(Q=>Q.setLoading),n=lo(Q=>Q.setLastFetched),r=lo(Q=>A?Q.usage[A]:void 0),i=e==="oauth"&&(A==="anthropic"||A==="openai"),a=x.useCallback(async()=>{if(!A||!i||ji.has(A))return;const Q=lo.getState().lastFetched[A]??0;if(!(Q&&Date.now()-Q<l2)){ji.add(A),s(A,!0);try{const l=await mA.getProviderUsage(A);t(A,l),n(A,Date.now())}catch{}finally{s(A,!1),ji.delete(A)}}},[A,i,t,s,n]),g=x.useRef(a);return g.current=a,x.useEffect(()=>{if(!A||!i)return;g.current();const Q=setInterval(()=>g.current(),B2);return()=>clearInterval(Q)},[i,A]),{usage:r,fetchUsage:a,isOAuthProvider:i}}function ti(A){const e=Ne(h=>h.setBalance),t=Ne(h=>h.setUsdcBalance),s=Ne(h=>h.setWalletAddress),n=Ne(h=>h.setLoading),r=Ne(h=>h.setScope),i=Ne(h=>h.setPayg),a=Ne(h=>h.setSubscription),g=Ne(h=>h.setLimits),Q=lo(h=>h.setUsage),l=Ne(h=>h.balance),C=Ne(h=>h.usdcBalance),I=Ne(h=>h.subscription),c=Ne(h=>h.network),u=x.useCallback(async()=>{if(A==="ottorouter"){n(!0);try{const[h,k,v]=await Promise.all([mA.getOttoRouterBalance(),mA.getOttoRouterUsdcBalance(c),mA.getOttoRouterWallet()]);if(h){e(h.balance),s(h.walletAddress),r(h.scope??null),i(h.payg??null),a(h.subscription??null),g(h.limits??null);const D=h.subscription;D?.active&&D.usageWindows&&Q("ottorouter",{provider:"ottorouter",primaryWindow:{usedPercent:D.usageWindows.fiveHour.percentUsed,windowSeconds:18e3,resetsAt:null},secondaryWindow:{usedPercent:D.usageWindows.weekly.percentUsed,windowSeconds:604800,resetsAt:null},limitReached:!1,planType:D.tierName??"GO"})}else v?.configured&&v.publicKey&&s(v.publicKey);k&&(t(k.usdcBalance),!h&&k.walletAddress&&s(k.walletAddress))}catch{}finally{n(!1)}}},[A,c,e,t,s,n,r,i,a,g,Q]),f=I?.active&&!I.usageWindows;return x.useEffect(()=>{A==="ottorouter"&&(l===null||C===null||f)&&u()},[A,l,C,f,u]),{fetchBalance:u}}function E2({session:A,isVisible:e,isGenerating:t,onNavigateToSession:s}){const{data:n}=Ac(A.sessionType==="branch"?A.id:void 0),{data:r}=Ag(A.id),i=x.useMemo(()=>{const O=A.totalInputTokens||0,J=A.totalOutputTokens||0,V=A.totalCachedTokens||0,eA=A.totalCacheCreationTokens||0;return aE(A.provider,A.model,{inputTokens:O,outputTokens:J,cachedInputTokens:V,cacheCreationInputTokens:eA})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),a=O=>O>=1e6?`${(O/1e6).toFixed(1)}M`:O>=1e3?`${(O/1e3).toFixed(1)}K`:O.toString(),g=A.currentContextTokens||0,Q=A.sessionType==="branch",l=n?.parent,C=x.useMemo(()=>gE(A.provider,A.model)?.limit?.context,[A.provider,A.model]),I=C?g/C*100:0,c=()=>I>=90?"text-red-600 dark:text-red-400":I>=70?"text-amber-600 dark:text-amber-400":"text-foreground",{data:u}=Vs(),f=u?.[A.provider]?.authType,{usage:h,isOAuthProvider:k}=c2(A.provider,f),v=A.provider==="ottorouter";ti(v?"ottorouter":void 0);const D=lo(O=>O.usage.ottorouter);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`absolute top-0 left-0 right-0 h-14 border-b border-border bg-background/40 backdrop-blur-xl supports-[backdrop-filter]:bg-background/20 z-10 transition-transform duration-200 ${e?"translate-y-0":"-translate-y-full"}`,children:o.jsxs("div",{className:"h-full px-6 flex items-center justify-between gap-4 text-sm",children:[o.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 text-muted-foreground",children:[Q?o.jsx(ao,{className:"w-4 h-4 flex-shrink-0 text-violet-500"}):o.jsx(iC,{className:"w-4 h-4 flex-shrink-0"}),o.jsx(QE,{sessionId:A.id,title:A.title,className:"text-foreground font-medium text-sm"}),r?.shared&&o.jsxs("button",{type:"button",onClick:()=>ho(r.url),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:[o.jsx(Ua,{className:"h-3 w-3"}),r.pendingMessages&&r.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Vt,{className:"h-2.5 w-2.5"}),r.pendingMessages]}):o.jsx(vt,{className:"h-2.5 w-2.5 opacity-60"})]}),Q&&l&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>s?.(l.id),className:"text-primary hover:underline flex items-center gap-0.5 truncate max-w-32",title:l.title||`Session ${l.id.slice(0,8)}`,children:[o.jsx("span",{className:"truncate",children:l.title||`Session ${l.id.slice(0,8)}`}),o.jsx(TB,{className:"h-3 w-3 flex-shrink-0"})]})]})]}),o.jsxs("div",{className:"flex-shrink-0 flex items-center gap-5 text-muted-foreground",children:[t&&o.jsx(Xp,{sessionId:A.id}),k&&h&&o.jsx(QB,{usage:h,provider:A.provider}),v&&D&&o.jsx(QB,{usage:D,provider:"ottorouter"}),o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs("div",{className:"flex items-center gap-1",title:`Current context window: ${g.toLocaleString()} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${c()}`,children:a(g)})]})}),i>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(OB,{className:"w-4 h-4"}),o.jsx("span",{className:"text-foreground font-medium",children:i.toFixed(4)})]}),o.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[o.jsx($t,{provider:A.provider,size:16}),o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})}),o.jsx(Q2,{})]})}const C2=x.memo(function({pendingTopup:e,onMethodSelected:t,onCancel:s}){const[n,r]=x.useState(!1),[i,a]=x.useState(null),g=Ne(c=>c.openTopupModal),Q=Ne(c=>!!c.subscription?.active),l=async()=>{a("crypto"),r(!0);try{await mA.selectTopupMethod(e.sessionId,"crypto"),t("crypto")}catch(c){de.error(c instanceof Error?c.message:"Failed to process payment"),r(!1),a(null)}},C=async()=>{a("fiat"),g(),mA.selectTopupMethod(e.sessionId,"fiat").catch(()=>{}),t("fiat")},I=async()=>{r(!0);try{await mA.cancelTopup(e.sessionId),s()}catch(c){de.error(c instanceof Error?c.message:"Failed to cancel"),r(!1)}};return o.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(wo,{className:"h-4 w-4 text-amber-500 flex-shrink-0"}),o.jsx("span",{className:"font-medium text-foreground text-sm",children:"Insufficient Balance"}),o.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium text-sm",children:"payment required"})]}),Q&&o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:"GO credits may not apply to this request. Add balance to continue."}),o.jsxs("div",{className:"ml-6 bg-muted/30 rounded-lg p-3 space-y-2 text-sm",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Request cost"}),o.jsxs("span",{className:"font-mono",children:["~$",e.amountUsd.toFixed(4)]})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Current balance"}),o.jsxs("span",{className:"font-mono",children:["$",e.currentBalance.toFixed(4)]})]})]}),o.jsxs("div",{className:"ml-6 flex flex-wrap items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:I,disabled:n,title:"Cancel request",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-border bg-background hover:bg-muted transition-colors disabled:opacity-50",children:[o.jsx(lt,{className:"w-3 h-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:l,disabled:n,title:"Pay with USDC from your wallet",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-violet-600 text-white hover:bg-violet-700 transition-colors disabled:opacity-50",children:[i==="crypto"&&n?o.jsx(Le,{className:"w-3 h-3 animate-spin"}):o.jsx(Ja,{className:"w-3 h-3"}),"Pay with USDC"]}),o.jsxs("button",{type:"button",onClick:C,disabled:n,title:"Top up with card (min $5)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-violet-500 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 transition-colors disabled:opacity-50",children:[i==="fiat"&&n?o.jsx(Le,{className:"w-3 h-3 animate-spin"}):o.jsx(fr,{className:"w-3 h-3"}),"Top up with Card",o.jsx("span",{className:"text-[10px] opacity-70",children:"(min $5)"})]})]}),o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:i==="crypto"?"Processing USDC payment from your wallet...":i==="fiat"?"Opening checkout...":"Select a payment method to continue your request."})]})}),bn=ht(A=>({pendingTopup:null,isProcessing:!1,selectedMethod:null,setPendingTopup:e=>A({pendingTopup:e,isProcessing:!1,selectedMethod:null}),setProcessing:e=>A({isProcessing:e}),setSelectedMethod:e=>A({selectedMethod:e}),clearPendingTopup:()=>A({pendingTopup:null,isProcessing:!1,selectedMethod:null})})),I2=x.memo(function({messages:e,session:t,sessionId:s,isGenerating:n,compact:r=!1,disableAutoScroll:i=!1,onSelectSession:a}){const g=ke(),{preferences:Q}=Zs(),l=x.useRef(null),C=x.useRef(null),I=x.useRef(null),[c,u]=x.useState(!0),f=x.useRef(!0),[h,k]=x.useState(!1),v=x.useRef(!1),D=x.useRef(void 0),O=x.useRef(0),J=x.useRef(void 0),V=x.useRef(!1),eA=x.useRef(t?.id),X=x.useRef(e.length),K=x.useRef(n),W=x.useRef(0),T=x.useRef(0),L=bn(b=>b.pendingTopup),w=bn(b=>b.clearPendingTopup),B=L&&L.sessionId===s,d=x.useCallback(()=>{const b=C.current;if(!b)return;const{scrollTop:E,scrollHeight:p,clientHeight:U}=b,R=p-E-U,_=p>W.current,tA=E<T.current-5;W.current=p,T.current=E,R<100?(f.current=!0,u(!0)):tA?(f.current=!1,u(!1),v.current=!0):!_&&f.current&&(f.current=!1,u(!1)),(tA||!f.current&&R>=100)&&(D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{v.current=!1},150));const IA=I.current;if(IA){const iA=IA.getBoundingClientRect(),UA=b.getBoundingClientRect();k(iA.bottom<UA.top)}},[]);x.useEffect(()=>{if(i)return;const b=t?.id!==eA.current;if(eA.current=t?.id,b&&(V.current=!1),!V.current&&e.length>0){V.current=!0;const E=C.current;E&&(E.scrollTop=E.scrollHeight)}},[e.length,t?.id,i]),x.useEffect(()=>{if(i)return;const b=n&&!K.current,E=e.length>X.current;K.current=n,X.current=e.length,b?(v.current=!1,f.current=!0,u(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const p=C.current;p&&(p.scrollTop=p.scrollHeight)})})):E&&!v.current&&!n&&(f.current=!0,u(!0))},[e.length,n,i]),x.useEffect(()=>{if(i)return;const b=C.current;if(!b||!c||v.current)return;O.current=b.scrollHeight-b.clientHeight;const E=()=>{const p=C.current;if(!p||v.current)return;const U=p.scrollTop,_=p.scrollHeight-p.clientHeight-U;if(Math.abs(_)<1){p.scrollTop=p.scrollHeight-p.clientHeight;return}if(Math.abs(_)<10){p.scrollTop=p.scrollHeight-p.clientHeight;return}p.scrollTop=U+_*.15,J.current=requestAnimationFrame(E)};J.current&&cancelAnimationFrame(J.current),J.current=requestAnimationFrame(E)},[e,c]),x.useEffect(()=>()=>{D.current&&clearTimeout(D.current),J.current&&cancelAnimationFrame(J.current)},[]);const N=()=>{v.current=!1,f.current=!0,u(!0);const b=C.current;b&&(b.scrollTop=b.scrollHeight)},G=x.useMemo(()=>e.filter(b=>b.role!=="system"),[e]),S=Q.fullWidthContent?r?"w-full space-y-4":"w-full space-y-6":r?"max-w-3xl mx-auto space-y-4":"max-w-3xl mx-auto space-y-6",j=x.useCallback(b=>async()=>{if(s&&b){g.setQueryData(["messages",s],E=>E&&E.map(p=>{if(p.id!==b)return p;const U=p.parts?.filter(R=>!(R.type==="error"||R.type==="tool_call"&&R.toolName==="finish"))??[];return{...p,status:"pending",parts:U,error:null}}));try{await mA.retryMessage(s,b)}catch(E){de.error(E instanceof Error?E.message:"Failed to retry")}}},[s,g]),H=x.useCallback(async()=>{if(s)try{await mA.sendMessage(s,{content:"/compact"})}catch(b){de.error(b instanceof Error?b.message:"Failed to compact")}},[s]);return e.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):o.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[t&&o.jsx(E2,{session:t,isVisible:h,isGenerating:n,onNavigateToSession:a}),o.jsxs("div",{ref:C,className:"flex-1 overflow-y-auto",onScroll:d,children:[o.jsx("div",{ref:I,children:t&&o.jsx(i2,{session:t,onNavigateToSession:a})}),o.jsx("div",{className:r?"p-4 pb-56":"p-6 pb-64",children:o.jsxs("div",{className:S,children:[G.map((b,E)=>{const p=G[E-1],U=G[E+1],R=E===G.length-1;if(b.role==="user"){const _=U&&U.role==="assistant"?U:void 0;return o.jsx(tc,{sessionId:s,message:b,isFirst:E===0,nextAssistantMessageId:_?.id},b.id)}if(b.role==="assistant"){const _=!p||p.role!=="assistant",tA=U&&U.role==="assistant";return o.jsx(ec,{sessionId:s,message:b,showHeader:_,hasNextAssistantMessage:tA,isLastMessage:R,onBranchCreated:a,onRetry:R?j(b.id):void 0,compact:r,onCompact:R?H:void 0},b.id)}return null}),B&&L&&o.jsx("div",{className:"py-4",children:o.jsx(C2,{pendingTopup:L,onMethodSelected:()=>w(),onCancel:()=>w()})}),o.jsx("div",{ref:l})]})})]}),!c&&o.jsxs("button",{type:"button",onClick:N,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:[o.jsx(aC,{className:"w-4 h-4"}),o.jsx("span",{children:"Scroll to bottom"})]})]})});class BE{abortController=null;handlers=new Map;running=!1;async connect(e){this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.running=!0;const t=!e.includes("localhost")&&!e.includes("127.0.0.1");try{const s=await fetch(e,{method:t?"POST":"GET",headers:{Accept:"text/event-stream"},signal:this.abortController.signal});if(!s.ok){console.error("[SSE] Connection failed:",s.status);return}const n=s.body?.getReader();if(!n){console.error("[SSE] No response body");return}const r=new TextDecoder;let i="";for(;this.running;){const{done:a,value:g}=await n.read();if(a)break;i+=r.decode(g,{stream:!0});let Q=i.indexOf(`
114
114
 
115
115
  `);for(;Q!==-1;){const l=i.slice(0,Q);i=i.slice(Q+2);const C=l.split(`
116
116
  `);let I="message",c="";for(const u of C)u.startsWith("event: ")?I=u.slice(7).trim():u.startsWith("data: ")?c+=(c?`
117
117
  `:"")+u.slice(6):u.startsWith(":");if(c)try{const u=JSON.parse(c);this.emit({type:I,payload:u})}catch(u){console.error(`[SSE] Failed to parse ${I}:`,u)}Q=i.indexOf(`
118
118
 
119
- `)}}}catch(s){s instanceof Error&&s.name==="AbortError"||s instanceof TypeError&&s.message==="Load failed"||console.error("[SSE] Connection error:",s)}}disconnect(){this.running=!1,this.abortController&&(this.abortController.abort(),this.abortController=null)}on(e,t){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e)?.add(t),()=>{this.off(e,t)}}off(e,t){const s=this.handlers.get(e);s&&(s.delete(t),s.size===0&&this.handlers.delete(e))}emit(e){const t=this.handlers.get(e.type);if(t)for(const n of t)n(e);const s=this.handlers.get("*");if(s)for(const n of s)n(e)}}function lE(A,e=!0){const t=ke(),s=x.useRef(null),n=x.useRef(null),{addPendingApproval:r,removePendingApproval:i,updatePendingApproval:a,setPendingApprovals:g}=Mr();x.useEffect(()=>{if(!A||!e)return;n.current=null;let Q=0;mA.getPendingApprovals(A).then(B=>{B.ok&&B.pending.length>0?g(B.pending):g([])}).catch(()=>{g([])});const l=new BE;s.current=l;const C=mA.getStreamUrl(A);console.log("[useSessionStream] Connecting to stream:",C),l.connect(C);const I=B=>{if(n.current){const d=B.findIndex(N=>N.id===n.current);if(d!==-1)return d}for(let d=B.length-1;d>=0;d-=1){const N=B[d];if(N.role==="assistant"&&N.status!=="complete")return d}return-1},c=B=>{if(B.contentJson&&typeof B.contentJson=="object"&&!Array.isArray(B.contentJson)&&"text"in B.contentJson)return String(B.contentJson.text??"");if(typeof B.content=="string"){try{const d=JSON.parse(B.content);if(d&&typeof d.text=="string")return d.text}catch{}return B.content}return""},u=B=>typeof B?.callId=="string"?B.callId:typeof B?.toolCallId=="string"?B.toolCallId:null,f=B=>typeof B?.name=="string"?B.name:typeof B?.toolName=="string"?B.toolName:null,h=B=>B?.args??B?.input,k=B=>typeof B?.delta=="string"?B.delta:typeof B?.inputTextDelta=="string"?B.inputTextDelta:null,v=B=>typeof B?.delta=="string"?B.delta:typeof B?.outputTextDelta=="string"?B.outputTextDelta:null,D=(B,d)=>{if(typeof d!="number")return B.length;const N=B.filter(b=>b.stepIndex===d).map(b=>b.index).filter(b=>Number.isFinite(b));if(N.length>0)return Math.max(...N)+.001;const G=B.filter(b=>typeof b.stepIndex=="number"&&b.stepIndex<d).map(b=>b.index).filter(b=>Number.isFinite(b)),S=B.filter(b=>typeof b.stepIndex=="number"&&b.stepIndex>d).map(b=>b.index).filter(b=>Number.isFinite(b)),j=G.length>0?Math.max(...G):null,H=S.length>0?Math.min(...S):null;return j!==null&&H!==null?(j+H)/2:j!==null?j+1:H!==null?H-1:B.length},O=B=>{const d=typeof B?.messageId=="string"?B.messageId:null,N=typeof B?.partId=="string"?B.partId:null,G=typeof B?.delta=="string"?B.delta:null;!d||!N||G===null||t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S],H=j.findIndex(R=>R.id===d);if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=E.findIndex(R=>R.id===N);const U=typeof B?.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={id:N,messageId:d,index:D(E,U),stepIndex:U,type:"reasoning",content:JSON.stringify({text:G}),contentJson:{text:G},agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};E.push(R),p=E.length-1}else{const R=E[p],tA=`${c(R)}${G}`;E[p]={...R,content:JSON.stringify({text:tA}),contentJson:{text:tA},stepIndex:U??R.stepIndex??null,completedAt:null}}return j[H]={...b,parts:E},j})},J=B=>{const d=typeof B?.messageId=="string"?B.messageId:null,N=typeof B?.partId=="string"?B.partId:null,G=typeof B?.delta=="string"?B.delta:null;!d||!N||G===null||t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S],H=j.findIndex(R=>R.id===d);if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=E.findIndex(R=>R.id===N);const U=typeof B?.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={id:N,messageId:d,index:D(E,U),stepIndex:U,type:"text",content:JSON.stringify({text:G}),contentJson:{text:G},agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};E.push(R),p=E.length-1}else{const R=E[p],tA=`${c(R)}${G}`;E[p]={...R,content:JSON.stringify({text:tA}),contentJson:{text:tA},stepIndex:U??R.stepIndex??null,completedAt:null}}return j[H]={...b,parts:E},j})},V=B=>{if(!B)return;const d=u(B),N=f(B);N&&t.setQueryData(["messages",A],G=>{if(!G)return G;const S=[...G];let j=I(S);if(typeof B.messageId=="string"){const _=S.findIndex(tA=>tA.id===B.messageId);_!==-1&&(j=_)}if(j===-1)return G;const H=S[j],b=H.parts?[...H.parts]:[];let E=-1;d&&(E=b.findIndex(_=>_.toolCallId===d&&_.ephemeral)),E===-1&&!d&&(E=b.findIndex(_=>_.ephemeral&&_.toolName===N));const p=h(B),U=typeof B.stepIndex=="number"?B.stepIndex:null,R={name:N};if(d&&(R.callId=d),p!==void 0&&(R.args=p),E===-1){const _={id:d?`ephemeral-tool-call-${d}`:`ephemeral-tool-call-${N}-${Date.now()}`,messageId:H.id,index:D(b,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:H.agent,provider:H.provider,model:H.model,startedAt:Date.now(),completedAt:null,toolName:N,toolCallId:d,toolDurationMs:null,ephemeral:!0};b.push(_)}else{const _=b[E],tA={...typeof _.contentJson=="object"&&!Array.isArray(_.contentJson)?_.contentJson:{},name:N};d&&(tA.callId=d),p!==void 0&&(tA.args=p),b[E]={..._,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??_.stepIndex??null,toolCallId:d??_.toolCallId,toolName:N}}return S[j]={...H,parts:b},S})},eA=(B,d)=>{if(!B)return;const N=u(B),G=f(B);G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S];let H=I(j);if(typeof B.messageId=="string"){const R=j.findIndex(_=>_.id===B.messageId);R!==-1&&(H=R)}if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=-1;N&&(p=E.findIndex(R=>R.toolCallId===N&&R.ephemeral)),p===-1&&!N&&(p=E.findIndex(R=>R.ephemeral&&R.toolName===G));const U=typeof B.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={name:G,_streamedInput:d};N&&(R.callId=N);const _={id:N?`ephemeral-tool-call-${N}`:`ephemeral-tool-call-${G}-${Date.now()}`,messageId:b.id,index:D(E,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:G,toolCallId:N,toolDurationMs:null,ephemeral:!0};E.push(_)}else{const R=E[p],_=typeof R.contentJson?._streamedInput=="string"?R.contentJson._streamedInput:"",tA={...typeof R.contentJson=="object"&&!Array.isArray(R.contentJson)?R.contentJson:{},_streamedInput:_+d};E[p]={...R,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??R.stepIndex??null}}return j[H]={...b,parts:E},j})},X=(B,d)=>{if(!B)return;const N=u(B),G=f(B);G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S];let H=I(j);if(typeof B.messageId=="string"){const R=j.findIndex(_=>_.id===B.messageId);R!==-1&&(H=R)}if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=-1;N&&(p=E.findIndex(R=>R.toolCallId===N&&R.ephemeral)),p===-1&&!N&&(p=E.findIndex(R=>R.ephemeral&&R.toolName===G));const U=typeof B.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={name:G,_streamedOutput:d};N&&(R.callId=N);const _={id:N?`ephemeral-tool-call-${N}`:`ephemeral-tool-call-${G}-${Date.now()}`,messageId:b.id,index:D(E,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:G,toolCallId:N,toolDurationMs:null,ephemeral:!0};E.push(_)}else{const R=E[p],_=typeof R.contentJson?._streamedOutput=="string"?R.contentJson._streamedOutput:"",tA={...typeof R.contentJson=="object"&&!Array.isArray(R.contentJson)?R.contentJson:{},_streamedOutput:_+d};E[p]={...R,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??R.stepIndex??null}}return j[H]={...b,parts:E},j})},K=B=>{const d=u(B);if(!d)return;const N=f(B),G=typeof B?.stepIndex=="number"?B.stepIndex:null,S=B?.result,j=B?.artifact,H=h(B);t.setQueryData(["messages",A],b=>{if(!b)return b;let E=!1;const p=Date.now(),U=b.map(R=>{if(!R.parts?.length)return R;let _=!1;const tA=R.parts.map(IA=>{if(!(IA.ephemeral&&IA.toolCallId===d))return IA;_=!0,E=!0;const iA={...typeof IA.contentJson=="object"&&!Array.isArray(IA.contentJson)?IA.contentJson:{},name:N??IA.toolName??"tool",callId:d};H!==void 0&&(iA.args=H),S!==void 0&&(iA.result=S),j!==void 0&&(iA.artifact=j);const UA=IA.startedAt&&Number.isFinite(IA.startedAt)?Math.max(0,p-IA.startedAt):IA.toolDurationMs;return{...IA,type:"tool_result",content:JSON.stringify(iA),contentJson:iA,stepIndex:G??IA.stepIndex??null,completedAt:p,toolName:N??IA.toolName,toolDurationMs:UA??null}});return _?{...R,parts:tA}:R});return E?U:b})},W=B=>{const d=u(B);d&&t.setQueryData(["messages",A],N=>{if(!N)return N;let G=!1;const S=N.map(j=>{if(!j.parts?.length)return j;const H=j.parts.filter(b=>!(b.ephemeral&&b.toolCallId===d));return H.length===j.parts.length?j:(G=!0,{...j,parts:H})});return G?S:N})},T=B=>{B&&t.setQueryData(["messages",A],d=>{if(!d)return d;const N=d.findIndex(j=>j.id===B);if(N===-1)return d;const G=d[N];if(!G.parts?.some(j=>j.ephemeral&&j.type==="tool_call"))return d;const S=[...d];return S[N]={...G,parts:G.parts?.filter(j=>!(j.ephemeral&&j.type==="tool_call"))??[]},S})},L=B=>{const d=typeof B?.id=="string"?B.id:null;d&&t.setQueryData(["messages",A],N=>{if(!N)return N;const G=[...N],S=G.findIndex(H=>H.id===d);if(S===-1)return N;const j=G[S];return G[S]={...j,status:"complete",completedAt:Date.now()},G})},w=l.on("*",B=>{const d=B.payload;switch(B.type){case"message.created":{const N=typeof d?.role=="string"?d.role:null,G=typeof d?.id=="string"?d.id:null;if(N==="assistant"&&G&&(n.current=G),G&&N){const S=typeof d?.agent=="string"?d.agent:"",j=typeof d?.provider=="string"?d.provider:"",H=typeof d?.model=="string"?d.model:"",b=typeof d?.content=="string"?d.content:null,E=N==="user"&&b?[{id:`${G}-text`,messageId:G,index:0,stepIndex:null,type:"text",content:JSON.stringify({text:b}),contentJson:{text:b},agent:S,provider:j,model:H,startedAt:Date.now(),completedAt:Date.now(),toolName:null,toolCallId:null,toolDurationMs:null}]:[];t.setQueryData(["messages",A],p=>{if(!p||p.some(_=>_.id===G))return p;const U={id:G,sessionId:A,role:N,status:N==="user"?"complete":"pending",agent:S,provider:j,model:H,createdAt:Date.now(),completedAt:null,latencyMs:null,promptTokens:null,completionTokens:null,totalTokens:null,error:null,parts:E},R=[...p,U];return R.sort((_,tA)=>_.createdAt-tA.createdAt),R})}break}case"message.part.delta":{J(d);break}case"reasoning.delta":{O(d);break}case"message.completed":{const N=typeof d?.id=="string"?d.id:null;N&&n.current===N&&(n.current=null),L(d),T(N),t.invalidateQueries({queryKey:["messages",A]}),t.invalidateQueries({queryKey:fo});break}case"tool.delta":{const N=typeof d?.channel=="string"?d.channel:null,G=N==="output"?v(d):k(d);N==="input"||N==null&&G?G?eA(d,G):V(d):N==="output"&&G&&X(d,G);break}case"tool.call":{V(d);break}case"tool.result":{K(d);break}case"tool.approval.required":{const N=typeof d?.callId=="string"?d.callId:null,G=typeof d?.toolName=="string"?d.toolName:null,S=typeof d?.messageId=="string"?d.messageId:null,j=d?.args;N&&G&&S&&r({callId:N,toolName:G,args:j,messageId:S,createdAt:Date.now()});break}case"tool.approval.resolved":{const N=typeof d?.callId=="string"?d.callId:null;N&&i(N);break}case"tool.approval.updated":{const N=typeof d?.callId=="string"?d.callId:null,G=d?.args;N&&a(N,G);break}case"error":{W(d);const N=typeof d?.messageId=="string"?d.messageId:null;N&&T(N),t.invalidateQueries({queryKey:["messages",A]});break}case"message.updated":{const N=typeof d?.id=="string"?d.id:null,G=typeof d?.status=="string"?d.status:null;N&&G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=S.findIndex(b=>b.id===N);if(j===-1)return S;const H=[...S];return H[j]={...H[j],status:G},H});break}case"queue.updated":{const N={currentMessageId:d?.currentMessageId,queuedMessages:d?.queuedMessages??[],queueLength:d?.queueLength??0};t.setQueryData(["queueState",A],N);break}}if(B.type==="finish-step"){const N=Date.now();N-Q>=2e3&&(Q=N,t.invalidateQueries({queryKey:fo}))}});return()=>{w(),l.disconnect()}},[A,t,r,i,e,g,a])}function u2(A){const{pendingApprovals:e,removePendingApproval:t}=Mr(),s=e,n=x.useCallback(async a=>{if(A)try{await mA.approveToolCall(A,a,!0),t(a)}catch(g){console.error("Failed to approve tool call:",g)}},[A,t]),r=x.useCallback(async a=>{if(A)try{await mA.approveToolCall(A,a,!1),t(a)}catch(g){console.error("Failed to reject tool call:",g)}},[A,t]),i=x.useCallback(async()=>{if(A)try{await Promise.all(s.map(a=>mA.approveToolCall(A,a.callId,!0)));for(const a of s)t(a.callId)}catch(a){console.error("Failed to approve all tool calls:",a)}},[A,s,t]);x.useEffect(()=>{if(!A||s.length===0)return;const a=g=>{if(g.target instanceof HTMLInputElement||g.target instanceof HTMLTextAreaElement||g.target?.isContentEditable)return;const Q=s[0];g.key==="y"||g.key==="Y"?(g.preventDefault(),n(Q.callId)):g.key==="n"||g.key==="N"||g.key==="Escape"?(g.preventDefault(),r(Q.callId)):(g.key==="a"||g.key==="A")&&(g.preventDefault(),i())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[A,s,n,r,i])}const d2=({height:A=22})=>{const e=Math.round(A*2.4686468646864688);return o.jsx("svg",{width:e,height:A,viewBox:"0 0 748 303",fill:"currentColor",className:"text-foreground","aria-label":"otto",role:"img",children:o.jsx("path",{d:"M192.877 257.682C192.877 263.287 191.783 268.551 189.596 273.473C187.545 278.395 184.674 282.701 180.982 286.393C177.428 289.947 173.189 292.818 168.268 295.006C163.482 297.057 158.287 298.082 152.682 298.082H44.1953C38.7266 298.082 33.5312 297.057 28.6094 295.006C23.6875 292.818 19.3809 289.947 15.6895 286.393C12.1348 282.701 9.26367 278.395 7.07617 273.473C5.02539 268.551 4 263.287 4 257.682V120.074C4 114.469 5.02539 109.205 7.07617 104.283C9.26367 99.3613 12.1348 95.123 15.6895 91.5684C19.3809 87.877 23.6875 85.0059 28.6094 82.9551C33.5312 80.7676 38.7266 79.6738 44.1953 79.6738H152.682C158.287 79.6738 163.482 80.7676 168.268 82.9551C173.189 85.0059 177.428 87.877 180.982 91.5684C184.674 95.123 187.545 99.3613 189.596 104.283C191.783 109.205 192.877 114.469 192.877 120.074V257.682ZM44.1953 120.074V257.682H152.682V120.074H44.1953ZM331.715 4V298.082H289.674V46.041H239.225V4H331.715ZM478.961 4V298.082H436.92V46.041H386.471V4H478.961ZM743.717 257.682C743.717 263.287 742.623 268.551 740.436 273.473C738.385 278.395 735.514 282.701 731.822 286.393C728.268 289.947 724.029 292.818 719.107 295.006C714.322 297.057 709.127 298.082 703.521 298.082H595.035C589.566 298.082 584.371 297.057 579.449 295.006C574.527 292.818 570.221 289.947 566.529 286.393C562.975 282.701 560.104 278.395 557.916 273.473C555.865 268.551 554.84 263.287 554.84 257.682V120.074C554.84 114.469 555.865 109.205 557.916 104.283C560.104 99.3613 562.975 95.123 566.529 91.5684C570.221 87.877 574.527 85.0059 579.449 82.9551C584.371 80.7676 589.566 79.6738 595.035 79.6738H703.521C709.127 79.6738 714.322 80.7676 719.107 82.9551C724.029 85.0059 728.268 87.877 731.822 91.5684C735.514 95.123 738.385 99.3613 740.436 104.283C742.623 109.205 743.717 114.469 743.717 120.074V257.682ZM595.035 120.074V257.682H703.521V120.074H595.035Z"})})},h2={sm:{ring:48,icon:20,iconSize:16},md:{ring:72,icon:32,iconSize:24},lg:{ring:96,icon:40,iconSize:32}},Ti=x.memo(function({status:e,label:t,sublabel:s,size:n="md"}){const{ring:r,icon:i,iconSize:a}=h2[n],g={position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:r,height:r},Q={content:'""',position:"absolute",inset:0,borderRadius:"50%"},l=()=>e==="success"?"rgb(34, 197, 94)":e==="error"?"rgb(239, 68, 68)":"currentColor";return o.jsxs("div",{className:"flex flex-col items-center justify-center gap-5",children:[o.jsxs("div",{style:g,children:[o.jsx("div",{style:{...Q,border:"2px solid hsl(var(--muted))"}}),e==="loading"&&o.jsx("div",{className:"animate-spin",style:{...Q,border:"2px solid transparent",borderTopColor:"hsl(var(--foreground))",animation:"spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite"}}),e==="success"&&o.jsx("div",{style:{...Q,border:`2px solid ${l()}`,opacity:.3}}),e==="error"&&o.jsx("div",{style:{...Q,border:`2px solid ${l()}`,opacity:.3}}),o.jsxs("div",{style:{position:"relative",zIndex:1},children:[e==="loading"&&o.jsx(d2,{height:Math.round(i*.65)}),e==="success"&&o.jsx(FB,{className:"text-green-500",style:{width:a,height:a}}),e==="error"&&o.jsx(va,{className:"text-red-500",style:{width:a,height:a}})]})]}),t&&o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),s&&o.jsx("span",{className:"text-xs text-muted-foreground",children:s})]})]})}),p2=[10,25,50,100],Oi=5,qi=2,Qs=500,f2=5e3,m2="https://share.ottocode.io/checkout/success";function w2(){return new Promise((A,e)=>{if(window.Razorpay){A();return}const t=document.createElement("script");t.src="https://checkout.razorpay.com/v1/checkout.js",t.onload=()=>A(),t.onerror=()=>e(new Error("Failed to load Razorpay")),document.head.appendChild(t)})}function x2({className:A="w-5 h-5"}){return o.jsxs("svg",{className:A,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("title",{children:"Polar"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.08734 21.1119C10.2671 24.6182 17.3085 23.2616 20.8148 18.0818C24.3211 12.9021 22.9645 5.86065 17.7848 2.35436C12.605 -1.15192 5.56353 0.204698 2.05724 5.38446C-1.44904 10.5642 -0.0924184 17.6057 5.08734 21.1119ZM6.58958 21.2045C11.3278 23.6286 17.3384 21.3531 20.0147 16.1221C22.6909 10.891 21.0194 4.68533 16.2811 2.2612C11.543 -0.162919 5.53235 2.11252 2.8561 7.34355C0.179842 12.5745 1.85138 18.7803 6.58958 21.2045Z"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.93988 22.4416C12.2169 23.8337 17.2485 20.1561 19.1782 14.2276C21.1078 8.29898 19.2047 2.3644 14.9276 0.9723C10.6505 -0.419794 5.61905 3.25775 3.68942 9.18633C1.7598 15.1149 3.6628 21.0495 7.93988 22.4416ZM9.24825 21.991C12.868 22.7631 16.7819 18.796 17.9904 13.1305C19.1988 7.46494 17.244 2.24622 13.6243 1.47416C10.0046 0.702105 6.09064 4.66908 4.88222 10.3347C3.67381 16.0002 5.62854 21.2189 9.24825 21.991Z"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2406 22.9252C13.1024 23.2308 15.9585 18.4574 16.6199 12.2635C17.2812 6.06969 15.4974 0.800854 12.6356 0.495275C9.77386 0.189695 6.91772 4.96309 6.25634 11.157C5.59498 17.3508 7.37878 22.6196 10.2406 22.9252ZM11.5798 21.04C13.6508 21.0073 15.264 16.8146 15.1828 11.6754C15.1017 6.53608 13.3568 2.39642 11.2858 2.42914C9.21463 2.46187 7.60148 6.65457 7.68268 11.7939C7.76387 16.9331 9.50864 21.0727 11.5798 21.04Z"})]})}function D2({className:A="w-5 h-5"}){return o.jsxs("svg",{className:A,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("title",{children:"Razorpay"}),o.jsx("path",{d:"M22.436 0l-11.91 7.773-1.174 4.276 6.625-4.297L11.65 24h4.391l6.395-24zM14.26 10.098L3.389 17.166 1.564 24h9.008l3.688-13.902Z"})]})}const yg=x.memo(function(){const e=Ne(kA=>kA.isTopupModalOpen),t=Ne(kA=>kA.closeTopupModal),s=Ne(kA=>kA.balance),n=Ne(kA=>kA.setBalance),r=Ne(kA=>kA.usdcBalance),i=Ne(kA=>kA.subscription),[a,g]=x.useState("amount"),[Q,l]=x.useState("polar"),[C,I]=x.useState(25),[c,u]=x.useState(""),[f,h]=x.useState(!1),[k,v]=x.useState(null),[D,O]=x.useState(null),[J,V]=x.useState(!1),[eA,X]=x.useState(!1),[K,W]=x.useState(null),[T,L]=x.useState(!1),[w,B]=x.useState(null),[d,N]=x.useState(0),[G,S]=x.useState(!1),j=x.useRef(null),H=f?parseFloat(c)||0:C,b=!!i?.active,E=Q==="razorpay"?qi:Oi,p=x.useCallback(async kA=>{if(kA<E||kA>Qs){v(null),O(null);return}V(!0);try{if(Q==="polar"){const VA=await mA.getPolarTopupEstimate(kA);v(VA),O(null)}else{const VA=await mA.getRazorpayTopupEstimate(kA);O(VA),v(null)}}catch{v(null),O(null)}finally{V(!1)}},[Q,E]);x.useEffect(()=>{if(e&&H>=E&&a==="amount"){const kA=setTimeout(()=>p(H),300);return()=>clearTimeout(kA)}},[e,H,p,a,E]);const U=x.useCallback(()=>{j.current&&(clearInterval(j.current),j.current=null),L(!1)},[]);x.useEffect(()=>{e||(U(),g("amount"),W(null),B(null),N(0))},[e,U]),x.useEffect(()=>()=>U(),[U]);const R=x.useCallback(kA=>{if(j.current)return;L(!0),N(0);const VA=async()=>{try{const ae=await mA.getPolarTopupStatus(kA);if(N(He=>He+1),ae?.confirmed){U(),B(ae.amountUsd),localStorage.removeItem("pendingPolarCheckout");const He=await mA.getOttoRouterBalance();He?.balance!==void 0&&n(He.balance),g("confirmed")}}catch{N(ae=>ae+1)}};VA(),j.current=setInterval(VA,f2)},[U,n]),_=kA=>{I(kA),h(!1),u("")},tA=kA=>{u(kA),h(!0)},IA=x.useCallback(kA=>{window.self!==window.top?window.parent.postMessage({type:"otto-open-url",url:kA},"*"):window.open(kA,"_blank")},[]),iA=async()=>{if(H<Oi||H>Qs){de.error(`Amount must be between $${Oi} and $${Qs}`);return}X(!0);try{const kA=await mA.createPolarCheckout(H,m2);if(kA.checkoutUrl&&kA.checkoutId){const VA={url:kA.checkoutUrl,checkoutId:kA.checkoutId,creditAmount:kA.creditAmount,chargeAmount:kA.chargeAmount};W(VA),localStorage.setItem("pendingPolarCheckout",kA.checkoutId),g("checkout"),IA(kA.checkoutUrl),R(kA.checkoutId)}}catch(kA){de.error(kA instanceof Error?kA.message:"Failed to create checkout")}finally{X(!1)}},UA=async()=>{if(H<qi||H>Qs){de.error(`Amount must be between $${qi} and $${Qs}`);return}X(!0);try{await w2();const kA=await mA.createRazorpayOrder(H);g("razorpay-processing");const VA=new window.Razorpay({key:kA.keyId,amount:kA.amount,currency:kA.currency,name:"Setu",description:`Top up $${kA.creditAmountUsd.toFixed(2)} credits`,order_id:kA.orderId,handler:async ae=>{try{const He=await mA.verifyRazorpayPayment({razorpay_order_id:ae.razorpay_order_id,razorpay_payment_id:ae.razorpay_payment_id,razorpay_signature:ae.razorpay_signature});if(He.success){B(He.credited);const le=await mA.getOttoRouterBalance();le?.balance!==void 0&&n(le.balance),g("confirmed")}}catch(He){de.error(He instanceof Error?He.message:"Payment verification failed"),g("amount")}},modal:{ondismiss:()=>{g("amount")}},theme:{color:"#7c3aed"}});VA.on("payment.failed",()=>{de.error("Payment failed. Please try again."),g("amount")}),VA.open()}catch(kA){de.error(kA instanceof Error?kA.message:"Failed to create order"),g("amount")}finally{X(!1)}},HA=()=>{Q==="polar"?iA():UA()},lA=async()=>{if(K){S(!0);try{const kA=await mA.getPolarTopupStatus(K.checkoutId);if(kA?.confirmed){U(),B(kA.amountUsd),localStorage.removeItem("pendingPolarCheckout");const VA=await mA.getOttoRouterBalance();VA?.balance!==void 0&&n(VA.balance),g("confirmed")}else de.error("Payment not confirmed yet. Keep waiting or try again.")}catch(kA){console.error("[OttoRouterTopupModal] Check failed:",kA),de.error("Failed to check payment status")}finally{S(!1)}}},qA=()=>{t()},re=H>=E&&H<=Qs,he=a==="confirmed"?"Payment Confirmed":a==="checkout"?"Waiting for Payment":a==="razorpay-processing"?"Processing Payment":"Add Credits";return o.jsx(Po,{isOpen:e,onClose:t,title:he,maxWidth:"md",children:o.jsxs("div",{className:"space-y-6",children:[a==="confirmed"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"py-4",children:o.jsx(Ti,{status:"success",label:`+$${w?.toFixed(2)??K?.creditAmount.toFixed(2)}`,sublabel:"Credits added to your balance"})}),o.jsx("button",{type:"button",onClick:qA,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors flex items-center justify-center gap-2",children:"Done"})]}),a==="razorpay-processing"&&o.jsx("div",{className:"py-8",children:o.jsx(Ti,{status:"loading",label:"Complete payment in the Razorpay window",sublabel:"Do not close this page"})}),a==="checkout"&&K&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"py-4",children:[o.jsx(Ti,{status:"loading",label:"Complete your payment",sublabel:"A checkout window has been opened"}),o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4 px-3 py-1.5 bg-muted/40 rounded-full w-fit mx-auto",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),o.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:T?`Checking... (${d})`:"Paused"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:lA,disabled:G,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:[G?o.jsx(Le,{className:"w-4 h-4 animate-spin"}):o.jsx(Vt,{className:"w-4 h-4"}),G?"Checking...":"Check Now"]}),o.jsxs("button",{type:"button",onClick:()=>IA(K.url),className:"w-full h-11 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors flex items-center justify-center gap-2",children:[o.jsx(vt,{className:"w-4 h-4"}),"Open Checkout Again"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Status checks automatically every 5 seconds. You can close this and it will keep checking."})]}),a==="amount"&&o.jsxs(o.Fragment,{children:[b&&o.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 border border-border rounded-lg px-3 py-2",children:"You are on GO. Top-ups add extra balance for additional usage."}),o.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-muted/40 rounded-lg",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Balance"}),o.jsxs("span",{className:"text-lg font-mono font-semibold",children:["$",s?.toFixed(2)??"0.00"]})]}),o.jsxs("div",{className:"flex rounded-lg border border-border overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>l("polar"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-sm font-medium transition-colors ${Q==="polar"?"bg-foreground text-background":"bg-transparent text-muted-foreground hover:text-foreground"}`,children:[o.jsx(x2,{className:"w-3.5 h-3.5"}),"Polar"]}),o.jsxs("button",{type:"button",onClick:()=>l("razorpay"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-sm font-medium transition-colors ${Q==="razorpay"?"bg-foreground text-background":"bg-transparent text-muted-foreground hover:text-foreground"}`,children:[o.jsx(D2,{className:"w-3.5 h-3.5"}),"Razorpay"]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-4 gap-2",children:p2.map(kA=>o.jsxs("button",{type:"button",onClick:()=>_(kA),className:`h-12 text-base font-mono rounded-lg border-2 transition-all ${!f&&C===kA?"bg-foreground text-background border-foreground":"bg-transparent border-border text-foreground hover:border-foreground/40"}`,children:["$",kA]},kA))}),o.jsxs("div",{className:"relative",children:[o.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground text-lg",children:"$"}),o.jsx("input",{type:"number",placeholder:"Custom",value:c,onChange:kA=>tA(kA.target.value),onFocus:()=>h(!0),min:E,max:Qs,step:"1",className:`w-full h-12 pl-8 pr-4 text-base font-mono bg-transparent border-2 rounded-lg outline-none transition-all ${f?"border-foreground":"border-border focus:border-foreground/40"}`})]})]}),o.jsx("div",{className:`grid transition-all duration-200 ease-out ${re?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"}`,children:o.jsx("div",{className:"overflow-hidden",children:o.jsx("div",{className:"space-y-3 py-4 border-t border-border",children:J?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsx("div",{className:"h-6 w-16 bg-muted/60 rounded animate-pulse"})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsx("div",{className:"h-4 w-12 bg-muted/60 rounded animate-pulse"})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsx("div",{className:"h-7 w-20 bg-muted/60 rounded animate-pulse"})]})]}):Q==="polar"&&k?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsxs("span",{className:"font-mono text-lg",children:["$",k.creditAmount.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["+$",k.feeAmount.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsxs("span",{className:"font-mono text-xl font-semibold",children:["$",k.chargeAmount.toFixed(2)]})]})]}):Q==="razorpay"&&D?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsxs("span",{className:"font-mono text-lg",children:["$",D.creditAmountUsd.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["+₹",D.feeAmountInr.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsxs("span",{className:"font-mono text-xl font-semibold",children:["₹",D.chargeAmountInr.toFixed(2)]})]}),o.jsxs("p",{className:"text-[10px] text-muted-foreground text-right",children:["1 USD ≈ ",D.exchangeRate," INR"]})]}):null})})}),o.jsxs("button",{type:"button",onClick:HA,disabled:!re||eA,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[eA?o.jsx(Le,{className:"w-4 h-4 animate-spin"}):o.jsx(fr,{className:"w-4 h-4"}),Q==="polar"?"Pay with Card":"Pay with Razorpay"]}),o.jsxs("div",{className:"relative pt-6",children:[o.jsxs("div",{className:"absolute inset-x-0 top-0 flex items-center",children:[o.jsx("div",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:"px-3 text-xs text-muted-foreground",children:"OR"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),o.jsxs("div",{className:"flex items-start gap-3 p-4 bg-muted/30 rounded-lg",children:[o.jsx(Ja,{className:"w-5 h-5 text-muted-foreground mt-0.5"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-sm",children:"Pay with USDC"}),r!==null&&o.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[r.toFixed(2)," USDC"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Send USDC to your Setu wallet to increase balance."})]})]})]})]})]})})}),y2=x.memo(function({sessionId:e,onSelectSession:t}){const{data:s=[],isLoading:n}=Qa(e),{data:r=[]}=Hn(),{preferences:i}=Zs();lE(e),u2(e);const a=x.useMemo(()=>r.find(Q=>Q.id===e),[r,e]),g=x.useMemo(()=>s.some(Q=>Q.role==="assistant"&&Q.status==="pending"),[s]);return n?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):o.jsxs(o.Fragment,{children:[o.jsx(I2,{messages:s,sessionId:e,session:a,isGenerating:g,compact:i.compactThread,onSelectSession:t}),o.jsx(yg,{})]})}),lB=1440*60*1e3;function N2(A){const e=Date.now()-A,t=Math.floor(e/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const s=Math.floor(t/60);if(s<24)return`${s}h ago`;const n=Math.floor(s/24);if(n<7)return`${n}d ago`;const r=Math.floor(n/7);if(r<5)return`${r}w ago`;const i=Math.floor(n/30);return i<12?`${i}mo ago`:`${Math.floor(n/365)}y ago`}function k2(A){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=t-lB,n=t-lB*7;return A>=t?"Today":A>=s?"Yesterday":A>=n?"Earlier":"Older"}const M2=x.memo(function({session:e,isActive:t,onClick:s}){const n=e.title||`Session ${e.id.slice(0,8)}`,r=e.isRunning??!1,i=e.lastActiveAt??e.createdAt,a=N2(i);return o.jsx("button",{type:"button",onClick:s,className:`w-full text-left px-3 py-2.5 rounded-lg transition-colors duration-150 ${t?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground hover:bg-sidebar-accent/50"}`,title:`${n} — ${a}`,children:o.jsxs("span",{className:"block min-w-0",children:[o.jsx("span",{className:`block truncate text-[13px] leading-5 ${t?"font-medium":"font-normal"}`,children:n}),o.jsxs("span",{className:"mt-0.5 flex items-center justify-between gap-3 text-[11px] leading-4 text-sidebar-muted-foreground",children:[o.jsx("span",{className:"truncate",children:a}),o.jsxs("span",{className:"relative flex h-2 w-2 shrink-0",children:[r&&o.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),o.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${r?"bg-emerald-500":"bg-sidebar-muted-foreground/35"}`})]})]})]})})}),Ng=ht(A=>({currentFocus:null,sessionIndex:0,gitFileIndex:0,setFocus:e=>A({currentFocus:e}),setSessionIndex:e=>A({sessionIndex:e}),setGitFileIndex:e=>A({gitFileIndex:e}),resetGitFileIndex:()=>A({gitFileIndex:0}),resetSessionIndex:()=>A({sessionIndex:0})})),b2=x.memo(function({activeSessionId:e,onSelectSession:t}){const{data:s=[],isLoading:n,hasNextPage:r,fetchNextPage:i,isFetchingNextPage:a}=Hn(),{currentFocus:g,sessionIndex:Q}=Ng(),l=x.useRef(new Map),C=x.useRef(null),I=x.useRef(void 0),c=x.useCallback(v=>{I.current=v,t(v)},[t]),u=x.useMemo(()=>s.map((v,D)=>({id:v.id,index:D,title:v.title,agent:v.agent,createdAt:v.createdAt,lastActiveAt:v.lastActiveAt,activityAt:v.lastActiveAt??v.createdAt})),[s]),f=x.useMemo(()=>new Map(s.map(v=>[v.id,v])),[s]),h=x.useMemo(()=>{const v=new Map;for(const D of u){const O=k2(D.activityAt),J=v.get(O)??[];J.push(D),v.set(O,J)}return Array.from(v.entries()).map(([D,O])=>({label:D,sessions:O}))},[u]);if(x.useEffect(()=>{if(g==="sessions"){const v=u[Q];v&&l.current.get(v.id)?.scrollIntoView({block:"nearest",behavior:"smooth"})}},[g,Q,u]),x.useEffect(()=>{if(!e||I.current===e||s.length===0)return;const v=s.findIndex(D=>D.id===e);if(v===-1&&r){i();return}v!==-1&&(I.current=e,requestAnimationFrame(()=>{l.current.get(e)?.scrollIntoView({block:"nearest",behavior:"smooth"})}))},[e,s,r,i]),x.useEffect(()=>{const v=C.current;if(!v)return;const D=()=>{const{scrollTop:O,scrollHeight:J,clientHeight:V}=v;J-O-V<100&&r&&!a&&i()};return v.addEventListener("scroll",D,{passive:!0}),()=>v.removeEventListener("scroll",D)},[r,a,i]),n)return o.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"})]});if(u.length===0)return o.jsx("div",{className:"px-4 py-8 text-center text-sm text-sidebar-muted-foreground",children:"No sessions yet. Create one to get started."});const k=v=>{const D=f.get(v.id);if(!D)return null;const O=g==="sessions"&&Q===v.index;return o.jsx("div",{ref:J=>{J?l.current.set(v.id,J):l.current.delete(v.id)},className:O?"ring-1 ring-sidebar-ring/40 rounded-md":"",children:o.jsx(M2,{session:D,isActive:v.id===e,onClick:()=>c(v.id)})},v.id)};return o.jsxs("div",{ref:C,className:"flex flex-col h-full overflow-y-auto scrollbar-hide",children:[o.jsx("div",{className:"h-14 shrink-0","aria-hidden":"true"}),h.length>0&&o.jsx("div",{className:"px-3 pt-3 pb-1",children:o.jsx("div",{className:"space-y-3",children:h.map(v=>o.jsxs("div",{children:[o.jsx("h4",{className:"sticky top-14 z-10 px-3 py-2 mb-1 text-[11px] font-medium uppercase tracking-[0.18em] text-sidebar-muted-foreground/80 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/75",children:v.label}),o.jsx("div",{className:"flex flex-col gap-1",children:v.sessions.map(D=>k(D))})]},v.label))})}),a&&o.jsx("div",{className:"flex justify-center py-3",children:o.jsx(Le,{className:"h-4 w-4 animate-spin text-sidebar-muted-foreground"})})]})}),F2=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function G2(A){const e=A.split(".").pop()?.toLowerCase()??"";return F2.has(e)}const v2={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 S2(A){const e=A.split(".").pop()?.toLowerCase()??"";return e?v2[e]??"plaintext":"plaintext"}function U2(A){const e=A.split("/");return e[e.length-1]}function R2({diff:A}){const e=document?.documentElement.classList.contains("dark")?Eo:Co,t=A.language&&A.language.trim().length>0?A.language:S2(A.file),s=U2(A.file);if(A.isNewFile&&A.content)return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[o.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:A.file,children:s}),o.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[o.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",A.insertions]}),o.jsx("span",{className:"text-muted-foreground",children:t})]})]}),o.jsx("div",{className:"px-4 py-3 bg-green-500/10 border-b border-green-500/20",children:o.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:["New file: ",A.insertions," lines"]})}),o.jsx("div",{className:"flex-1 overflow-auto",children:o.jsx("div",{className:"code-with-line-numbers",children:o.jsx(qt,{language:t,style:e,wrapLines:!0,wrapLongLines:!0,lineProps:()=>({className:"code-line"}),customStyle:{margin:0,padding:"1rem",background:"transparent"},codeTagProps:{style:{flex:1}},children:A.content})})})]});if(A.isBinary){const l=G2(A.file)?`${Dl()}/v1/files/raw?path=${encodeURIComponent(A.file)}`:null;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[o.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:A.file,children:s}),o.jsx("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:o.jsx("span",{className:"text-muted-foreground",children:"Binary file"})})]}),l?o.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-auto",children:o.jsx("img",{src:l,alt:s,className:"max-w-full max-h-[60vh] object-contain rounded border border-border"})}):o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx("div",{className:"p-4 text-center",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Binary file - cannot display diff"})})})]})}const n=A.diff.split(`
119
+ `)}}}catch(s){s instanceof Error&&s.name==="AbortError"||s instanceof TypeError&&s.message==="Load failed"||console.error("[SSE] Connection error:",s)}}disconnect(){this.running=!1,this.abortController&&(this.abortController.abort(),this.abortController=null)}on(e,t){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e)?.add(t),()=>{this.off(e,t)}}off(e,t){const s=this.handlers.get(e);s&&(s.delete(t),s.size===0&&this.handlers.delete(e))}emit(e){const t=this.handlers.get(e.type);if(t)for(const n of t)n(e);const s=this.handlers.get("*");if(s)for(const n of s)n(e)}}function lE(A,e=!0){const t=ke(),s=x.useRef(null),n=x.useRef(null),{addPendingApproval:r,removePendingApproval:i,updatePendingApproval:a,setPendingApprovals:g}=Mr();x.useEffect(()=>{if(!A||!e)return;n.current=null;let Q=0;mA.getPendingApprovals(A).then(B=>{B.ok&&B.pending.length>0?g(B.pending):g([])}).catch(()=>{g([])});const l=new BE;s.current=l;const C=mA.getStreamUrl(A);console.log("[useSessionStream] Connecting to stream:",C),l.connect(C);const I=B=>{if(n.current){const d=B.findIndex(N=>N.id===n.current);if(d!==-1)return d}for(let d=B.length-1;d>=0;d-=1){const N=B[d];if(N.role==="assistant"&&N.status!=="complete")return d}return-1},c=B=>{if(B.contentJson&&typeof B.contentJson=="object"&&!Array.isArray(B.contentJson)&&"text"in B.contentJson)return String(B.contentJson.text??"");if(typeof B.content=="string"){try{const d=JSON.parse(B.content);if(d&&typeof d.text=="string")return d.text}catch{}return B.content}return""},u=B=>typeof B?.callId=="string"?B.callId:typeof B?.toolCallId=="string"?B.toolCallId:null,f=B=>typeof B?.name=="string"?B.name:typeof B?.toolName=="string"?B.toolName:null,h=B=>B?.args??B?.input,k=B=>typeof B?.delta=="string"?B.delta:typeof B?.inputTextDelta=="string"?B.inputTextDelta:null,v=B=>typeof B?.delta=="string"?B.delta:typeof B?.outputTextDelta=="string"?B.outputTextDelta:null,D=(B,d)=>{const N=(()=>{const S=B.map(j=>j.index).filter(j=>Number.isFinite(j));return S.length>0?Math.max(...S)+.001:0})();if(typeof d!="number")return N;const G=B.filter(S=>S.stepIndex===d).map(S=>S.index).filter(S=>Number.isFinite(S));return G.length>0?Math.max(...G)+.001:N},O=B=>{const d=typeof B?.messageId=="string"?B.messageId:null,N=typeof B?.partId=="string"?B.partId:null,G=typeof B?.delta=="string"?B.delta:null;!d||!N||G===null||t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S],H=j.findIndex(R=>R.id===d);if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=E.findIndex(R=>R.id===N);const U=typeof B?.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={id:N,messageId:d,index:D(E,U),stepIndex:U,type:"reasoning",content:JSON.stringify({text:G}),contentJson:{text:G},agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};E.push(R),p=E.length-1}else{const R=E[p],tA=`${c(R)}${G}`;E[p]={...R,content:JSON.stringify({text:tA}),contentJson:{text:tA},stepIndex:U??R.stepIndex??null,completedAt:null}}return j[H]={...b,parts:E},j})},J=B=>{const d=typeof B?.messageId=="string"?B.messageId:null,N=typeof B?.partId=="string"?B.partId:null,G=typeof B?.delta=="string"?B.delta:null;!d||!N||G===null||t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S],H=j.findIndex(R=>R.id===d);if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=E.findIndex(R=>R.id===N);const U=typeof B?.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={id:N,messageId:d,index:D(E,U),stepIndex:U,type:"text",content:JSON.stringify({text:G}),contentJson:{text:G},agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:null,toolCallId:null,toolDurationMs:null};E.push(R),p=E.length-1}else{const R=E[p],tA=`${c(R)}${G}`;E[p]={...R,content:JSON.stringify({text:tA}),contentJson:{text:tA},stepIndex:U??R.stepIndex??null,completedAt:null}}return j[H]={...b,parts:E},j})},V=B=>{if(!B)return;const d=u(B),N=f(B);N&&t.setQueryData(["messages",A],G=>{if(!G)return G;const S=[...G];let j=I(S);if(typeof B.messageId=="string"){const _=S.findIndex(tA=>tA.id===B.messageId);_!==-1&&(j=_)}if(j===-1)return G;const H=S[j],b=H.parts?[...H.parts]:[];let E=-1;d&&(E=b.findIndex(_=>_.toolCallId===d&&_.ephemeral)),E===-1&&!d&&(E=b.findIndex(_=>_.ephemeral&&_.toolName===N));const p=h(B),U=typeof B.stepIndex=="number"?B.stepIndex:null,R={name:N};if(d&&(R.callId=d),p!==void 0&&(R.args=p),E===-1){const _={id:d?`ephemeral-tool-call-${d}`:`ephemeral-tool-call-${N}-${Date.now()}`,messageId:H.id,index:D(b,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:H.agent,provider:H.provider,model:H.model,startedAt:Date.now(),completedAt:null,toolName:N,toolCallId:d,toolDurationMs:null,ephemeral:!0};b.push(_)}else{const _=b[E],tA={...typeof _.contentJson=="object"&&!Array.isArray(_.contentJson)?_.contentJson:{},name:N};d&&(tA.callId=d),p!==void 0&&(tA.args=p),b[E]={..._,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??_.stepIndex??null,toolCallId:d??_.toolCallId,toolName:N}}return S[j]={...H,parts:b},S})},eA=(B,d)=>{if(!B)return;const N=u(B),G=f(B);G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S];let H=I(j);if(typeof B.messageId=="string"){const R=j.findIndex(_=>_.id===B.messageId);R!==-1&&(H=R)}if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=-1;N&&(p=E.findIndex(R=>R.toolCallId===N&&R.ephemeral)),p===-1&&!N&&(p=E.findIndex(R=>R.ephemeral&&R.toolName===G));const U=typeof B.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={name:G,_streamedInput:d};N&&(R.callId=N);const _={id:N?`ephemeral-tool-call-${N}`:`ephemeral-tool-call-${G}-${Date.now()}`,messageId:b.id,index:D(E,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:G,toolCallId:N,toolDurationMs:null,ephemeral:!0};E.push(_)}else{const R=E[p],_=typeof R.contentJson?._streamedInput=="string"?R.contentJson._streamedInput:"",tA={...typeof R.contentJson=="object"&&!Array.isArray(R.contentJson)?R.contentJson:{},_streamedInput:_+d};E[p]={...R,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??R.stepIndex??null}}return j[H]={...b,parts:E},j})},X=(B,d)=>{if(!B)return;const N=u(B),G=f(B);G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=[...S];let H=I(j);if(typeof B.messageId=="string"){const R=j.findIndex(_=>_.id===B.messageId);R!==-1&&(H=R)}if(H===-1)return S;const b=j[H],E=b.parts?[...b.parts]:[];let p=-1;N&&(p=E.findIndex(R=>R.toolCallId===N&&R.ephemeral)),p===-1&&!N&&(p=E.findIndex(R=>R.ephemeral&&R.toolName===G));const U=typeof B.stepIndex=="number"?B.stepIndex:null;if(p===-1){const R={name:G,_streamedOutput:d};N&&(R.callId=N);const _={id:N?`ephemeral-tool-call-${N}`:`ephemeral-tool-call-${G}-${Date.now()}`,messageId:b.id,index:D(E,U),stepIndex:U,type:"tool_call",content:JSON.stringify(R),contentJson:R,agent:b.agent,provider:b.provider,model:b.model,startedAt:Date.now(),completedAt:null,toolName:G,toolCallId:N,toolDurationMs:null,ephemeral:!0};E.push(_)}else{const R=E[p],_=typeof R.contentJson?._streamedOutput=="string"?R.contentJson._streamedOutput:"",tA={...typeof R.contentJson=="object"&&!Array.isArray(R.contentJson)?R.contentJson:{},_streamedOutput:_+d};E[p]={...R,content:JSON.stringify(tA),contentJson:tA,stepIndex:U??R.stepIndex??null}}return j[H]={...b,parts:E},j})},K=B=>{const d=u(B);if(!d)return;const N=f(B),G=typeof B?.stepIndex=="number"?B.stepIndex:null,S=B?.result,j=B?.artifact,H=h(B);t.setQueryData(["messages",A],b=>{if(!b)return b;let E=!1;const p=Date.now(),U=b.map(R=>{if(!R.parts?.length)return R;let _=!1;const tA=R.parts.map(IA=>{if(!(IA.ephemeral&&IA.toolCallId===d))return IA;_=!0,E=!0;const iA={...typeof IA.contentJson=="object"&&!Array.isArray(IA.contentJson)?IA.contentJson:{},name:N??IA.toolName??"tool",callId:d};H!==void 0&&(iA.args=H),S!==void 0&&(iA.result=S),j!==void 0&&(iA.artifact=j);const UA=IA.startedAt&&Number.isFinite(IA.startedAt)?Math.max(0,p-IA.startedAt):IA.toolDurationMs;return{...IA,type:"tool_result",content:JSON.stringify(iA),contentJson:iA,stepIndex:G??IA.stepIndex??null,completedAt:p,toolName:N??IA.toolName,toolDurationMs:UA??null}});return _?{...R,parts:tA}:R});return E?U:b})},W=B=>{const d=u(B);d&&t.setQueryData(["messages",A],N=>{if(!N)return N;let G=!1;const S=N.map(j=>{if(!j.parts?.length)return j;const H=j.parts.filter(b=>!(b.ephemeral&&b.toolCallId===d));return H.length===j.parts.length?j:(G=!0,{...j,parts:H})});return G?S:N})},T=B=>{B&&t.setQueryData(["messages",A],d=>{if(!d)return d;const N=d.findIndex(j=>j.id===B);if(N===-1)return d;const G=d[N];if(!G.parts?.some(j=>j.ephemeral&&j.type==="tool_call"))return d;const S=[...d];return S[N]={...G,parts:G.parts?.filter(j=>!(j.ephemeral&&j.type==="tool_call"))??[]},S})},L=B=>{const d=typeof B?.id=="string"?B.id:null;d&&t.setQueryData(["messages",A],N=>{if(!N)return N;const G=[...N],S=G.findIndex(H=>H.id===d);if(S===-1)return N;const j=G[S];return G[S]={...j,status:"complete",completedAt:Date.now()},G})},w=l.on("*",B=>{const d=B.payload;switch(B.type){case"message.created":{const N=typeof d?.role=="string"?d.role:null,G=typeof d?.id=="string"?d.id:null;if(N==="assistant"&&G&&(n.current=G),G&&N){const S=typeof d?.agent=="string"?d.agent:"",j=typeof d?.provider=="string"?d.provider:"",H=typeof d?.model=="string"?d.model:"",b=typeof d?.content=="string"?d.content:null,E=N==="user"&&b?[{id:`${G}-text`,messageId:G,index:0,stepIndex:null,type:"text",content:JSON.stringify({text:b}),contentJson:{text:b},agent:S,provider:j,model:H,startedAt:Date.now(),completedAt:Date.now(),toolName:null,toolCallId:null,toolDurationMs:null}]:[];t.setQueryData(["messages",A],p=>{if(!p||p.some(_=>_.id===G))return p;const U={id:G,sessionId:A,role:N,status:N==="user"?"complete":"pending",agent:S,provider:j,model:H,createdAt:Date.now(),completedAt:null,latencyMs:null,promptTokens:null,completionTokens:null,totalTokens:null,error:null,parts:E},R=[...p,U];return R.sort((_,tA)=>_.createdAt-tA.createdAt),R})}break}case"message.part.delta":{J(d);break}case"reasoning.delta":{O(d);break}case"message.completed":{const N=typeof d?.id=="string"?d.id:null;N&&n.current===N&&(n.current=null),L(d),T(N),t.invalidateQueries({queryKey:["messages",A]}),t.invalidateQueries({queryKey:fo});break}case"tool.delta":{const N=typeof d?.channel=="string"?d.channel:null,G=N==="output"?v(d):k(d);N==="input"||N==null&&G?G?eA(d,G):V(d):N==="output"&&G&&X(d,G);break}case"tool.call":{V(d);break}case"tool.result":{K(d);break}case"tool.approval.required":{const N=typeof d?.callId=="string"?d.callId:null,G=typeof d?.toolName=="string"?d.toolName:null,S=typeof d?.messageId=="string"?d.messageId:null,j=d?.args;N&&G&&S&&r({callId:N,toolName:G,args:j,messageId:S,createdAt:Date.now()});break}case"tool.approval.resolved":{const N=typeof d?.callId=="string"?d.callId:null;N&&i(N);break}case"tool.approval.updated":{const N=typeof d?.callId=="string"?d.callId:null,G=d?.args;N&&a(N,G);break}case"error":{W(d);const N=typeof d?.messageId=="string"?d.messageId:null;N&&T(N),t.invalidateQueries({queryKey:["messages",A]});break}case"message.updated":{const N=typeof d?.id=="string"?d.id:null,G=typeof d?.status=="string"?d.status:null;N&&G&&t.setQueryData(["messages",A],S=>{if(!S)return S;const j=S.findIndex(b=>b.id===N);if(j===-1)return S;const H=[...S];return H[j]={...H[j],status:G},H});break}case"queue.updated":{const N={currentMessageId:d?.currentMessageId,queuedMessages:d?.queuedMessages??[],queueLength:d?.queueLength??0};t.setQueryData(["queueState",A],N);break}}if(B.type==="finish-step"){const N=Date.now();N-Q>=2e3&&(Q=N,t.invalidateQueries({queryKey:fo}))}});return()=>{w(),l.disconnect()}},[A,t,r,i,e,g,a])}function u2(A){const{pendingApprovals:e,removePendingApproval:t}=Mr(),s=e,n=x.useCallback(async a=>{if(A)try{await mA.approveToolCall(A,a,!0),t(a)}catch(g){console.error("Failed to approve tool call:",g)}},[A,t]),r=x.useCallback(async a=>{if(A)try{await mA.approveToolCall(A,a,!1),t(a)}catch(g){console.error("Failed to reject tool call:",g)}},[A,t]),i=x.useCallback(async()=>{if(A)try{await Promise.all(s.map(a=>mA.approveToolCall(A,a.callId,!0)));for(const a of s)t(a.callId)}catch(a){console.error("Failed to approve all tool calls:",a)}},[A,s,t]);x.useEffect(()=>{if(!A||s.length===0)return;const a=g=>{if(g.target instanceof HTMLInputElement||g.target instanceof HTMLTextAreaElement||g.target?.isContentEditable)return;const Q=s[0];g.key==="y"||g.key==="Y"?(g.preventDefault(),n(Q.callId)):g.key==="n"||g.key==="N"||g.key==="Escape"?(g.preventDefault(),r(Q.callId)):(g.key==="a"||g.key==="A")&&(g.preventDefault(),i())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[A,s,n,r,i])}const d2=({height:A=22})=>{const e=Math.round(A*2.4686468646864688);return o.jsx("svg",{width:e,height:A,viewBox:"0 0 748 303",fill:"currentColor",className:"text-foreground","aria-label":"otto",role:"img",children:o.jsx("path",{d:"M192.877 257.682C192.877 263.287 191.783 268.551 189.596 273.473C187.545 278.395 184.674 282.701 180.982 286.393C177.428 289.947 173.189 292.818 168.268 295.006C163.482 297.057 158.287 298.082 152.682 298.082H44.1953C38.7266 298.082 33.5312 297.057 28.6094 295.006C23.6875 292.818 19.3809 289.947 15.6895 286.393C12.1348 282.701 9.26367 278.395 7.07617 273.473C5.02539 268.551 4 263.287 4 257.682V120.074C4 114.469 5.02539 109.205 7.07617 104.283C9.26367 99.3613 12.1348 95.123 15.6895 91.5684C19.3809 87.877 23.6875 85.0059 28.6094 82.9551C33.5312 80.7676 38.7266 79.6738 44.1953 79.6738H152.682C158.287 79.6738 163.482 80.7676 168.268 82.9551C173.189 85.0059 177.428 87.877 180.982 91.5684C184.674 95.123 187.545 99.3613 189.596 104.283C191.783 109.205 192.877 114.469 192.877 120.074V257.682ZM44.1953 120.074V257.682H152.682V120.074H44.1953ZM331.715 4V298.082H289.674V46.041H239.225V4H331.715ZM478.961 4V298.082H436.92V46.041H386.471V4H478.961ZM743.717 257.682C743.717 263.287 742.623 268.551 740.436 273.473C738.385 278.395 735.514 282.701 731.822 286.393C728.268 289.947 724.029 292.818 719.107 295.006C714.322 297.057 709.127 298.082 703.521 298.082H595.035C589.566 298.082 584.371 297.057 579.449 295.006C574.527 292.818 570.221 289.947 566.529 286.393C562.975 282.701 560.104 278.395 557.916 273.473C555.865 268.551 554.84 263.287 554.84 257.682V120.074C554.84 114.469 555.865 109.205 557.916 104.283C560.104 99.3613 562.975 95.123 566.529 91.5684C570.221 87.877 574.527 85.0059 579.449 82.9551C584.371 80.7676 589.566 79.6738 595.035 79.6738H703.521C709.127 79.6738 714.322 80.7676 719.107 82.9551C724.029 85.0059 728.268 87.877 731.822 91.5684C735.514 95.123 738.385 99.3613 740.436 104.283C742.623 109.205 743.717 114.469 743.717 120.074V257.682ZM595.035 120.074V257.682H703.521V120.074H595.035Z"})})},h2={sm:{ring:48,icon:20,iconSize:16},md:{ring:72,icon:32,iconSize:24},lg:{ring:96,icon:40,iconSize:32}},Ti=x.memo(function({status:e,label:t,sublabel:s,size:n="md"}){const{ring:r,icon:i,iconSize:a}=h2[n],g={position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:r,height:r},Q={content:'""',position:"absolute",inset:0,borderRadius:"50%"},l=()=>e==="success"?"rgb(34, 197, 94)":e==="error"?"rgb(239, 68, 68)":"currentColor";return o.jsxs("div",{className:"flex flex-col items-center justify-center gap-5",children:[o.jsxs("div",{style:g,children:[o.jsx("div",{style:{...Q,border:"2px solid hsl(var(--muted))"}}),e==="loading"&&o.jsx("div",{className:"animate-spin",style:{...Q,border:"2px solid transparent",borderTopColor:"hsl(var(--foreground))",animation:"spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite"}}),e==="success"&&o.jsx("div",{style:{...Q,border:`2px solid ${l()}`,opacity:.3}}),e==="error"&&o.jsx("div",{style:{...Q,border:`2px solid ${l()}`,opacity:.3}}),o.jsxs("div",{style:{position:"relative",zIndex:1},children:[e==="loading"&&o.jsx(d2,{height:Math.round(i*.65)}),e==="success"&&o.jsx(FB,{className:"text-green-500",style:{width:a,height:a}}),e==="error"&&o.jsx(va,{className:"text-red-500",style:{width:a,height:a}})]})]}),t&&o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),s&&o.jsx("span",{className:"text-xs text-muted-foreground",children:s})]})]})}),p2=[10,25,50,100],Oi=5,qi=2,Qs=500,f2=5e3,m2="https://share.ottocode.io/checkout/success";function w2(){return new Promise((A,e)=>{if(window.Razorpay){A();return}const t=document.createElement("script");t.src="https://checkout.razorpay.com/v1/checkout.js",t.onload=()=>A(),t.onerror=()=>e(new Error("Failed to load Razorpay")),document.head.appendChild(t)})}function x2({className:A="w-5 h-5"}){return o.jsxs("svg",{className:A,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("title",{children:"Polar"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.08734 21.1119C10.2671 24.6182 17.3085 23.2616 20.8148 18.0818C24.3211 12.9021 22.9645 5.86065 17.7848 2.35436C12.605 -1.15192 5.56353 0.204698 2.05724 5.38446C-1.44904 10.5642 -0.0924184 17.6057 5.08734 21.1119ZM6.58958 21.2045C11.3278 23.6286 17.3384 21.3531 20.0147 16.1221C22.6909 10.891 21.0194 4.68533 16.2811 2.2612C11.543 -0.162919 5.53235 2.11252 2.8561 7.34355C0.179842 12.5745 1.85138 18.7803 6.58958 21.2045Z"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.93988 22.4416C12.2169 23.8337 17.2485 20.1561 19.1782 14.2276C21.1078 8.29898 19.2047 2.3644 14.9276 0.9723C10.6505 -0.419794 5.61905 3.25775 3.68942 9.18633C1.7598 15.1149 3.6628 21.0495 7.93988 22.4416ZM9.24825 21.991C12.868 22.7631 16.7819 18.796 17.9904 13.1305C19.1988 7.46494 17.244 2.24622 13.6243 1.47416C10.0046 0.702105 6.09064 4.66908 4.88222 10.3347C3.67381 16.0002 5.62854 21.2189 9.24825 21.991Z"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2406 22.9252C13.1024 23.2308 15.9585 18.4574 16.6199 12.2635C17.2812 6.06969 15.4974 0.800854 12.6356 0.495275C9.77386 0.189695 6.91772 4.96309 6.25634 11.157C5.59498 17.3508 7.37878 22.6196 10.2406 22.9252ZM11.5798 21.04C13.6508 21.0073 15.264 16.8146 15.1828 11.6754C15.1017 6.53608 13.3568 2.39642 11.2858 2.42914C9.21463 2.46187 7.60148 6.65457 7.68268 11.7939C7.76387 16.9331 9.50864 21.0727 11.5798 21.04Z"})]})}function D2({className:A="w-5 h-5"}){return o.jsxs("svg",{className:A,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("title",{children:"Razorpay"}),o.jsx("path",{d:"M22.436 0l-11.91 7.773-1.174 4.276 6.625-4.297L11.65 24h4.391l6.395-24zM14.26 10.098L3.389 17.166 1.564 24h9.008l3.688-13.902Z"})]})}const yg=x.memo(function(){const e=Ne(kA=>kA.isTopupModalOpen),t=Ne(kA=>kA.closeTopupModal),s=Ne(kA=>kA.balance),n=Ne(kA=>kA.setBalance),r=Ne(kA=>kA.usdcBalance),i=Ne(kA=>kA.subscription),[a,g]=x.useState("amount"),[Q,l]=x.useState("polar"),[C,I]=x.useState(25),[c,u]=x.useState(""),[f,h]=x.useState(!1),[k,v]=x.useState(null),[D,O]=x.useState(null),[J,V]=x.useState(!1),[eA,X]=x.useState(!1),[K,W]=x.useState(null),[T,L]=x.useState(!1),[w,B]=x.useState(null),[d,N]=x.useState(0),[G,S]=x.useState(!1),j=x.useRef(null),H=f?parseFloat(c)||0:C,b=!!i?.active,E=Q==="razorpay"?qi:Oi,p=x.useCallback(async kA=>{if(kA<E||kA>Qs){v(null),O(null);return}V(!0);try{if(Q==="polar"){const VA=await mA.getPolarTopupEstimate(kA);v(VA),O(null)}else{const VA=await mA.getRazorpayTopupEstimate(kA);O(VA),v(null)}}catch{v(null),O(null)}finally{V(!1)}},[Q,E]);x.useEffect(()=>{if(e&&H>=E&&a==="amount"){const kA=setTimeout(()=>p(H),300);return()=>clearTimeout(kA)}},[e,H,p,a,E]);const U=x.useCallback(()=>{j.current&&(clearInterval(j.current),j.current=null),L(!1)},[]);x.useEffect(()=>{e||(U(),g("amount"),W(null),B(null),N(0))},[e,U]),x.useEffect(()=>()=>U(),[U]);const R=x.useCallback(kA=>{if(j.current)return;L(!0),N(0);const VA=async()=>{try{const ae=await mA.getPolarTopupStatus(kA);if(N(He=>He+1),ae?.confirmed){U(),B(ae.amountUsd),localStorage.removeItem("pendingPolarCheckout");const He=await mA.getOttoRouterBalance();He?.balance!==void 0&&n(He.balance),g("confirmed")}}catch{N(ae=>ae+1)}};VA(),j.current=setInterval(VA,f2)},[U,n]),_=kA=>{I(kA),h(!1),u("")},tA=kA=>{u(kA),h(!0)},IA=x.useCallback(kA=>{window.self!==window.top?window.parent.postMessage({type:"otto-open-url",url:kA},"*"):window.open(kA,"_blank")},[]),iA=async()=>{if(H<Oi||H>Qs){de.error(`Amount must be between $${Oi} and $${Qs}`);return}X(!0);try{const kA=await mA.createPolarCheckout(H,m2);if(kA.checkoutUrl&&kA.checkoutId){const VA={url:kA.checkoutUrl,checkoutId:kA.checkoutId,creditAmount:kA.creditAmount,chargeAmount:kA.chargeAmount};W(VA),localStorage.setItem("pendingPolarCheckout",kA.checkoutId),g("checkout"),IA(kA.checkoutUrl),R(kA.checkoutId)}}catch(kA){de.error(kA instanceof Error?kA.message:"Failed to create checkout")}finally{X(!1)}},UA=async()=>{if(H<qi||H>Qs){de.error(`Amount must be between $${qi} and $${Qs}`);return}X(!0);try{await w2();const kA=await mA.createRazorpayOrder(H);g("razorpay-processing");const VA=new window.Razorpay({key:kA.keyId,amount:kA.amount,currency:kA.currency,name:"Setu",description:`Top up $${kA.creditAmountUsd.toFixed(2)} credits`,order_id:kA.orderId,handler:async ae=>{try{const He=await mA.verifyRazorpayPayment({razorpay_order_id:ae.razorpay_order_id,razorpay_payment_id:ae.razorpay_payment_id,razorpay_signature:ae.razorpay_signature});if(He.success){B(He.credited);const le=await mA.getOttoRouterBalance();le?.balance!==void 0&&n(le.balance),g("confirmed")}}catch(He){de.error(He instanceof Error?He.message:"Payment verification failed"),g("amount")}},modal:{ondismiss:()=>{g("amount")}},theme:{color:"#7c3aed"}});VA.on("payment.failed",()=>{de.error("Payment failed. Please try again."),g("amount")}),VA.open()}catch(kA){de.error(kA instanceof Error?kA.message:"Failed to create order"),g("amount")}finally{X(!1)}},HA=()=>{Q==="polar"?iA():UA()},lA=async()=>{if(K){S(!0);try{const kA=await mA.getPolarTopupStatus(K.checkoutId);if(kA?.confirmed){U(),B(kA.amountUsd),localStorage.removeItem("pendingPolarCheckout");const VA=await mA.getOttoRouterBalance();VA?.balance!==void 0&&n(VA.balance),g("confirmed")}else de.error("Payment not confirmed yet. Keep waiting or try again.")}catch(kA){console.error("[OttoRouterTopupModal] Check failed:",kA),de.error("Failed to check payment status")}finally{S(!1)}}},qA=()=>{t()},re=H>=E&&H<=Qs,he=a==="confirmed"?"Payment Confirmed":a==="checkout"?"Waiting for Payment":a==="razorpay-processing"?"Processing Payment":"Add Credits";return o.jsx(Po,{isOpen:e,onClose:t,title:he,maxWidth:"md",children:o.jsxs("div",{className:"space-y-6",children:[a==="confirmed"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"py-4",children:o.jsx(Ti,{status:"success",label:`+$${w?.toFixed(2)??K?.creditAmount.toFixed(2)}`,sublabel:"Credits added to your balance"})}),o.jsx("button",{type:"button",onClick:qA,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors flex items-center justify-center gap-2",children:"Done"})]}),a==="razorpay-processing"&&o.jsx("div",{className:"py-8",children:o.jsx(Ti,{status:"loading",label:"Complete payment in the Razorpay window",sublabel:"Do not close this page"})}),a==="checkout"&&K&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"py-4",children:[o.jsx(Ti,{status:"loading",label:"Complete your payment",sublabel:"A checkout window has been opened"}),o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4 px-3 py-1.5 bg-muted/40 rounded-full w-fit mx-auto",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),o.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:T?`Checking... (${d})`:"Paused"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:lA,disabled:G,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:[G?o.jsx(Le,{className:"w-4 h-4 animate-spin"}):o.jsx(Vt,{className:"w-4 h-4"}),G?"Checking...":"Check Now"]}),o.jsxs("button",{type:"button",onClick:()=>IA(K.url),className:"w-full h-11 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors flex items-center justify-center gap-2",children:[o.jsx(vt,{className:"w-4 h-4"}),"Open Checkout Again"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Status checks automatically every 5 seconds. You can close this and it will keep checking."})]}),a==="amount"&&o.jsxs(o.Fragment,{children:[b&&o.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 border border-border rounded-lg px-3 py-2",children:"You are on GO. Top-ups add extra balance for additional usage."}),o.jsxs("div",{className:"flex items-center justify-between py-3 px-4 bg-muted/40 rounded-lg",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Balance"}),o.jsxs("span",{className:"text-lg font-mono font-semibold",children:["$",s?.toFixed(2)??"0.00"]})]}),o.jsxs("div",{className:"flex rounded-lg border border-border overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>l("polar"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-sm font-medium transition-colors ${Q==="polar"?"bg-foreground text-background":"bg-transparent text-muted-foreground hover:text-foreground"}`,children:[o.jsx(x2,{className:"w-3.5 h-3.5"}),"Polar"]}),o.jsxs("button",{type:"button",onClick:()=>l("razorpay"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-sm font-medium transition-colors ${Q==="razorpay"?"bg-foreground text-background":"bg-transparent text-muted-foreground hover:text-foreground"}`,children:[o.jsx(D2,{className:"w-3.5 h-3.5"}),"Razorpay"]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-4 gap-2",children:p2.map(kA=>o.jsxs("button",{type:"button",onClick:()=>_(kA),className:`h-12 text-base font-mono rounded-lg border-2 transition-all ${!f&&C===kA?"bg-foreground text-background border-foreground":"bg-transparent border-border text-foreground hover:border-foreground/40"}`,children:["$",kA]},kA))}),o.jsxs("div",{className:"relative",children:[o.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground text-lg",children:"$"}),o.jsx("input",{type:"number",placeholder:"Custom",value:c,onChange:kA=>tA(kA.target.value),onFocus:()=>h(!0),min:E,max:Qs,step:"1",className:`w-full h-12 pl-8 pr-4 text-base font-mono bg-transparent border-2 rounded-lg outline-none transition-all ${f?"border-foreground":"border-border focus:border-foreground/40"}`})]})]}),o.jsx("div",{className:`grid transition-all duration-200 ease-out ${re?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"}`,children:o.jsx("div",{className:"overflow-hidden",children:o.jsx("div",{className:"space-y-3 py-4 border-t border-border",children:J?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsx("div",{className:"h-6 w-16 bg-muted/60 rounded animate-pulse"})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsx("div",{className:"h-4 w-12 bg-muted/60 rounded animate-pulse"})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsx("div",{className:"h-7 w-20 bg-muted/60 rounded animate-pulse"})]})]}):Q==="polar"&&k?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsxs("span",{className:"font-mono text-lg",children:["$",k.creditAmount.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["+$",k.feeAmount.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsxs("span",{className:"font-mono text-xl font-semibold",children:["$",k.chargeAmount.toFixed(2)]})]})]}):Q==="razorpay"&&D?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Credits"}),o.jsxs("span",{className:"font-mono text-lg",children:["$",D.creditAmountUsd.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Fee"}),o.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["+₹",D.feeAmountInr.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-border",children:[o.jsx("span",{className:"font-medium",children:"Total"}),o.jsxs("span",{className:"font-mono text-xl font-semibold",children:["₹",D.chargeAmountInr.toFixed(2)]})]}),o.jsxs("p",{className:"text-[10px] text-muted-foreground text-right",children:["1 USD ≈ ",D.exchangeRate," INR"]})]}):null})})}),o.jsxs("button",{type:"button",onClick:HA,disabled:!re||eA,className:"w-full h-12 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[eA?o.jsx(Le,{className:"w-4 h-4 animate-spin"}):o.jsx(fr,{className:"w-4 h-4"}),Q==="polar"?"Pay with Card":"Pay with Razorpay"]}),o.jsxs("div",{className:"relative pt-6",children:[o.jsxs("div",{className:"absolute inset-x-0 top-0 flex items-center",children:[o.jsx("div",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:"px-3 text-xs text-muted-foreground",children:"OR"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),o.jsxs("div",{className:"flex items-start gap-3 p-4 bg-muted/30 rounded-lg",children:[o.jsx(Ja,{className:"w-5 h-5 text-muted-foreground mt-0.5"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-sm",children:"Pay with USDC"}),r!==null&&o.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[r.toFixed(2)," USDC"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Send USDC to your Setu wallet to increase balance."})]})]})]})]})]})})}),y2=x.memo(function({sessionId:e,onSelectSession:t}){const{data:s=[],isLoading:n}=Qa(e),{data:r=[]}=Hn(),{preferences:i}=Zs();lE(e),u2(e);const a=x.useMemo(()=>r.find(Q=>Q.id===e),[r,e]),g=x.useMemo(()=>s.some(Q=>Q.role==="assistant"&&Q.status==="pending"),[s]);return n?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Loading messages..."}):o.jsxs(o.Fragment,{children:[o.jsx(I2,{messages:s,sessionId:e,session:a,isGenerating:g,compact:i.compactThread,onSelectSession:t}),o.jsx(yg,{})]})}),lB=1440*60*1e3;function N2(A){const e=Date.now()-A,t=Math.floor(e/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const s=Math.floor(t/60);if(s<24)return`${s}h ago`;const n=Math.floor(s/24);if(n<7)return`${n}d ago`;const r=Math.floor(n/7);if(r<5)return`${r}w ago`;const i=Math.floor(n/30);return i<12?`${i}mo ago`:`${Math.floor(n/365)}y ago`}function k2(A){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=t-lB,n=t-lB*7;return A>=t?"Today":A>=s?"Yesterday":A>=n?"Earlier":"Older"}const M2=x.memo(function({session:e,isActive:t,onClick:s}){const n=e.title||`Session ${e.id.slice(0,8)}`,r=e.isRunning??!1,i=e.lastActiveAt??e.createdAt,a=N2(i);return o.jsx("button",{type:"button",onClick:s,className:`w-full text-left px-3 py-2.5 rounded-lg transition-colors duration-150 ${t?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground hover:bg-sidebar-accent/50"}`,title:`${n} — ${a}`,children:o.jsxs("span",{className:"block min-w-0",children:[o.jsx("span",{className:`block truncate text-[13px] leading-5 ${t?"font-medium":"font-normal"}`,children:n}),o.jsxs("span",{className:"mt-0.5 flex items-center justify-between gap-3 text-[11px] leading-4 text-sidebar-muted-foreground",children:[o.jsx("span",{className:"truncate",children:a}),o.jsxs("span",{className:"relative flex h-2 w-2 shrink-0",children:[r&&o.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),o.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${r?"bg-emerald-500":"bg-sidebar-muted-foreground/35"}`})]})]})]})})}),Ng=ht(A=>({currentFocus:null,sessionIndex:0,gitFileIndex:0,setFocus:e=>A({currentFocus:e}),setSessionIndex:e=>A({sessionIndex:e}),setGitFileIndex:e=>A({gitFileIndex:e}),resetGitFileIndex:()=>A({gitFileIndex:0}),resetSessionIndex:()=>A({sessionIndex:0})})),b2=x.memo(function({activeSessionId:e,onSelectSession:t}){const{data:s=[],isLoading:n,hasNextPage:r,fetchNextPage:i,isFetchingNextPage:a}=Hn(),{currentFocus:g,sessionIndex:Q}=Ng(),l=x.useRef(new Map),C=x.useRef(null),I=x.useRef(void 0),c=x.useCallback(v=>{I.current=v,t(v)},[t]),u=x.useMemo(()=>s.map((v,D)=>({id:v.id,index:D,title:v.title,agent:v.agent,createdAt:v.createdAt,lastActiveAt:v.lastActiveAt,activityAt:v.lastActiveAt??v.createdAt})),[s]),f=x.useMemo(()=>new Map(s.map(v=>[v.id,v])),[s]),h=x.useMemo(()=>{const v=new Map;for(const D of u){const O=k2(D.activityAt),J=v.get(O)??[];J.push(D),v.set(O,J)}return Array.from(v.entries()).map(([D,O])=>({label:D,sessions:O}))},[u]);if(x.useEffect(()=>{if(g==="sessions"){const v=u[Q];v&&l.current.get(v.id)?.scrollIntoView({block:"nearest",behavior:"smooth"})}},[g,Q,u]),x.useEffect(()=>{if(!e||I.current===e||s.length===0)return;const v=s.findIndex(D=>D.id===e);if(v===-1&&r){i();return}v!==-1&&(I.current=e,requestAnimationFrame(()=>{l.current.get(e)?.scrollIntoView({block:"nearest",behavior:"smooth"})}))},[e,s,r,i]),x.useEffect(()=>{const v=C.current;if(!v)return;const D=()=>{const{scrollTop:O,scrollHeight:J,clientHeight:V}=v;J-O-V<100&&r&&!a&&i()};return v.addEventListener("scroll",D,{passive:!0}),()=>v.removeEventListener("scroll",D)},[r,a,i]),n)return o.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"}),o.jsx("div",{className:"h-8 rounded-md bg-sidebar-accent/50 animate-pulse"})]});if(u.length===0)return o.jsx("div",{className:"px-4 py-8 text-center text-sm text-sidebar-muted-foreground",children:"No sessions yet. Create one to get started."});const k=v=>{const D=f.get(v.id);if(!D)return null;const O=g==="sessions"&&Q===v.index;return o.jsx("div",{ref:J=>{J?l.current.set(v.id,J):l.current.delete(v.id)},className:O?"ring-1 ring-sidebar-ring/40 rounded-md":"",children:o.jsx(M2,{session:D,isActive:v.id===e,onClick:()=>c(v.id)})},v.id)};return o.jsxs("div",{ref:C,className:"flex flex-col h-full overflow-y-auto scrollbar-hide",children:[o.jsx("div",{className:"h-14 shrink-0","aria-hidden":"true"}),h.length>0&&o.jsx("div",{className:"px-3 pt-3 pb-1",children:o.jsx("div",{className:"space-y-3",children:h.map(v=>o.jsxs("div",{children:[o.jsx("h4",{className:"sticky top-14 z-10 px-3 py-2 mb-1 text-[11px] font-medium uppercase tracking-[0.18em] text-sidebar-muted-foreground/80 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/75",children:v.label}),o.jsx("div",{className:"flex flex-col gap-1",children:v.sessions.map(D=>k(D))})]},v.label))})}),a&&o.jsx("div",{className:"flex justify-center py-3",children:o.jsx(Le,{className:"h-4 w-4 animate-spin text-sidebar-muted-foreground"})})]})}),F2=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function G2(A){const e=A.split(".").pop()?.toLowerCase()??"";return F2.has(e)}const v2={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 S2(A){const e=A.split(".").pop()?.toLowerCase()??"";return e?v2[e]??"plaintext":"plaintext"}function U2(A){const e=A.split("/");return e[e.length-1]}function R2({diff:A}){const e=document?.documentElement.classList.contains("dark")?Eo:Co,t=A.language&&A.language.trim().length>0?A.language:S2(A.file),s=U2(A.file);if(A.isNewFile&&A.content)return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[o.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:A.file,children:s}),o.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[o.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",A.insertions]}),o.jsx("span",{className:"text-muted-foreground",children:t})]})]}),o.jsx("div",{className:"px-4 py-3 bg-green-500/10 border-b border-green-500/20",children:o.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:["New file: ",A.insertions," lines"]})}),o.jsx("div",{className:"flex-1 overflow-auto",children:o.jsx("div",{className:"code-with-line-numbers",children:o.jsx(qt,{language:t,style:e,wrapLines:!0,wrapLongLines:!0,lineProps:()=>({className:"code-line"}),customStyle:{margin:0,padding:"1rem",background:"transparent"},codeTagProps:{style:{flex:1}},children:A.content})})})]});if(A.isBinary){const l=G2(A.file)?`${Dl()}/v1/files/raw?path=${encodeURIComponent(A.file)}`:null;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[o.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:A.file,children:s}),o.jsx("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:o.jsx("span",{className:"text-muted-foreground",children:"Binary file"})})]}),l?o.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-auto",children:o.jsx("img",{src:l,alt:s,className:"max-w-full max-h-[60vh] object-contain rounded border border-border"})}):o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx("div",{className:"p-4 text-center",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Binary file - cannot display diff"})})})]})}const n=A.diff.split(`
120
120
  `),r=[];let i=0,a=0;for(const Q of n)if(Q.startsWith("@@")){const l=Q.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);l&&(i=parseInt(l[1],10),a=parseInt(l[2],10)),r.push({oldLineNumber:null,newLineNumber:null,content:Q,codeContent:Q,type:"hunk"})}else Q.startsWith("diff")||Q.startsWith("index")||Q.startsWith("---")||Q.startsWith("+++")?r.push({oldLineNumber:null,newLineNumber:null,content:Q,codeContent:Q,type:"meta"}):Q.startsWith("+")?(r.push({oldLineNumber:null,newLineNumber:a,content:Q,codeContent:Q.slice(1),type:"add"}),a++):Q.startsWith("-")?(r.push({oldLineNumber:i,newLineNumber:null,content:Q,codeContent:Q.slice(1),type:"delete"}),i++):(r.push({oldLineNumber:i,newLineNumber:a,content:Q,codeContent:Q,type:"context"}),i++,a++);const g=(Q,l)=>{let C="flex hover:bg-muted/20",I="flex-shrink-0 w-20 px-2 py-0.5 text-xs font-mono select-none border-r border-border",c="flex-1 px-4 py-0.5 font-mono text-xs overflow-x-auto";Q.type==="hunk"?(C+=" bg-blue-500/10",I+=" text-blue-600 dark:text-blue-400",c+=" text-blue-600 dark:text-blue-400 font-semibold"):Q.type==="add"?(C+=" bg-green-500/10",I+=" text-green-700 dark:text-green-400",c+=" text-green-700 dark:text-green-400"):Q.type==="delete"?(C+=" bg-red-500/10",I+=" text-red-600 dark:text-red-400",c+=" text-red-600 dark:text-red-400"):Q.type==="meta"?(c+=" text-muted-foreground",I+=" text-muted-foreground"):(c+=" text-foreground/80",I+=" text-muted-foreground");const u=Q.oldLineNumber!==null?Q.oldLineNumber.toString():"",f=Q.newLineNumber!==null?Q.newLineNumber.toString():"";let h=Q.content||" ";return Q.type!=="meta"&&Q.type!=="hunk"&&t!=="plaintext"&&Q.codeContent.trim()&&(h=o.jsx(qt,{language:t,style:e,customStyle:{margin:0,padding:0,background:"transparent",display:"inline",fontSize:"inherit",lineHeight:"inherit"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent"}},PreTag:"span",children:Q.codeContent}),Q.type==="add"?h=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"select-none",children:"+"}),h]}):Q.type==="delete"&&(h=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"select-none",children:"-"}),h]}))),o.jsxs("div",{className:C,children:[o.jsx("div",{className:I,"aria-hidden":"true",style:{pointerEvents:"none"},children:o.jsxs("div",{className:"flex justify-between gap-2",children:[o.jsx("span",{className:"text-right w-8",children:u}),o.jsx("span",{className:"text-right w-8",children:f})]})}),o.jsx("div",{className:c,children:h})]},l)};return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"px-4 py-2 bg-muted/50 flex items-center justify-between min-h-10",children:[o.jsx("span",{className:"font-mono text-sm text-foreground truncate",title:A.file,children:s}),o.jsxs("div",{className:"flex items-center gap-3 text-xs flex-shrink-0",children:[A.insertions>0&&o.jsxs("span",{className:"text-green-600 dark:text-green-500",children:["+",A.insertions]}),A.deletions>0&&o.jsxs("span",{className:"text-red-600 dark:text-red-500",children:["-",A.deletions]}),o.jsx("span",{className:"text-muted-foreground",children:t})]})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:A.diff.trim()===""?o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No changes to display"}):o.jsx("div",{className:"min-w-max",children:r.map(g)})})]})}function K2(A,e=2){const t=A.split("/");return t.length<=e+1?A:`../${t.slice(-e).join("/")}`}function $r({file:A,staged:e,showModifiedIndicator:t=!1}){const{openDiff:s}=Te(),n=Wn(),r=og(),i=jl(),a=Tl(),g=za(D=>D.openConfirmation),[Q,l]=x.useState(e),C=async D=>{D.stopPropagation();const O=D.target.checked;l(O);try{O?await n.mutateAsync([A.path]):await r.mutateAsync([A.path])}catch(J){l(!O),console.error("Failed to stage/unstage file:",J)}},I=async D=>{D.stopPropagation(),g({title:"Restore File",message:`Restore ${A.path} to HEAD state? This will discard all changes.`,confirmLabel:"Restore",variant:"destructive",onConfirm:async()=>{try{await i.mutateAsync([A.path])}catch(O){throw console.error("Failed to restore file:",O),O}}})},c=async D=>{D.stopPropagation(),g({title:"Delete File",message:`Delete ${A.path}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{try{await a.mutateAsync([A.path])}catch(O){throw console.error("Failed to delete file:",O),O}}})},u=()=>{s(A.path,e)},h=(()=>{switch(A.status){case"added":case"untracked":return{icon:YB,color:"text-green-500",label:"A",labelColor:"text-green-500"};case"deleted":return{icon:gC,color:"text-red-500",label:"D",labelColor:"text-red-500"};case"modified":return{icon:es,color:"text-blue-500",label:"M",labelColor:"text-blue-500"};case"renamed":return{icon:es,color:"text-purple-500",label:"R",labelColor:"text-purple-500"};case"conflicted":return{icon:qB,color:"text-red-500",label:"C",labelColor:"text-red-500"};default:return{icon:es,color:"text-muted-foreground",label:"?",labelColor:"text-muted-foreground"}}})(),k=h.icon,v=K2(A.path,2);return o.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-1.5 hover:bg-muted/50 cursor-pointer group transition-colors w-full text-left h-9",onClick:u,children:[o.jsx("input",{type:"checkbox",checked:Q,onChange:C,onClick:D=>D.stopPropagation(),className:"w-4 h-4 rounded border-border","aria-label":`${Q?"Unstage":"Stage"} ${A.path}`}),o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx(k,{className:`w-4 h-4 flex-shrink-0 ${h.color}`}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-foreground font-mono truncate",title:`${A.path}
121
121
  ${A.absPath}`,children:v}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("span",{className:`text-xs font-semibold ${h.labelColor}`,children:h.label}),t&&o.jsx("div",{title:"Also modified in working directory",children:o.jsx(wo,{className:"w-3.5 h-3.5 text-orange-500"})})]})]})})]}),A.insertions!==void 0||A.deletions!==void 0?o.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[A.insertions!==void 0&&A.insertions>0&&o.jsxs("span",{className:"text-green-500",children:["+",A.insertions]}),A.deletions!==void 0&&A.deletions>0&&o.jsxs("span",{className:"text-red-500",children:["-",A.deletions]})]}):null,o.jsxs("div",{className:"w-7 flex items-center justify-center flex-shrink-0",children:[!e&&A.status==="untracked"&&o.jsx("button",{type:"button",onClick:c,className:"p-1 hover:bg-destructive/10 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete untracked file","aria-label":`Delete ${A.path}`,children:o.jsx(mr,{className:"w-4 h-4 text-destructive"})}),!e&&A.status!=="untracked"&&A.status!=="added"&&o.jsx("button",{type:"button",onClick:I,className:"p-1 hover:bg-destructive/10 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Restore file to HEAD (Shift+R)","aria-label":`Restore ${A.path}`,children:o.jsx(jB,{className:"w-4 h-4 text-destructive"})}),e&&!t&&o.jsx(Yt,{className:"w-4 h-4 text-green-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}function J2({status:A}){const{openCommitModal:e,openDiff:t}=Te(),s=Wn();og();const{currentFocus:n,gitFileIndex:r}=Ng(),i=x.useRef(new Map),a=(A.conflicted?.length??0)>0,g=A.staged.length>0,Q=A.unstaged.length>0||A.untracked.length>0,l=[...A.unstaged,...A.untracked],C=l.length>0;x.useMemo(()=>[...A.conflicted??[],...A.staged,...A.unstaged,...A.untracked],[A]);const I=new Set(A.unstaged.map(f=>f.path)),c=()=>{const f=l.map(h=>h.path);f.length>0&&s.mutate(f)},u=A.conflicted?.length??0;return x.useEffect(()=>{if(n==="git"&&r>=0){i.current.get(r)?.scrollIntoView({block:"nearest",behavior:"smooth"});const k=[...A.conflicted??[],...A.staged,...A.unstaged,...A.untracked][r];if(k){const v=A.staged.includes(k);t(k.path,v)}}},[n,r,A.conflicted,A.staged,A.unstaged,A.untracked,t]),o.jsxs("div",{className:"flex flex-col",children:[a&&o.jsxs("div",{className:"border-b border-border",children:[o.jsx("div",{className:"px-3 py-2 bg-red-500/10 flex items-center justify-between",children:o.jsxs("span",{className:"text-xs font-semibold text-red-500 uppercase flex items-center gap-1.5",children:[o.jsx(qB,{className:"w-3.5 h-3.5"}),"Conflicts (",u,")"]})}),o.jsx("div",{className:"divide-y divide-border",children:A.conflicted?.map((f,h)=>{const k=h,v=n==="git"&&r===k;return o.jsx("div",{ref:D=>{D?i.current.set(k,D):i.current.delete(k)},className:v?"ring-1 ring-inset ring-primary/40":"",children:o.jsx($r,{file:f,staged:!1})},f.path)})})]}),g&&o.jsxs("div",{className:"border-b border-border",children:[o.jsxs("div",{className:"px-3 py-2 bg-muted/50 flex items-center justify-between",children:[o.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Staged Changes (",A.staged.length,")"]}),o.jsxs("div",{className:"flex items-center gap-1",children:[A.staged.length>0&&!a&&o.jsxs(Be,{variant:"primary",size:"sm",onClick:e,className:"h-6 text-xs",children:[o.jsx(Cn,{className:"w-3 h-3 mr-1"}),"Commit"]}),A.staged.length>0&&a&&o.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve conflicts first"})]})]}),o.jsx("div",{className:"divide-y divide-border",children:A.staged.map((f,h)=>{const k=u+h,v=n==="git"&&r===k;return o.jsx("div",{ref:D=>{D?i.current.set(k,D):i.current.delete(k)},className:v?"ring-1 ring-inset ring-primary/40":"",children:o.jsx($r,{file:f,staged:!0,showModifiedIndicator:I.has(f.path)})},f.path)})})]}),Q&&o.jsxs("div",{children:[o.jsxs("div",{className:"px-3 py-2 bg-muted/50 flex items-center justify-between",children:[o.jsxs("span",{className:"text-xs font-semibold text-foreground uppercase",children:["Changes (",A.unstaged.length+A.untracked.length,")"]}),C&&o.jsxs(Be,{variant:"ghost",size:"sm",onClick:c,title:"Stage all changes",className:"h-6 text-xs",children:[o.jsx(QC,{className:"w-3 h-3 mr-1"}),"Stage All"]})]}),o.jsxs("div",{className:"divide-y divide-border",children:[A.unstaged.map((f,h)=>{const k=u+A.staged.length+h,v=n==="git"&&r===k;return o.jsx("div",{ref:D=>{D?i.current.set(k,D):i.current.delete(k)},className:v?"ring-1 ring-inset ring-primary/40":"",children:o.jsx($r,{file:f,staged:!1})},f.path)}),A.untracked.map((f,h)=>{const k=u+A.staged.length+A.unstaged.length+h,v=n==="git"&&r===k;return o.jsx("div",{ref:D=>{D?i.current.set(k,D):i.current.delete(k)},className:v?"ring-1 ring-inset ring-primary/40":"",children:o.jsx($r,{file:f,staged:!1})},f.path)})]})]}),!a&&!g&&!Q&&o.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No changes"})]})}const cB="git",EB=320,L2=320,j2=600,T2=x.memo(function({onFixWithAI:e}){const t=Te(iA=>iA.isExpanded),s=Te(iA=>iA.collapseSidebar),n=os(iA=>iA.widths[cB]??EB),{data:r,isLoading:i,error:a,refetch:g}=Pn(),{data:Q}=Kp(),l=ke(),C=Sp(),I=Up(),c=Rp(),u=Jp(),f=Lp(),[h,k]=x.useState([]),[v,D]=x.useState(!1),[O,J]=x.useState(!1),[V,eA]=x.useState("origin"),[X,K]=x.useState(""),[W,T]=x.useState(null);x.useEffect(()=>{t&&l.invalidateQueries({queryKey:["git","status"]})},[t,l]);const L=()=>{g()},w=x.useCallback((iA,UA)=>{const HA=`${Date.now()}-${Math.random().toString(36).slice(2,7)}`;k(lA=>[...lA,{id:HA,message:iA,context:UA}])},[]),B=x.useCallback(iA=>{k(UA=>UA.filter(HA=>HA.id!==iA))},[]),d=async()=>{try{await C.mutateAsync()}catch(iA){w(iA instanceof Error?iA.message:"Failed to push","git push")}},N=async()=>{try{await I.mutateAsync()}catch(iA){w(iA instanceof Error?iA.message:"Failed to pull","git pull")}},G=async()=>{if(!(!V.trim()||!X.trim()))try{await u.mutateAsync({name:V.trim(),url:X.trim()}),eA("origin"),K(""),J(!1)}catch(iA){w(iA instanceof Error?iA.message:"Failed to add remote","git remote add")}},S=async iA=>{if(W!==iA){T(iA);return}T(null);try{await f.mutateAsync(iA)}catch(UA){w(UA instanceof Error?UA.message:"Failed to remove remote","git remote remove")}},j=x.useCallback(iA=>{const UA=iA.context?`I got a git error during ${iA.context}:
122
122