@aidotnet/server-win32-x64 0.14.3108 → 0.14.3110
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.
- package/bin/astra-server.exe +2 -2
- package/bin/wwwroot/assets/{ClientsPage-G2RzDwxF.js → ClientsPage-DF3rflag.js} +1 -1
- package/bin/wwwroot/assets/{KeyPage-B5yEJIx1.js → KeyPage-B7_1Yr16.js} +1 -1
- package/bin/wwwroot/assets/{McpPage-Cqa0o8pN.js → McpPage-CvN5NYlZ.js} +2 -2
- package/bin/wwwroot/assets/{ModelDetailPage-7guGX9zo.js → ModelDetailPage-CyE8Xpqg.js} +1 -1
- package/bin/wwwroot/assets/{ModelsPage-BDyBn2ka.js → ModelsPage-Cct68Oc8.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-DIXK68XW.js → PluginsPage-DiMYLnBv.js} +1 -1
- package/bin/wwwroot/assets/{PrivacyPage-BXSsUc19.js → PrivacyPage-Bdyo4YN_.js} +1 -1
- package/bin/wwwroot/assets/{ProviderDetailPage-ZAGqduuj.js → ProviderDetailPage-CZLD3Mo2.js} +1 -1
- package/bin/wwwroot/assets/{ProvidersPage-BtVpzabI.js → ProvidersPage-DhvpZLqS.js} +1 -1
- package/bin/wwwroot/assets/{SettingsPage-PTbLN9Jh.js → SettingsPage-QVURVf8n.js} +2 -2
- package/bin/wwwroot/assets/{SkillsPage-CX6F2OHt.js → SkillsPage-DUAhBBjy.js} +1 -1
- package/bin/wwwroot/assets/{SmartRoutingPage-Xs6563FH.js → SmartRoutingPage-yxPbwM3u.js} +1 -1
- package/bin/wwwroot/assets/{TokenDetailPage-BCsrS5MY.js → TokenDetailPage-jvkJ9wIf.js} +1 -1
- package/bin/wwwroot/assets/{TokenPoolEditor-yKDplMAk.js → TokenPoolEditor-eWoOGd9t.js} +1 -1
- package/bin/wwwroot/assets/{TokensPage-CovQvxys.js → TokensPage-BTnINKwi.js} +1 -1
- package/bin/wwwroot/assets/{TracesPage-nE3zf5Pt.js → TracesPage-CGAcVl3u.js} +2 -2
- package/bin/wwwroot/assets/{TrayPanelPage-NhkC5uY7.js → TrayPanelPage-CackS8OH.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-DsZLtFjY.js → TrayPanelView-Cj0Pwm7y.js} +1 -1
- package/bin/wwwroot/assets/{TrayTitleSource-U2fI0rGJ.js → TrayTitleSource-EINzpQeQ.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-C7ORfHsK.js → checkbox-DFbPH3ZB.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-Cm30hox1.js → confirm-morph-Cu1awcrW.js} +1 -1
- package/bin/wwwroot/assets/{format-hEAJVPjJ.js → format-Bw-mDeuE.js} +2 -2
- package/bin/wwwroot/assets/{index-CUXoLKaW.js → index-D2hgi2oA.js} +3 -3
- package/bin/wwwroot/assets/{radio-cards-B9j0qfgH.js → radio-cards-C0nGl7Px.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-CiuAGjJv.js → sortable.esm-KYAcfdq_.js} +1 -1
- package/bin/wwwroot/assets/{use-transform-DS7fo517.js → use-transform-BEsJGrlr.js} +1 -1
- package/bin/wwwroot/index.html +4 -4
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,o as t,r as n}from"./createLucideIcon-7fjTeqBK.js";import{A as r,Ar as i,C as a,D as o,Dr as s,E as c,F as l,Fa as u,H as d,J as f,L as p,La as m,M as h,Ma as g,Mi as _,Mn as v,N as y,Na as b,Nn as x,Oi as S,Or as C,Pa as w,Pi as T,Pn as E,To as D,U as O,V as k,W as A,X as j,Xr as M,Xt as ee,_a as N,c as P,da as te,ea as ne,ii as F,j as I,ma as L,o as R,p as z,u as B,ut as V,vr as re,vt as ie,wi as H,wn as ae,wo as oe,x as U,yn as se,yr as ce,z as le}from"./format-hEAJVPjJ.js";import{A as ue,F as de,H as fe,I as W,P as pe,U as G,V as K,W as q}from"./TrayTitleSource-U2fI0rGJ.js";import{t as me}from"./archive-CiVf7slo.js";import{t as J}from"./arrow-left-DhPqlXf4.js";import{t as he}from"./chart-column-TQVFilUc.js";import{t as ge}from"./chevron-down-CQQqnJvT.js";import{t as _e}from"./chevron-up-BNvDpRa-.js";import{t as ve}from"./circle-question-mark-DdDavLt6.js";import{t as ye}from"./cloud-download-l1GjuXcO.js";import{t as be}from"./cloud-upload-CincxlRw.js";import{t as xe}from"./flask-conical-P-TiuT25.js";import{t as Se}from"./image-plus-C5rL1_SU.js";import{t as Ce}from"./plus-c3HzV6VX.js";import{t as we}from"./refresh-cw-CoLAai2c.js";import{t as Te}from"./server-CuiQSQOX.js";import{t as Ee}from"./square-DO9MseLK.js";import{t as De}from"./trash-BHBJn5GS.js";import{t as Oe}from"./upload-yXA41tlC.js";import{t as ke}from"./x-AFrW8zH7.js";import{A as Ae,B as je,F as Me,K as Ne,M as Pe,V as Fe,W as Ie,u as Le,v as Re,w as ze,y as Be}from"./index-CUXoLKaW.js";import{t as Ve}from"./radio-cards-B9j0qfgH.js";import{t as He}from"./checkbox-C7ORfHsK.js";var Y={root:`_root_2bejs_1`,horizontal:`_horizontal_2bejs_5`,list:`_list_2bejs_7`,item:`_item_2bejs_9`,vertical:`_vertical_2bejs_13`,compact:`_compact_2bejs_15`,head:`_head_2bejs_21`,marker:`_marker_2bejs_39`,ring:`_ring_2bejs_41`,disc:`_disc_2bejs_43`,glyph:`_glyph_2bejs_45`,icon:`_icon_2bejs_47`,connector:`_connector_2bejs_61`,fill:`_fill_2bejs_69`,text:`_text_2bejs_79`,label:`_label_2bejs_85`,slot:`_slot_2bejs_93`,slotInner:`_slotInner_2bejs_95`,description:`_description_2bejs_97`,error:`_error_2bejs_97`,caption:`_caption_2bejs_105`,captionLabel:`_captionLabel_2bejs_107`,srOnly:`_srOnly_2bejs_125`},X=t(n(),1),Z=D(),Ue=e=>`blur(${e}px)`,Q={duration:0},We={duration:j.duration.fast,ease:[...j.ease.standard]},Ge={duration:j.duration.standard,ease:[...j.ease.enter]},Ke={opacity:0,y:`0.3em`,filter:Ue(j.blur.soft)},qe={opacity:1,y:0,filter:Ue(0)},Je={opacity:0,y:`-0.3em`,filter:Ue(j.blur.subtle)},Ye={opacity:0,scale:.5,filter:Ue(j.blur.subtle)},Xe={opacity:1,scale:1,filter:Ue(0)};function Ze({text:e,className:t,reduced:n}){let r=(0,X.useRef)(null),i=(0,X.useRef)(0),a=u(`auto`);return(0,X.useLayoutEffect)(()=>{i.current=performance.now()+700},[e]),(0,X.useEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let t=e.offsetHeight;if(!o||n||performance.now()>i.current){o=!0,a.jump(t);return}b(a,t,j.spring.smooth)});return s.observe(e),()=>s.disconnect()},[a,n]),(0,Z.jsx)(g.span,{className:Y.slot,style:{height:a},children:(0,Z.jsx)(`span`,{ref:r,className:Y.slotInner,children:(0,Z.jsx)(m,{mode:`popLayout`,initial:!1,children:e?(0,Z.jsx)(g.span,{className:t,initial:Ke,animate:qe,exit:{...Je,transition:n?Q:We},transition:n?Q:Ge,children:e},`${t}:${e}`):null})})})}function Qe({kind:e,number:t,delay:n,reduced:r}){let i=r?Q:{scale:{...j.spring.snappy,delay:n},opacity:{duration:j.duration.fast,delay:n},filter:{duration:j.duration.fast,delay:n}},a={...Ye,transition:r?Q:We},o=r?Q:{duration:j.duration.standard,ease:j.ease.enter,delay:n+.04};return e===`number`?(0,Z.jsx)(g.span,{className:Y.glyph,initial:Ye,animate:Xe,exit:a,transition:i,children:t}):(0,Z.jsx)(g.svg,{className:`${Y.glyph} ${Y.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:Ye,animate:Xe,exit:a,transition:i,children:e===`check`?(0,Z.jsx)(g.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:o}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:o}),(0,Z.jsx)(g.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Q:{...j.spring.snappy,delay:n+.16}})]})})}function $e({number:e,kind:t,current:n,glyphDelay:r,ringDelay:i,reduced:a}){return(0,Z.jsxs)(`span`,{className:Y.marker,"aria-hidden":`true`,children:[(0,Z.jsx)(m,{initial:!1,children:n?(0,Z.jsx)(g.span,{className:Y.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:a?Q:We},transition:a?Q:{scale:{...j.spring.snappy,delay:i},opacity:{duration:j.duration.fast,delay:i}}},`ring`):null}),(0,Z.jsx)(`span`,{className:Y.disc,children:(0,Z.jsx)(m,{initial:!1,children:(0,Z.jsx)(Qe,{kind:t,number:e,delay:r,reduced:a},t)})})]})}var et={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function tt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:r,details:i=`all`,compact:a=!1,label:o=`Progress`,completeLabel:s=`All steps complete`,className:c}){let l=w()??!1,u=e.length,d=Math.min(Math.max(Math.round(t),0),u),[f,p]=(0,X.useState)({to:d,from:d});f.to!==d&&p({to:d,from:f.to});let m=f.from,h=j.stagger.line,_=e=>l?0:d>m?e>=m&&e<d?(e-m)*h:0:e>=d&&e<m?(m-1-e)*h:0,v=l?0:Math.max(0,Math.abs(d-m)-1)*h+.12,y=!!r,b=n===`vertical`,x=d>=u?void 0:e[d];function S(e){let t=!b&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let C=y?`nav`:`div`,T=[Y.root,b?Y.vertical:Y.horizontal,a?Y.compact:``,c].filter(Boolean).join(` `);return(0,Z.jsxs)(C,{className:T,"aria-label":o,role:y?void 0:`group`,children:[(0,Z.jsx)(`ol`,{className:Y.list,style:b?void 0:{gridTemplateColumns:u>1?`repeat(${u-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:y?S:void 0,children:e.map((e,t)=>{let a=t===d,o=e.error?`error`:t<d?`complete`:a?`current`:`upcoming`,s=y&&t<d,c=e.error??(i===`all`||a?e.description:void 0),f=e.error?`error`:t<d?`check`:`number`,p=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($e,{number:t+1,kind:f,current:a,glyphDelay:_(t),ringDelay:v,reduced:l}),(0,Z.jsxs)(`span`,{className:Y.text,children:[(0,Z.jsx)(`span`,{className:Y.label,children:e.label}),et[o]?(0,Z.jsxs)(`span`,{className:Y.srOnly,children:[`, `,et[o]]}):null,(0,Z.jsx)(Ze,{text:c,className:e.error?Y.error:Y.description,reduced:l})]})]});return(0,Z.jsxs)(`li`,{className:Y.item,"data-status":o,children:[t<u-1?(0,Z.jsx)(`span`,{className:Y.connector,"aria-hidden":`true`,children:(0,Z.jsx)(g.span,{className:Y.fill,initial:!1,animate:b?{scaleY:+(t<d)}:{scaleX:+(t<d)},transition:l?Q:{...j.spring.smooth,delay:_(t)}},n)}):null,y?(0,Z.jsx)(`button`,{type:`button`,className:Y.head,"data-clickable":s||void 0,"data-reachable":t<=d||void 0,"aria-current":a?`step`:void 0,"aria-disabled":!s||void 0,tabIndex:s?void 0:-1,onClick:s?()=>r?.(t):void 0,children:p}):(0,Z.jsx)(`span`,{className:Y.head,"aria-current":a?`step`:void 0,children:p})]},e.id)})}),b?null:(0,Z.jsxs)(`span`,{className:Y.caption,"aria-hidden":`true`,children:[(0,Z.jsx)(Ze,{text:x?.label??s,className:Y.captionLabel,reduced:l}),(0,Z.jsx)(Ze,{text:x?.error??x?.description,className:x?.error?Y.error:Y.description,reduced:l})]}),(0,Z.jsx)(`span`,{className:Y.srOnly,"aria-live":`polite`,children:x?`Step ${d+1} of ${u}: ${x.label}`:s})]})}var nt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},rt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},it=e=>`${e.source}\u0000${e.ref}`,at=e=>e.status!==`skip`&&e.status!==`same`;function ot(e){try{return new URL(e).host}catch{return e}}function st({open:e,onOpenChange:t}){let{t:n}=a(),{toast:r}=q(),i=E(e),s=x(),[c,l]=(0,X.useState)(``),[u,f]=(0,X.useState)(new Set),[p,m]=(0,X.useState)(null);(0,X.useEffect)(()=>{i.data&&f(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(it)))},[i.data]),(0,X.useEffect)(()=>{e&&(l(``),m(null))},[e]);let h=c.trim().toLowerCase(),g=e=>!h||e.name.toLowerCase().includes(h)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(h)),_=(0,X.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>u.has(it(e))&&at(e)),[i.data,u]),v=(e,t)=>f(n=>{let r=new Set(n);return t?r.add(it(e)):r.delete(it(e)),r});return(0,Z.jsx)(fe,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{icon:(0,Z.jsx)(we,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||s.isPending,children:n(`import.rescan`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:_.length===0||s.isPending,onClick:()=>{m(null),s.mutate(_.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{m(G(e)),i.refetch()}})},children:n(`import.selected`,{count:_.length})})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(le,{value:c,onChange:l,placeholder:n(`import.search`)}),p&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:p}),i.isLoading&&(0,Z.jsx)(d,{lines:3}),i.isError&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:G(i.error)}),(0,Z.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,Z.jsx)(ct,{source:e,matches:g,selected:u,onToggle:v,filtering:h.length>0},e.id))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function ct({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:o}=a(),s=e.items.filter(t);return(0,Z.jsxs)(`section`,{"aria-label":e.name,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 px-1`,children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:e.name}),e.path&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:o(`import.path`,{path:e.path}),children:e.path})]}),e.error?(0,Z.jsx)(U,{tone:`danger`,title:o(`import.sourceError`,{error:e.error})}):e.found?s.length===0?(0,Z.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(i?`import.noMatch`:`import.noItems`)}):(0,Z.jsx)(`ul`,{className:`card divide-y divide-[var(--border)]`,children:s.map(e=>(0,Z.jsx)(lt,{c:e,checked:n.has(it(e)),onToggle:t=>r(e,t)},it(e)))}):(0,Z.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(`import.notFound`)})]})}function lt({c:e,checked:t,onToggle:n}){let{t:r}=a(),i=at(e),o=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,s=e.endpoints.map(e=>`${nt[e.protocol]??e.protocol} · ${ot(e.baseUrl)}`).join(` / `);return(0,Z.jsxs)(`li`,{className:V(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,Z.jsx)(He,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,Z.jsx)(c,{tone:rt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,Z.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),s&&(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:s,children:s}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,Z.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,Z.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),o&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:o}),e.ignoredFields.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}function ut({onRestored:e}){let{t}=a(),{toast:n}=q(),r=L(),i=F(),s=ae(),c=_(),u=te(),d=M(),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(`astra`),[x,S]=(0,X.useState)(`none`),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(null);(0,X.useEffect)(()=>{r.data&&(p(r.data.url),h(r.data.username),b(r.data.folder))},[r.data]);let D=e=>E(G(e)),O=r.data?.configured===!0,k=i.isPending||c.isPending||u.isPending||d.isPending||s.isPending;return(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":t(`backup.webdav.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`backup.webdav.title`)}),(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`backup.webdav.hint`)}),(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.url`),placeholder:`https://dav.example.com/remote.php/dav/files/me`,mono:!0,value:f,onChange:e=>p(e.target.value)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.username`),placeholder:t(`backup.webdav.username`),autoComplete:`off`,value:m,onChange:e=>h(e.target.value)}),(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":t(`backup.webdav.password`),placeholder:r.data?.hasPassword?t(`backup.webdav.passwordKept`):t(`backup.webdav.password`),value:g,onChange:e=>v(e.target.value)})]}),(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.folder`),placeholder:t(`backup.webdav.folder`),mono:!0,value:y,onChange:e=>b(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,disabled:k||f.trim().length===0,onClick:()=>{E(null),i.mutate({url:f,username:m,folder:y,password:g||void 0},{onSuccess:()=>{v(``),n(t(`backup.webdav.saved`))},onError:D})},children:t(`backup.webdav.save`)}),(0,Z.jsx)(o,{disabled:k||!O,onClick:()=>{E(null),c.mutate(void 0,{onSuccess:()=>n(t(`backup.webdav.testOk`)),onError:D})},children:t(`backup.webdav.test`)}),O&&(0,Z.jsx)(o,{disabled:k,onClick:()=>{E(null),s.mutate(void 0,{onSuccess:()=>{p(``),h(``),v(``)},onError:D})},children:t(`backup.webdav.forget`)})]}),O&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] text-[var(--text-muted)]`,children:t(`backup.export.secrets`)}),(0,Z.jsx)(K,{className:`w-64`,ariaLabel:t(`backup.export.secrets`),value:x,onChange:e=>S(e),options:[{value:`none`,label:t(`backup.secrets.none`)},{value:`passphrase`,label:t(`backup.secrets.passphrase`)}]})]}),x===`passphrase`&&(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":`${t(`backup.webdav.title`)} ${t(`backup.passphrase`)}`,placeholder:t(`backup.passphrase`),value:C,onChange:e=>w(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(be,{className:`size-3.5`}),disabled:k||x===`passphrase`&&C.length<8,onClick:()=>{E(null),u.mutate({secrets:x,passphrase:x===`passphrase`?C:void 0},{onSuccess:e=>n(t(`backup.webdav.uploadDone`,{count:e.uploaded})),onError:D})},children:t(`backup.webdav.upload`)}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(ye,{className:`size-3.5`}),disabled:k,onClick:()=>{E(null),d.mutate(void 0,{onSuccess:e,onError:D})},children:t(`backup.webdav.restore`)})]})]}),T&&(0,Z.jsx)(U,{tone:`danger`,title:t(`common.error`),children:T})]})}var dt={new:`green`,sameHost:`orange`,same:`neutral`,invalid:`red`},ft=e=>e.status===`new`||e.status===`sameHost`;function pt(e,t){let n=URL.createObjectURL(new Blob([JSON.stringify(t,null,2)],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}function mt(e){return typeof e==`object`&&!!e&&e.format===`astra-providers`&&Array.isArray(e.providers)}function ht({open:e,onOpenChange:t}){let{t:n}=a(),{toast:r}=q(),i=se(),s=re(),c=v(),u=(0,X.useRef)(null),[d,f]=(0,X.useState)(`none`),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(null),[_,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(new Set),[E,D]=(0,X.useState)(null),O=()=>{g(null),i.mutate({secrets:d,passphrase:d===`passphrase`?p:void 0},{onSuccess:e=>{pt(`astra-providers-${new Date().toISOString().slice(0,10)}.json`,e),r(n(`backup.export.done`,{count:e.providers.length})),m(``)},onError:e=>g(G(e))})},k=(e,t)=>{D(null),s.mutate({file:e,passphrase:e.secrets===`passphrase`?t:void 0},{onSuccess:e=>{C(e),T(new Set(e.items.filter(e=>e.status===`new`).map(e=>e.index)))},onError:e=>{C(null),D(G(e))}})},A=e=>{C(null),D(null),y(e),e.secrets!==`passphrase`&&k(e,``)},j=async e=>{if(C(null),y(null),D(null),e)try{let t=JSON.parse(await e.text());if(!mt(t))throw Error(`not a backup`);y(t),t.secrets!==`passphrase`&&k(t,``)}catch{D(n(`backup.import.badFile`))}},M=()=>{_&&(D(null),c.mutate({file:_,passphrase:_.secrets===`passphrase`?b:void 0,indexes:[...w]},{onSuccess:e=>{r(e.skipped.length>0?n(`backup.import.doneSkipped`,{count:e.added.length,skipped:e.skipped.length}):n(`backup.import.done`,{count:e.added.length})),y(null),C(null),x(``),t(!1)},onError:e=>D(G(e))}))},ee=(e,t)=>T(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),N=_?.secrets===`passphrase`&&!S,P=i.isPending||d===`passphrase`&&p.length<8;return(0,Z.jsx)(fe,{open:e,onOpenChange:t,width:640,title:n(`backup.title`),description:n(`backup.detail`),children:(0,Z.jsxs)(`div`,{className:`grid gap-6`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":n(`backup.export.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:n(`backup.export.title`)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] text-[var(--text-muted)]`,children:n(`backup.export.secrets`)}),(0,Z.jsx)(K,{className:`w-64`,ariaLabel:n(`backup.export.secrets`),value:d,onChange:e=>f(e),options:[{value:`none`,label:n(`backup.secrets.none`)},{value:`passphrase`,label:n(`backup.secrets.passphrase`)},{value:`plaintext`,label:n(`backup.secrets.plaintext`)}]})]}),d!==`none`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.secrets.hint`)}),d===`passphrase`&&(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":n(`backup.passphrase`),placeholder:n(`backup.passphrase`),value:p,onChange:e=>m(e.target.value)}),d===`passphrase`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.passphrase.hint`)}),d===`plaintext`&&(0,Z.jsx)(U,{tone:`warning`,title:n(`backup.plaintext.warn`)}),h&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:h}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(je,{className:`size-3.5`}),disabled:P,onClick:O,children:n(`backup.export.run`)})})]}),(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":n(`backup.import.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:n(`backup.import.title`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`input`,{ref:u,type:`file`,accept:`.json,application/json`,className:`hidden`,"aria-label":n(`backup.import.choose`),onChange:e=>{j(e.target.files?.[0]),e.target.value=``}}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(Oe,{className:`size-3.5`}),onClick:()=>u.current?.click(),children:n(`backup.import.choose`)})]}),N&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`backup.import.encrypted`)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(l,{className:`flex-1`,type:`password`,autoComplete:`off`,"aria-label":n(`backup.passphrase`),placeholder:n(`backup.passphrase`),value:b,onChange:e=>x(e.target.value)}),(0,Z.jsx)(o,{disabled:b.length===0||s.isPending,onClick:()=>_&&k(_,b),children:n(`backup.import.preview`)})]})]}),E&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:E}),S&&(0,Z.jsxs)(Z.Fragment,{children:[S.secrets===`none`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.import.noKeys`)}),(0,Z.jsx)(`ul`,{className:`card max-h-[320px] divide-y divide-[var(--border)] overflow-auto`,children:S.items.map(e=>(0,Z.jsx)(gt,{item:e,checked:w.has(e.index),onToggle:t=>ee(e.index,t)},e.index))}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{variant:`primary`,disabled:w.size===0||c.isPending,onClick:M,children:n(`backup.import.run`,{count:w.size})})})]})]}),(0,Z.jsx)(ut,{onRestored:A})]})})}function gt({item:e,checked:t,onToggle:n}){let{t:r}=a(),i=ft(e);return(0,Z.jsxs)(`li`,{className:V(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,Z.jsx)(He,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,Z.jsx)(c,{tone:dt[e.status],children:r(`backup.status.${e.status}`)})]}),e.endpoints&&e.endpoints.length>0&&(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,children:e.endpoints.map(e=>e.baseUrl).join(` / `)}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[e.hasKey&&(0,Z.jsx)(`span`,{className:`font-mono`,children:e.keyMasked??`••••`}),(0,Z.jsx)(`span`,{children:r(`backup.models`,{count:e.modelCount})})]}),e.existing&&e.status!==`new`&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:e.existing.name}),e.error&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--danger)]`,children:e.error}),e.ignored.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignored.join(`, `)})})]})]})}var _t=`astra.providers.view`,vt=`astra.providers.charts`;function yt(e){try{return localStorage.getItem(e)}catch{return null}}function bt(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function xt(){let[e,t]=(0,X.useState)(()=>yt(_t)===`table`?`table`:`grid`);return[e,e=>{t(e),bt(_t,e===`table`?`table`:null)}]}function St(){let[e,t]=(0,X.useState)(()=>yt(vt)!==`0`);return[e,e=>{t(e),bt(vt,e?null:`0`)}]}var Ct=5;function wt(e){return!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`}function Tt(e,t){return e.enabled?wt(e)?`noKey`:t&&t.requests>=Ct&&t.successRate<.9?`lowSuccess`:`healthy`:`disabled`}var Et={healthy:`green`,noKey:`orange`,lowSuccess:`red`,disabled:`neutral`};function Dt(e,t){return t(e===`disabled`?`providers.card.disabled`:e===`noKey`?`providers.noKey`:e===`lowSuccess`?`providers.card.lowSuccess`:`providers.card.active`)}var Ot=[`var(--accent)`,`var(--success)`,`var(--warning)`,`#af52de`,`#5ac8fa`,`#ff2d55`],kt=`var(--text-muted)`;function At(e){return e>=.97?`var(--success)`:e>=.9?`var(--warning)`:`var(--danger)`}function jt({data:e,labels:t,max:n,className:r}){return(0,Z.jsx)(`span`,{className:V(`flex h-[22px] shrink-0 items-end gap-[2px]`,r),title:e.map((e,n)=>`${t[n]}: ${e}`).join(`
|
|
1
|
+
import{a as e,o as t,r as n}from"./createLucideIcon-7fjTeqBK.js";import{A as r,Ar as i,C as a,D as o,Dr as s,E as c,F as l,Fa as u,H as d,J as f,L as p,La as m,M as h,Ma as g,Mi as _,Mn as v,N as y,Na as b,Nn as x,Oi as S,Or as C,Pa as w,Pi as T,Pn as E,To as D,U as O,V as k,W as A,X as j,Xr as M,Xt as ee,_a as N,c as P,da as te,ea as ne,ii as F,j as I,ma as L,o as R,p as z,u as B,ut as V,vr as re,vt as ie,wi as H,wn as ae,wo as oe,x as U,yn as se,yr as ce,z as le}from"./format-Bw-mDeuE.js";import{A as ue,F as de,H as fe,I as W,P as pe,U as G,V as K,W as q}from"./TrayTitleSource-EINzpQeQ.js";import{t as me}from"./archive-CiVf7slo.js";import{t as J}from"./arrow-left-DhPqlXf4.js";import{t as he}from"./chart-column-TQVFilUc.js";import{t as ge}from"./chevron-down-CQQqnJvT.js";import{t as _e}from"./chevron-up-BNvDpRa-.js";import{t as ve}from"./circle-question-mark-DdDavLt6.js";import{t as ye}from"./cloud-download-l1GjuXcO.js";import{t as be}from"./cloud-upload-CincxlRw.js";import{t as xe}from"./flask-conical-P-TiuT25.js";import{t as Se}from"./image-plus-C5rL1_SU.js";import{t as Ce}from"./plus-c3HzV6VX.js";import{t as we}from"./refresh-cw-CoLAai2c.js";import{t as Te}from"./server-CuiQSQOX.js";import{t as Ee}from"./square-DO9MseLK.js";import{t as De}from"./trash-BHBJn5GS.js";import{t as Oe}from"./upload-yXA41tlC.js";import{t as ke}from"./x-AFrW8zH7.js";import{A as Ae,B as je,F as Me,K as Ne,M as Pe,V as Fe,W as Ie,u as Le,v as Re,w as ze,y as Be}from"./index-D2hgi2oA.js";import{t as Ve}from"./radio-cards-C0nGl7Px.js";import{t as He}from"./checkbox-DFbPH3ZB.js";var Y={root:`_root_2bejs_1`,horizontal:`_horizontal_2bejs_5`,list:`_list_2bejs_7`,item:`_item_2bejs_9`,vertical:`_vertical_2bejs_13`,compact:`_compact_2bejs_15`,head:`_head_2bejs_21`,marker:`_marker_2bejs_39`,ring:`_ring_2bejs_41`,disc:`_disc_2bejs_43`,glyph:`_glyph_2bejs_45`,icon:`_icon_2bejs_47`,connector:`_connector_2bejs_61`,fill:`_fill_2bejs_69`,text:`_text_2bejs_79`,label:`_label_2bejs_85`,slot:`_slot_2bejs_93`,slotInner:`_slotInner_2bejs_95`,description:`_description_2bejs_97`,error:`_error_2bejs_97`,caption:`_caption_2bejs_105`,captionLabel:`_captionLabel_2bejs_107`,srOnly:`_srOnly_2bejs_125`},X=t(n(),1),Z=D(),Ue=e=>`blur(${e}px)`,Q={duration:0},We={duration:j.duration.fast,ease:[...j.ease.standard]},Ge={duration:j.duration.standard,ease:[...j.ease.enter]},Ke={opacity:0,y:`0.3em`,filter:Ue(j.blur.soft)},qe={opacity:1,y:0,filter:Ue(0)},Je={opacity:0,y:`-0.3em`,filter:Ue(j.blur.subtle)},Ye={opacity:0,scale:.5,filter:Ue(j.blur.subtle)},Xe={opacity:1,scale:1,filter:Ue(0)};function Ze({text:e,className:t,reduced:n}){let r=(0,X.useRef)(null),i=(0,X.useRef)(0),a=u(`auto`);return(0,X.useLayoutEffect)(()=>{i.current=performance.now()+700},[e]),(0,X.useEffect)(()=>{let e=r.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver>`u`)return;let o=!1,s=new ResizeObserver(()=>{let t=e.offsetHeight;if(!o||n||performance.now()>i.current){o=!0,a.jump(t);return}b(a,t,j.spring.smooth)});return s.observe(e),()=>s.disconnect()},[a,n]),(0,Z.jsx)(g.span,{className:Y.slot,style:{height:a},children:(0,Z.jsx)(`span`,{ref:r,className:Y.slotInner,children:(0,Z.jsx)(m,{mode:`popLayout`,initial:!1,children:e?(0,Z.jsx)(g.span,{className:t,initial:Ke,animate:qe,exit:{...Je,transition:n?Q:We},transition:n?Q:Ge,children:e},`${t}:${e}`):null})})})}function Qe({kind:e,number:t,delay:n,reduced:r}){let i=r?Q:{scale:{...j.spring.snappy,delay:n},opacity:{duration:j.duration.fast,delay:n},filter:{duration:j.duration.fast,delay:n}},a={...Ye,transition:r?Q:We},o=r?Q:{duration:j.duration.standard,ease:j.ease.enter,delay:n+.04};return e===`number`?(0,Z.jsx)(g.span,{className:Y.glyph,initial:Ye,animate:Xe,exit:a,transition:i,children:t}):(0,Z.jsx)(g.svg,{className:`${Y.glyph} ${Y.icon}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:Ye,animate:Xe,exit:a,transition:i,children:e===`check`?(0,Z.jsx)(g.path,{d:`M5.5 12.5l4.25 4.25L18.5 8`,initial:{pathLength:0},animate:{pathLength:1},transition:o}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g.path,{d:`M12 6.75v6.5`,initial:{pathLength:0},animate:{pathLength:1},transition:o}),(0,Z.jsx)(g.circle,{cx:12,cy:17.4,r:1.4,fill:`currentColor`,stroke:`none`,initial:{scale:0},animate:{scale:1},transition:r?Q:{...j.spring.snappy,delay:n+.16}})]})})}function $e({number:e,kind:t,current:n,glyphDelay:r,ringDelay:i,reduced:a}){return(0,Z.jsxs)(`span`,{className:Y.marker,"aria-hidden":`true`,children:[(0,Z.jsx)(m,{initial:!1,children:n?(0,Z.jsx)(g.span,{className:Y.ring,initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:a?Q:We},transition:a?Q:{scale:{...j.spring.snappy,delay:i},opacity:{duration:j.duration.fast,delay:i}}},`ring`):null}),(0,Z.jsx)(`span`,{className:Y.disc,children:(0,Z.jsx)(m,{initial:!1,children:(0,Z.jsx)(Qe,{kind:t,number:e,delay:r,reduced:a},t)})})]})}var et={complete:`Completed`,current:``,upcoming:`Not started`,error:`Error`};function tt({steps:e,current:t,orientation:n=`horizontal`,onStepSelect:r,details:i=`all`,compact:a=!1,label:o=`Progress`,completeLabel:s=`All steps complete`,className:c}){let l=w()??!1,u=e.length,d=Math.min(Math.max(Math.round(t),0),u),[f,p]=(0,X.useState)({to:d,from:d});f.to!==d&&p({to:d,from:f.to});let m=f.from,h=j.stagger.line,_=e=>l?0:d>m?e>=m&&e<d?(e-m)*h:0:e>=d&&e<m?(m-1-e)*h:0,v=l?0:Math.max(0,Math.abs(d-m)-1)*h+.12,y=!!r,b=n===`vertical`,x=d>=u?void 0:e[d];function S(e){let t=!b&&getComputedStyle(e.currentTarget).direction===`rtl`,n=[`ArrowUp`,t?`ArrowRight`:`ArrowLeft`],r=[`ArrowDown`,t?`ArrowLeft`:`ArrowRight`];if(![...n,...r,`Home`,`End`].includes(e.key))return;let i=Array.from(e.currentTarget.querySelectorAll(`button[data-reachable]`)),a=i.indexOf(e.target);a<0||(e.preventDefault(),i[e.key===`Home`?0:e.key===`End`?i.length-1:n.includes(e.key)?Math.max(0,a-1):Math.min(i.length-1,a+1)]?.focus())}let C=y?`nav`:`div`,T=[Y.root,b?Y.vertical:Y.horizontal,a?Y.compact:``,c].filter(Boolean).join(` `);return(0,Z.jsxs)(C,{className:T,"aria-label":o,role:y?void 0:`group`,children:[(0,Z.jsx)(`ol`,{className:Y.list,style:b?void 0:{gridTemplateColumns:u>1?`repeat(${u-1}, minmax(0, 1fr)) auto`:`auto`},onKeyDown:y?S:void 0,children:e.map((e,t)=>{let a=t===d,o=e.error?`error`:t<d?`complete`:a?`current`:`upcoming`,s=y&&t<d,c=e.error??(i===`all`||a?e.description:void 0),f=e.error?`error`:t<d?`check`:`number`,p=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($e,{number:t+1,kind:f,current:a,glyphDelay:_(t),ringDelay:v,reduced:l}),(0,Z.jsxs)(`span`,{className:Y.text,children:[(0,Z.jsx)(`span`,{className:Y.label,children:e.label}),et[o]?(0,Z.jsxs)(`span`,{className:Y.srOnly,children:[`, `,et[o]]}):null,(0,Z.jsx)(Ze,{text:c,className:e.error?Y.error:Y.description,reduced:l})]})]});return(0,Z.jsxs)(`li`,{className:Y.item,"data-status":o,children:[t<u-1?(0,Z.jsx)(`span`,{className:Y.connector,"aria-hidden":`true`,children:(0,Z.jsx)(g.span,{className:Y.fill,initial:!1,animate:b?{scaleY:+(t<d)}:{scaleX:+(t<d)},transition:l?Q:{...j.spring.smooth,delay:_(t)}},n)}):null,y?(0,Z.jsx)(`button`,{type:`button`,className:Y.head,"data-clickable":s||void 0,"data-reachable":t<=d||void 0,"aria-current":a?`step`:void 0,"aria-disabled":!s||void 0,tabIndex:s?void 0:-1,onClick:s?()=>r?.(t):void 0,children:p}):(0,Z.jsx)(`span`,{className:Y.head,"aria-current":a?`step`:void 0,children:p})]},e.id)})}),b?null:(0,Z.jsxs)(`span`,{className:Y.caption,"aria-hidden":`true`,children:[(0,Z.jsx)(Ze,{text:x?.label??s,className:Y.captionLabel,reduced:l}),(0,Z.jsx)(Ze,{text:x?.error??x?.description,className:x?.error?Y.error:Y.description,reduced:l})]}),(0,Z.jsx)(`span`,{className:Y.srOnly,"aria-live":`polite`,children:x?`Step ${d+1} of ${u}: ${x.label}`:s})]})}var nt={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},rt={new:`green`,same:`neutral`,sameHost:`orange`,off:`neutral`,skip:`red`},it=e=>`${e.source}\u0000${e.ref}`,at=e=>e.status!==`skip`&&e.status!==`same`;function ot(e){try{return new URL(e).host}catch{return e}}function st({open:e,onOpenChange:t}){let{t:n}=a(),{toast:r}=q(),i=E(e),s=x(),[c,l]=(0,X.useState)(``),[u,f]=(0,X.useState)(new Set),[p,m]=(0,X.useState)(null);(0,X.useEffect)(()=>{i.data&&f(new Set(i.data.flatMap(e=>e.items).filter(e=>e.status===`new`).map(it)))},[i.data]),(0,X.useEffect)(()=>{e&&(l(``),m(null))},[e]);let h=c.trim().toLowerCase(),g=e=>!h||e.name.toLowerCase().includes(h)||e.endpoints.some(e=>e.baseUrl.toLowerCase().includes(h)),_=(0,X.useMemo)(()=>(i.data??[]).flatMap(e=>e.items).filter(e=>u.has(it(e))&&at(e)),[i.data,u]),v=(e,t)=>f(n=>{let r=new Set(n);return t?r.add(it(e)):r.delete(it(e)),r});return(0,Z.jsx)(fe,{open:e,onOpenChange:t,width:680,title:n(`import.title`),description:n(`import.detail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{icon:(0,Z.jsx)(we,{className:`size-3.5`}),onClick:()=>void i.refetch(),disabled:i.isFetching||s.isPending,children:n(`import.rescan`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:_.length===0||s.isPending,onClick:()=>{m(null),s.mutate(_.map(e=>({source:e.source,ref:e.ref})),{onSuccess:e=>{let i=e.skipped.length;r(i>0?n(`import.doneSkipped`,{count:e.added.length,skipped:i}):n(`import.done`,{count:e.added.length})),t(!1)},onError:e=>{m(G(e)),i.refetch()}})},children:n(`import.selected`,{count:_.length})})]}),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(le,{value:c,onChange:l,placeholder:n(`import.search`)}),p&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:p}),i.isLoading&&(0,Z.jsx)(d,{lines:3}),i.isError&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:G(i.error)}),(0,Z.jsx)(`div`,{className:`grid max-h-[460px] gap-4 overflow-auto pr-1`,children:i.data?.map(e=>(0,Z.jsx)(ct,{source:e,matches:g,selected:u,onToggle:v,filtering:h.length>0},e.id))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`import.footnote`)})]})})}function ct({source:e,matches:t,selected:n,onToggle:r,filtering:i}){let{t:o}=a(),s=e.items.filter(t);return(0,Z.jsxs)(`section`,{"aria-label":e.name,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 px-1`,children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:e.name}),e.path&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:o(`import.path`,{path:e.path}),children:e.path})]}),e.error?(0,Z.jsx)(U,{tone:`danger`,title:o(`import.sourceError`,{error:e.error})}):e.found?s.length===0?(0,Z.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(i?`import.noMatch`:`import.noItems`)}):(0,Z.jsx)(`ul`,{className:`card divide-y divide-[var(--border)]`,children:s.map(e=>(0,Z.jsx)(lt,{c:e,checked:n.has(it(e)),onToggle:t=>r(e,t)},it(e)))}):(0,Z.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:o(`import.notFound`)})]})}function lt({c:e,checked:t,onToggle:n}){let{t:r}=a(),i=at(e),o=e.status===`skip`&&e.skipReason?r(`import.skip.${e.skipReason}`):e.status===`same`&&e.existing?r(`import.existing`,{name:e.existing.name}):e.status===`sameHost`&&e.existing?r(`import.sameHostHint`,{name:e.existing.name}):null,s=e.endpoints.map(e=>`${nt[e.protocol]??e.protocol} · ${ot(e.baseUrl)}`).join(` / `);return(0,Z.jsxs)(`li`,{className:V(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,Z.jsx)(He,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,Z.jsx)(c,{tone:rt[e.status],children:r(`import.status.${e.status}`)}),e.fromApp&&(0,Z.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:e.fromApp})]}),s&&(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,title:s,children:s}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.hasKey?e.keyMasked??`••••`:r(`import.noKey`)}),e.models.length>0&&(0,Z.jsx)(`span`,{children:r(`import.models`,{count:e.models.length})}),e.templateId&&(0,Z.jsx)(`span`,{children:r(`import.template`,{id:e.templateId})})]}),o&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-secondary,var(--text-muted))]`,children:o}),e.ignoredFields.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignoredFields.join(`, `)})})]})]})}function ut({onRestored:e}){let{t}=a(),{toast:n}=q(),r=L(),i=F(),s=ae(),c=_(),u=te(),d=M(),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(`astra`),[x,S]=(0,X.useState)(`none`),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(null);(0,X.useEffect)(()=>{r.data&&(p(r.data.url),h(r.data.username),b(r.data.folder))},[r.data]);let D=e=>E(G(e)),O=r.data?.configured===!0,k=i.isPending||c.isPending||u.isPending||d.isPending||s.isPending;return(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":t(`backup.webdav.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`backup.webdav.title`)}),(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`backup.webdav.hint`)}),(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.url`),placeholder:`https://dav.example.com/remote.php/dav/files/me`,mono:!0,value:f,onChange:e=>p(e.target.value)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.username`),placeholder:t(`backup.webdav.username`),autoComplete:`off`,value:m,onChange:e=>h(e.target.value)}),(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":t(`backup.webdav.password`),placeholder:r.data?.hasPassword?t(`backup.webdav.passwordKept`):t(`backup.webdav.password`),value:g,onChange:e=>v(e.target.value)})]}),(0,Z.jsx)(l,{"aria-label":t(`backup.webdav.folder`),placeholder:t(`backup.webdav.folder`),mono:!0,value:y,onChange:e=>b(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,disabled:k||f.trim().length===0,onClick:()=>{E(null),i.mutate({url:f,username:m,folder:y,password:g||void 0},{onSuccess:()=>{v(``),n(t(`backup.webdav.saved`))},onError:D})},children:t(`backup.webdav.save`)}),(0,Z.jsx)(o,{disabled:k||!O,onClick:()=>{E(null),c.mutate(void 0,{onSuccess:()=>n(t(`backup.webdav.testOk`)),onError:D})},children:t(`backup.webdav.test`)}),O&&(0,Z.jsx)(o,{disabled:k,onClick:()=>{E(null),s.mutate(void 0,{onSuccess:()=>{p(``),h(``),v(``)},onError:D})},children:t(`backup.webdav.forget`)})]}),O&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] text-[var(--text-muted)]`,children:t(`backup.export.secrets`)}),(0,Z.jsx)(K,{className:`w-64`,ariaLabel:t(`backup.export.secrets`),value:x,onChange:e=>S(e),options:[{value:`none`,label:t(`backup.secrets.none`)},{value:`passphrase`,label:t(`backup.secrets.passphrase`)}]})]}),x===`passphrase`&&(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":`${t(`backup.webdav.title`)} ${t(`backup.passphrase`)}`,placeholder:t(`backup.passphrase`),value:C,onChange:e=>w(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(be,{className:`size-3.5`}),disabled:k||x===`passphrase`&&C.length<8,onClick:()=>{E(null),u.mutate({secrets:x,passphrase:x===`passphrase`?C:void 0},{onSuccess:e=>n(t(`backup.webdav.uploadDone`,{count:e.uploaded})),onError:D})},children:t(`backup.webdav.upload`)}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(ye,{className:`size-3.5`}),disabled:k,onClick:()=>{E(null),d.mutate(void 0,{onSuccess:e,onError:D})},children:t(`backup.webdav.restore`)})]})]}),T&&(0,Z.jsx)(U,{tone:`danger`,title:t(`common.error`),children:T})]})}var dt={new:`green`,sameHost:`orange`,same:`neutral`,invalid:`red`},ft=e=>e.status===`new`||e.status===`sameHost`;function pt(e,t){let n=URL.createObjectURL(new Blob([JSON.stringify(t,null,2)],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}function mt(e){return typeof e==`object`&&!!e&&e.format===`astra-providers`&&Array.isArray(e.providers)}function ht({open:e,onOpenChange:t}){let{t:n}=a(),{toast:r}=q(),i=se(),s=re(),c=v(),u=(0,X.useRef)(null),[d,f]=(0,X.useState)(`none`),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(null),[_,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(new Set),[E,D]=(0,X.useState)(null),O=()=>{g(null),i.mutate({secrets:d,passphrase:d===`passphrase`?p:void 0},{onSuccess:e=>{pt(`astra-providers-${new Date().toISOString().slice(0,10)}.json`,e),r(n(`backup.export.done`,{count:e.providers.length})),m(``)},onError:e=>g(G(e))})},k=(e,t)=>{D(null),s.mutate({file:e,passphrase:e.secrets===`passphrase`?t:void 0},{onSuccess:e=>{C(e),T(new Set(e.items.filter(e=>e.status===`new`).map(e=>e.index)))},onError:e=>{C(null),D(G(e))}})},A=e=>{C(null),D(null),y(e),e.secrets!==`passphrase`&&k(e,``)},j=async e=>{if(C(null),y(null),D(null),e)try{let t=JSON.parse(await e.text());if(!mt(t))throw Error(`not a backup`);y(t),t.secrets!==`passphrase`&&k(t,``)}catch{D(n(`backup.import.badFile`))}},M=()=>{_&&(D(null),c.mutate({file:_,passphrase:_.secrets===`passphrase`?b:void 0,indexes:[...w]},{onSuccess:e=>{r(e.skipped.length>0?n(`backup.import.doneSkipped`,{count:e.added.length,skipped:e.skipped.length}):n(`backup.import.done`,{count:e.added.length})),y(null),C(null),x(``),t(!1)},onError:e=>D(G(e))}))},ee=(e,t)=>T(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),N=_?.secrets===`passphrase`&&!S,P=i.isPending||d===`passphrase`&&p.length<8;return(0,Z.jsx)(fe,{open:e,onOpenChange:t,width:640,title:n(`backup.title`),description:n(`backup.detail`),children:(0,Z.jsxs)(`div`,{className:`grid gap-6`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":n(`backup.export.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:n(`backup.export.title`)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] text-[var(--text-muted)]`,children:n(`backup.export.secrets`)}),(0,Z.jsx)(K,{className:`w-64`,ariaLabel:n(`backup.export.secrets`),value:d,onChange:e=>f(e),options:[{value:`none`,label:n(`backup.secrets.none`)},{value:`passphrase`,label:n(`backup.secrets.passphrase`)},{value:`plaintext`,label:n(`backup.secrets.plaintext`)}]})]}),d!==`none`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.secrets.hint`)}),d===`passphrase`&&(0,Z.jsx)(l,{type:`password`,autoComplete:`new-password`,"aria-label":n(`backup.passphrase`),placeholder:n(`backup.passphrase`),value:p,onChange:e=>m(e.target.value)}),d===`passphrase`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.passphrase.hint`)}),d===`plaintext`&&(0,Z.jsx)(U,{tone:`warning`,title:n(`backup.plaintext.warn`)}),h&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:h}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(je,{className:`size-3.5`}),disabled:P,onClick:O,children:n(`backup.export.run`)})})]}),(0,Z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":n(`backup.import.title`),children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:n(`backup.import.title`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`input`,{ref:u,type:`file`,accept:`.json,application/json`,className:`hidden`,"aria-label":n(`backup.import.choose`),onChange:e=>{j(e.target.files?.[0]),e.target.value=``}}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(Oe,{className:`size-3.5`}),onClick:()=>u.current?.click(),children:n(`backup.import.choose`)})]}),N&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`backup.import.encrypted`)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(l,{className:`flex-1`,type:`password`,autoComplete:`off`,"aria-label":n(`backup.passphrase`),placeholder:n(`backup.passphrase`),value:b,onChange:e=>x(e.target.value)}),(0,Z.jsx)(o,{disabled:b.length===0||s.isPending,onClick:()=>_&&k(_,b),children:n(`backup.import.preview`)})]})]}),E&&(0,Z.jsx)(U,{tone:`danger`,title:n(`common.error`),children:E}),S&&(0,Z.jsxs)(Z.Fragment,{children:[S.secrets===`none`&&(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`backup.import.noKeys`)}),(0,Z.jsx)(`ul`,{className:`card max-h-[320px] divide-y divide-[var(--border)] overflow-auto`,children:S.items.map(e=>(0,Z.jsx)(gt,{item:e,checked:w.has(e.index),onToggle:t=>ee(e.index,t)},e.index))}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{variant:`primary`,disabled:w.size===0||c.isPending,onClick:M,children:n(`backup.import.run`,{count:w.size})})})]})]}),(0,Z.jsx)(ut,{onRestored:A})]})})}function gt({item:e,checked:t,onToggle:n}){let{t:r}=a(),i=ft(e);return(0,Z.jsxs)(`li`,{className:V(`flex items-start gap-3 px-4 py-3`,!i&&`opacity-60`),children:[(0,Z.jsx)(He,{checked:t&&i,disabled:!i,onCheckedChange:e=>n(e===!0),"aria-label":e.name}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,title:e.name,children:e.name}),(0,Z.jsx)(c,{tone:dt[e.status],children:r(`backup.status.${e.status}`)})]}),e.endpoints&&e.endpoints.length>0&&(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-[var(--text-muted)]`,children:e.endpoints.map(e=>e.baseUrl).join(` / `)}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-3 text-[11px] text-[var(--text-muted)]`,children:[e.hasKey&&(0,Z.jsx)(`span`,{className:`font-mono`,children:e.keyMasked??`••••`}),(0,Z.jsx)(`span`,{children:r(`backup.models`,{count:e.modelCount})})]}),e.existing&&e.status!==`new`&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:e.existing.name}),e.error&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--danger)]`,children:e.error}),e.ignored.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--warning)]`,children:r(`import.ignored`,{fields:e.ignored.join(`, `)})})]})]})}var _t=`astra.providers.view`,vt=`astra.providers.charts`;function yt(e){try{return localStorage.getItem(e)}catch{return null}}function bt(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function xt(){let[e,t]=(0,X.useState)(()=>yt(_t)===`table`?`table`:`grid`);return[e,e=>{t(e),bt(_t,e===`table`?`table`:null)}]}function St(){let[e,t]=(0,X.useState)(()=>yt(vt)!==`0`);return[e,e=>{t(e),bt(vt,e?null:`0`)}]}var Ct=5;function wt(e){return!e.hasApiKey&&e.authScheme!==`none`&&e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`}function Tt(e,t){return e.enabled?wt(e)?`noKey`:t&&t.requests>=Ct&&t.successRate<.9?`lowSuccess`:`healthy`:`disabled`}var Et={healthy:`green`,noKey:`orange`,lowSuccess:`red`,disabled:`neutral`};function Dt(e,t){return t(e===`disabled`?`providers.card.disabled`:e===`noKey`?`providers.noKey`:e===`lowSuccess`?`providers.card.lowSuccess`:`providers.card.active`)}var Ot=[`var(--accent)`,`var(--success)`,`var(--warning)`,`#af52de`,`#5ac8fa`,`#ff2d55`],kt=`var(--text-muted)`;function At(e){return e>=.97?`var(--success)`:e>=.9?`var(--warning)`:`var(--danger)`}function jt({data:e,labels:t,max:n,className:r}){return(0,Z.jsx)(`span`,{className:V(`flex h-[22px] shrink-0 items-end gap-[2px]`,r),title:e.map((e,n)=>`${t[n]}: ${e}`).join(`
|
|
2
2
|
`),children:e.map((e,t)=>(0,Z.jsx)(`i`,{className:`block w-[6px] rounded-t-[2px]`,style:{height:e>0?`${Math.max(14,Math.sqrt(e/Math.max(1,n))*100)}%`:2,background:e>0?`var(--accent)`:`var(--border)`}},t))})}function Mt(e,t,n,r){let i=e.filter(e=>n(e)>0).sort((e,t)=>n(t)-n(e)),a=i.slice(0,Ot.length).map((e,r)=>({key:e.providerId,name:t.get(e.providerId)??e.name??e.providerId,value:n(e),color:Ot[r]})),o=i.slice(Ot.length).reduce((e,t)=>e+n(t),0);return o>0?[...a,{key:`__other`,name:r,value:o,color:kt}]:a}var Nt=[`today`,`7d`,`30d`];function Pt({providers:e,stats:t,stats7d:n,range:r,chartsOpen:i}){let{t:o}=a(),s=new Map(e.map(e=>[e.id,e.name])),c=t.reduce((e,t)=>e+t.requests,0),l=t.reduce((e,t)=>e+t.successRequests,0),u=t.reduce((e,t)=>e+t.costUsd,0),d=t.reduce((e,t)=>e+t.failoversOut,0),f=e.filter(e=>e.enabled).length,p=t.filter(e=>e.requests>0&&s.has(e.providerId)).length,m=Mt(t,s,e=>e.requests,o(`providers.overview.others`)),h=Mt(t,s,e=>e.costUsd,o(`providers.overview.others`)),g=m.filter(e=>e.key!==`__other`),_={healthy:0,noKey:0,lowSuccess:0,disabled:0};for(let t of e)_[Tt(t,n.get(t.id))]++;let v=o(`range.${r}`);return(0,Z.jsxs)(`div`,{className:`mb-3 grid gap-3`,children:[(0,Z.jsxs)(`div`,{className:`card px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,Z.jsx)(Ft,{label:o(`providers.overview.requests`),value:B(c,!0),hint:v}),(0,Z.jsx)(Ft,{label:o(`providers.overview.cost`),value:z(u),hint:v}),(0,Z.jsx)(Ft,{label:o(`providers.overview.successRate`),value:c>0?P(l/c):`—`,color:c>0?At(l/c):void 0,hint:d>0?o(`providers.overview.failoverCount`,{count:d}):v}),(0,Z.jsx)(Ft,{label:o(`providers.overview.enabled`),value:`${f} / ${e.length}`,hint:o(`providers.overview.withTraffic`,{count:p})})]}),i&&m.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 flex h-2.5 overflow-hidden rounded-full bg-[var(--border)]`,"aria-label":o(`providers.overview.share`),children:m.map(e=>(0,Z.jsx)(`span`,{className:`h-full border-r border-[var(--surface)] last:border-r-0`,style:{width:`${e.value/c*100}%`,background:e.color},title:`${e.name}: ${e.value} (${P(e.value/c)})`},e.key))}),(0,Z.jsx)(Rt,{items:m,total:c})]})]}),i&&(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1.3fr_1fr_1fr]`,children:[(0,Z.jsx)(It,{title:o(`providers.overview.ranking`),hint:v,children:g.length===0?(0,Z.jsx)(Lt,{text:o(`providers.overview.noData`)}):(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:g.map(e=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[96px_1fr_44px] items-center gap-2 text-[12px]`,children:[(0,Z.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,Z.jsx)(`span`,{className:`h-2 overflow-hidden rounded-full bg-[var(--border)]`,children:(0,Z.jsx)(`i`,{className:`block h-full rounded-full`,style:{width:`${e.value/g[0].value*100}%`,background:e.color}})}),(0,Z.jsx)(`span`,{className:`num text-right text-[var(--text-secondary)]`,children:B(e.value,!0)})]},e.key))})}),(0,Z.jsx)(It,{title:o(`providers.overview.costShare`),hint:z(u),children:h.length===0?(0,Z.jsx)(Lt,{text:o(`providers.overview.noCost`)}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Z.jsx)(zt,{items:h,total:u,label:z(u,{compact:!0})}),(0,Z.jsx)(Rt,{items:h,total:u,column:!0})]})}),(0,Z.jsx)(It,{title:o(`providers.overview.health`),hint:o(`range.7d`),children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(Bt,{tone:`green`,label:o(`providers.overview.healthy`),value:_.healthy}),(0,Z.jsx)(Bt,{tone:`red`,label:o(`providers.overview.lowSuccess`),value:_.lowSuccess}),(0,Z.jsx)(Bt,{tone:`orange`,label:o(`providers.noKey`),value:_.noKey}),(0,Z.jsx)(Bt,{tone:`neutral`,label:o(`providers.card.disabled`),value:_.disabled})]})})]})]})}function Ft({label:e,value:t,hint:n,color:r}){return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,Z.jsx)(`div`,{className:`num truncate text-[19px] font-semibold leading-tight`,style:r?{color:r}:void 0,children:t}),n&&(0,Z.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:n})]})}function It({title:e,hint:t,children:n}){return(0,Z.jsxs)(`div`,{className:`card min-h-[164px] px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex items-center justify-between gap-2 text-[12px]`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-[var(--text-secondary)]`,children:e}),t&&(0,Z.jsx)(`span`,{className:`num text-[var(--text-muted)]`,children:t})]}),n]})}function Lt({text:e}){return(0,Z.jsx)(`div`,{className:`grid h-[110px] place-items-center text-[12px] text-[var(--text-muted)]`,children:e})}function Rt({items:e,total:t,column:n}){return(0,Z.jsx)(`div`,{className:V(`mt-2 flex min-w-0 gap-x-3.5 gap-y-1 text-[11px] text-[var(--text-secondary)]`,n?`mt-0 flex-col`:`flex-wrap`),children:e.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,title:e.name,children:[(0,Z.jsx)(`i`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color}}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`num shrink-0 text-[var(--text-muted)]`,children:P(e.value/t)})]},e.key))})}function zt({items:e,total:t,label:n}){let r=0,i=e.map(e=>{let n=r;return r+=e.value/t*360,`${e.color} ${n}deg ${r}deg`}).join(`, `);return(0,Z.jsx)(`div`,{className:`grid size-[104px] shrink-0 place-items-center rounded-full`,style:{background:`conic-gradient(${i})`},children:(0,Z.jsx)(`div`,{className:`num grid size-[70px] place-items-center rounded-full bg-[var(--surface)] text-[12px] font-semibold`,children:n})})}function Bt({tone:e,label:t,value:n}){return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[color-mix(in_oklab,var(--text)_5%,transparent)] px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`num text-[18px] font-semibold leading-tight`,children:n}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate text-[11px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(I,{tone:e}),t]})]})}var Vt={lowSuccess:0,noKey:1,healthy:2,disabled:3};function Ht({providers:e,stats7d:t,usage:n,labels:r,max:i,onOpen:o}){let{t:s}=a(),c=e.map(e=>{let r=t.get(e.id),i=n(e);return{id:e.id,name:e.name,health:Vt[Tt(e,r)],models:e.modelCount,requests:i.reduce((e,t)=>e+t,0),successRate:r&&r.requests>0?r.successRate:-1,ttft:r?.avgTtftMs??-1,tokens:r?r.inputTokens+r.outputTokens:0,cost:r?.costUsd??0,enabled:+!!e.enabled,p:e,stat:r,days:i}}),l=[{key:`name`,label:s(`providers.col.provider`),render:(e,t)=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-2 text-left`,onClick:()=>o(t.p),children:[(0,Z.jsx)(`span`,{className:V(!t.p.enabled&&`opacity-50 grayscale`),children:(0,Z.jsx)(ze,{name:t.p.name,icon:t.p.icon,colorKey:t.p.templateId,size:22})}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:V(`block truncate font-medium hover:text-[var(--accent)]`,!t.p.enabled&&`text-[var(--text-muted)]`),children:t.name}),(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:Wt(t.p.endpoints[0]?.baseUrl)??`—`})]})]})},{key:`health`,label:s(`providers.col.status`),width:112,render:(e,t)=>{let n=Tt(t.p,t.stat);return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(I,{tone:Et[n]}),Dt(n,s)]})}},{key:`models`,label:s(`providers.col.models`),numeric:!0,width:56},{key:`days`,label:s(`providers.col.trend`),sortable:!1,width:84,render:(e,t)=>(0,Z.jsx)(jt,{data:t.days,labels:r,max:i})},{key:`requests`,label:s(`providers.col.requests`),numeric:!0,width:80,render:(e,t)=>t.requests?B(t.requests,!0):`—`},{key:`successRate`,label:s(`providers.col.successRate`),width:124,render:(e,t)=>t.successRate<0?(0,Z.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`}):(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,Z.jsx)(`span`,{className:`h-[5px] w-10 overflow-hidden rounded-full bg-[var(--border)]`,children:(0,Z.jsx)(`i`,{className:`block h-full`,style:{width:`${t.successRate*100}%`,background:At(t.successRate)}})}),(0,Z.jsx)(`span`,{className:`num text-[12px]`,children:P(t.successRate)})]})},{key:`ttft`,label:s(`providers.col.ttft`),numeric:!0,width:92,render:(e,t)=>(0,Z.jsx)(Ut,{children:t.ttft<0?`—`:R(t.ttft)})},{key:`tokens`,label:s(`providers.col.tokens`),numeric:!0,width:128,render:(e,t)=>(0,Z.jsx)(Ut,{children:t.stat&&t.tokens>0?`${B(t.stat.inputTokens,!0)} / ${B(t.stat.outputTokens,!0)}`:`—`})},{key:`cost`,label:s(`providers.col.cost`),numeric:!0,width:96,render:(e,t)=>(0,Z.jsx)(Ut,{children:t.cost>0?z(t.cost):`—`})},{key:`enabled`,label:s(`providers.col.enabled`),width:64,render:(e,t)=>(0,Z.jsx)(Gt,{provider:t.p})}];return(0,Z.jsx)(Ae,{caption:s(`nav.providers`),rowKey:`id`,rows:c,columns:l,defaultSort:{key:`requests`,direction:`desc`}})}var Ut=({children:e})=>(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:e});function Wt(e){if(!e)return null;try{return new URL(e).host}catch{return e}}function Gt({provider:e}){let{t}=a(),n=ne(e.id),{toast:r}=q();return(0,Z.jsx)(`span`,{className:`ml-1 inline-flex`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(O,{checked:e.enabled,label:t(`common.enabled`),onChange:e=>n.mutate({enabled:e},{onError:e=>r(G(e),`error`)})})})}var Kt=e=>e.authScheme!==`oauth-subscription`&&e.authScheme!==`plugin`,qt=e=>e.category!==`subscription`&&e.category!==`custom`&&e.authScheme!==`oauth-subscription`;function Jt({open:e,onOpenChange:t,provider:n}){let{t:r}=a(),{toast:i}=q(),s=S(),c=H(n.id),[l,u]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(s.data??[]).filter(qt);(0,X.useEffect)(()=>{e&&(u(n.templateId??``),p(``))},[e,n.templateId]);let h=m.find(e=>e.id===l),g=h?h.variants?.find(e=>e.id===f)?.endpointsOverride??h.endpoints:[],_=l===n.templateId&&!f;return(0,Z.jsxs)(fe,{open:e,onOpenChange:t,title:r(`providers.templateSwitch`),description:r(`providers.templateSwitchDetail`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:!h||_,loading:c.isPending,onClick:()=>h&&c.mutate({templateId:h.id,variantId:f||null},{onSuccess:()=>{t(!1),i(r(`providers.templateSwitched`,{name:h.name}),`success`)},onError:e=>i(G(e),`error`)}),children:r(`common.apply`)})]}),children:[s.isLoading&&(0,Z.jsx)(d,{}),s.isError&&(0,Z.jsx)(U,{tone:`danger`,title:r(`common.error`),children:G(s.error)}),(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(y,{label:r(`providers.templateSwitchTarget`),children:(0,Z.jsx)(K,{value:l,onChange:e=>{u(e),p(``)},options:m.map(e=>({value:e.id,label:e.id===n.templateId?r(`providers.templateSwitchCurrent`,{name:e.name}):e.name,detail:e.id}))})}),h?.variants&&h.variants.length>0&&(0,Z.jsx)(y,{label:r(`providers.variant`),children:(0,Z.jsx)(K,{value:f,onChange:p,options:[{value:``,label:r(`providers.variantDefault`)},...h.variants.map(e=>({value:e.id,label:e.name}))]})}),h&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-2 text-[13px] font-medium`,children:r(`providers.templateSwitchEndpoints`)}),(0,Z.jsx)(`ul`,{className:`grid gap-1 text-[12px]`,children:g.map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-3`,children:[(0,Z.jsx)(`span`,{className:`w-36 shrink-0 text-[var(--text-secondary)]`,children:$.find(t=>t.value===e.protocol)?.label??e.protocol}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono break-all`,children:e.baseUrl})]},e.protocol))})]})]})]})}function Yt({provider:e,httpStatus:t,className:n}){return t!==401&&t!==403||!e.templateId||!Kt(e)?null:(0,Z.jsx)(Xt,{provider:e,className:n})}function Xt({provider:e,className:t}){let{t:n}=a(),{toast:r,confirm:i}=q(),s=S(),c=H(e.id),l=s.data?.find(t=>t.id===e.templateId),u=(l?.keyAlternatives??[]).flatMap(e=>s.data?.filter(t=>t.id===e)??[]);if(!l||u.length===0)return null;let d=async e=>{let t=[...new Set(e.endpoints.map(e=>e.baseUrl))].join(`, `);await i({title:n(`providers.templateSwitchConfirm`,{alt:e.name}),detail:n(`providers.templateSwitchConfirmDetail`,{urls:t}),confirmLabel:n(`providers.keyAlternative.switch`,{alt:e.name})})&&c.mutate({templateId:e.id},{onSuccess:()=>r(n(`providers.templateSwitched`,{name:e.name}),`success`),onError:e=>r(G(e),`error`)})};return(0,Z.jsxs)(U,{className:t,tone:`warning`,title:n(`providers.keyAlternative.title`),children:[n(`providers.keyAlternative.rejected`,{name:l.name,alt:u.map(e=>e.name).join(` / `)}),(0,Z.jsx)(`span`,{className:`mt-2 flex flex-wrap gap-2`,children:u.map(e=>(0,Z.jsx)(o,{size:`sm`,loading:c.isPending,onClick:()=>void d(e),children:n(`providers.keyAlternative.switch`,{alt:e.name})},e.id))})]})}var Zt=3,Qt=256,$t=4096,en=`A small red circle on a white background.`,tn=`Change the red circle to blue. Keep everything else the same.`;function nn(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();return t.startsWith(`gpt-image`)||t.startsWith(`chatgpt-image`)||t.startsWith(`dall-e`)}var rn={idle:`providers.testDialog.status.idle`,queued:`providers.testDialog.status.queued`,running:`providers.testDialog.status.running`,success:`providers.testDialog.status.success`,failed:`providers.testDialog.status.failed`,cancelled:`providers.testDialog.status.cancelled`};function an(e){let t=e.endpoints.map(e=>e.protocol);return e.preferredUpstreamProtocols.find(e=>t.includes(e))??t[0]??`openai-chat`}var on=e=>typeof e==`number`?e:null,sn=e=>typeof e==`string`?e:null;function cn({provider:e,open:t,onOpenChange:n}){let{t:r}=a(),i=oe(),c=s(t?e.id:void 0),l=e.endpoints.map(e=>e.protocol),[u,d]=(0,X.useState)(`single`),[f,p]=(0,X.useState)(()=>an(e)),[m,h]=(0,X.useState)(!0),[g,_]=(0,X.useState)(``),[v,b]=(0,X.useState)(Qt),[x,S]=(0,X.useState)({size:``,quality:``,count:1,operation:`generate`,input:null}),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(C);T.current=C;let[E,D]=(0,X.useState)(null),[O,A]=(0,X.useState)({}),[j,M]=(0,X.useState)([]),[ee,N]=(0,X.useState)(new Set),[P,te]=(0,X.useState)([]),[ne,F]=(0,X.useState)(``),[I,L]=(0,X.useState)(null),[R,z]=(0,X.useState)(!1),B=(0,X.useRef)(null),V=(0,X.useRef)(new Map),re=(0,X.useRef)(!1),ie=(0,X.useRef)(!1),H=(0,X.useMemo)(()=>{let e=[...c.data??[]].sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.sortOrder-t.sortOrder).map(e=>e.modelId);return[...e,...P.filter(t=>!e.includes(t))]},[c.data,P]);(0,X.useEffect)(()=>{if(t){let e=T.current||(c.data??[]).find(e=>e.enabled)?.modelId||(c.data??[])[0]?.modelId||``;!T.current&&e&&nn(e)&&p(`openai-images`),w(e);return}ie.current=!1,B.current?.abort();for(let e of V.current.values())e.abort();V.current.clear(),D(null),A({}),M([]),N(new Set),te([]),F(``),L(null)},[t,c.data]);let ae=(0,X.useCallback)((t,n=!1)=>nn(t)||!n&&f===`openai-images`?{modelId:t,protocol:`openai-images`,prompt:g.trim()||null,imageOperation:x.operation,...x.operation===`edit`&&x.input?{imageInput:x.input.data}:{},imageSize:x.size.trim()||null,imageQuality:x.quality||null,imageCount:x.count,imagePreview:!n}:{modelId:t,protocol:f===`openai-images`?an(e):f,stream:m,prompt:g.trim()||null,maxOutputTokens:v??Qt},[f,m,g,v,x,e]),U=(0,X.useCallback)((t,n,r,i=!1)=>Cn(e.id,t,ae(t,i),n,r),[e.id,ae]),se=t=>{w(t),nn(t)?p(`openai-images`):f===`openai-images`&&p(an(e))},ce=()=>{let e=C.trim();if(!e)return;B.current?.abort();let t=new AbortController;B.current=t,ie.current=!0,L(null),D({modelId:e,status:`running`,text:``,reasoning:``}),U(e,t.signal,e=>{e.status!==`running`&&e.status!==`queued`&&ue(),D(e)})},le=e=>{if(e.length===0)return;ie.current=!0,re.current=!1,L(null),M(e),A(Object.fromEntries(e.map(e=>[e,{modelId:e,status:`queued`,text:``,reasoning:``}])));let t=0;Promise.all(Array.from({length:Math.min(Zt,e.length)},async()=>{for(;;){if(!ie.current)return;let n=e[t++];if(n===void 0)return;if(re.current){A(e=>({...e,[n]:{...e[n],status:`cancelled`}}));continue}let r=new AbortController;V.current.set(n,r),await U(n,r.signal,e=>A(t=>({...t,[n]:e})),!0),V.current.delete(n),ue()}}))},ue=()=>void i.invalidateQueries({queryKey:[`requests`]}),de=()=>{re.current=!0,A(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.status===`queued`?{...t,status:`cancelled`}:t])))},W=E?.status===`running`||j.some(e=>O[e]?.status===`running`||O[e]?.status===`queued`&&!re.current),pe=j.filter(e=>O[e]&&O[e].status!==`queued`&&O[e].status!==`running`).length,G=j.filter(e=>O[e]?.status===`success`).length,K=j.filter(e=>O[e]?.status===`failed`).length,q=(e,t)=>N(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),me=()=>{W||n(!1)},he=e=>e.stopPropagation();return(0,Z.jsx)(`span`,{onClick:he,onKeyDown:he,children:(0,Z.jsxs)(fe,{open:t,onOpenChange:e=>e?n(!0):me(),width:1040,title:r(`providers.testDialog.title`,{name:e.name}),description:r(`providers.testDialog.subtitle`),footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mr-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.realRequest`)}),(0,Z.jsx)(o,{disabled:W,onClick:()=>n(!1),icon:(0,Z.jsx)(ke,{className:`size-3.5`}),children:r(`common.close`)}),u===`single`?W?(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(Ee,{className:`size-3.5`}),onClick:()=>B.current?.abort(),children:r(`providers.testDialog.stop`)}):(0,Z.jsx)(o,{variant:`primary`,disabled:C.trim()===``,icon:(0,Z.jsx)(xe,{className:`size-3.5`}),onClick:ce,children:r(E?`providers.testDialog.retest`:`providers.testDialog.start`)}):W?(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(Ee,{className:`size-3.5`}),onClick:de,children:r(`providers.testDialog.stopRest`)}):(0,Z.jsx)(o,{variant:`primary`,disabled:ee.size===0,icon:(0,Z.jsx)(xe,{className:`size-3.5`}),onClick:()=>le([...ee]),children:r(`providers.testDialog.testN`,{count:ee.size})})]}),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-4`,children:[(0,Z.jsx)(ze,{name:e.name,icon:e.icon,colorKey:e.templateId,size:32}),(0,Z.jsx)(k,{items:[{value:`single`,label:r(`providers.testDialog.modeSingle`)},{value:`batch`,label:r(`providers.testDialog.modeBatch`)}],value:u,onChange:e=>{d(e),L(null)},ariaLabel:r(`providers.testDialog.config`)})]}),u===`single`?(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,300px)_minmax(0,1fr)] gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 border-r border-[var(--border)] pr-6`,children:[(0,Z.jsx)(`h3`,{className:`text-[13px] font-medium`,children:r(`providers.testDialog.config`)}),(0,Z.jsx)(y,{label:r(`providers.testDialog.model`),children:(0,Z.jsx)(ln,{value:C,models:H,onChange:se})}),(0,Z.jsx)(hn,{protocols:l,protocol:f,onProtocol:p,stream:m,onStream:h,maxTokens:v,onMaxTokens:b,prompt:g,onPrompt:_,image:x,onImage:S}),(0,Z.jsx)(`p`,{className:`mt-auto text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.savedCredentials`)})]}),(0,Z.jsx)(_n,{provider:e,run:E,onRetest:ce})]}):I===null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xn,{known:H,selected:ee,onToggle:q,onSelectAll:e=>N(e?new Set(H):new Set),onClear:()=>N(new Set),search:ne,onSearch:F,onAdd:e=>{te(t=>t.includes(e)?t:[...t,e]),N(t=>new Set(t).add(e)),F(``)},configOpen:R,onConfigOpen:z,protocols:l,protocol:f,onProtocol:p,stream:m,onStream:h,maxTokens:v,onMaxTokens:b,prompt:g,onPrompt:_,image:x,onImage:S,batch:!0,hasImageModels:H.some(nn)}),j.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:W?r(`providers.testDialog.progress`,{done:pe,total:j.length,ok:G,failed:K}):r(`providers.testDialog.progressDone`,{total:j.length,ok:G,failed:K})}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-strong)]`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full transition-[width]`,style:{width:`${pe/j.length*100}%`,background:`var(--accent)`}})})]}):null,j.length>0?(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(Sn,{order:j,runs:O,onView:L})}):null]}):(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(o,{variant:`plain`,icon:(0,Z.jsx)(J,{className:`size-4`}),"aria-label":r(`common.back`),onClick:()=>L(null)}),(0,Z.jsx)(`span`,{className:`font-mono text-[13px]`,children:I})]}),(0,Z.jsx)(_n,{provider:e,run:O[I]??null})]})]})})}function ln({value:e,models:t,onChange:n}){let{t:r}=a(),[i,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(0),[u,d]=(0,X.useState)(null),f=u===null?t:t.filter(e=>e.toLowerCase().includes(u.trim().toLowerCase())),p=()=>{d(null),c(Math.max(0,t.indexOf(e))),o(!0)},m=e=>{n(e),d(null),o(!1)};return(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(l,{className:`pr-9 font-mono`,value:e,placeholder:r(`providers.testDialog.modelPlaceholder`),"aria-expanded":i,role:`combobox`,onFocus:p,onClick:p,onChange:e=>{n(e.target.value),d(e.target.value),c(0),o(!0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!i)return p();if(f.length===0)return;let t=e.key===`ArrowDown`?1:-1;c(e=>(e+t+f.length)%f.length)}else e.key===`Enter`&&i?(e.preventDefault(),f[s]&&m(f[s])):e.key===`Escape`&&o(!1)}}),(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 grid w-8 place-items-center text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":r(`providers.testDialog.showModels`),onClick:()=>i?o(!1):p(),children:(0,Z.jsx)(ge,{className:`size-4`})}),i&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:()=>o(!1)}),(0,Z.jsx)(`ul`,{className:`absolute inset-x-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] py-1 shadow-lg`,children:f.length===0?(0,Z.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noModels`)}):f.map((e,t)=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`button`,{type:`button`,className:V(`block w-full truncate px-3 py-1.5 text-left font-mono text-[12px] hover:bg-[var(--surface-strong)]`,t===s&&`bg-[var(--surface-strong)]`),onMouseEnter:()=>c(t),onMouseDown:t=>{t.preventDefault(),m(e)},children:e})},e))})]})]})}var un=4194304,dn=[`image/png`,`image/jpeg`,`image/webp`],fn=[`auto`,`1024x1024`,`1536x1024`,`1024x1536`,`512x512`,`256x256`],pn=[`auto`,`low`,`medium`,`high`,`standard`,`hd`],mn=4;function hn({protocols:e,batch:t=!1,hasImageModels:n=!1,...r}){let{t:i}=a(),o=e.map(e=>({value:e,label:$.find(t=>t.value===e)?.label??e}));!t&&e.some(e=>e===`openai-chat`||e===`openai-responses`)&&o.push({value:`openai-images`,label:`OpenAI Images`});let s=!t&&r.protocol===`openai-images`,c=e=>r.onImage({...r.image,...e}),u=r.image.operation===`edit`,d=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y,{label:i(`providers.testDialog.imageOperation`),hint:u?i(`providers.testDialog.imageEditHint`):void 0,children:(0,Z.jsx)(k,{items:[{value:`generate`,label:i(`providers.testDialog.imageGenerate`)},{value:`edit`,label:i(`providers.testDialog.imageEdit`)}],value:r.image.operation,onChange:e=>c({operation:e}),ariaLabel:i(`providers.testDialog.imageOperation`)})}),u?(0,Z.jsx)(gn,{value:r.image.input,onChange:e=>c({input:e})}):null,(0,Z.jsxs)(y,{label:i(`providers.testDialog.imageSize`),hint:i(`providers.testDialog.imageSizeHint`),children:[(0,Z.jsx)(l,{className:`font-mono`,list:`provider-test-image-sizes`,value:r.image.size,placeholder:`1024x1024`,"aria-label":i(`providers.testDialog.imageSize`),onChange:e=>c({size:e.target.value})}),(0,Z.jsx)(`datalist`,{id:`provider-test-image-sizes`,children:fn.map(e=>(0,Z.jsx)(`option`,{value:e},e))})]}),(0,Z.jsx)(y,{label:i(`providers.testDialog.imageQuality`),children:(0,Z.jsx)(K,{value:r.image.quality,onChange:e=>c({quality:e}),options:[{value:``,label:i(`providers.testDialog.imageDefault`)},...pn.map(e=>({value:e,label:e}))]})}),(0,Z.jsx)(y,{label:i(`providers.testDialog.imageCount`),children:(0,Z.jsx)(p,{value:r.image.count,min:1,placeholder:`1`,label:i(`providers.testDialog.imageCount`),onChange:e=>c({count:e===null?1:Math.min(mn,Math.max(1,Math.round(e)))})})})]}),f=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:i(`providers.testDialog.stream`)}),(0,Z.jsx)(O,{checked:r.stream,label:i(`providers.testDialog.stream`),onChange:r.onStream})]}),(0,Z.jsx)(y,{label:i(`providers.testDialog.maxTokens`),children:(0,Z.jsx)(p,{value:r.maxTokens,min:1,placeholder:String(Qt),label:i(`providers.testDialog.maxTokens`),onChange:e=>r.onMaxTokens(e===null?null:Math.min($t,Math.max(1,Math.round(e))))})})]});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y,{label:i(`providers.testDialog.protocol`),hint:t&&n?i(`providers.testDialog.batchAutoHint`):void 0,children:(0,Z.jsx)(K,{value:r.protocol,onChange:r.onProtocol,options:o})}),t?(0,Z.jsxs)(Z.Fragment,{children:[f,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h4`,{className:`pt-1 text-[12px] font-medium`,children:i(`providers.testDialog.imageSection`)}),d]}):null]}):s?d:f,(0,Z.jsx)(y,{label:i(`providers.testDialog.prompt`),hint:i(`providers.testDialog.promptHint`),children:(0,Z.jsx)(A,{rows:4,value:r.prompt,placeholder:s?u?tn:en:`Reply with OK.`,onChange:e=>r.onPrompt(e.target.value)})})]})}function gn({value:e,onChange:t}){let{t:n}=a(),r=(0,X.useRef)(null),[i,s]=(0,X.useState)(null),c=e=>{if(!e)return;if(!dn.includes(e.type))return s(n(`providers.testDialog.imageInputType`));if(e.size>un)return s(n(`providers.testDialog.imageInputTooLarge`));let r=new FileReader;r.onerror=()=>s(n(`providers.testDialog.imageInputUnreadable`)),r.onload=()=>{let n=String(r.result);s(null),t({name:e.name,bytes:e.size,data:n.slice(n.indexOf(`,`)+1),preview:n})},r.readAsDataURL(e)};return(0,Z.jsxs)(y,{label:n(`providers.testDialog.imageInput`),hint:i??void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e?(0,Z.jsx)(`img`,{src:e.preview,alt:``,className:`size-12 shrink-0 rounded-md border border-[var(--border)] object-cover`}):(0,Z.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center rounded-md border border-[var(--border)] bg-white`,children:(0,Z.jsx)(`span`,{className:`size-7 rounded-full bg-[#ff2020]`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[12px]`,title:e?.name,children:e?e.name:n(`providers.testDialog.imageInputDefault`)}),(0,Z.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e?`${(e.bytes/1024).toFixed(+(e.bytes<10240))} KB`:n(`providers.testDialog.imageInputLimits`)})]}),(0,Z.jsx)(`input`,{ref:r,type:`file`,hidden:!0,accept:dn.join(`,`),"aria-label":n(`providers.testDialog.imageInput`),onChange:e=>{c(e.target.files?.[0]),e.target.value=``}}),(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(Se,{className:`size-3.5`}),onClick:()=>r.current?.click(),children:n(`providers.testDialog.imageInputPick`)}),e?(0,Z.jsx)(o,{size:`sm`,variant:`plain`,onClick:()=>(s(null),t(null)),children:n(`providers.testDialog.imageInputReset`)}):null]}),i?(0,Z.jsx)(`p`,{className:`mt-1 text-[11px] text-[var(--danger)]`,children:i}):null]})}function _n({provider:e,run:t,onRetest:n}){let{t:r}=a(),[i,s]=(0,X.useState)(`preview`),l=t?.text??``,u=t?.raw??``,d=Object.entries(t?.headers??{}),p=t?.ttftMs!=null&&t?.httpMs!=null?Math.max(0,t.ttftMs-t.httpMs):null,m=i===`raw`?u:i===`headers`?d.map(([e,t])=>`${e}: ${t}`).join(`
|
|
3
3
|
`):l;return(0,Z.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n&&t&&t.status!==`running`?(0,Z.jsx)(o,{size:`sm`,icon:(0,Z.jsx)(xe,{className:`size-3.5`}),onClick:n,children:r(`providers.testDialog.retest`)}):null,(0,Z.jsx)(Be,{content:r(`providers.testDialog.metricsHelp`),children:(0,Z.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center text-[var(--text-muted)]`,tabIndex:0,children:(0,Z.jsx)(ve,{className:`size-4`})})}),(0,Z.jsx)(bn,{run:t}),t?.httpStatus?(0,Z.jsxs)(c,{tone:`neutral`,children:[`HTTP `,t.httpStatus]}):null]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)] sm:grid-cols-4`,children:[(0,Z.jsx)(yn,{label:r(`providers.testDialog.metrics.http`),value:t?.httpMs}),(0,Z.jsx)(yn,{label:r(`providers.testDialog.metrics.firstWait`),value:p}),(0,Z.jsx)(yn,{label:r(`providers.testDialog.metrics.ttft`),value:t?.ttftMs}),(0,Z.jsx)(yn,{label:r(`providers.testDialog.metrics.total`),value:t?.totalMs})]}),(0,Z.jsxs)(`section`,{className:`card overflow-hidden`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b border-[var(--border)] px-4 py-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[12px] font-medium`,children:r(`providers.testDialog.reply`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(k,{items:[{value:`preview`,label:r(`providers.testDialog.preview`)},{value:`raw`,label:r(`providers.testDialog.raw`)},{value:`headers`,label:r(`providers.testDialog.headers`)}],value:i,onChange:s,ariaLabel:r(`providers.testDialog.reply`)}),(0,Z.jsx)(f,{value:m,label:r(i===`headers`?`providers.testDialog.headers`:`providers.testDialog.reply`),iconOnly:!0})]})]}),(0,Z.jsx)(`div`,{className:`h-[360px] overflow-auto px-4 py-3`,children:i===`headers`?d.length===0?(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.headersEmpty`)}):(0,Z.jsx)(`table`,{className:`w-full text-[11px]`,children:(0,Z.jsx)(`tbody`,{children:d.map(([e,t])=>(0,Z.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0 align-top`,children:[(0,Z.jsx)(`th`,{className:`w-[220px] py-1.5 pr-4 text-left font-mono font-normal text-[var(--text-secondary)]`,children:e}),(0,Z.jsx)(`td`,{className:`py-1.5 font-mono break-all whitespace-pre-wrap selectable`,children:t})]},e))})}):i===`raw`?u?(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsxs)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:[r(`providers.testDialog.rawNote`),t?.contentType?` · ${t.contentType}`:``]}),(0,Z.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] break-all whitespace-pre-wrap selectable`,children:u}),t?.rawTruncated?(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--warning)]`,children:r(`providers.testDialog.rawTruncated`)}):null]}):(0,Z.jsx)(vn,{run:t}):t?.error?(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsx)(U,{tone:`danger`,title:r(`providers.testDialog.status.failed`),children:t.error}),(0,Z.jsx)(Yt,{provider:e,httpStatus:t.httpStatus})]}):l||t?.reasoning||t?.images?.length?(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[t?.reasoning?(0,Z.jsxs)(`div`,{className:`rounded-md border border-[var(--border)] bg-[var(--surface-strong)] p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[11px] text-[var(--text-muted)]`,children:r(`providers.testDialog.reasoning`)}),(0,Z.jsx)(`pre`,{className:`font-mono text-[11px] leading-[1.6] whitespace-pre-wrap selectable`,children:t.reasoning})]}):null,l?(0,Z.jsx)(`pre`,{className:`font-mono text-[12px] leading-[1.7] break-words whitespace-pre-wrap selectable`,children:l}):null,t?.images?.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:t.images.map((e,t)=>{let n=`data:${e.mime};base64,${e.data}`;return(0,Z.jsxs)(`figure`,{className:`grid gap-1.5`,children:[(0,Z.jsx)(`img`,{src:n,alt:r(`providers.testDialog.imageAlt`,{n:t+1}),className:`max-h-[420px] max-w-full self-start rounded-md border border-[var(--border)] object-contain`}),(0,Z.jsx)(`a`,{className:`self-start text-[11px] text-[var(--accent)]`,href:n,download:`astra-test-${t+1}.${e.mime===`image/jpeg`?`jpg`:e.mime===`image/webp`?`webp`:`png`}`,children:r(`providers.testDialog.imageSave`)})]},t)})}):null]}):t?.status===`success`?(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`providers.testDialog.noText`)}):(0,Z.jsx)(vn,{run:t})})]})]})}function vn({run:e}){let{t}=a();return e?.status===`running`||e?.status===`queued`?(0,Z.jsx)(`div`,{className:`grid h-full place-items-center text-[12px] text-[var(--text-muted)]`,children:t(rn[e.status])}):(0,Z.jsxs)(`div`,{className:`grid h-full place-items-center content-center gap-2 text-center`,children:[(0,Z.jsx)(Fe,{className:`mx-auto size-6 text-[var(--text-muted)]`}),(0,Z.jsx)(`div`,{className:`text-[13px]`,children:t(`providers.testDialog.emptyTitle`)}),(0,Z.jsx)(`p`,{className:`mx-auto max-w-[320px] text-[11px] text-[var(--text-muted)]`,children:t(`providers.testDialog.emptyDetail`)})]})}function yn({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`bg-[var(--surface)] px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:e}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[15px] tabular-nums`,children:t==null?`—`:R(t)})]})}function bn({run:e}){let{t}=a(),n=e?.status??`idle`;return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(I,{tone:n===`success`?`green`:n===`failed`?`red`:n===`running`?`orange`:`neutral`}),t(rn[n])]})}function xn({known:e,selected:t,onToggle:n,onSelectAll:r,onClear:i,search:s,onSearch:c,onAdd:l,configOpen:u,onConfigOpen:d,...f}){let{t:p}=a(),m=s.trim(),h=m.toLowerCase(),g=h?e.filter(e=>e.toLowerCase().includes(h)):e,_=m!==``&&!e.some(e=>e.toLowerCase()===h);return(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[12px] text-[var(--text-secondary)]`,children:p(`providers.testDialog.selected`,{n:t.size,total:e.length})}),(0,Z.jsx)(`div`,{className:`min-w-[220px] flex-1`,children:(0,Z.jsx)(le,{value:s,onChange:c,placeholder:p(`providers.testDialog.searchModels`)})}),(0,Z.jsx)(o,{variant:`plain`,disabled:t.size===0,onClick:i,children:p(`providers.testDialog.clearSelection`)}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(xe,{className:`size-3.5`}),onClick:()=>d(!0),children:p(`providers.testDialog.config`)})]}),(0,Z.jsx)(`div`,{className:`card max-h-[420px] overflow-auto`,children:g.length===0&&!_?(0,Z.jsx)(`p`,{className:`px-4 py-6 text-center text-[12px] text-[var(--text-muted)]`,children:p(`providers.testDialog.noModels`)}):(0,Z.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(He,{checked:t.size===e.length&&e.length>0||t.size!==0&&`indeterminate`,onCheckedChange:e=>r(e!==!1),"aria-label":p(`providers.testDialog.clearSelection`)}),(0,Z.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:p(`providers.testDialog.ownFilter`)})]}),_?(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,Z.jsx)(Ce,{className:`size-3.5 shrink-0 text-[var(--accent)]`}),(0,Z.jsx)(`button`,{type:`button`,className:`text-left font-mono text-[12px] text-[var(--accent)]`,onClick:()=>l(m),children:p(`providers.testDialog.addModel`,{id:m})})]}):null,g.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,Z.jsx)(He,{checked:t.has(e),onCheckedChange:t=>n(e,t!==!1),"aria-label":e}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:e,children:e})]},e))]})}),(0,Z.jsx)(fe,{open:u,onOpenChange:d,width:480,title:p(`providers.testDialog.config`),description:p(`providers.testDialog.savedCredentials`),children:(0,Z.jsx)(`div`,{className:`grid gap-4`,children:(0,Z.jsx)(hn,{...f})})})]})}function Sn({order:e,runs:t,onView:n}){let{t:r}=a();return(0,Z.jsx)(`div`,{className:`card overflow-hidden`,children:(0,Z.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-[var(--border)] text-left text-[11px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.model`)}),(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.statusColumn`)}),(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.ttft`)}),(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.metrics.total`)}),(0,Z.jsx)(`th`,{className:`px-4 py-2 font-normal`,children:r(`providers.testDialog.reply`)})]})}),(0,Z.jsx)(`tbody`,{children:e.map(e=>{let i=t[e];return(0,Z.jsxs)(`tr`,{className:`border-b border-[var(--border)] last:border-0`,children:[(0,Z.jsxs)(`td`,{className:`px-4 py-2 font-mono`,children:[e,i?.imageOperation?(0,Z.jsx)(c,{tone:`neutral`,className:`ml-2 align-middle`,children:r(i.imageOperation===`edit`?`providers.testDialog.imageEdit`:`providers.testDialog.imageGenerate`)}):null]}),(0,Z.jsx)(`td`,{className:`px-4 py-2`,children:(0,Z.jsx)(bn,{run:i??null})}),(0,Z.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.ttftMs==null?`—`:R(i.ttftMs)}),(0,Z.jsx)(`td`,{className:`px-4 py-2 font-mono tabular-nums`,children:i?.totalMs==null?`—`:R(i.totalMs)}),(0,Z.jsx)(`td`,{className:`px-4 py-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] disabled:text-[var(--text-muted)]`,disabled:!i,onClick:()=>n(e),children:r(`providers.testDialog.view`)})})]},e)})})]})})}async function Cn(e,t,n,r,i){let a={modelId:t,status:`running`,text:``,reasoning:``,...n.protocol===`openai-images`?{imageOperation:n.imageOperation===`edit`?`edit`:`generate`}:{}};i(a);let o=e=>{a={...a,...e},i(a)};try{await ie(e,n,e=>{let t=e.data??{};switch(e.event){case`headers`:o({httpStatus:on(t.httpStatus),httpMs:on(t.httpMs),contentType:sn(t.contentType),headers:wn(t.headers)});break;case`delta`:{let e=sn(t.text)??``;sn(t.kind)===`reasoning`?o({reasoning:a.reasoning+e}):o({text:a.text+e});break}case`done`:{let t=e.data;o({status:t.ok?`success`:`failed`,error:t.error??null,httpStatus:t.httpStatus??null,httpMs:t.httpMs??null,ttftMs:t.ttftMs??null,totalMs:t.totalMs??null,text:t.text??``,reasoning:t.reasoning??``,raw:t.raw??``,rawTruncated:t.rawTruncated??!1,images:t.images??[],contentType:t.contentType??null,headers:wn(t.headers)});break}}},r)}catch(e){e?.name===`AbortError`?o({status:`cancelled`,error:null}):o({status:`failed`,error:e instanceof N?e.message:String(e)})}}function wn(e){if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`?t[n]=r:r!=null&&(t[n]=String(r));return t}var Tn=e({AUTH_OPTIONS:()=>En,PROTOCOL_OPTIONS:()=>$,ProvidersPage:()=>Dn}),$=[{value:`openai-chat`,label:`OpenAI Chat`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic`,label:`Anthropic Messages`},{value:`gemini`,label:`Gemini`}],En=[{value:`bearer`,label:`Authorization: Bearer`},{value:`x-api-key`,label:`x-api-key`},{value:`x-goog-api-key`,label:`x-goog-api-key`},{value:`query-key`,label:`?key=`},{value:`none`,label:`—`},{value:`oauth-subscription`,label:`OAuth 订阅`}];function Dn(){let{t:e}=a(),t=Ie(),[n,r]=Ne(),s=i(),[c,l]=(0,X.useState)(n.get(`new`)===`1`),[u,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1);(0,X.useEffect)(()=>{n.get(`new`)===`1`&&(l(!0),n.delete(`new`),r(n,{replace:!0}))},[n,r]),Me(e=>{e===`new-provider`&&l(!0)});let g=T(`7d`,`day`,`provider`),[_,v]=(0,X.useState)(`7d`),y=C(`7d`),b=C(_),[x,S]=xt(),[w,E]=St(),[D,O]=(0,X.useState)(null),A=(0,X.useMemo)(()=>{let e=kn(On),t=new Map,n=0;for(let r of g.data??[]){let i=e.indexOf(r.bucket);if(i<0)continue;let a=t.get(r.key);a||t.set(r.key,a={requests:e.map(()=>0),costUsd:0}),a.requests[i]=(a.requests[i]??0)+r.requests,a.costUsd+=r.costUsd,n=Math.max(n,a.requests[i])}return{days:e,labels:e.map(e=>e.slice(5)),byProvider:t,max:n}},[g.data]),j=(0,X.useMemo)(()=>new Map((y.data??[]).map(e=>[e.providerId,e])),[y.data]),M=e=>A.byProvider.get(e.name)?.requests??A.days.map(()=>0);return(0,Z.jsxs)(Re,{title:e(`nav.providers`),subtitle:s.data?e(`providers.count`,{count:s.data.length}):void 0,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{icon:(0,Z.jsx)(me,{className:`size-3.5`}),onClick:()=>m(!0),children:e(`providers.backup`)}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(je,{className:`size-3.5`}),onClick:()=>f(!0),children:e(`providers.import`)}),(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(Ce,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`providers.add`)})]}),children:[(0,Z.jsxs)(`div`,{className:`mx-auto max-w-[1100px]`,children:[s.isLoading&&(0,Z.jsx)(d,{lines:4}),s.isError&&(0,Z.jsx)(U,{tone:`danger`,title:e(`common.error`),children:G(s.error)}),s.data?.length===0&&(0,Z.jsx)(`div`,{className:`card`,children:(0,Z.jsx)(h,{icon:(0,Z.jsx)(Te,{className:`size-6`}),title:e(`providers.empty`),detail:e(`providers.emptyDetail`),action:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,icon:(0,Z.jsx)(Ce,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`providers.add`)}),(0,Z.jsx)(o,{icon:(0,Z.jsx)(je,{className:`size-3.5`}),onClick:()=>f(!0),children:e(`providers.import`)})]})})}),s.data&&s.data.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(k,{ariaLabel:e(`providers.overview.range`),value:_,onChange:v,items:Nt.map(t=>({value:t,label:e(`range.${t}`)}))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`plain`,size:`sm`,icon:w?(0,Z.jsx)(_e,{className:`size-3.5`}):(0,Z.jsx)(he,{className:`size-3.5`}),onClick:()=>E(!w),children:e(w?`providers.overview.hideCharts`:`providers.overview.showCharts`)}),(0,Z.jsx)(k,{ariaLabel:e(`providers.view.label`),value:x,onChange:S,items:[{value:`grid`,label:e(`providers.view.grid`)},{value:`table`,label:e(`providers.view.table`)}]})]})]}),(0,Z.jsx)(Pt,{providers:s.data,stats:b.data??[],stats7d:j,range:_,chartsOpen:w}),x===`table`?(0,Z.jsx)(Ht,{providers:s.data,stats7d:j,usage:M,labels:A.labels,max:A.max,onOpen:e=>t(`/providers/${e.id}`)}):(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,260px),1fr))] gap-3`,children:s.data.map(e=>(0,Z.jsx)(jn,{p:e,labels:A.labels,max:A.max,requests:M(e),stat:j.get(e.id),onOpen:()=>t(`/providers/${e.id}`),onTest:()=>O(e)},e.id))})]})]}),(0,Z.jsx)(st,{open:u,onOpenChange:f}),(0,Z.jsx)(ht,{open:p,onOpenChange:m}),(0,Z.jsx)(Un,{open:c,onOpenChange:l,onCreated:e=>t(`/providers/${e.id}`)}),D&&(0,Z.jsx)(cn,{provider:D,open:!0,onOpenChange:e=>!e&&O(null)})]})}var On=7;function kn(e){let t=new Date;return Array.from({length:e},(n,r)=>{let i=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(e-1-r));return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,`0`)}-${String(i.getDate()).padStart(2,`0`)}`})}var An=e=>e.stopPropagation();function jn({p:e,labels:t,max:n,requests:r,stat:i,onOpen:s,onTest:l}){let{t:u,locale:d}=a(),f=Tt(e,i),p=e.authScheme===`plugin`?u(`providers.card.plugin`):e.authScheme===`oauth-subscription`?u(`providers.card.subscription`):e.authScheme===`none`?u(`providers.card.noAuth`):e.hasApiKey?e.apiKeyMasked??`••••`:u(`providers.noKey`),m=pe(e)?W(e.quota,u,d):null,h=pe(e)?de(e.quota):null,g=r.reduce((e,t)=>e+t,0),_=Wt(e.endpoints[0]?.baseUrl);return(0,Z.jsxs)(`div`,{className:V(`card flex h-[116px] cursor-pointer flex-col gap-[7px] px-3 py-2.5 transition-colors hover:border-[var(--border-strong,var(--border))]`,!e.enabled&&`opacity-60`),role:`button`,tabIndex:0,"aria-label":e.name,title:e.name,onClick:s,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:V(`inline-flex shrink-0`,!e.enabled&&`grayscale`),children:(0,Z.jsx)(ze,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[14px] font-semibold`,children:e.name}),(0,Z.jsx)(`span`,{title:Dt(f,u),className:`inline-flex`,children:(0,Z.jsx)(I,{tone:Et[f]})}),e.templateUpdateAvailable&&(0,Z.jsx)(c,{tone:`accent`,children:u(`providers.templateUpdate`)}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11.5px] text-[var(--text-muted)]`,children:u(`providers.modelCount`,{count:e.modelCount})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center`,onClick:An,children:[(0,Z.jsx)(o,{variant:`plain`,size:`sm`,icon:(0,Z.jsx)(xe,{className:`size-3.5`}),"aria-label":u(`providers.test`),title:u(`providers.test`),onClick:l}),(0,Z.jsx)(Gt,{provider:e})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-1.5 text-[11.5px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-mono`,title:e.endpoints[0]?.baseUrl,children:_??`—`}),(0,Z.jsx)(`span`,{children:`·`}),h?(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[var(--warning)]`,title:h.message,children:u(`providers.quota.failed`,{error:ue(h,u)})}):m?(0,Z.jsx)(`span`,{className:`num min-w-0 truncate text-[var(--text-secondary)]`,title:m,children:m}):(0,Z.jsx)(`span`,{className:V(`min-w-0 truncate`,e.hasApiKey&&e.authScheme!==`oauth-subscription`&&`font-mono`),children:p})]}),(0,Z.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2.5`,onClick:An,children:[(0,Z.jsx)(jt,{data:r,labels:t,max:n}),g>0?(0,Z.jsxs)(`span`,{className:`flex gap-2.5 whitespace-nowrap text-[11.5px] text-[var(--text-secondary)]`,title:u(`providers.card.requests7d`),children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`b`,{className:`num font-semibold text-[var(--text)]`,children:B(g,!0)}),` `,u(`providers.card.requestsUnit`)]}),i&&i.requests>0&&(0,Z.jsx)(`span`,{className:`num`,style:{color:At(i.successRate)},title:u(`providers.col.successRate`),children:P(i.successRate)}),i&&i.costUsd>0&&(0,Z.jsx)(`span`,{className:`num`,children:z(i.costUsd)})]}):(0,Z.jsx)(`span`,{className:`text-[11.5px] text-[var(--text-muted)]`,children:u(`providers.card.noRequests7d`)})]})]})}var Mn=`plugin:`,Nn=[`recommended`,`official`,`subscription`,`coding`,`cn`,`aggregator`,`inference`,`local`,`custom`],Pn={"openai-chat":`Chat`,"openai-responses":`Responses`,anthropic:`Anthropic`,gemini:`Gemini`},Fn=e=>$.find(t=>t.value===e)?.label??e,In=e=>(0,Z.jsx)(`span`,{title:e,children:e}),Ln=e=>{let t=/^(.+?)\s*[((]([^()()]+)[))]$/.exec(e);return t?[t[1],t[2]]:[e,null]},Rn=/[\s,,]+/;function zn(e,t,n){let r=new Set(t.map(e=>e.protocol)),i=n.map(e=>e.protocol);return[...e.filter(e=>i.includes(e)),...i.filter(t=>!r.has(t)&&!e.includes(t))]}function Bn({label:e,hint:t,children:n}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-[13px] font-medium`,children:e}),n,t&&(0,Z.jsx)(`div`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:t})]})}function Vn({value:e,onChange:t}){let{t:n}=a(),r=e.map(e=>e.protocol),i=$.filter(e=>!r.includes(e.value)),s=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[e.map((i,a)=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(K,{className:`w-44`,ariaLabel:n(`providers.protocol`),value:i.protocol,onChange:e=>s(a,{protocol:e}),options:$.filter(e=>e.value===i.protocol||!r.includes(e.value))}),(0,Z.jsx)(l,{className:`min-w-52 flex-1`,mono:!0,"aria-label":n(`providers.baseUrl`),placeholder:`https://api.example.com/v1`,value:i.baseUrl,onChange:e=>s(a,{baseUrl:e.target.value})}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,title:n(`providers.fullUrlHint`),children:[(0,Z.jsx)(O,{checked:!!i.fullUrl,label:n(`providers.fullUrl`),onChange:e=>s(a,{fullUrl:e})}),n(`providers.fullUrl`)]}),(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(De,{className:`size-3.5`}),"aria-label":n(`common.delete`),disabled:e.length===1,onClick:()=>t(e.filter((e,t)=>t!==a))})]},a)),i.length>0&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(Ce,{className:`size-3.5`}),onClick:()=>t([...e,{protocol:i[0].value,baseUrl:e[0]?.baseUrl??``}]),children:n(`providers.addEndpoint`)})})]})}function Hn({value:e,onChange:t}){let{t:n}=a(),r=(n,r)=>t(e.map((e,t)=>t===n?r:e));return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[e.map(([i,a],s)=>(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(l,{className:`w-44`,mono:!0,"aria-label":n(`providers.headerName`),placeholder:`Header`,value:i,onChange:e=>r(s,[e.target.value,a])}),(0,Z.jsx)(l,{className:`min-w-0 flex-1`,mono:!0,"aria-label":n(`providers.headerValue`),placeholder:`value`,value:a,onChange:e=>r(s,[i,e.target.value])}),(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(De,{className:`size-3.5`}),"aria-label":n(`common.delete`),onClick:()=>t(e.filter((e,t)=>t!==s))})]},s)),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{size:`sm`,variant:`plain`,icon:(0,Z.jsx)(Ce,{className:`size-3.5`}),onClick:()=>t([...e,[``,``]]),children:n(`providers.addHeader`)})})]})}function Un({open:e,onOpenChange:t,onCreated:n}){let{t:s}=a(),{toast:c}=q(),u=S(),f=ce(),m=ee(),h=i(),g=(0,X.useMemo)(()=>new Set((h.data??[]).filter(e=>e.authScheme===`oauth-subscription`&&e.templateId).map(e=>e.templateId)),[h.data]),_=Ie(),[v,b]=(0,X.useState)(``),[x,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[j,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(``),[te,ne]=(0,X.useState)(`bearer`),[F,I]=(0,X.useState)([]),[L,R]=(0,X.useState)([]),[z,B]=(0,X.useState)([]),[V,re]=(0,X.useState)(``),[ie,H]=(0,X.useState)(1),[ae,oe]=(0,X.useState)(``),[se,ue]=(0,X.useState)(``);(0,X.useEffect)(()=>{e||(C(null),T(null),b(``),D(``),k(``),M(``),P(``))},[e]);let de=(0,X.useMemo)(()=>{let e=v.trim().toLowerCase(),t=(u.data??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.includes(e));return Nn.map(e=>({category:e,items:t.filter(t=>t.category===e)})).filter(e=>e.items.length)},[u.data,v]),W=(0,X.useMemo)(()=>{let e=v.trim().toLowerCase();return(h.data??[]).filter(t=>t.authScheme===`plugin`&&!t.settings.plugin?.absent&&(!e||t.name.toLowerCase().includes(e)||t.id.includes(e)))},[h.data,v]),pe=e=>{C(e),M(``),re(``),oe(``),ue(``),e===`custom`?(D(``),P(``),ne(`bearer`),I([{protocol:`openai-chat`,baseUrl:``}]),R([`openai-chat`]),B([]),H(1)):(D(e.name),P(e.priceKey??e.id),ne(e.auth.scheme),I(e.endpoints.map(e=>({...e}))),R([...e.preferredUpstreamProtocols]),B(Object.entries(e.defaultHeaders??{})),H(e.defaultPriceMultiplier??1))},me=e=>{R(t=>zn(t,F,e)),I(e)},J=x&&x!==`custom`?x:null,he=J?.authScheme===`oauth-subscription`,ge=se.split(Rn).map(e=>e.trim()).filter(Boolean),_e=(J?.keyAlternatives??[]).flatMap(e=>(u.data??[]).filter(t=>t.id===e)),ve=()=>{let e=x===`custom`;m.mutate({templateId:e?null:x.id,variantId:j||null,name:E.trim()||null,apiKey:O.trim()||null,priceKey:N,...he?{}:{endpoints:F.map(e=>({...e,baseUrl:e.baseUrl.trim()})),authScheme:te,preferredUpstreamProtocols:L.filter(e=>F.some(t=>t.protocol===e)),extraHeaders:Object.fromEntries(z.filter(([e])=>e.trim()).map(([e,t])=>[e.trim(),t])),httpProxy:V.trim()||null,priceMultiplier:ie,notes:ae.trim()||null,...ge.length>0?{models:ge}:{}}},{onSuccess:e=>{t(!1),c(s(`providers.created`,{name:e.name}),`success`),n(e)},onError:e=>c(G(e),`error`)})},ye=()=>{if(w===`custom`)pe(`custom`);else if(w?.startsWith(Mn)){let e=W.find(e=>Mn+e.id===w);e&&(t(!1),n(e))}else{let e=(u.data??[]).find(e=>e.id===w);e&&!g.has(e.id)&&pe(e)}},be=he||F.length>0&&F.every(e=>/^https?:\/\//.test(e.baseUrl.trim())),xe=x!==null&&be&&(x===`custom`?E.trim()!==``:!J.requiresApiKey||te===`none`||O.trim()!==``);return(0,Z.jsxs)(fe,{open:e,onOpenChange:t,width:640,title:s(x?`providers.addTitleDetails`:`providers.addTitle`),description:x?J?J.name:s(`providers.custom`):s(`providers.addDetail`),footer:x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{className:`mr-auto`,variant:`plain`,onClick:()=>C(null),children:s(`common.back`)}),(0,Z.jsx)(o,{onClick:()=>t(!1),children:s(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:!xe,loading:m.isPending,onClick:ve,children:s(`providers.create`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{onClick:()=>t(!1),children:s(`common.cancel`)}),(0,Z.jsx)(o,{variant:`primary`,disabled:!w,onClick:ye,children:s(`common.continue`)})]}),children:[(0,Z.jsx)(tt,{className:`mb-6`,label:s(`providers.addTitle`),current:+!!x,steps:[{id:`template`,label:s(`providers.step.template`)},{id:`details`,label:s(`providers.step.details`)}]}),x?(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(y,{label:s(`providers.name`),children:(0,Z.jsx)(l,{value:E,onChange:e=>D(e.target.value)})}),J?.variants&&J.variants.length>0&&(0,Z.jsx)(y,{label:s(`providers.variant`),children:(0,Z.jsx)(K,{value:j,onChange:e=>{M(e);let t=J.variants?.find(t=>t.id===e);P(t?.priceKey??J.priceKey??J.id),me((t?.endpointsOverride??J.endpoints).map(e=>({...e})))},options:[{value:``,label:s(`providers.variantDefault`)},...J.variants.map(e=>({value:e.id,label:e.name}))]})}),x===`custom`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Bn,{label:s(`providers.section.endpoints`),hint:s(`providers.baseUrlHint`),children:(0,Z.jsx)(Vn,{value:F,onChange:me})}),(0,Z.jsx)(y,{label:s(`providers.authScheme`),children:(0,Z.jsx)(K,{value:te,onChange:ne,options:En})})]}),he?(0,Z.jsx)(U,{tone:`info`,title:s(`providers.subscriptionWizardHint`),children:s(`providers.subscriptionWizardDetail`)}):(0,Z.jsxs)(`div`,{className:`font-mono`,children:[(0,Z.jsx)(Pe,{label:s(`providers.apiKey`),description:s(`providers.apiKeyHint`),autoComplete:`off`,placeholder:`sk-…`,value:O,onChange:e=>k(e.target.value)}),J?.apiKeyUrl&&(0,Z.jsx)(`a`,{className:`mt-2 inline-block font-sans text-[12px] text-[var(--accent)]`,href:J.apiKeyUrl,target:`_blank`,rel:`noreferrer`,children:s(`providers.getKey`)})]}),J&&_e.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(`span`,{children:s(`providers.keyAlternative.wizard`,{name:J.name,alt:_e.map(e=>e.name).join(` / `)})}),_e.map(e=>(0,Z.jsx)(o,{size:`sm`,variant:`plain`,onClick:()=>{T(e.id),pe(e)},children:s(`providers.keyAlternative.pick`,{alt:e.name})},e.id))]}),(0,Z.jsx)(y,{label:s(`providers.priceKey`),hint:s(`providers.priceKeyHint`),children:(0,Z.jsx)(K,{value:N,onChange:P,options:[{value:``,label:s(`providers.priceKeyNone`)},...(f.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey}))]})}),!he&&(0,Z.jsx)(r,{title:s(`providers.moreOptions`),children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[J&&(0,Z.jsx)(Bn,{label:s(`providers.section.endpoints`),hint:s(`providers.endpointsFooter`),children:(0,Z.jsx)(Vn,{value:F,onChange:me})}),new Set(F.map(e=>e.protocol)).size>1&&(0,Z.jsx)(Bn,{label:s(`providers.preferred`),hint:s(`providers.preferredHint`),children:(0,Z.jsx)(Le,{label:s(`providers.preferred`),options:$.filter(e=>F.some(t=>t.protocol===e.value)).map(e=>{let t=L.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:L,onValueChange:e=>{let t=L.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));R([...t,...n])}})}),J&&(0,Z.jsx)(y,{label:s(`providers.authScheme`),children:(0,Z.jsx)(K,{value:te,onChange:ne,options:En})}),(0,Z.jsx)(Bn,{label:s(`providers.headers`),children:(0,Z.jsx)(Hn,{value:z,onChange:B})}),(0,Z.jsx)(y,{label:s(`providers.proxy`),hint:s(`providers.proxyHint`),children:(0,Z.jsx)(l,{mono:!0,placeholder:`http://127.0.0.1:7890`,value:V,onChange:e=>re(e.target.value)})}),(0,Z.jsx)(Bn,{label:s(`providers.multiplier`),hint:s(`providers.multiplierHint`),children:(0,Z.jsx)(p,{className:`w-28`,label:s(`providers.multiplier`),step:.01,min:0,value:ie,onChange:e=>H(e??1)})}),(0,Z.jsx)(y,{label:s(`providers.initialModels`),hint:J?s(`providers.initialModelsTemplateHint`,{count:J.models.length}):s(`providers.initialModelsCustomHint`),children:(0,Z.jsx)(A,{rows:3,mono:!0,value:se,onChange:e=>ue(e.target.value)})}),(0,Z.jsx)(y,{label:s(`providers.notes`),children:(0,Z.jsx)(l,{value:ae,onChange:e=>oe(e.target.value)})}),(0,Z.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:s(`providers.moreOptionsDetail`)})]})}),J&&J.models.length>0&&ge.length===0&&(0,Z.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:s(`providers.templateModels`,{count:J.models.length})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(le,{value:v,onChange:b,placeholder:s(`providers.searchTemplates`)}),u.isLoading&&(0,Z.jsx)(d,{lines:4}),u.isError&&(0,Z.jsx)(U,{tone:`danger`,title:s(`common.error`),children:G(u.error)}),de.map(e=>(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:s(`providers.category.${e.category}`)}),(0,Z.jsx)(Ve,{name:`provider-template`,"aria-label":s(`providers.category.${e.category}`),density:`compact`,minColumnWidth:168,value:e.items.some(e=>e.id===w)?w:null,onValueChange:T,options:e.items.map(e=>{let t=[...new Set(e.endpoints.map(e=>e.protocol))],[n,r]=Ln(e.name);return{value:e.id,label:(0,Z.jsx)(`span`,{title:e.name,children:n}),description:(0,Z.jsx)(`span`,{title:t.map(Fn).join(` · `),children:r??t.map(e=>Pn[e]).join(` · `)}),icon:(0,Z.jsx)(ze,{name:e.name,icon:e.icon,colorKey:e.id,size:28}),disabled:g.has(e.id),disabledReason:In(s(`providers.subscriptionAdded`))}})})]},e.category)),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:s(`providers.category.plugin`)}),W.length>0?(0,Z.jsx)(Ve,{name:`provider-template-plugin`,"aria-label":s(`providers.category.plugin`),density:`compact`,minColumnWidth:168,value:w?.startsWith(Mn)?w:null,onValueChange:T,options:W.map(e=>({value:Mn+e.id,label:In(e.name),description:In(s(`providers.pluginProvided`)),icon:(0,Z.jsx)(ze,{name:e.name,icon:e.icon,colorKey:e.id,size:28})}))}):(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[var(--radius-md)] border border-dashed border-[var(--border)] px-3 py-2.5`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:s(`providers.pluginHint`)}),(0,Z.jsx)(o,{size:`sm`,onClick:()=>{t(!1),_(`/plugins/market`)},children:s(`plugins.browseMarket`)})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`mb-2 text-[12px] font-medium text-[var(--text-secondary)]`,children:s(`providers.custom`)}),(0,Z.jsx)(Ve,{name:`provider-template-custom`,"aria-label":s(`providers.custom`),layout:`list`,density:`compact`,value:w===`custom`?`custom`:null,onValueChange:T,options:[{value:`custom`,label:s(`providers.custom`),description:s(`providers.customDetail`),icon:(0,Z.jsx)(`span`,{className:`inline-flex size-7 items-center justify-center rounded-[8px] border border-dashed border-[var(--border-strong)] text-[var(--text-secondary)]`,children:(0,Z.jsx)(Ce,{className:`size-4`})})}]})]})]})]})}export{Yt as a,cn as i,$ as n,Jt as o,Tn as r,Kt as s,En as t};
|