@cline/cli-linux-arm64 3.0.47-nightly.1785415224 → 3.0.48

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.
@@ -1,4 +1,4 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{i as n,r}from"./bundle-mjs-D3mlU5Wg.js";import{t as i}from"./react-dom-Cmec2Q1Q.js";import{$ as a,A as o,B as s,Bt as c,D as l,E as u,F as d,Ht as f,I as p,K as m,L as h,Mt as g,O as ee,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as te,Y as ne,Z as re,_ as D,c as O,ct as ie,d as ae,dt as k,et as oe,f as se,ft as ce,g as le,h as ue,k as de,l as fe,lt as pe,m as me,p as he,st as ge,u as _e,v as ve,w as ye,x as be,xt as xe,y as A}from"./vscode-DBs95Ixu.js";import{A as Se,C as Ce,D as we,E as Te,F as Ee,I as De,M as Oe,N as ke,O as Ae,P as je,S as Me,T as Ne,_ as Pe,a as Fe,b as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as He,j as Ue,k as We,l as Ge,n as Ke,p as qe,r as Je,s as Ye,t as j,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./label-DAWPWDwk.js";import{a as tt,i as nt,n as rt,r as it,t as M}from"./desktop-client-B4hwKFvn.js";import{a as at,i as ot,n as st,r as ct,t as lt}from"./switch-D32hLf2L.js";import{$ as ut,B as dt,C as ft,Ct as pt,G as mt,Mt as ht,Nt as gt,O as _t,Pt as vt,Q as yt,S as bt,Tt as xt,W as St,X as Ct,Z as wt,_ as Tt,a as Et,at as Dt,b as N,bt as Ot,c as kt,ct as At,d as jt,dt as Mt,et as Nt,f as Pt,ft as Ft,g as It,gt as Lt,h as Rt,ht as P,i as zt,it as Bt,kt as Vt,m as Ht,mt as F,n as Ut,nt as Wt,o as Gt,ot as Kt,pt as qt,r as Jt,rt as Yt,s as I,t as Xt,tt as Zt,u as Qt,v as $t,vt as en,w as tn,wt as nn,x as rn,xt as an,y as on,yt as sn,z as cn}from"./index-BP5ly3Hx.js";var ln=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),un=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),dn=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),fn=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),pn=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mn=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),hn=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),gn=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),_n=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),vn=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),yn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),bn=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),xn=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Sn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),L=e(n(),1),Cn=L.createContext({disabled:!1});function wn(){return L.useContext(Cn)}var Tn=L.createContext(void 0);function En(e=!0){let t=L.useContext(Tn);if(t===void 0&&!e)throw Error(c(3));return t}var R=r();function Dn(e){let t=e instanceof Error?e.message:String(e);return t.includes(`unsupported desktop command: cline_account`)?Error(`The desktop sidecar is running an older build that does not support account commands. Restart the sidecar or reload the app, then try again.`):e instanceof Error?e:Error(t)}function On(e){let t=e.toLowerCase();return t.includes(`no cline account auth token found`)||t.includes(`requires re-authentication`)||t.includes(`auth token`)||t.includes(`unauthorized`)}async function kn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function An(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function jn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function Mn(e){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Nn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Pn(e,t){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Fn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function In(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)([]),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)([]),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(0),[T,E]=(0,L.useState)([]),[te,ne]=(0,L.useState)(!1),[re,D]=(0,L.useState)(null),[O,ie]=(0,L.useState)(!1),ae=d.find(e=>e.active)??null,k=(0,L.useCallback)(()=>{a(null),s(null),l(null),f([]),_([]),C(!1),x(null),E([]),ie(!1),D(null)},[]),oe=(0,L.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([kn(),An(),jn()]),r=n.find(e=>e.active)??null,i=r?await Mn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){k();let t=Dn(e).message;g(t)}finally{m(!1)}},[k]);(0,L.useEffect)(()=>{oe()},[oe]);let se=async()=>{r(`sign-in`),g(null);try{await M.invoke(`run_provider_oauth_login`,{provider:`cline`}),await oe(),t(`overview`)}catch(e){let t=Dn(e).message;g(t),k()}finally{r(null)}},ce=async()=>{r(`sign-out`);try{await M.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),k(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=Dn(e).message;g(t)}finally{r(null)}},le=(0,L.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=ae?await Pn(ae.organizationId,ae.memberId):await Nn();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=Dn(t).message;x(n)}finally{w.current===e&&y(!1)}},[ae]);(0,L.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[ae?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!S&&le()},[e,S,le]);let ue=(0,L.useCallback)(async()=>{ne(!0),D(null);try{let e=await Fn();E(e),ie(!0)}catch(e){let t=Dn(e).message;D(t)}finally{ne(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!O&&ue()},[e,O,ue]);let de=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),fe=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),pe=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),me=ae?c?.balance??o?.balance??null:o?.balance??null,he=[`overview`,`usage`,`billing`],ge=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(fn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(nt,{className:`h-4 w-4`}),`Retry`]})]}),_e=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(St,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(A,{disabled:n!==null,onClick:()=>void se(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(vn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,R.jsx)(tt,{className:`h-4 w-4`})]})]})]})}),ve=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(at,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:he.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:u(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&ve(),h&&(On(h)?_e():ge(h,oe)),!p&&!h&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,de(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,R.jsx)(tt,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(A,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void ce(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(at,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(yn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),me!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(mn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:ae?`${ae.name} Balance`:`Credits Balance`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,pe(me)]})}),ae&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,pe(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(un,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,R.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:ae?`Recent API usage and token consumption for ${ae.name}.`:`Recent API usage and token consumption across all providers.`}),v&&ve(),b&&ge(b,le),!v&&!b&&S&&(ee.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:ee.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:pe(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:de(e.createdAt)}),(0,R.jsx)(`p`,{children:fe(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),te&&ve(),re&&ge(re,ue),!te&&!re&&O&&(T.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Sn,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:de(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,pe(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Ln=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Rn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),g=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),ee=n.includes(g),_=r.models.length>0,v=r.modelsSourceUrl.trim().length>0,y=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(_||v)&&!ee,b=e=>{if((e.key===`Enter`||e.key===`,`)&&a.trim()){e.preventDefault();let t=a.trim().replace(/,/g,``);t&&!r.models.includes(t)&&i(e=>({...e,models:[...e.models,t],defaultModel:e.defaultModel||t})),o(``)}else e.key===`Backspace`&&!a&&r.models.length>0&&i(e=>({...e,models:e.models.slice(0,-1)}))},x=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},C=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},w=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},E=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},te=async()=>{if(!(!y||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,R.jsxs)(Gt,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(I,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(A,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(ln,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),ee?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(A,{onClick:()=>x(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(Ue,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:b,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(A,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ln.map(e=>(0,R.jsx)(A,{onClick:()=>S(e),className:u(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(A,{onClick:()=>d(!l),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,R.jsx)(De,{className:u(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>w(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(A,{onClick:()=>E(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(ye,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(A,{onClick:C,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,R.jsx)(Oe,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(A,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void te(),disabled:!y||f,className:u(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,y&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function zn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Bn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Vn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Hn(e){let t=e.label.toLowerCase(),n=`flag`in e?e.flag.toLowerCase():e.key.toLowerCase();return t.includes(`token`)||t.includes(`secret`)||t.includes(`key`)||n.includes(`token`)||n.includes(`secret`)||n.includes(`key`)}function Un(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Wn(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??``;return!(n.equals!==void 0&&r!==n.equals||n.notEquals!==void 0&&r===n.notEquals)}function Gn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Kn(e){let t=e[0];return{channelId:t?.id??``,values:Gn(t),securityEnabled:!1,securityValues:{}}}function qn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)(null),v=(0,L.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),y=(0,L.useMemo)(()=>{let e={...Gn(v),...p.values};return(v?.fields??[]).filter(t=>Wn(t,e))},[v,p.values]),b=(0,L.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:Kn(e.available))},[]),x=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await M.invoke(`list_connector_channels`);b(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[b]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=()=>{m(Kn(e)),g(null),f(!0)},C=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},w=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},T=async()=>{if(!v){g(`Choose a channel`);return}for(let e of v.fields)if(y.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&v.security){for(let e of v.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(v.id),g(null),l(null);try{let e=await M.invoke(`start_connector_channel`,{channel:v.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}});b(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);g(t)}finally{s(null)}},E=async e=>{s(e.type),l(null);try{let t=await M.invoke(`stop_connector_channel`,{channel:e.type});b(t),_(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(zt,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{disabled:i,onClick:()=>void x(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(nt,{className:u(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(A,{disabled:e.length===0,onClick:S,size:`sm`,type:`button`,children:[(0,R.jsx)(Oe,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,R.jsx)(Et,{children:`Loading channels...`}):n.length===0?(0,R.jsx)(Et,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Ee,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:zn(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Bn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Vn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(A,{disabled:o===t.type,onClick:()=>_(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(ye,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(Le,{open:d,onOpenChange:f,children:(0,R.jsxs)(Ge,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:`Add Channel`}),(0,R.jsx)(Xe,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Channel`}),(0,R.jsxs)(Ve,{onValueChange:t=>{t&&m({channelId:t,values:Gn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:`Select channel`})}),(0,R.jsx)(Be,{children:e.map(e=>(0,R.jsx)(Pe,{value:e.id,children:e.name},e.id))})]})]}),y.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(j,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(Ve,{onValueChange:t=>{t&&C(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:e.placeholder})}),(0,R.jsx)(Be,{children:e.options.map(e=>(0,R.jsx)(Pe,{value:e.value,children:e.label},e.value))})]}):Un(e)?(0,R.jsx)(Ye,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,R.jsx)(O,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),v?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(lt,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?v.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:e.label}),(0,R.jsx)(O,{onChange:t=>w(e.key,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(A,{disabled:o!==null||!v,onClick:()=>void T(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)(It,{open:ee!==null,onOpenChange:e=>{e||_(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Remove Channel`}),(0,R.jsxs)(N,{children:[`Confirm that you want to stop the active`,` `,ee?zn(ee,e):`channel`,` `,`channel for `,ee?Bn(ee):``,`.`]})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:o!==null||!ee,onClick:()=>{ee&&E(ee)},variant:`destructive`,children:`Remove`})]})]})})]})}function Jn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yn(e){let t=Jn(e);if(t.length===0)return;let n={};for(let e of t){let t=e.indexOf(`=`);if(t<=0)continue;let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();r&&(n[r]=i)}return Object.keys(n).length>0?n:void 0}function Xn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Zn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Qn(e){return!e||Object.keys(e).length===0?[{id:crypto.randomUUID(),key:``,value:``}]:Object.entries(e).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}))}function $n(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Qn(e?.env),url:e?.url??``,headersText:Xn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function er(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(!1),[ee,_]=(0,L.useState)(`create`),[v,y]=(0,L.useState)(()=>$n()),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),w=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),T=(0,L.useCallback)(async()=>{s(!0),f(null);try{let e=await M.invoke(`list_mcp_servers`);w(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[w]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[T]);let E=async(e,t)=>{m(e.name),f(null);try{let n=await M.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});w(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},te=async e=>{m(e.previousName??e.name),f(null);try{let t=await M.invoke(`upsert_mcp_server`,{input:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{m(null)}},ne=async e=>{m(e),f(null);try{let t=await M.invoke(`delete_mcp_server`,{name:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},re=(0,L.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=Jn(e.argsText);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,command:r,args:a.length>0?a:void 0,cwd:e.cwd.trim()||void 0,env:Object.keys(n).length>0?n:void 0,disabled:e.disabled,metadata:i}}let a=e.url.trim();if(!a)throw Error(`URL is required for sse and streamableHttp transport.`);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,url:a,headers:Yn(e.headersText),disabled:e.disabled,metadata:i}},[]),D=()=>{_(`create`),y($n()),x(null),g(!0)},ie=e=>{_(`edit`),y($n(e)),x(null),g(!0)},ae=async()=>{x(null);try{let e=re(v);await te(e),g(!1)}catch(e){x(e instanceof Error?e.message:String(e))}},k=async()=>{l(!0),f(null);try{let e=await M.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},oe=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),se=(e,t,n)=>{y(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},ce=()=>{y(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},le=e=>{y(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(zt,{children:`cline config mcp`}),(0,R.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:o,children:(0,R.jsx)(nt,{className:u(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(A,{size:`sm`,onClick:D,children:[(0,R.jsx)(Oe,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(A,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void k(),disabled:c,children:n||`Open settings file`})]}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):oe.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:oe.map(e=>{let t=p===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Ee,{className:u(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ie(e),disabled:t,children:(0,R.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>C(e),disabled:t,children:(0,R.jsx)(ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(lt,{checked:!e.disabled,onCheckedChange:t=>E(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Zn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Xn(e.headers)]})]})]},e.name)})}),(0,R.jsx)(Le,{open:h,onOpenChange:e=>{g(e),e||x(null)},children:(0,R.jsxs)(Ge,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:ee===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(Xe,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(O,{id:`mcp-name`,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Transport type`}),(0,R.jsxs)(Ve,{value:v.transportType,onValueChange:e=>y(t=>({...t,transportType:e})),children:[(0,R.jsx)(Ze,{className:`w-full`,children:(0,R.jsx)(et,{placeholder:`Select transport`})}),(0,R.jsxs)(Be,{children:[(0,R.jsx)(Pe,{value:`stdio`,children:`stdio`}),(0,R.jsx)(Pe,{value:`sse`,children:`sse`}),(0,R.jsx)(Pe,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),v.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(O,{id:`mcp-command`,value:v.command,onChange:e=>y(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(Ye,{id:`mcp-args`,value:v.argsText,onChange:e=>y(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(O,{id:`mcp-cwd`,value:v.cwd,onChange:e=>y(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{children:`Environment variables`}),(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:ce,children:(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:v.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>le(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(O,{value:e.key,onChange:t=>se(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(O,{type:`password`,value:e.value,onChange:t=>se(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(O,{id:`mcp-url`,value:v.url,onChange:e=>y(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(Ye,{id:`mcp-headers`,value:v.headersText,onChange:e=>y(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(Ye,{id:`mcp-metadata`,value:v.metadataText,onChange:e=>y(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(lt,{checked:!v.disabled,onCheckedChange:e=>y(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),b?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void ae(),disabled:p!==null,children:p===null?ee===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)(It,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Delete MCP Server`}),(0,R.jsx)(N,{children:S?`Delete MCP server "${S.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:p!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:p!==null||!S,onClick:()=>{S&&(ne(S.name),C(null))},children:`Delete`})]})]})})]})}function tr(e){let t={...e.configValues??{}};e.apiKey!==void 0&&t.apiKey===void 0&&(t.apiKey=e.apiKey),e.baseUrl!==void 0&&t.baseUrl===void 0&&(t.baseUrl=e.baseUrl);for(let n of e.configFields??[])t[n.path]===void 0&&n.defaultValue!==void 0&&(t[n.path]=n.defaultValue);return t}function nr(e){return e==null?``:String(e)}function rr(e,t){if(e.type===`boolean`)return!!t;if(typeof t==`boolean`)return t;if(e.type===`select`){let n=e.options?.find(e=>String(e.value)===t);if(n)return n.value}let n=t.trim();if(n.length===0)return null;if(e.type===`number`){let e=Number(n);return Number.isFinite(e)?e:null}return n}function ir({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:u(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(A,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(ct,{className:`size-4`})}),(0,R.jsxs)(A,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(pn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:u(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,R.jsxs)(`div`,{className:u(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,R.jsxs)(`div`,{className:u(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,R.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,R.jsx)(lt,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,R.jsx)(dn,{className:`size-4`})})]},e.id))]})]})})}function ar({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,d]=(0,L.useState)({}),[f,p]=(0,L.useState)(()=>tr(e)),[m,h]=(0,L.useState)(null),[g,ee]=(0,L.useState)(null),_=(0,L.useRef)(void 0),v=e.configFields??[],y=nr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,S=g?.providerId===e.id?g.modelId:null,C=x.trim().toLowerCase(),w=C?b.filter(e=>e.name.toLowerCase().includes(C)||e.id.toLowerCase().includes(C)):b,T=c===`panel`;(0,L.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=rr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=nr(r)),e.path===`baseUrl`&&(a.baseUrl=nr(r)),n(a)},te=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{ee({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>ee(null),1600)})};return(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(A,{"aria-label":T?`Close provider details`:`Back to providers`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,onClick:t,variant:`ghost`,children:T?(0,R.jsx)(Ue,{className:`h-4 w-4`}):(0,R.jsx)(ln,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,R.jsx)(`section`,{className:u(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=f[e.path],n=nr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(lt,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,R.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>E(e,t.target.value),value:n,children:[(0,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(dt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(O,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>E(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(A,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,R.jsxs)(`section`,{className:u(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(ct,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(A,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,R.jsx)(nt,{className:u(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(_n,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(ke,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>te(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(je,{className:`size-3 shrink-0`}),S===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(A,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(it,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var or,sr=Object.freeze({status:`aborted`});function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var cr=Symbol(`zod_brand`),lr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ur=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(or=globalThis).__zod_globalConfig??(or.__zod_globalConfig={});var dr=globalThis.__zod_globalConfig;function fr(e){return e&&Object.assign(dr,e),dr}var pr=t({BIGINT_FORMAT_RANGES:()=>Yr,Class:()=>vi,NUMBER_FORMAT_RANGES:()=>Jr,aborted:()=>ri,allowsEval:()=>Lr,assert:()=>vr,assertEqual:()=>mr,assertIs:()=>gr,assertNever:()=>_r,assertNotEqual:()=>hr,assignProp:()=>Dr,base64ToUint8Array:()=>fi,base64urlToUint8Array:()=>mi,cached:()=>xr,captureStackTrace:()=>Fr,cleanEnum:()=>di,cleanRegex:()=>Cr,clone:()=>Gr,cloneDef:()=>kr,createTransparentProxy:()=>Kr,defineLazy:()=>V,esc:()=>Nr,escapeRegex:()=>Wr,explicitlyAborted:()=>ii,extend:()=>Qr,finalizeIssue:()=>si,floatSafeRemainder:()=>wr,getElementAtPath:()=>Ar,getEnumValues:()=>yr,getLengthableOrigin:()=>li,getParsedType:()=>Vr,getSizableOrigin:()=>ci,hexToUint8Array:()=>gi,isObject:()=>Ir,isPlainObject:()=>Rr,issue:()=>ui,joinValues:()=>B,jsonStringifyReplacer:()=>br,merge:()=>ei,mergeDefs:()=>Or,normalizeParams:()=>H,nullish:()=>Sr,numKeys:()=>Br,objectClone:()=>Er,omit:()=>Zr,optionalKeys:()=>qr,parsedType:()=>W,partial:()=>ti,pick:()=>Xr,prefixIssues:()=>ai,primitiveTypes:()=>Ur,promiseAllObject:()=>jr,propertyKeyTypes:()=>Hr,randomString:()=>Mr,required:()=>ni,safeExtend:()=>$r,shallowClone:()=>zr,slugify:()=>Pr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>pi,uint8ArrayToBase64url:()=>hi,uint8ArrayToHex:()=>_i,unwrapMessage:()=>oi});function mr(e){return e}function hr(e){return e}function gr(e){}function _r(e){throw Error(`Unexpected value in exhaustive check`)}function vr(e){}function yr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function B(e,t=`|`){return e.map(e=>U(e)).join(t)}function br(e,t){return typeof t==`bigint`?t.toString():t}function xr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Sr(e){return e==null}function Cr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Tr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tr)return r===void 0&&(r=Tr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Er(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Or(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function kr(e){return Or(e._zod.def)}function Ar(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function jr(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function Mr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Nr(e){return JSON.stringify(e)}function Pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Fr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ir(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Lr=xr(()=>{if(dr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Rr(e){if(Ir(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Ir(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function zr(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Br(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Vr=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Hr=new Set([`string`,`number`,`symbol`]),Ur=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Kr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function qr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Dr(this,`shape`,e),e},checks:[]}))}function Zr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Dr(this,`shape`,r),r},checks:[]}))}function Qr(e,t){if(!Rr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function $r(e,t){if(!Rr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function ei(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ti(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Dr(this,`shape`,i),i},checks:[]}))}function ni(e,t,n){return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Dr(this,`shape`,i),i}}))}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ii(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ai(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function oi(e){return typeof e==`string`?e:e?.message}function si(e,t,n){let r=e.message?e.message:oi(e.inst?._zod.def?.error?.(e))??oi(t?.error?.(e))??oi(n.customError?.(e))??oi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ci(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ui(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function di(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function fi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function pi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function mi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return fi(t+`=`.repeat((4-t.length%4)%4))}function hi(e){return pi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function gi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function _i(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var vi=class{constructor(...e){}},yi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,br,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bi=z(`$ZodError`,yi),xi=z(`$ZodError`,yi,{Parent:Error});function Si(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ci(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function wi(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ti(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ei(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ti(e.path)}`);return t.join(`
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{i as n,r}from"./bundle-mjs-D3mlU5Wg.js";import{t as i}from"./react-dom-Cmec2Q1Q.js";import{$ as a,A as o,B as s,Bt as c,D as l,E as u,F as d,Ht as f,I as p,K as m,L as h,Mt as g,O as ee,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as te,Y as ne,Z as re,_ as D,c as O,ct as ie,d as ae,dt as k,et as oe,f as se,ft as ce,g as le,h as ue,k as de,l as fe,lt as pe,m as me,p as he,st as ge,u as _e,v as ve,w as ye,x as be,xt as xe,y as A}from"./vscode-DBs95Ixu.js";import{A as Se,C as Ce,D as we,E as Te,F as Ee,I as De,M as Oe,N as ke,O as Ae,P as je,S as Me,T as Ne,_ as Pe,a as Fe,b as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as He,j as Ue,k as We,l as Ge,n as Ke,p as qe,r as Je,s as Ye,t as j,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./label-GlIPa0AI.js";import{a as tt,i as nt,n as rt,r as it,t as M}from"./desktop-client-B4hwKFvn.js";import{a as at,i as ot,n as st,r as ct,t as lt}from"./switch-D32hLf2L.js";import{$ as ut,B as dt,C as ft,Ct as pt,G as mt,Mt as ht,Nt as gt,O as _t,Pt as vt,Q as yt,S as bt,Tt as xt,W as St,X as Ct,Z as wt,_ as Tt,a as Et,at as Dt,b as N,bt as Ot,c as kt,ct as At,d as jt,dt as Mt,et as Nt,f as Pt,ft as Ft,g as It,gt as Lt,h as Rt,ht as P,i as zt,it as Bt,kt as Vt,m as Ht,mt as F,n as Ut,nt as Wt,o as Gt,ot as Kt,pt as qt,r as Jt,rt as Yt,s as I,t as Xt,tt as Zt,u as Qt,v as $t,vt as en,w as tn,wt as nn,x as rn,xt as an,y as on,yt as sn,z as cn}from"./index-jvbYRXxp.js";var ln=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),un=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),dn=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),fn=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),pn=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mn=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),hn=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),gn=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),_n=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),vn=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),yn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),bn=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),xn=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Sn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),L=e(n(),1),Cn=L.createContext({disabled:!1});function wn(){return L.useContext(Cn)}var Tn=L.createContext(void 0);function En(e=!0){let t=L.useContext(Tn);if(t===void 0&&!e)throw Error(c(3));return t}var R=r();function Dn(e){let t=e instanceof Error?e.message:String(e);return t.includes(`unsupported desktop command: cline_account`)?Error(`The desktop sidecar is running an older build that does not support account commands. Restart the sidecar or reload the app, then try again.`):e instanceof Error?e:Error(t)}function On(e){let t=e.toLowerCase();return t.includes(`no cline account auth token found`)||t.includes(`requires re-authentication`)||t.includes(`auth token`)||t.includes(`unauthorized`)}async function kn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function An(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function jn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function Mn(e){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Nn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Pn(e,t){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Fn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function In(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)([]),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)([]),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(0),[T,E]=(0,L.useState)([]),[te,ne]=(0,L.useState)(!1),[re,D]=(0,L.useState)(null),[O,ie]=(0,L.useState)(!1),ae=d.find(e=>e.active)??null,k=(0,L.useCallback)(()=>{a(null),s(null),l(null),f([]),_([]),C(!1),x(null),E([]),ie(!1),D(null)},[]),oe=(0,L.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([kn(),An(),jn()]),r=n.find(e=>e.active)??null,i=r?await Mn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){k();let t=Dn(e).message;g(t)}finally{m(!1)}},[k]);(0,L.useEffect)(()=>{oe()},[oe]);let se=async()=>{r(`sign-in`),g(null);try{await M.invoke(`run_provider_oauth_login`,{provider:`cline`}),await oe(),t(`overview`)}catch(e){let t=Dn(e).message;g(t),k()}finally{r(null)}},ce=async()=>{r(`sign-out`);try{await M.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),k(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=Dn(e).message;g(t)}finally{r(null)}},le=(0,L.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=ae?await Pn(ae.organizationId,ae.memberId):await Nn();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=Dn(t).message;x(n)}finally{w.current===e&&y(!1)}},[ae]);(0,L.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[ae?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!S&&le()},[e,S,le]);let ue=(0,L.useCallback)(async()=>{ne(!0),D(null);try{let e=await Fn();E(e),ie(!0)}catch(e){let t=Dn(e).message;D(t)}finally{ne(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!O&&ue()},[e,O,ue]);let de=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),fe=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),pe=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),me=ae?c?.balance??o?.balance??null:o?.balance??null,he=[`overview`,`usage`,`billing`],ge=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(fn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(nt,{className:`h-4 w-4`}),`Retry`]})]}),_e=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(St,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(A,{disabled:n!==null,onClick:()=>void se(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(vn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,R.jsx)(tt,{className:`h-4 w-4`})]})]})]})}),ve=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(at,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:he.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:u(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&ve(),h&&(On(h)?_e():ge(h,oe)),!p&&!h&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,de(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,R.jsx)(tt,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(A,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void ce(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(at,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(yn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),me!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(mn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:ae?`${ae.name} Balance`:`Credits Balance`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,pe(me)]})}),ae&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,pe(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(un,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,R.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:ae?`Recent API usage and token consumption for ${ae.name}.`:`Recent API usage and token consumption across all providers.`}),v&&ve(),b&&ge(b,le),!v&&!b&&S&&(ee.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:ee.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:pe(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:de(e.createdAt)}),(0,R.jsx)(`p`,{children:fe(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),te&&ve(),re&&ge(re,ue),!te&&!re&&O&&(T.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Sn,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:de(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,pe(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Ln=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Rn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),g=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),ee=n.includes(g),_=r.models.length>0,v=r.modelsSourceUrl.trim().length>0,y=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(_||v)&&!ee,b=e=>{if((e.key===`Enter`||e.key===`,`)&&a.trim()){e.preventDefault();let t=a.trim().replace(/,/g,``);t&&!r.models.includes(t)&&i(e=>({...e,models:[...e.models,t],defaultModel:e.defaultModel||t})),o(``)}else e.key===`Backspace`&&!a&&r.models.length>0&&i(e=>({...e,models:e.models.slice(0,-1)}))},x=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},C=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},w=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},E=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},te=async()=>{if(!(!y||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,R.jsxs)(Gt,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(I,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(A,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(ln,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),ee?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(A,{onClick:()=>x(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(Ue,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:b,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(A,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ln.map(e=>(0,R.jsx)(A,{onClick:()=>S(e),className:u(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(A,{onClick:()=>d(!l),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,R.jsx)(De,{className:u(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>w(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(A,{onClick:()=>E(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(ye,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(A,{onClick:C,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,R.jsx)(Oe,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(A,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void te(),disabled:!y||f,className:u(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,y&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function zn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Bn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Vn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Hn(e){let t=e.label.toLowerCase(),n=`flag`in e?e.flag.toLowerCase():e.key.toLowerCase();return t.includes(`token`)||t.includes(`secret`)||t.includes(`key`)||n.includes(`token`)||n.includes(`secret`)||n.includes(`key`)}function Un(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Wn(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??``;return!(n.equals!==void 0&&r!==n.equals||n.notEquals!==void 0&&r===n.notEquals)}function Gn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Kn(e){let t=e[0];return{channelId:t?.id??``,values:Gn(t),securityEnabled:!1,securityValues:{}}}function qn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)(null),v=(0,L.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),y=(0,L.useMemo)(()=>{let e={...Gn(v),...p.values};return(v?.fields??[]).filter(t=>Wn(t,e))},[v,p.values]),b=(0,L.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:Kn(e.available))},[]),x=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await M.invoke(`list_connector_channels`);b(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[b]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=()=>{m(Kn(e)),g(null),f(!0)},C=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},w=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},T=async()=>{if(!v){g(`Choose a channel`);return}for(let e of v.fields)if(y.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&v.security){for(let e of v.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(v.id),g(null),l(null);try{let e=await M.invoke(`start_connector_channel`,{channel:v.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}});b(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);g(t)}finally{s(null)}},E=async e=>{s(e.type),l(null);try{let t=await M.invoke(`stop_connector_channel`,{channel:e.type});b(t),_(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(zt,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{disabled:i,onClick:()=>void x(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(nt,{className:u(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(A,{disabled:e.length===0,onClick:S,size:`sm`,type:`button`,children:[(0,R.jsx)(Oe,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,R.jsx)(Et,{children:`Loading channels...`}):n.length===0?(0,R.jsx)(Et,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Ee,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:zn(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Bn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Vn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(A,{disabled:o===t.type,onClick:()=>_(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(ye,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(Le,{open:d,onOpenChange:f,children:(0,R.jsxs)(Ge,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:`Add Channel`}),(0,R.jsx)(Xe,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Channel`}),(0,R.jsxs)(Ve,{onValueChange:t=>{t&&m({channelId:t,values:Gn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:`Select channel`})}),(0,R.jsx)(Be,{children:e.map(e=>(0,R.jsx)(Pe,{value:e.id,children:e.name},e.id))})]})]}),y.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(j,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(Ve,{onValueChange:t=>{t&&C(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:e.placeholder})}),(0,R.jsx)(Be,{children:e.options.map(e=>(0,R.jsx)(Pe,{value:e.value,children:e.label},e.value))})]}):Un(e)?(0,R.jsx)(Ye,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,R.jsx)(O,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),v?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(lt,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?v.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:e.label}),(0,R.jsx)(O,{onChange:t=>w(e.key,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(A,{disabled:o!==null||!v,onClick:()=>void T(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)(It,{open:ee!==null,onOpenChange:e=>{e||_(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Remove Channel`}),(0,R.jsxs)(N,{children:[`Confirm that you want to stop the active`,` `,ee?zn(ee,e):`channel`,` `,`channel for `,ee?Bn(ee):``,`.`]})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:o!==null||!ee,onClick:()=>{ee&&E(ee)},variant:`destructive`,children:`Remove`})]})]})})]})}function Jn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yn(e){let t=Jn(e);if(t.length===0)return;let n={};for(let e of t){let t=e.indexOf(`=`);if(t<=0)continue;let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();r&&(n[r]=i)}return Object.keys(n).length>0?n:void 0}function Xn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Zn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Qn(e){return!e||Object.keys(e).length===0?[{id:crypto.randomUUID(),key:``,value:``}]:Object.entries(e).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}))}function $n(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Qn(e?.env),url:e?.url??``,headersText:Xn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function er(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(!1),[ee,_]=(0,L.useState)(`create`),[v,y]=(0,L.useState)(()=>$n()),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),w=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),T=(0,L.useCallback)(async()=>{s(!0),f(null);try{let e=await M.invoke(`list_mcp_servers`);w(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[w]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[T]);let E=async(e,t)=>{m(e.name),f(null);try{let n=await M.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});w(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},te=async e=>{m(e.previousName??e.name),f(null);try{let t=await M.invoke(`upsert_mcp_server`,{input:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{m(null)}},ne=async e=>{m(e),f(null);try{let t=await M.invoke(`delete_mcp_server`,{name:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},re=(0,L.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=Jn(e.argsText);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,command:r,args:a.length>0?a:void 0,cwd:e.cwd.trim()||void 0,env:Object.keys(n).length>0?n:void 0,disabled:e.disabled,metadata:i}}let a=e.url.trim();if(!a)throw Error(`URL is required for sse and streamableHttp transport.`);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,url:a,headers:Yn(e.headersText),disabled:e.disabled,metadata:i}},[]),D=()=>{_(`create`),y($n()),x(null),g(!0)},ie=e=>{_(`edit`),y($n(e)),x(null),g(!0)},ae=async()=>{x(null);try{let e=re(v);await te(e),g(!1)}catch(e){x(e instanceof Error?e.message:String(e))}},k=async()=>{l(!0),f(null);try{let e=await M.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},oe=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),se=(e,t,n)=>{y(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},ce=()=>{y(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},le=e=>{y(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(zt,{children:`cline config mcp`}),(0,R.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:o,children:(0,R.jsx)(nt,{className:u(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(A,{size:`sm`,onClick:D,children:[(0,R.jsx)(Oe,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(A,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void k(),disabled:c,children:n||`Open settings file`})]}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):oe.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:oe.map(e=>{let t=p===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Ee,{className:u(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ie(e),disabled:t,children:(0,R.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>C(e),disabled:t,children:(0,R.jsx)(ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(lt,{checked:!e.disabled,onCheckedChange:t=>E(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Zn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Xn(e.headers)]})]})]},e.name)})}),(0,R.jsx)(Le,{open:h,onOpenChange:e=>{g(e),e||x(null)},children:(0,R.jsxs)(Ge,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:ee===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(Xe,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(O,{id:`mcp-name`,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Transport type`}),(0,R.jsxs)(Ve,{value:v.transportType,onValueChange:e=>y(t=>({...t,transportType:e})),children:[(0,R.jsx)(Ze,{className:`w-full`,children:(0,R.jsx)(et,{placeholder:`Select transport`})}),(0,R.jsxs)(Be,{children:[(0,R.jsx)(Pe,{value:`stdio`,children:`stdio`}),(0,R.jsx)(Pe,{value:`sse`,children:`sse`}),(0,R.jsx)(Pe,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),v.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(O,{id:`mcp-command`,value:v.command,onChange:e=>y(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(Ye,{id:`mcp-args`,value:v.argsText,onChange:e=>y(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(O,{id:`mcp-cwd`,value:v.cwd,onChange:e=>y(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{children:`Environment variables`}),(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:ce,children:(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:v.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>le(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(O,{value:e.key,onChange:t=>se(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(O,{type:`password`,value:e.value,onChange:t=>se(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(O,{id:`mcp-url`,value:v.url,onChange:e=>y(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(Ye,{id:`mcp-headers`,value:v.headersText,onChange:e=>y(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(Ye,{id:`mcp-metadata`,value:v.metadataText,onChange:e=>y(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(lt,{checked:!v.disabled,onCheckedChange:e=>y(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),b?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void ae(),disabled:p!==null,children:p===null?ee===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)(It,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Delete MCP Server`}),(0,R.jsx)(N,{children:S?`Delete MCP server "${S.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:p!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:p!==null||!S,onClick:()=>{S&&(ne(S.name),C(null))},children:`Delete`})]})]})})]})}function tr(e){let t={...e.configValues??{}};e.apiKey!==void 0&&t.apiKey===void 0&&(t.apiKey=e.apiKey),e.baseUrl!==void 0&&t.baseUrl===void 0&&(t.baseUrl=e.baseUrl);for(let n of e.configFields??[])t[n.path]===void 0&&n.defaultValue!==void 0&&(t[n.path]=n.defaultValue);return t}function nr(e){return e==null?``:String(e)}function rr(e,t){if(e.type===`boolean`)return!!t;if(typeof t==`boolean`)return t;if(e.type===`select`){let n=e.options?.find(e=>String(e.value)===t);if(n)return n.value}let n=t.trim();if(n.length===0)return null;if(e.type===`number`){let e=Number(n);return Number.isFinite(e)?e:null}return n}function ir({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:u(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(A,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(ct,{className:`size-4`})}),(0,R.jsxs)(A,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(pn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:u(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,R.jsxs)(`div`,{className:u(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,R.jsxs)(`div`,{className:u(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,R.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,R.jsx)(lt,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,R.jsx)(dn,{className:`size-4`})})]},e.id))]})]})})}function ar({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,d]=(0,L.useState)({}),[f,p]=(0,L.useState)(()=>tr(e)),[m,h]=(0,L.useState)(null),[g,ee]=(0,L.useState)(null),_=(0,L.useRef)(void 0),v=e.configFields??[],y=nr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,S=g?.providerId===e.id?g.modelId:null,C=x.trim().toLowerCase(),w=C?b.filter(e=>e.name.toLowerCase().includes(C)||e.id.toLowerCase().includes(C)):b,T=c===`panel`;(0,L.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=rr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=nr(r)),e.path===`baseUrl`&&(a.baseUrl=nr(r)),n(a)},te=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{ee({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>ee(null),1600)})};return(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(A,{"aria-label":T?`Close provider details`:`Back to providers`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,onClick:t,variant:`ghost`,children:T?(0,R.jsx)(Ue,{className:`h-4 w-4`}):(0,R.jsx)(ln,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,R.jsx)(`section`,{className:u(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=f[e.path],n=nr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(lt,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,R.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>E(e,t.target.value),value:n,children:[(0,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(dt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(O,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>E(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(A,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,R.jsxs)(`section`,{className:u(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(ct,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(A,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,R.jsx)(nt,{className:u(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(_n,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(ke,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>te(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(je,{className:`size-3 shrink-0`}),S===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(A,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(it,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var or,sr=Object.freeze({status:`aborted`});function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var cr=Symbol(`zod_brand`),lr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ur=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(or=globalThis).__zod_globalConfig??(or.__zod_globalConfig={});var dr=globalThis.__zod_globalConfig;function fr(e){return e&&Object.assign(dr,e),dr}var pr=t({BIGINT_FORMAT_RANGES:()=>Yr,Class:()=>vi,NUMBER_FORMAT_RANGES:()=>Jr,aborted:()=>ri,allowsEval:()=>Lr,assert:()=>vr,assertEqual:()=>mr,assertIs:()=>gr,assertNever:()=>_r,assertNotEqual:()=>hr,assignProp:()=>Dr,base64ToUint8Array:()=>fi,base64urlToUint8Array:()=>mi,cached:()=>xr,captureStackTrace:()=>Fr,cleanEnum:()=>di,cleanRegex:()=>Cr,clone:()=>Gr,cloneDef:()=>kr,createTransparentProxy:()=>Kr,defineLazy:()=>V,esc:()=>Nr,escapeRegex:()=>Wr,explicitlyAborted:()=>ii,extend:()=>Qr,finalizeIssue:()=>si,floatSafeRemainder:()=>wr,getElementAtPath:()=>Ar,getEnumValues:()=>yr,getLengthableOrigin:()=>li,getParsedType:()=>Vr,getSizableOrigin:()=>ci,hexToUint8Array:()=>gi,isObject:()=>Ir,isPlainObject:()=>Rr,issue:()=>ui,joinValues:()=>B,jsonStringifyReplacer:()=>br,merge:()=>ei,mergeDefs:()=>Or,normalizeParams:()=>H,nullish:()=>Sr,numKeys:()=>Br,objectClone:()=>Er,omit:()=>Zr,optionalKeys:()=>qr,parsedType:()=>W,partial:()=>ti,pick:()=>Xr,prefixIssues:()=>ai,primitiveTypes:()=>Ur,promiseAllObject:()=>jr,propertyKeyTypes:()=>Hr,randomString:()=>Mr,required:()=>ni,safeExtend:()=>$r,shallowClone:()=>zr,slugify:()=>Pr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>pi,uint8ArrayToBase64url:()=>hi,uint8ArrayToHex:()=>_i,unwrapMessage:()=>oi});function mr(e){return e}function hr(e){return e}function gr(e){}function _r(e){throw Error(`Unexpected value in exhaustive check`)}function vr(e){}function yr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function B(e,t=`|`){return e.map(e=>U(e)).join(t)}function br(e,t){return typeof t==`bigint`?t.toString():t}function xr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Sr(e){return e==null}function Cr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Tr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tr)return r===void 0&&(r=Tr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Er(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Or(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function kr(e){return Or(e._zod.def)}function Ar(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function jr(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function Mr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Nr(e){return JSON.stringify(e)}function Pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Fr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ir(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Lr=xr(()=>{if(dr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Rr(e){if(Ir(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Ir(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function zr(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Br(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Vr=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Hr=new Set([`string`,`number`,`symbol`]),Ur=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Kr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function qr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Dr(this,`shape`,e),e},checks:[]}))}function Zr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Dr(this,`shape`,r),r},checks:[]}))}function Qr(e,t){if(!Rr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function $r(e,t){if(!Rr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function ei(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ti(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Dr(this,`shape`,i),i},checks:[]}))}function ni(e,t,n){return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Dr(this,`shape`,i),i}}))}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ii(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ai(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function oi(e){return typeof e==`string`?e:e?.message}function si(e,t,n){let r=e.message?e.message:oi(e.inst?._zod.def?.error?.(e))??oi(t?.error?.(e))??oi(n.customError?.(e))??oi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ci(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ui(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function di(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function fi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function pi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function mi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return fi(t+`=`.repeat((4-t.length%4)%4))}function hi(e){return pi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function gi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function _i(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var vi=class{constructor(...e){}},yi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,br,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bi=z(`$ZodError`,yi),xi=z(`$ZodError`,yi,{Parent:Error});function Si(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ci(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function wi(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ti(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ei(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ti(e.path)}`);return t.join(`
2
2
  `)}var Di=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new lr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>si(e,a,fr())));throw Fr(t,i?.callee),t}return o.value},Oi=Di(xi),ki=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>si(e,a,fr())));throw Fr(t,i?.callee),t}return o.value},Ai=ki(xi),ji=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new lr;return a.issues.length?{success:!1,error:new(e??bi)(a.issues.map(e=>si(e,i,fr())))}:{success:!0,data:a.value}},Mi=ji(xi),Ni=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>si(e,i,fr())))}:{success:!0,data:a.value}},Pi=Ni(xi),Fi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Di(e)(t,n,i)},Ii=Fi(xi),Li=e=>(t,n,r)=>Di(e)(t,n,r),Ri=Li(xi),zi=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ki(e)(t,n,i)},Bi=zi(xi),Vi=e=>async(t,n,r)=>ki(e)(t,n,r),Hi=Vi(xi),Ui=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ji(e)(t,n,i)},Wi=Ui(xi),Gi=e=>(t,n,r)=>ji(e)(t,n,r),Ki=Gi(xi),qi=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ni(e)(t,n,i)},Ji=qi(xi),Yi=e=>async(t,n,r)=>Ni(e)(t,n,r),Xi=Yi(xi),Zi=t({base64:()=>wa,base64url:()=>Ta,bigint:()=>Ia,boolean:()=>za,browserEmail:()=>ga,cidrv4:()=>Sa,cidrv6:()=>Ca,cuid:()=>Qi,cuid2:()=>$i,date:()=>ja,datetime:()=>Pa,domain:()=>Da,duration:()=>ia,e164:()=>ka,email:()=>da,emoji:()=>va,extendedDuration:()=>aa,guid:()=>oa,hex:()=>Wa,hostname:()=>Ea,html5Email:()=>fa,httpProtocol:()=>Oa,idnEmail:()=>ha,integer:()=>La,ipv4:()=>ya,ipv6:()=>ba,ksuid:()=>na,lowercase:()=>Ha,mac:()=>xa,md5_base64:()=>Ja,md5_base64url:()=>Ya,md5_hex:()=>qa,nanoid:()=>ra,null:()=>Ba,number:()=>Ra,rfc5322Email:()=>pa,sha1_base64:()=>Za,sha1_base64url:()=>Qa,sha1_hex:()=>Xa,sha256_base64:()=>eo,sha256_base64url:()=>to,sha256_hex:()=>$a,sha384_base64:()=>ro,sha384_base64url:()=>io,sha384_hex:()=>no,sha512_base64:()=>oo,sha512_base64url:()=>so,sha512_hex:()=>ao,string:()=>Fa,time:()=>Na,ulid:()=>ea,undefined:()=>Va,unicodeEmail:()=>ma,uppercase:()=>Ua,uuid:()=>sa,uuid4:()=>ca,uuid6:()=>la,uuid7:()=>ua,xid:()=>ta}),Qi=/^[cC][0-9a-z]{6,}$/,$i=/^[0-9a-z]+$/,ea=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ta=/^[0-9a-vA-V]{20}$/,na=/^[A-Za-z0-9]{27}$/,ra=/^[a-zA-Z0-9_-]{21}$/,ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,aa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,oa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,sa=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ca=sa(4),la=sa(6),ua=sa(7),da=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fa=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,pa=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ma=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ha=ma,ga=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,_a=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function va(){return new RegExp(_a,`u`)}var ya=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ba=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xa=e=>{let t=Wr(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Sa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ca=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ta=/^[A-Za-z0-9_-]*$/,Ea=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Da=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Oa=/^https?$/,ka=/^\+[1-9]\d{6,14}$/,Aa=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ja=RegExp(`^${Aa}$`);function Ma(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Na(e){return RegExp(`^${Ma(e)}$`)}function Pa(e){let t=Ma({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Aa}T(?:${r})$`)}var Fa=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ia=/^-?\d+n?$/,La=/^-?\d+$/,Ra=/^-?\d+(?:\.\d+)?$/,za=/^(?:true|false)$/i,Ba=/^null$/i,Va=/^undefined$/i,Ha=/^[^A-Z]*$/,Ua=/^[^a-z]*$/,Wa=/^[0-9a-fA-F]*$/;function Ga(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Ka(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var qa=/^[0-9a-fA-F]{32}$/,Ja=Ga(22,`==`),Ya=Ka(22),Xa=/^[0-9a-fA-F]{40}$/,Za=Ga(27,`=`),Qa=Ka(27),$a=/^[0-9a-fA-F]{64}$/,eo=Ga(43,`=`),to=Ka(43),no=/^[0-9a-fA-F]{96}$/,ro=Ga(64,``),io=Ka(64),ao=/^[0-9a-fA-F]{128}$/,oo=Ga(86,`==`),so=Ka(86),co=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lo={number:`number`,bigint:`bigint`,object:`date`},uo=z(`$ZodCheckLessThan`,(e,t)=>{co.init(e,t);let n=lo[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fo=z(`$ZodCheckGreaterThan`,(e,t)=>{co.init(e,t);let n=lo[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),po=z(`$ZodCheckMultipleOf`,(e,t)=>{co.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):wr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mo=z(`$ZodCheckNumberFormat`,(e,t)=>{co.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Jr[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=La)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ho=z(`$ZodCheckBigIntFormat`,(e,t)=>{co.init(e,t);let[n,r]=Yr[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),go=z(`$ZodCheckMaxSize`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:ci(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_o=z(`$ZodCheckMinSize`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:ci(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vo=z(`$ZodCheckSizeEquals`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:ci(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yo=z(`$ZodCheckMaxLength`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=li(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bo=z(`$ZodCheckMinLength`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=li(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xo=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=li(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),So=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;co.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Co=z(`$ZodCheckRegex`,(e,t)=>{So.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wo=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ha,So.init(e,t)}),To=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ua,So.init(e,t)}),Eo=z(`$ZodCheckIncludes`,(e,t)=>{co.init(e,t);let n=Wr(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Do=z(`$ZodCheckStartsWith`,(e,t)=>{co.init(e,t);let n=RegExp(`^${Wr(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Oo=z(`$ZodCheckEndsWith`,(e,t)=>{co.init(e,t);let n=RegExp(`.*${Wr(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function ko(e,t,n){e.issues.length&&t.issues.push(...ai(n,e.issues))}var Ao=z(`$ZodCheckProperty`,(e,t)=>{co.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>ko(n,e,t.property));ko(n,e,t.property)}}),jo=z(`$ZodCheckMimeType`,(e,t)=>{co.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Mo=z(`$ZodCheckOverwrite`,(e,t)=>{co.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),No=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
3
3
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
4
4
  `))}},Po={major:4,minor:4,patch:3},G=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Po;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=ri(e),i;for(let a of t){if(a._zod.def.when){if(ii(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new lr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=ri(e,t))});else{if(e.issues.length===t)continue;r||=ri(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(ri(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new lr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new lr;return o.then(e=>t(e,r,a))}return t(o,r,a)}}V(e,`~standard`,()=>({validate:t=>{try{let n=Mi(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Pi(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Fo=z(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fa(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Io=z(`$ZodStringFormat`,(e,t)=>{So.init(e,t),Fo.init(e,t)}),Lo=z(`$ZodGUID`,(e,t)=>{t.pattern??=oa,Io.init(e,t)}),Ro=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=sa(e)}else t.pattern??=sa();Io.init(e,t)}),zo=z(`$ZodEmail`,(e,t)=>{t.pattern??=da,Io.init(e,t)}),Bo=z(`$ZodURL`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Oa.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Vo=z(`$ZodEmoji`,(e,t)=>{t.pattern??=va(),Io.init(e,t)}),Ho=z(`$ZodNanoID`,(e,t)=>{t.pattern??=ra,Io.init(e,t)}),Uo=z(`$ZodCUID`,(e,t)=>{t.pattern??=Qi,Io.init(e,t)}),Wo=z(`$ZodCUID2`,(e,t)=>{t.pattern??=$i,Io.init(e,t)}),Go=z(`$ZodULID`,(e,t)=>{t.pattern??=ea,Io.init(e,t)}),Ko=z(`$ZodXID`,(e,t)=>{t.pattern??=ta,Io.init(e,t)}),qo=z(`$ZodKSUID`,(e,t)=>{t.pattern??=na,Io.init(e,t)}),Jo=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Pa(t),Io.init(e,t)}),Yo=z(`$ZodISODate`,(e,t)=>{t.pattern??=ja,Io.init(e,t)}),Xo=z(`$ZodISOTime`,(e,t)=>{t.pattern??=Na(t),Io.init(e,t)}),Zo=z(`$ZodISODuration`,(e,t)=>{t.pattern??=ia,Io.init(e,t)}),Qo=z(`$ZodIPv4`,(e,t)=>{t.pattern??=ya,Io.init(e,t),e._zod.bag.format=`ipv4`}),$o=z(`$ZodIPv6`,(e,t)=>{t.pattern??=ba,Io.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),es=z(`$ZodMAC`,(e,t)=>{t.pattern??=xa(t.delimiter),Io.init(e,t),e._zod.bag.format=`mac`}),ts=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Sa,Io.init(e,t)}),ns=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ca,Io.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function rs(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var is=z(`$ZodBase64`,(e,t)=>{t.pattern??=wa,Io.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{rs(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function as(e){if(!Ta.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rs(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var os=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ta,Io.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{as(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ss=z(`$ZodE164`,(e,t)=>{t.pattern??=ka,Io.init(e,t)});function cs(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var ls=z(`$ZodJWT`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{cs(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),us=z(`$ZodCustomStringFormat`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),ds=z(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ra,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fs=z(`$ZodNumberFormat`,(e,t)=>{mo.init(e,t),ds.init(e,t)}),ps=z(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=za,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ms=z(`$ZodBigInt`,(e,t)=>{G.init(e,t),e._zod.pattern=Ia,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),hs=z(`$ZodBigIntFormat`,(e,t)=>{ho.init(e,t),ms.init(e,t)}),gs=z(`$ZodSymbol`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),_s=z(`$ZodUndefined`,(e,t)=>{G.init(e,t),e._zod.pattern=Va,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),vs=z(`$ZodNull`,(e,t)=>{G.init(e,t),e._zod.pattern=Ba,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ys=z(`$ZodAny`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),bs=z(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),xs=z(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Ss=z(`$ZodVoid`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),Cs=z(`$ZodDate`,(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function ws(e,t,n){e.issues.length&&t.issues.push(...ai(n,e.issues)),t.value[n]=e.value}var Ts=z(`$ZodArray`,(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ws(t,n,e))):ws(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Es(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ai(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Ds(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=qr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Os(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Es(e,n,i,t,u,d))):Es(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var ks=z(`$ZodObject`,(e,t)=>{if(G.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=xr(()=>Ds(t));V(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ir,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Es(n,t,e,s,r,i))):Es(a,t,e,s,r,i)}return i?Os(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),As=z(`$ZodObjectJIT`,(e,t)=>{ks.init(e,t);let n=e._zod.parse,r=xr(()=>Ds(t)),i=e=>{let t=new No([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Nr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Nr(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="./cline-logo-filled.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Cline Hub</title>
8
- <script type="module" crossorigin src="./assets/index-BP5ly3Hx.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-jvbYRXxp.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-CNC7AqOf.js">
10
10
  <link rel="modulepreload" crossorigin href="./assets/bundle-mjs-D3mlU5Wg.js">
11
11
  <link rel="modulepreload" crossorigin href="./assets/react-dom-Cmec2Q1Q.js">
@@ -1 +1 @@
1
- import{createRequire as GG}from"node:module";var QG=GG(import.meta.url);import{normalizePluginManifest as IG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as UG,createRequire as y}from"node:module";import{dirname as M,extname as I,isAbsolute as XG,resolve as K}from"node:path";import{fileURLToPath as P}from"node:url";import{PLUGIN_FILE_EXTENSIONS as YG}from"@cline/shared";var m=M(P(import.meta.url)),ZG=y(import.meta.url),$G=K(m,"..","..","..","..",".."),S=WG($G),qG=["@cline/sdk","@cline/agents","@cline/core","@cline/core/hub","@cline/core/hub/daemon-entry","@cline/core/telemetry","@cline/llms","@cline/llms/browser","@cline/shared","@cline/shared/automation","@cline/shared/browser","@cline/shared/storage","@cline/shared/db","@cline/shared/types"],b=new Set(UG.flatMap((G)=>[G,G.replace(/^node:/,"")])),j=new Set(YG),KG=["development","node","import","require","default"];function WG(G){let Q={},U={"@cline/sdk":K(G,"packages/sdk/src/index.ts"),"@cline/agents":K(G,"packages/agents/src/index.ts"),"@cline/core":K(G,"packages/core/src/index.ts"),"@cline/llms":K(G,"packages/llms/src/index.ts"),"@cline/shared":K(G,"packages/shared/src/index.ts"),"@cline/shared/storage":K(G,"packages/shared/src/storage/index.ts"),"@cline/shared/db":K(G,"packages/shared/src/db/index.ts")};for(let[Y,Z]of Object.entries(U))if(_(Z))Q[Y]=Z;for(let Y of["agents","core","llms","shared"]){let Z=K(G,"packages",Y),$=K(Z,"package.json");if(!_($))continue;try{let X=JSON.parse(C($,"utf8"));if(typeof X.name!=="string"||!X.exports)continue;if(typeof X.exports==="string"){let q=K(Z,X.exports);if(_(q))Q[X.name]=q;continue}if(typeof X.exports!=="object")continue;for(let[q,w]of Object.entries(X.exports)){let A=_G(Z,w);if(!A)continue;let L=q==="."?X.name:`${X.name}/${q.replace(/^\.\//,"")}`;Q[L]=A}}catch{}}return Q}function _G(G,Q){let U=R(Q);if(!U)return null;let Y=h(G,U);for(let Z of Y)if(_(Z))return Z;return null}function R(G,Q=new Set){if(typeof G==="string")return G;if(!G||typeof G!=="object")return null;if(Q.has(G))return null;Q.add(G);let U=G;for(let Y of KG){let Z=R(U[Y],Q);if(Z)return Z}return null}function h(G,Q){let U=Q.replace(/^\.\//,""),Y=[K(G,Q)];if(U.startsWith("dist/")){let Z=U.replace(/^dist\//,"src/").replace(/\.(mjs|cjs|js)$/,"");return[K(G,`${Z}.ts`),K(G,`${Z}.tsx`),K(G,`${Z}.mts`),K(G,`${Z}.cts`),...Y]}return Y}function LG(G){return Object.fromEntries(Object.entries(G).sort(([Q],[U])=>U.length-Q.length))}function H(G){return!(G.startsWith(".")||G.startsWith("/")||G.startsWith("file:")||G.startsWith("data:")||G.startsWith("http:")||G.startsWith("https:"))}function J(G){if(G.startsWith("@")){let[Q,U]=G.split("/",3);return U?`${Q}/${U}`:G}return G.split("/",1)[0]??G}function wG(G){let Q=J(G);if(G===Q)return".";return`.${G.slice(Q.length)}`}function d(G){return J(G).startsWith("@cline/")}function V(G,Q){let U=J(Q),Y=M(G);while(!0){let Z=K(Y,"node_modules",U);if(_(Z)||_(K(Z,"package.json")))return!0;let $=K(Y,"..");if($===Y)return!1;Y=$}}function f(G){return T(G)!==null}function T(G){try{return ZG.resolve(G)}catch{}return AG(G)}function AG(G){let Q=J(G),U=u(Q);if(!U)return null;let Y=K(U,"package.json");try{let Z=JSON.parse(C(Y,"utf8")),$=wG(G),X=$==="."&&typeof Z.exports==="string"?Z.exports:Z.exports&&typeof Z.exports==="object"&&Object.hasOwn(Z.exports,$)?Z.exports[$]:void 0,q=R(X)??($==="."&&typeof Z.main==="string"?Z.main:null);if(!q)return null;let w=K(U,q),A=[w,...h(U,q).filter((L)=>L!==w)];for(let L of A)if(_(L))return L;return null}catch{return null}}function zG(){let G=[m],Q=process.env.CLINE_WRAPPER_PATH?.trim();if(Q)G.push(M(M(Q)));let U=process.execPath?.trim();if(U)G.push(M(U));return[...new Set(G.map((Y)=>K(Y)))]}function MG(G,Q){let U=G;while(!0){let Y=K(U,"package.json");if(_(Y))try{if(JSON.parse(C(Y,"utf8")).name===Q)return U}catch{}let Z=K(U,"node_modules",Q,"package.json");if(_(Z))return M(Z);let $=K(U,"..");if($===U)return null;U=$}}function u(G){for(let Q of zG()){let U=MG(Q,G);if(U)return U}return null}function FG(G){let U=M(G);for(let Y=0;Y<4;Y++){let Z=K(U,"package.json");if(_(Z))try{let X=JSON.parse(C(Z,"utf8"));return X!=null&&typeof X==="object"&&"cline"in X}catch{return!1}let $=K(U,"..");if($===U)return!1;U=$}return!1}function c(G,Q){let U=Q.startsWith("file:")?P(Q):XG(Q)?Q:K(M(G),Q);if(_(U)&&j.has(I(U)))return U;for(let Y of j){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of j){let Z=K(U,`index${Y}`);if(_(Z))return Z}return null}function l(G){let Q=new Set,U=[/\bimport\s+(?:type\s+)?[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bexport\s+[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bimport\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g,/\brequire\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g];for(let Y of U)for(let Z of G.matchAll(Y)){let $=Z[1];if($)Q.add($)}return[...Q]}function JG(G){return I(G)!==".ts"}function g(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!j.has(I(G)))return;let Y=C(G,"utf8"),Z=JG(G);for(let $ of l(Y)){if($.startsWith("node:")||b.has($))continue;if(H($)){if(!Z)continue;if(Object.hasOwn(S,$)||Object.hasOwn(S,J($))||V(G,$)||d($)&&f($)||Q&&f($))continue;throw Error(`Cannot find module '${J($)}'`)}let X=c(G,$);if(X)g(X,Q,U)}}function n(G,Q=new Set,U=new Set){if(Q.has(G)||!_(G))return U;if(Q.add(G),!j.has(I(G)))return U;let Y=C(G,"utf8");for(let Z of l(Y)){if(U.add(Z),H(Z))continue;let $=c(G,Z);if($)n($,Q,U)}return U}function CG(G,Q){let U=y(G),Y={},Z=n(G),$=new Set(qG);for(let[X,q]of Object.entries(S)){try{U.resolve(X);continue}catch{}Y[X]=q}for(let X of Z)if(H(X)&&(d(X)||Q))$.add(X);for(let X of $){if(Object.hasOwn(Y,X)||V(G,X))continue;let q=T(X);if(q)Y[X]=q}if(!Q)return Y;for(let X of Z){if(!H(X)||Object.hasOwn(Y,X)||V(G,X)||X.startsWith("node:")||b.has(X))continue;let q=T(X);if(q)Y[X]=q}return Y}function OG(G){let Q=I(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var F;function jG(){if(F!==void 0)return F;let G=u("jiti");if(!G)return F=null,null;let Q=K(G,"dist","babel.cjs");if(!_(Q))return F=null,null;try{let Y=y(Q)(Q);F=typeof Y==="function"?Y:null}catch{F=null}return F}async function o(G,Q={}){let U=!FG(G);g(G,U);let Y=CG(G,U),Z=LG(Y),$=await import("jiti"),X=typeof $==="function"?$:typeof $.default==="function"?$.default:void 0;if(!X)throw Error("Unable to load jiti");let q=Object.entries(Z).filter(([,W])=>OG(W)).map(([W])=>W),w=jG(),A=w?(W)=>w({...W,interopDefault:!0}):void 0;return await X(G,{alias:Z,cache:Q.useCache,requireCache:Q.useCache,esmResolve:!0,interopDefault:!1,nativeModules:[...b],transformModules:q,tryNative:!1,...A?{transform:A}:{}}).import(G,{})}function p(G,Q){if(!G)return!0;if(G.providerIds?.length){if(!Q?.providerId||!G.providerIds.includes(Q.providerId))return!1}if(G.modelIds?.length){if(!Q?.modelId||!G.modelIds.includes(Q.modelId))return!1}return!0}function z(G){return typeof G==="object"&&G!==null}function s(G){return Array.isArray(G)&&G.every((Q)=>typeof Q==="string")}function BG(G,Q){if(!z(G))throw Error(`Invalid plugin module: ${Q}`);if(typeof G.name!=="string"||!G.name)throw Error(`Invalid plugin name: ${Q}`);if(!z(G.manifest))throw Error(`Invalid plugin manifest: ${Q}`);if(Object.hasOwn(G.manifest,"providerIds")&&!s(G.manifest.providerIds))throw Error(`Invalid plugin manifest.providerIds: ${Q}`);if(Object.hasOwn(G.manifest,"modelIds")&&!s(G.manifest.modelIds))throw Error(`Invalid plugin manifest.modelIds: ${Q}`)}function DG(G){if(!z(G))throw Error("Plugin setup context must be an object");if(G.session!==void 0&&!z(G.session))throw Error("Plugin setup context session must be an object");if(G.client!==void 0&&!z(G.client))throw Error("Plugin setup context client must be an object");if(G.user!==void 0&&!z(G.user))throw Error("Plugin setup context user must be an object");if(G.workspaceInfo!==void 0&&!z(G.workspaceInfo))throw Error("Plugin setup context workspaceInfo must be an object");if(G.automation!==void 0&&!z(G.automation))throw Error("Plugin setup context automation must be an object");if(G.automation!==void 0&&typeof G.automation.ingestEvent!=="function")throw Error("Plugin setup context automation.ingestEvent must be a function");if(G.logger!==void 0&&!z(G.logger))throw Error("Plugin setup context logger must be an object")}var t=0,N=new Map,v=new Map;function HG(G){let Q=G instanceof Error?G.message:String(G),U=G instanceof Error?G.stack:void 0;return{message:Q,stack:U}}function k(G,Q,U,Y){if(!process.send)return;process.send({type:"response",id:G,ok:Q,result:U,error:Y})}function x(G,Q){if(!process.send)return;process.send({type:"event",name:G,payload:Q})}globalThis.__clinePluginHost={emitEvent:x};globalThis.__clineSessionEnv={cwd:void 0,workspaceInfo:void 0};function i(G){if(!G||typeof G!=="object")return{};return G}function NG(G){if(!G||typeof G!=="object")return;let Q={...G};if(Q.error instanceof Error)Q.error={name:Q.error.name,message:Q.error.message,stack:Q.error.stack};return Q}function EG(G){let Q=(U,Y,Z)=>{x("plugin_log",{level:U,pluginName:G,message:Y,metadata:NG(Z)})};return{debug:(U,Y)=>Q("debug",U,Y),log:(U,Y)=>Q("log",U,Y),error:(U,Y)=>Q("error",U,Y)}}function O(G,Q){let U=`${G}:${Q}`,Y=(v.get(U)??0)+1;return v.set(U,Y),`${G}_${Q}_${Y}`}function SG(G){let Q=typeof G.eventType==="string"?G.eventType.trim():"",U=typeof G.source==="string"?G.source.trim():"";if(!Q)throw Error("Automation event type contribution requires eventType");if(!U)throw Error("Automation event type contribution requires source");return{...G,eventType:Q,source:U,examples:G.examples?[...G.examples]:void 0,metadata:G.metadata?i(G.metadata):void 0}}function B(G){let Q=N.get(G);if(!Q)throw Error(`Unknown sandbox plugin id: ${G}`);return Q}async function VG(G){let Q;try{let U=await o(G.pluginPath);if(Q=U.default??U[G.exportName],BG(Q,G.pluginPath),Q.manifest=IG(Q.manifest),!p(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],rules:[],messageBuilders:[],providers:[],automationEventTypes:[],mcpServers:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,rules:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let q=O(G.pluginId,"tool");Z.tools.set(q,X.execute),Y.tools.push({id:q,name:X.name,description:X.description,inputSchema:X.inputSchema,timeoutMs:X.timeoutMs,retryable:X.retryable})},registerCommand:(X)=>{let q=O(G.pluginId,"command");if(typeof X.handler==="function")Z.commands.set(q,X.handler);Y.commands.push({id:q,name:X.name,description:X.description})},registerRule:(X)=>{let q=O(G.pluginId,"rule");if(typeof X.content==="function"){Z.rules.set(q,X.content),Y.rules.push({id:q,ruleId:X.id,source:X.source,hasContentHandler:!0});return}Y.rules.push({id:q,ruleId:X.id,content:X.content,source:X.source})},registerMessageBuilder:(X)=>{let q=O(G.pluginId,"builder");Z.messageBuilders.set(q,X.build),Y.messageBuilders.push({id:q,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:O(G.pluginId,"provider"),name:X.name,description:X.description,metadata:i(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:O(G.pluginId,"automation_event"),...SG(X)})},registerMcpServer:(X)=>{Y.mcpServers.push(X)}};if(typeof Q.setup==="function")try{let X={...G.setupCtxBase,...G.loggerEnabled?{logger:EG(Q.name)}:{},...Q.manifest.capabilities.includes("automationEvents")?{automation:{ingestEvent:(q)=>{x("automation_event",q)}}}:{}};DG(X),await Q.setup($,X)}catch(X){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q.name,phase:"setup",message:X instanceof Error?X.message:String(X),stack:X instanceof Error?X.stack:void 0}}}return{type:"loaded",state:{plugin:Q,handlers:Z},descriptor:{pluginId:G.pluginId,pluginPath:G.pluginPath,name:Q.name,manifest:Q.manifest,hooks:Q.hooks?Object.entries(Q.hooks).filter(([,X])=>typeof X==="function").map(([X])=>X):void 0,contributions:Y}}}catch(U){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q?.name,phase:"load",message:U instanceof Error?U.message:String(U),stack:U instanceof Error?U.stack:void 0}}}}async function TG(G){if(N.clear(),t=0,v.clear(),G.cwd)try{process.chdir(G.cwd)}catch{}let Q=globalThis.__clineSessionEnv;if(Q)Q.cwd=G.cwd,Q.workspaceInfo=G.workspaceInfo;let U=[],Y=[],Z=[],$=G.exportName||"plugin",X=new Map,q={providerId:G.providerId,modelId:G.modelId},w={session:G.session,client:G.client,user:G.user,workspaceInfo:G.workspaceInfo},A=await Promise.all((G.pluginPaths||[]).map((L)=>{let W=`plugin_${++t}`;return VG({pluginPath:L,pluginId:W,exportName:$,targeting:q,setupCtxBase:w,loggerEnabled:G.loggerEnabled})}));for(let L of A){if(L.type==="skipped")continue;if(L.type==="failure"){Y.push(L.failure);continue}let{descriptor:W,state:r}=L,E=X.get(W.name);if(E!==void 0){let D=U[E];if(!D)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:D.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${D.pluginPath}`}),N.delete(D.pluginId),U.splice(E,1),X.clear();for(let[a,e]of U.entries())X.set(e.name,a)}}N.set(W.pluginId,r),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function yG(G){let U=B(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function bG(G){let U=B(G.pluginId).handlers.tools.get(G.contributionId);if(typeof U!=="function")throw Error("Unknown sandbox tool contribution");return await U(G.input,G.context)}async function RG(G){let U=B(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function kG(G){let U=B(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}async function vG(G){let U=B(G.pluginId).handlers.rules.get(G.contributionId);if(typeof U!=="function")return"";return await U()}var xG={initialize:TG,invokeHook:yG,executeTool:bG,executeCommand:RG,buildMessages:kG,resolveRuleContent:vG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=xG[G.method];if(!Q){k(G.id,!1,void 0,{message:`Unknown method: ${String(G.method)}`});return}try{let U=await Q(G.args||{});k(G.id,!0,U)}catch(U){k(G.id,!1,void 0,HG(U))}});
1
+ import{createRequire as QG}from"node:module";var UG=QG(import.meta.url);import{normalizePluginManifest as BG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as XG,createRequire as R}from"node:module";import{dirname as J,extname as I,isAbsolute as YG,resolve as q}from"node:path";import{fileURLToPath as h}from"node:url";import{PLUGIN_FILE_EXTENSIONS as ZG}from"@cline/shared";var m=J(h(import.meta.url)),$G=R(import.meta.url),KG=q(m,"..","..","..","..",".."),T=_G(KG),qG=["@cline/sdk","@cline/agents","@cline/core","@cline/core/hub","@cline/core/hub/daemon-entry","@cline/core/telemetry","@cline/llms","@cline/llms/browser","@cline/shared","@cline/shared/automation","@cline/shared/browser","@cline/shared/storage","@cline/shared/db","@cline/shared/types"],k=new Set(XG.flatMap((G)=>[G,G.replace(/^node:/,"")])),j=new Set(ZG),WG=["development","node","import","require","default"];function _G(G){let Q={},U={"@cline/sdk":q(G,"packages/sdk/src/index.ts"),"@cline/agents":q(G,"packages/agents/src/index.ts"),"@cline/core":q(G,"packages/core/src/index.ts"),"@cline/llms":q(G,"packages/llms/src/index.ts"),"@cline/shared":q(G,"packages/shared/src/index.ts"),"@cline/shared/storage":q(G,"packages/shared/src/storage/index.ts"),"@cline/shared/db":q(G,"packages/shared/src/db/index.ts")};for(let[Y,Z]of Object.entries(U))if(_(Z))Q[Y]=Z;for(let Y of["agents","core","llms","shared"]){let Z=q(G,"packages",Y),$=q(Z,"package.json");if(!_($))continue;try{let X=JSON.parse(C($,"utf8"));if(typeof X.name!=="string"||!X.exports)continue;if(typeof X.exports==="string"){let K=q(Z,X.exports);if(_(K))Q[X.name]=K;continue}if(typeof X.exports!=="object")continue;for(let[K,A]of Object.entries(X.exports)){let L=wG(Z,A);if(!L)continue;let w=K==="."?X.name:`${X.name}/${K.replace(/^\.\//,"")}`;Q[w]=L}}catch{}}return Q}function wG(G,Q){let U=v(Q);if(!U)return null;let Y=d(G,U);for(let Z of Y)if(_(Z))return Z;return null}function v(G,Q=new Set){if(typeof G==="string")return G;if(!G||typeof G!=="object")return null;if(Q.has(G))return null;Q.add(G);let U=G;for(let Y of WG){let Z=v(U[Y],Q);if(Z)return Z}return null}function d(G,Q){let U=Q.replace(/^\.\//,""),Y=[q(G,Q)];if(U.startsWith("dist/")){let Z=U.replace(/^dist\//,"src/").replace(/\.(mjs|cjs|js)$/,"");return[q(G,`${Z}.ts`),q(G,`${Z}.tsx`),q(G,`${Z}.mts`),q(G,`${Z}.cts`),...Y]}return Y}function AG(G){return Object.fromEntries(Object.entries(G).sort(([Q],[U])=>U.length-Q.length))}function H(G){return!(G.startsWith(".")||G.startsWith("/")||G.startsWith("file:")||G.startsWith("data:")||G.startsWith("http:")||G.startsWith("https:"))}function M(G){if(G.startsWith("@")){let[Q,U]=G.split("/",3);return U?`${Q}/${U}`:G}return G.split("/",1)[0]??G}function LG(G){let Q=M(G);if(G===Q)return".";return`.${G.slice(Q.length)}`}function u(G){return M(G).startsWith("@cline/")}function y(G,Q){let U=M(Q),Y=J(G);while(!0){let Z=q(Y,"node_modules",U);if(_(Z)||_(q(Z,"package.json")))return!0;let $=q(Y,"..");if($===Y)return!1;Y=$}}function P(G){return b(G)!==null}function b(G){try{return $G.resolve(G)}catch{}return FG(G)}function FG(G){let Q=M(G),U=c(Q);if(!U)return null;let Y=q(U,"package.json");try{let Z=JSON.parse(C(Y,"utf8")),$=LG(G),X=$==="."&&typeof Z.exports==="string"?Z.exports:Z.exports&&typeof Z.exports==="object"&&Object.hasOwn(Z.exports,$)?Z.exports[$]:void 0,K=v(X)??($==="."&&typeof Z.main==="string"?Z.main:null);if(!K)return null;let A=q(U,K),L=[A,...d(U,K).filter((w)=>w!==A)];for(let w of L)if(_(w))return w;return null}catch{return null}}function JG(){let G=[m],Q=process.env.CLINE_WRAPPER_PATH?.trim();if(Q)G.push(J(J(Q)));let U=process.execPath?.trim();if(U)G.push(J(U));return[...new Set(G.map((Y)=>q(Y)))]}function zG(G,Q){let U=G;while(!0){let Y=q(U,"package.json");if(_(Y))try{if(JSON.parse(C(Y,"utf8")).name===Q)return U}catch{}let Z=q(U,"node_modules",Q,"package.json");if(_(Z))return J(Z);let $=q(U,"..");if($===U)return null;U=$}}function c(G){for(let Q of JG()){let U=zG(Q,G);if(U)return U}return null}function MG(G){let U=J(G);for(let Y=0;Y<4;Y++){let Z=q(U,"package.json");if(_(Z))try{let X=JSON.parse(C(Z,"utf8"));return X!=null&&typeof X==="object"&&"cline"in X}catch{return!1}let $=q(U,"..");if($===U)return!1;U=$}return!1}function l(G,Q){let U=Q.startsWith("file:")?h(Q):YG(Q)?Q:q(J(G),Q);if(_(U)&&j.has(I(U)))return U;for(let Y of j){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of j){let Z=q(U,`index${Y}`);if(_(Z))return Z}return null}function g(G){let Q=new Set,U=[/\bimport\s+(?:type\s+)?[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bexport\s+[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bimport\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g,/\brequire\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g];for(let Y of U)for(let Z of G.matchAll(Y)){let $=Z[1];if($)Q.add($)}return[...Q]}function CG(G){return I(G)!==".ts"}function n(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!j.has(I(G)))return;let Y=C(G,"utf8"),Z=CG(G);for(let $ of g(Y)){if($.startsWith("node:")||k.has($))continue;if(H($)){if(!Z)continue;if(Object.hasOwn(T,$)||Object.hasOwn(T,M($))||y(G,$)||u($)&&P($)||Q&&P($))continue;throw Error(`Cannot find module '${M($)}'`)}let X=l(G,$);if(X)n(X,Q,U)}}function o(G,Q=new Set,U=new Set){if(Q.has(G)||!_(G))return U;if(Q.add(G),!j.has(I(G)))return U;let Y=C(G,"utf8");for(let Z of g(Y)){if(U.add(Z),H(Z))continue;let $=l(G,Z);if($)o($,Q,U)}return U}function OG(G,Q){let U=R(G),Y={},Z=o(G),$=new Set(qG);for(let[X,K]of Object.entries(T)){try{U.resolve(X);continue}catch{}Y[X]=K}for(let X of Z)if(H(X)&&(u(X)||Q))$.add(X);for(let X of $){if(Object.hasOwn(Y,X)||y(G,X))continue;let K=b(X);if(K)Y[X]=K}if(!Q)return Y;for(let X of Z){if(!H(X)||Object.hasOwn(Y,X)||y(G,X)||X.startsWith("node:")||k.has(X))continue;let K=b(X);if(K)Y[X]=K}return Y}function jG(G){let Q=I(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var z;function IG(){if(z!==void 0)return z;let G=c("jiti");if(!G)return z=null,null;let Q=q(G,"dist","babel.cjs");if(!_(Q))return z=null,null;try{let Y=R(Q)(Q);z=typeof Y==="function"?Y:null}catch{z=null}return z}async function p(G,Q={}){let U=!MG(G);n(G,U);let Y=OG(G,U),Z=AG(Y),$=await import("jiti"),X=typeof $==="function"?$:typeof $.default==="function"?$.default:void 0;if(!X)throw Error("Unable to load jiti");let K=Object.entries(Z).filter(([,W])=>jG(W)).map(([W])=>W),A=IG(),L=A?(W)=>A({...W,interopDefault:!0}):void 0;return await X(G,{alias:Z,cache:Q.useCache,requireCache:Q.useCache,esmResolve:!0,interopDefault:!1,nativeModules:[...k],transformModules:K,tryNative:!1,...L?{transform:L}:{}}).import(G,{})}function s(G,Q){if(!G)return!0;if(G.providerIds?.length){if(!Q?.providerId||!G.providerIds.includes(Q.providerId))return!1}if(G.modelIds?.length){if(!Q?.modelId||!G.modelIds.includes(Q.modelId))return!1}return!0}function F(G){return typeof G==="object"&&G!==null}function t(G){return Array.isArray(G)&&G.every((Q)=>typeof Q==="string")}function DG(G,Q){if(!F(G))throw Error(`Invalid plugin module: ${Q}`);if(typeof G.name!=="string"||!G.name)throw Error(`Invalid plugin name: ${Q}`);if(!F(G.manifest))throw Error(`Invalid plugin manifest: ${Q}`);if(Object.hasOwn(G.manifest,"providerIds")&&!t(G.manifest.providerIds))throw Error(`Invalid plugin manifest.providerIds: ${Q}`);if(Object.hasOwn(G.manifest,"modelIds")&&!t(G.manifest.modelIds))throw Error(`Invalid plugin manifest.modelIds: ${Q}`)}function HG(G){if(!F(G))throw Error("Plugin setup context must be an object");if(G.session!==void 0&&!F(G.session))throw Error("Plugin setup context session must be an object");if(G.client!==void 0&&!F(G.client))throw Error("Plugin setup context client must be an object");if(G.user!==void 0&&!F(G.user))throw Error("Plugin setup context user must be an object");if(G.workspaceInfo!==void 0&&!F(G.workspaceInfo))throw Error("Plugin setup context workspaceInfo must be an object");if(G.automation!==void 0&&!F(G.automation))throw Error("Plugin setup context automation must be an object");if(G.automation!==void 0&&typeof G.automation.ingestEvent!=="function")throw Error("Plugin setup context automation.ingestEvent must be a function");if(G.logger!==void 0&&!F(G.logger))throw Error("Plugin setup context logger must be an object")}var i=0,N=new Map,f=new Map;function NG(G){let Q=G instanceof Error?G.message:String(G),U=G instanceof Error?G.stack:void 0;return{message:Q,stack:U}}function x(G,Q,U,Y){if(!process.send)return;process.send({type:"response",id:G,ok:Q,result:U,error:Y})}function E(G,Q){if(!process.send)return;process.send({type:"event",name:G,payload:Q})}globalThis.__clinePluginHost={emitEvent:E};globalThis.__clineSessionEnv={cwd:void 0,workspaceInfo:void 0};function r(G){if(!G||typeof G!=="object")return{};return G}function S(G){if(!G||typeof G!=="object")return;let Q={...G};if(Q.error instanceof Error)Q.error={name:Q.error.name,message:Q.error.message,stack:Q.error.stack};return Q}function SG(G){let Q=(U,Y,Z)=>{E("plugin_log",{level:U,pluginName:G,message:Y,metadata:S(Z)})};return{debug:(U,Y)=>Q("debug",U,Y),log:(U,Y)=>Q("log",U,Y),error:(U,Y)=>Q("error",U,Y)}}function EG(G){let Q=(Z)=>{E("plugin_telemetry",{pluginName:G,...Z})},U=(Z)=>($,X,K,A,L)=>{Q({kind:"metric",metric:Z,name:$,value:X,attributes:S(K),description:A,required:L})},Y=()=>{};return{capture:(Z)=>{Q({kind:"event",event:Z?.event,properties:S(Z?.properties)})},captureRequired:(Z,$)=>{Q({kind:"event",event:Z,properties:S($),required:!0})},recordCounter:U("counter"),recordHistogram:U("histogram"),recordGauge:U("gauge"),isEnabled:()=>!0,setDistinctId:Y,setMetadata:Y,updateMetadata:Y,setCommonProperties:Y,updateCommonProperties:Y,flush:async()=>{},dispose:async()=>{}}}function O(G,Q){let U=`${G}:${Q}`,Y=(f.get(U)??0)+1;return f.set(U,Y),`${G}_${Q}_${Y}`}function VG(G){let Q=typeof G.eventType==="string"?G.eventType.trim():"",U=typeof G.source==="string"?G.source.trim():"";if(!Q)throw Error("Automation event type contribution requires eventType");if(!U)throw Error("Automation event type contribution requires source");return{...G,eventType:Q,source:U,examples:G.examples?[...G.examples]:void 0,metadata:G.metadata?r(G.metadata):void 0}}function B(G){let Q=N.get(G);if(!Q)throw Error(`Unknown sandbox plugin id: ${G}`);return Q}async function TG(G){let Q;try{let U=await p(G.pluginPath);if(Q=U.default??U[G.exportName],DG(Q,G.pluginPath),Q.manifest=BG(Q.manifest),!s(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],rules:[],messageBuilders:[],providers:[],automationEventTypes:[],mcpServers:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,rules:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let K=O(G.pluginId,"tool");Z.tools.set(K,X.execute),Y.tools.push({id:K,name:X.name,description:X.description,inputSchema:X.inputSchema,timeoutMs:X.timeoutMs,retryable:X.retryable})},registerCommand:(X)=>{let K=O(G.pluginId,"command");if(typeof X.handler==="function")Z.commands.set(K,X.handler);Y.commands.push({id:K,name:X.name,description:X.description})},registerRule:(X)=>{let K=O(G.pluginId,"rule");if(typeof X.content==="function"){Z.rules.set(K,X.content),Y.rules.push({id:K,ruleId:X.id,source:X.source,hasContentHandler:!0});return}Y.rules.push({id:K,ruleId:X.id,content:X.content,source:X.source})},registerMessageBuilder:(X)=>{let K=O(G.pluginId,"builder");Z.messageBuilders.set(K,X.build),Y.messageBuilders.push({id:K,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:O(G.pluginId,"provider"),name:X.name,description:X.description,metadata:r(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:O(G.pluginId,"automation_event"),...VG(X)})},registerMcpServer:(X)=>{Y.mcpServers.push(X)}};if(typeof Q.setup==="function")try{let X={...G.setupCtxBase,...G.telemetryEnabled?{telemetry:EG(Q.name)}:{},...G.loggerEnabled?{logger:SG(Q.name)}:{},...Q.manifest.capabilities.includes("automationEvents")?{automation:{ingestEvent:(K)=>{E("automation_event",K)}}}:{}};HG(X),await Q.setup($,X)}catch(X){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q.name,phase:"setup",message:X instanceof Error?X.message:String(X),stack:X instanceof Error?X.stack:void 0}}}return{type:"loaded",state:{plugin:Q,handlers:Z},descriptor:{pluginId:G.pluginId,pluginPath:G.pluginPath,name:Q.name,manifest:Q.manifest,hooks:Q.hooks?Object.entries(Q.hooks).filter(([,X])=>typeof X==="function").map(([X])=>X):void 0,contributions:Y}}}catch(U){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q?.name,phase:"load",message:U instanceof Error?U.message:String(U),stack:U instanceof Error?U.stack:void 0}}}}async function yG(G){if(N.clear(),i=0,f.clear(),G.cwd)try{process.chdir(G.cwd)}catch{}let Q=globalThis.__clineSessionEnv;if(Q)Q.cwd=G.cwd,Q.workspaceInfo=G.workspaceInfo;let U=[],Y=[],Z=[],$=G.exportName||"plugin",X=new Map,K={providerId:G.providerId,modelId:G.modelId},A={session:G.session,client:G.client,user:G.user,workspaceInfo:G.workspaceInfo},L=await Promise.all((G.pluginPaths||[]).map((w)=>{let W=`plugin_${++i}`;return TG({pluginPath:w,pluginId:W,exportName:$,targeting:K,setupCtxBase:A,loggerEnabled:G.loggerEnabled,telemetryEnabled:G.telemetryEnabled})}));for(let w of L){if(w.type==="skipped")continue;if(w.type==="failure"){Y.push(w.failure);continue}let{descriptor:W,state:a}=w,V=X.get(W.name);if(V!==void 0){let D=U[V];if(!D)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:D.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${D.pluginPath}`}),N.delete(D.pluginId),U.splice(V,1),X.clear();for(let[e,GG]of U.entries())X.set(GG.name,e)}}N.set(W.pluginId,a),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function bG(G){let U=B(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function RG(G){let U=B(G.pluginId).handlers.tools.get(G.contributionId);if(typeof U!=="function")throw Error("Unknown sandbox tool contribution");return await U(G.input,G.context)}async function kG(G){let U=B(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function vG(G){let U=B(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}async function xG(G){let U=B(G.pluginId).handlers.rules.get(G.contributionId);if(typeof U!=="function")return"";return await U()}var fG={initialize:yG,invokeHook:bG,executeTool:RG,executeCommand:kG,buildMessages:vG,resolveRuleContent:xG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=fG[G.method];if(!Q){x(G.id,!1,void 0,{message:`Unknown method: ${String(G.method)}`});return}try{let U=await Q(G.args||{});x(G.id,!0,U)}catch(U){x(G.id,!1,void 0,NG(U))}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cline/cli-linux-arm64",
3
- "version": "3.0.47-nightly.1785415224",
3
+ "version": "3.0.48",
4
4
  "description": "Cline CLI binary for linux arm64",
5
5
  "os": [
6
6
  "linux"