nextclaw 0.20.5 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cli/app/index.js +812 -3
  2. package/dist/cli/app/index.js.map +1 -1
  3. package/package.json +16 -16
  4. package/ui-dist/assets/api-BCDb13Uv.js +8 -0
  5. package/ui-dist/assets/app-presenter-provider-C-QMjK7m.js +3 -0
  6. package/ui-dist/assets/arrow-left-rIXFA2Zy.js +1 -0
  7. package/ui-dist/assets/{channels-list-page-BnGxv6ma.js → channels-list-page-DnqwsKGe.js} +6 -6
  8. package/ui-dist/assets/chat-page-CsQx20xL.js +105 -0
  9. package/ui-dist/assets/{config-split-page-CWN2YG9U.js → config-split-page-BwhGqmUS.js} +1 -1
  10. package/ui-dist/assets/confirm-dialog-DBkKcQ1q.js +5 -0
  11. package/ui-dist/assets/{desktop-update-config-abmYzHSy.js → desktop-update-config-BE9KjiXi.js} +1 -1
  12. package/ui-dist/assets/dist-BI0bX8jv.js +1 -0
  13. package/ui-dist/assets/dist-C8JRt-tf.js +1 -0
  14. package/ui-dist/assets/{doc-browser-context-Cb1sEUT0.js → doc-browser-context-VHUOIUXL.js} +1 -1
  15. package/ui-dist/assets/doc-browser-eqdNEerh.js +1 -0
  16. package/ui-dist/assets/doc-browser-lpF_pyx4.js +1 -0
  17. package/ui-dist/assets/ellipsis-C9VB2CxT.js +1 -0
  18. package/ui-dist/assets/es2015-BCw3Q7nY.js +41 -0
  19. package/ui-dist/assets/external-link-Bp7_4s9t.js +1 -0
  20. package/ui-dist/assets/index-BCq7kbC8.css +1 -0
  21. package/ui-dist/assets/{index-Ccbswzt9.js → index-DTdPDqto.js} +12 -12
  22. package/ui-dist/assets/key-round-Ccy6oND3.js +1 -0
  23. package/ui-dist/assets/loader-circle-OpH4EErP.js +1 -0
  24. package/ui-dist/assets/{mcp-marketplace-page-CmUKUeno.js → mcp-marketplace-page-B-GxKOqS.js} +2 -2
  25. package/ui-dist/assets/mcp-marketplace-page-Dm-0-w51.js +1 -0
  26. package/ui-dist/assets/{model-config-Dbo3zWDl.js → model-config-BXPnV_7n.js} +1 -1
  27. package/ui-dist/assets/{notice-card-CFTFtJky.js → notice-card-Dsbkl7u7.js} +1 -1
  28. package/ui-dist/assets/play-CvgYhNbo.js +1 -0
  29. package/ui-dist/assets/plus-DHcP-K1U.js +1 -0
  30. package/ui-dist/assets/popover-BTLZE5Iz.js +1 -0
  31. package/ui-dist/assets/provider-scoped-model-input-DKI9KN7N.js +1 -0
  32. package/ui-dist/assets/providers-list-Bko6B7dE.js +1 -0
  33. package/ui-dist/assets/react-BqS8oMyM.js +8 -0
  34. package/ui-dist/assets/refresh-cw-BIaj7txb.js +1 -0
  35. package/ui-dist/assets/remote-DHn_b8QU.js +1 -0
  36. package/ui-dist/assets/rotate-cw-DMqSkRJQ.js +1 -0
  37. package/ui-dist/assets/{runtime-config-page-Dg8aEgWx.js → runtime-config-page-DX_wSK1J.js} +1 -1
  38. package/ui-dist/assets/save-BEoORten.js +1 -0
  39. package/ui-dist/assets/search-COFh_SFI.js +1 -0
  40. package/ui-dist/assets/{search-config-DAibVFGR.js → search-config-DA5By-tE.js} +1 -1
  41. package/ui-dist/assets/{secrets-config-CoJzy13_.js → secrets-config-eDxG7iN4.js} +1 -1
  42. package/ui-dist/assets/{status-dot-D8xx5ZR8.js → status-dot-oWBjTovo.js} +1 -1
  43. package/ui-dist/assets/{tabs-DxmND60Q.js → tabs-CGaY0BVO.js} +1 -1
  44. package/ui-dist/assets/{tabs-custom-Cjo0bHw8.js → tabs-custom-D2fPYb4G.js} +1 -1
  45. package/ui-dist/assets/{tag-chip-DnNWFRMu.js → tag-chip-TVkgofS1.js} +1 -1
  46. package/ui-dist/assets/tooltip-BwHPKBv9.js +1 -0
  47. package/ui-dist/assets/trash-2-D3psAGrz.js +1 -0
  48. package/ui-dist/assets/x-CHAxzyp2.js +1 -0
  49. package/ui-dist/index.html +25 -24
  50. package/ui-dist/assets/api-BAyyGaoz.js +0 -15
  51. package/ui-dist/assets/app-presenter-provider-DqHHfC1K.js +0 -3
  52. package/ui-dist/assets/arrow-left-Bn-3Pj3p.js +0 -1
  53. package/ui-dist/assets/boxes-ClVuotcz.js +0 -1
  54. package/ui-dist/assets/chat-page-DInyWLb4.js +0 -105
  55. package/ui-dist/assets/confirm-dialog-CVbgKuHp.js +0 -5
  56. package/ui-dist/assets/createLucideIcon-CjPUPAAK.js +0 -1
  57. package/ui-dist/assets/dist-hkrb6Ynt.js +0 -41
  58. package/ui-dist/assets/doc-browser-BlrpUKVJ.js +0 -1
  59. package/ui-dist/assets/doc-browser-kJ2ClG0H.js +0 -1
  60. package/ui-dist/assets/ellipsis-CdkxFkVZ.js +0 -1
  61. package/ui-dist/assets/external-link-CT9_qFwN.js +0 -1
  62. package/ui-dist/assets/index-BGXTR0F_.css +0 -1
  63. package/ui-dist/assets/key-round-xJfR4iRe.js +0 -1
  64. package/ui-dist/assets/loader-circle-BI6HJDg5.js +0 -1
  65. package/ui-dist/assets/mcp-marketplace-page-DH11bSVx.js +0 -1
  66. package/ui-dist/assets/play-DyBWW2j4.js +0 -1
  67. package/ui-dist/assets/plus-BlnBmcKE.js +0 -1
  68. package/ui-dist/assets/popover-DPqa_Mfb.js +0 -1
  69. package/ui-dist/assets/provider-scoped-model-input-C6xL7zSJ.js +0 -1
  70. package/ui-dist/assets/providers-list-DOj_7GL8.js +0 -1
  71. package/ui-dist/assets/react-oAHNoVya.js +0 -1
  72. package/ui-dist/assets/refresh-cw-o8NSmIYV.js +0 -1
  73. package/ui-dist/assets/remote-fCE5fLsj.js +0 -1
  74. package/ui-dist/assets/rotate-cw-DA8EqNAH.js +0 -1
  75. package/ui-dist/assets/save-D4-g0EAq.js +0 -1
  76. package/ui-dist/assets/search-G2cMn3M5.js +0 -1
  77. package/ui-dist/assets/trash-2-C9tc-9sQ.js +0 -1
  78. package/ui-dist/assets/x-DmLl2yG6.js +0 -1
  79. /package/ui-dist/assets/{config-hints-TmNgpFHv.js → config-hints-Ceiol9x4.js} +0 -0
  80. /package/ui-dist/assets/{provider-models-CXUgDxGR.js → provider-models-C_yOh6DE.js} +0 -0
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-C8JRt-tf.js";var t=e(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-C8JRt-tf.js";var t=e(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),n=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t as n,n as t};
@@ -1,4 +1,4 @@
1
- import{d as e,h as t,i as n,m as r,v as i}from"./react-oAHNoVya.js";import{$t as a,Bt as o,C as s,Ft as c,Ht as l,Mt as u,Pt as d,Qt as f,S as p,T as m,Vt as h,b as ee,en as g,mt as _,nn as v,tn as y,w as b,x as te,zt as x}from"./api-BAyyGaoz.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./confirm-dialog-CVbgKuHp.js";import{t as O}from"./createLucideIcon-CjPUPAAK.js";import{t as k}from"./notice-card-CFTFtJky.js";import{n as ne}from"./doc-browser-context-Cb1sEUT0.js";import{Et as re,J as A,K as j,X as M,Y as N,h as ie,q as P,u as F,wt as ae}from"./index-Ccbswzt9.js";import{t as I}from"./tag-chip-DnNWFRMu.js";var oe=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:y()})}getOptimisticResult(e){return e.behavior=y(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:s,isRefetchError:c}=r,l=n.fetchMeta?.fetchMore?.direction,u=s&&l===`forward`,d=i&&l===`forward`,f=s&&l===`backward`,p=i&&l===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:a(t,n.data),hasPreviousPage:g(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:c&&!u&&!f,isRefetching:o&&!d&&!p}}};function L(e,t){return l(e,oe,t)}var se=O(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),ce=O(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]);function R(e){if(!e||e.pages.length===0)return;let t=e.pages.flatMap(e=>e.items);return{...e.pages[e.pages.length-1],items:t,pages:e.pages,loadedItems:t.length,loadedPages:e.pages.length}}var z=r();function B({scope:e,searchText:t,searchPlaceholder:r,sort:i,onSearchTextChange:a,onSortChange:o}){return(0,z.jsx)(`div`,{className:`mb-4`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,z.jsx)(ce,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,z.jsx)(`input`,{value:t,onChange:e=>a(e.target.value),placeholder:r,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e===`all`&&(0,z.jsxs)(j,{value:i,onValueChange:e=>o(e),children:[(0,z.jsx)(N,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,z.jsx)(M,{})}),(0,z.jsxs)(P,{children:[(0,z.jsx)(A,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,z.jsx)(A,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function V({count:e}){return(0,z.jsx)(z.Fragment,{children:Array.from({length:e},(e,t)=>(0,z.jsx)(`article`,{className:`h-full rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,z.jsx)(F,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,z.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(F,{className:`h-3 w-12`}),(0,z.jsx)(F,{className:`h-3 w-24`})]}),(0,z.jsx)(F,{className:`h-3 w-full`})]})]}),(0,z.jsx)(F,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function H({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,z.jsxs)(`div`,{className:`py-4`,children:[e&&(0,z.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,z.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function U(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function W(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function G(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:W(e),text:typeof t==`string`?t.trim():``})).filter(e=>e.text.length>0);if(t.length>0){let e=new Map(t.map(e=>[e.locale,e.text]));for(let t of n){let n=W(t),r=e.get(n);if(r)return r}for(let e of n){let n=W(e).split(`-`)[0];if(!n)continue;let r=t.find(e=>e.locale===n||e.locale.startsWith(`${n}-`));if(r)return r.text}return t[0]?.text??``}}return t?.trim()??``}function le(e,t){if(!e)return``;for(let n of t)if(W(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}var K=i(t(),1),ue=160;function q(e){let t=(0,K.useRef)(null),n=(0,K.useRef)(null),r=(0,K.useRef)(e.onLoadMore),i=(0,K.useRef)(!1);return(0,K.useEffect)(()=>{r.current=e.onLoadMore},[e.onLoadMore]),(0,K.useEffect)(()=>{e.disabled&&(i.current=!1)},[e.disabled]),(0,K.useEffect)(()=>{let a=t.current,o=n.current,s=e.thresholdPx??ue;if(e.disabled||!a||!o)return;let c=()=>{i.current||e.disabled||(i.current=!0,Promise.resolve(r.current()).finally(()=>{i.current=!1}))},l=()=>{o.getBoundingClientRect().top-a.getBoundingClientRect().bottom<=s&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:a,rootMargin:`0px 0px ${s}px 0px`});return e.observe(o),l(),()=>{e.disconnect()}}return a.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{a.removeEventListener(`scroll`,l)}},[e.disabled,e.thresholdPx,e.watchValue]),{containerRef:t,sentinelRef:n}}function J(e){return(e??``).trim().toLowerCase()}function de(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=J(r);!e||t.has(e)||t.set(e,n)}}return t}function fe(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=J(e);if(!n)continue;let r=t.get(n);if(r)return r}}function Y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function X(e,t,n,r,i){let a=`<!doctype html>
1
+ import{d as e,g as t,i as n,m as r,y as i}from"./react-BqS8oMyM.js";import{$t as a,Bt as o,C as s,Ft as c,Ht as l,Mt as u,Pt as d,Qt as f,S as p,T as m,Vt as h,b as ee,en as g,mt as _,nn as v,tn as y,w as b,x as te,zt as x}from"./api-BCDb13Uv.js";import{c as S}from"./dist-C8JRt-tf.js";import{a as C,i as w,n as T,o as E,r as D,s as O}from"./confirm-dialog-DBkKcQ1q.js";import{t as k}from"./notice-card-Dsbkl7u7.js";import{n as ne}from"./doc-browser-context-VHUOIUXL.js";import{Et as re,J as A,K as j,X as M,Y as N,h as ie,q as P,u as F,wt as ae}from"./index-DTdPDqto.js";import{t as I}from"./tag-chip-TVkgofS1.js";var oe=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:y()})}getOptimisticResult(e){return e.behavior=y(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:s,isRefetchError:c}=r,l=n.fetchMeta?.fetchMore?.direction,u=s&&l===`forward`,d=i&&l===`forward`,f=s&&l===`backward`,p=i&&l===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:a(t,n.data),hasPreviousPage:g(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:c&&!u&&!f,isRefetching:o&&!d&&!p}}};function L(e,t){return l(e,oe,t)}var se=S(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),ce=S(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]);function R(e){if(!e||e.pages.length===0)return;let t=e.pages.flatMap(e=>e.items);return{...e.pages[e.pages.length-1],items:t,pages:e.pages,loadedItems:t.length,loadedPages:e.pages.length}}var z=r();function B({scope:e,searchText:t,searchPlaceholder:r,sort:i,onSearchTextChange:a,onSortChange:o}){return(0,z.jsx)(`div`,{className:`mb-4`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,z.jsx)(ce,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,z.jsx)(`input`,{value:t,onChange:e=>a(e.target.value),placeholder:r,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e===`all`&&(0,z.jsxs)(j,{value:i,onValueChange:e=>o(e),children:[(0,z.jsx)(N,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,z.jsx)(M,{})}),(0,z.jsxs)(P,{children:[(0,z.jsx)(A,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,z.jsx)(A,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function V({count:e}){return(0,z.jsx)(z.Fragment,{children:Array.from({length:e},(e,t)=>(0,z.jsx)(`article`,{className:`h-full rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,z.jsx)(F,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,z.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(F,{className:`h-3 w-12`}),(0,z.jsx)(F,{className:`h-3 w-24`})]}),(0,z.jsx)(F,{className:`h-3 w-full`})]})]}),(0,z.jsx)(F,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function H({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,z.jsxs)(`div`,{className:`py-4`,children:[e&&(0,z.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,z.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function U(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function W(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function G(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:W(e),text:typeof t==`string`?t.trim():``})).filter(e=>e.text.length>0);if(t.length>0){let e=new Map(t.map(e=>[e.locale,e.text]));for(let t of n){let n=W(t),r=e.get(n);if(r)return r}for(let e of n){let n=W(e).split(`-`)[0];if(!n)continue;let r=t.find(e=>e.locale===n||e.locale.startsWith(`${n}-`));if(r)return r.text}return t[0]?.text??``}}return t?.trim()??``}function le(e,t){if(!e)return``;for(let n of t)if(W(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}var K=i(t(),1),ue=160;function q(e){let t=(0,K.useRef)(null),n=(0,K.useRef)(null),r=(0,K.useRef)(e.onLoadMore),i=(0,K.useRef)(!1);return(0,K.useEffect)(()=>{r.current=e.onLoadMore},[e.onLoadMore]),(0,K.useEffect)(()=>{e.disabled&&(i.current=!1)},[e.disabled]),(0,K.useEffect)(()=>{let a=t.current,o=n.current,s=e.thresholdPx??ue;if(e.disabled||!a||!o)return;let c=()=>{i.current||e.disabled||(i.current=!0,Promise.resolve(r.current()).finally(()=>{i.current=!1}))},l=()=>{o.getBoundingClientRect().top-a.getBoundingClientRect().bottom<=s&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:a,rootMargin:`0px 0px ${s}px 0px`});return e.observe(o),l(),()=>{e.disconnect()}}return a.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{a.removeEventListener(`scroll`,l)}},[e.disabled,e.thresholdPx,e.watchValue]),{containerRef:t,sentinelRef:n}}function J(e){return(e??``).trim().toLowerCase()}function de(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=J(r);!e||t.has(e)||t.set(e,n)}}return t}function fe(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=J(e);if(!n)continue;let r=t.get(n);if(r)return r}}function Y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function X(e,t,n,r,i){let a=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -37,4 +37,4 @@ import{d as e,h as t,i as n,m as r,v as i}from"./react-oAHNoVya.js";import{$t as
37
37
  </section>
38
38
  </main>
39
39
  </body>
40
- </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(a)}`}function Z(e,t,r){return G(t?.summaryI18n,t?.summary,e)||le(r,e)||n(`marketplaceInstalledLocalSummary`)}function pe(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function Q(e){let{item:t,record:r,localeFallbacks:i,onOpen:a,onInstall:o,onToggle:s,onDoctor:l,onRemove:u}=e,d=r,f=t?.name??r?.label??r?.id??`MCP`,p=Z(i,t,r),m=pe(t,r),h=d?d.enabled===!1?n(`marketplaceDisable`):n(`statusReady`):null;return(0,z.jsx)(`article`,{onClick:a,className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:f}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:m}),(0,z.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:p}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(t?.tags??[]).map(e=>(0,z.jsx)(I,{children:e},e)),h?(0,z.jsx)(I,{tone:`success`,children:h}):null]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!d&&t&&o?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:n(`marketplaceInstall`)}):null,d?(0,z.jsxs)(z.Fragment,{children:[s?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:d.enabled===!1?n(`marketplaceEnable`):n(`marketplaceDisable`)}):null,l?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-blue-200 text-blue-700 hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700`,onClick:e=>{e.stopPropagation(),l()},children:n(`marketplaceMcpDoctor`)}):null,u?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-rose-200 text-rose-600 hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600`,onClick:e=>{e.stopPropagation(),u()},children:n(`marketplaceMcpRemove`)}):null]}):null]})]})})}function me(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,z.jsx)(w,{open:n,onOpenChange:i,children:t?(0,z.jsx)(he,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function he(e){let{item:t,pending:r,onOpenChange:i,onSubmit:a}=e,o=t.install,[s,l]=(0,K.useState)(o?.defaultName??``),[u,f]=(0,K.useState)(!0),[p,m]=(0,K.useState)(Object.fromEntries((o?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,z.jsxs)(E,{children:[(0,z.jsxs)(T,{children:[(0,z.jsx)(D,{children:n(`marketplaceMcpInstallDialogTitle`)}),(0,z.jsx)(C,{children:t.name})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:n(`marketplaceMcpServerName`)}),(0,z.jsx)(d,{value:s,onChange:e=>l(e.target.value),placeholder:o?.defaultName??`mcp-server`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:n(`marketplaceMcpAllAgents`)}),(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:n(`marketplaceMcpAllAgentsDescription`)})]}),(0,z.jsx)(_,{checked:u,onCheckedChange:f})]}),(o?.inputs??[]).map(e=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,z.jsx)(d,{type:e.secret?`password`:`text`,value:p[e.id]??``,onChange:t=>m(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,z.jsxs)(S,{children:[(0,z.jsx)(c,{variant:`outline`,onClick:()=>i(!1),disabled:r,children:n(`cancel`)}),(0,z.jsx)(c,{onClick:()=>void a({name:s,allAgents:u,inputs:p}),disabled:r||!s.trim(),children:n(r?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function ge(e){let{result:t,targetName:r,open:i,pending:a,onOpenChange:o}=e;return(0,z.jsx)(w,{open:i,onOpenChange:o,children:(0,z.jsxs)(E,{children:[(0,z.jsxs)(T,{children:[(0,z.jsx)(D,{children:n(`marketplaceMcpDoctorTitle`)}),(0,z.jsx)(C,{children:r??`-`})]}),a?(0,z.jsx)(`div`,{className:`text-sm text-gray-500`,children:n(`loading`)}):null,!a&&t?(0,z.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorAccessible`),`:`,` `,t.accessible?n(`statusReady`):n(`marketplaceOperationFailed`)]}),(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTransport`),`:`,` `,t.transport.toUpperCase()]}),(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTools`),`: `,t.toolCount]}),t.error?(0,z.jsx)(k,{tone:`danger`,description:t.error,className:`rounded-lg`}):null]}):null]})})}function _e(e){let t=L({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,K.useMemo)(()=>R(t.data),[t.data]);return{...t,data:n}}function ve(){return h({queryKey:[`marketplace-mcp-installed`],queryFn:()=>p(),staleTime:1e4})}function ye(){let e=f();return o({mutationFn:b,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||n(`marketplaceInstallSuccessMcp`))},onError:e=>{x.error(e.message||n(`marketplaceInstallFailed`))}})}function be(){let e=f();return o({mutationFn:m,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||n(`marketplaceMcpManageSuccess`))},onError:e=>{x.error(e.message||n(`marketplaceOperationFailed`))}})}var $=12;function xe(){let[t,r]=(0,K.useState)(`catalog`),[i,a]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(`relevance`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),{language:v}=ae(),y=ne(),{confirm:b,ConfirmDialog:x}=ie(),S=(0,K.useMemo)(()=>U(v),[v]);(0,K.useEffect)(()=>{let e=window.setTimeout(()=>{c(i.trim())},250);return()=>window.clearTimeout(e)},[i]);let C=_e({q:s||void 0,sort:l,pageSize:$}),w=ve(),{containerRef:T,sentinelRef:E}=q({disabled:t!==`catalog`||C.isError||!C.hasNextPage||C.isFetchingNextPage,onLoadMore:()=>C.fetchNextPage(),watchValue:`${t}:${s}:${l}:${C.data?.loadedItems??0}:${C.data?.loadedPages??0}`});(0,K.useEffect)(()=>{let e=T.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[T,s,t,l]);let D=ye(),O=be(),A=o({mutationFn:ee,onSuccess:(e,t)=>{h(t),_(e)}}),j=(0,K.useMemo)(()=>de(w.data?.records??[]),[w.data?.records]),M=(0,K.useMemo)(()=>(w.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return s?t.includes(s.toLowerCase()):!0}),[w.data?.records,s]),N=async(e,t)=>{let r=e?.name??t?.label??t?.id??`MCP`,i={title:r,kind:`content`,dedupeKey:e?`marketplace:mcp:${e.slug}`:`marketplace:mcp:${t?.id??t?.spec??r}`},a=Z(S,e,t);if(!e){let e=X(r,JSON.stringify(t??{},null,2),n(`marketplaceInstalledLocalSummary`),t?.docsUrl,a);y.open(e,i);return}try{let t=await te(e.slug),n=X(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,a);y.open(n,i)}catch(e){let t=X(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),a,void 0,a);y.open(t,i)}},P=async e=>{f&&(await D.mutateAsync({spec:f.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),p(null))},F=async(e,t)=>{let r=t.id||t.spec;r&&(e===`remove`&&!await b({title:`${n(`marketplaceMcpRemoveTitle`)} ${r}?`,description:n(`marketplaceMcpRemoveDescription`),confirmLabel:n(`marketplaceMcpRemove`),variant:`destructive`})||await O.mutateAsync({action:e,id:r,spec:t.spec}))},I=[{id:`catalog`,label:n(`marketplaceMcpTabCatalog`),icon:re},{id:`installed`,label:n(`marketplaceMcpTabInstalled`),icon:se,count:w.data?.total??0}];return(0,z.jsxs)(u,{className:`flex h-full min-h-0 flex-col pb-0 px-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-6 w-full max-w-[1400px] h-full min-h-0 mx-auto`,children:[(0,z.jsxs)(`div`,{className:`relative overflow-hidden rounded-[32px] bg-gradient-to-br from-[#0F172A] via-[#1E1B4B] to-[#312E81] px-10 py-14 text-white shadow-xl isolate`,children:[(0,z.jsx)(`div`,{className:`absolute top-0 right-0 -m-32 opacity-30 pointer-events-none mix-blend-screen scale-150 transform-gpu`,children:(0,z.jsx)(`div`,{className:`w-[500px] h-[500px] rounded-full bg-gradient-to-tl from-fuchsia-500/40 via-purple-500/30 to-indigo-500/20 blur-[80px]`})}),(0,z.jsx)(`div`,{className:`absolute bottom-0 left-0 -m-32 opacity-20 pointer-events-none mix-blend-screen transform-gpu`,children:(0,z.jsx)(`div`,{className:`w-[400px] h-[400px] rounded-full bg-gradient-to-tr from-blue-500/40 to-cyan-500/20 blur-[80px]`})}),(0,z.jsxs)(`div`,{className:`relative z-10 flex flex-col gap-3`,children:[(0,z.jsx)(`h1`,{className:`text-[38px] font-extrabold tracking-[-0.02em] leading-tight drop-shadow-sm text-transparent bg-clip-text bg-gradient-to-r from-white via-white to-white/70`,children:n(`marketplaceMcpPageTitle`)}),(0,z.jsx)(`p`,{className:`text-[17px] font-medium text-purple-100/70 max-w-2xl leading-relaxed tracking-wide`,children:n(`marketplaceMcpPageDescription`)})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 mt-2`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-gray-100/60 backdrop-blur-sm rounded-2xl w-fit border border-gray-200/50 shadow-inner`,children:I.map(n=>{let i=t===n.id,a=n.icon;return(0,z.jsxs)(`button`,{onClick:()=>r(n.id),className:e(`relative flex items-center gap-2 px-5 py-2.5 rounded-xl font-semibold text-[14px] transition-all duration-300`,i?`text-gray-900 bg-white shadow-[0_2px_10px_rgb(0,0,0,0.06)]`:`text-gray-500 hover:text-gray-700 hover:bg-gray-200/40`),children:[(0,z.jsx)(a,{className:e(`w-4 h-4`,i?`text-primary`:`text-gray-400`)}),n.label,n.id===`installed`&&typeof n.count==`number`&&(0,z.jsx)(`span`,{className:e(`ml-1 flex items-center justify-center h-5 px-1.5 min-w-5 rounded-full text-[11px] font-bold transition-colors`,i?`bg-primary/10 text-primary`:`bg-gray-200 text-gray-500`),children:n.count})]},n.id)})}),(0,z.jsx)(`div`,{className:`flex-1 w-full md:max-w-md`,children:(0,z.jsx)(B,{scope:t===`catalog`?`all`:`installed`,searchText:i,searchPlaceholder:n(`marketplaceMcpSearchPlaceholder`),sort:l,onSearchTextChange:a,onSortChange:d})})]}),(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col mt-2`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-1`,children:(0,z.jsxs)(`h3`,{className:`text-[18px] font-bold tracking-tight text-gray-900 flex items-center gap-2`,children:[n(t===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,z.jsx)(`span`,{className:`flex items-center justify-center h-6 px-2 rounded-lg bg-gray-100 text-[12px] font-semibold text-gray-500`,children:t===`catalog`?C.data?.total??0:w.data?.total??0})]})}),(0,z.jsxs)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-y-auto pr-3 pb-8 -mx-1 px-1 custom-scrollbar`,"aria-busy":C.isLoading||C.isFetchingNextPage,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-[22px] md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 items-stretch`,children:[t===`catalog`&&C.isLoading&&(0,z.jsx)(V,{count:$}),t===`catalog`&&!C.isLoading&&(C.data?.items??[]).map(e=>{let t=fe(e,j);return(0,z.jsx)(Q,{item:e,record:t,localeFallbacks:S,onOpen:()=>void N(e,t),onInstall:()=>p(e),onToggle:t?()=>void F(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{h(t.id??null),_(null),A.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void F(`remove`,t):void 0},e.id)}),t===`installed`&&M.map(e=>(0,z.jsx)(Q,{record:e,localeFallbacks:S,onOpen:()=>void N(void 0,e),onToggle:()=>void F(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{h(e.id??null),_(null),A.mutateAsync(e.id??``)},onRemove:()=>void F(`remove`,e)},e.id??e.spec))]}),t===`catalog`&&C.isError&&(0,z.jsx)(k,{tone:`danger`,title:n(`marketplaceMcpSectionCatalog`),description:C.error.message}),t===`installed`&&w.isError&&(0,z.jsx)(k,{tone:`danger`,title:n(`marketplaceMcpSectionInstalled`),description:w.error.message}),t===`catalog`&&!C.isLoading&&!C.isError&&(C.data?.items?.length??0)===0&&(0,z.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,z.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoMcp`)})}),t===`installed`&&!w.isError&&M.length===0&&(0,z.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,z.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoInstalledMcp`)})}),t===`catalog`&&!C.isError&&(0,z.jsx)(H,{hasMore:!!C.hasNextPage,loading:C.isFetchingNextPage,sentinelRef:E})]})]})]}),(0,z.jsx)(me,{item:f,open:!!f,pending:D.isPending,onOpenChange:e=>!e&&p(null),onSubmit:P}),(0,z.jsx)(ge,{open:!!m,targetName:m,result:g,pending:A.isPending,onOpenChange:e=>!e&&h(null)}),(0,z.jsx)(x,{})]})}export{B as a,R as c,G as i,L as l,q as n,H as o,U as r,V as s,xe as t};
40
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(a)}`}function Z(e,t,r){return G(t?.summaryI18n,t?.summary,e)||le(r,e)||n(`marketplaceInstalledLocalSummary`)}function pe(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function Q(e){let{item:t,record:r,localeFallbacks:i,onOpen:a,onInstall:o,onToggle:s,onDoctor:l,onRemove:u}=e,d=r,f=t?.name??r?.label??r?.id??`MCP`,p=Z(i,t,r),m=pe(t,r),h=d?d.enabled===!1?n(`marketplaceDisable`):n(`statusReady`):null;return(0,z.jsx)(`article`,{onClick:a,className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:f}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:m}),(0,z.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:p}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(t?.tags??[]).map(e=>(0,z.jsx)(I,{children:e},e)),h?(0,z.jsx)(I,{tone:`success`,children:h}):null]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!d&&t&&o?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:n(`marketplaceInstall`)}):null,d?(0,z.jsxs)(z.Fragment,{children:[s?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:d.enabled===!1?n(`marketplaceEnable`):n(`marketplaceDisable`)}):null,l?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-blue-200 text-blue-700 hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700`,onClick:e=>{e.stopPropagation(),l()},children:n(`marketplaceMcpDoctor`)}):null,u?(0,z.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-rose-200 text-rose-600 hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600`,onClick:e=>{e.stopPropagation(),u()},children:n(`marketplaceMcpRemove`)}):null]}):null]})]})})}function me(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,z.jsx)(T,{open:n,onOpenChange:i,children:t?(0,z.jsx)(he,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function he(e){let{item:t,pending:r,onOpenChange:i,onSubmit:a}=e,o=t.install,[s,l]=(0,K.useState)(o?.defaultName??``),[u,f]=(0,K.useState)(!0),[p,m]=(0,K.useState)(Object.fromEntries((o?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,z.jsxs)(D,{children:[(0,z.jsxs)(E,{children:[(0,z.jsx)(O,{children:n(`marketplaceMcpInstallDialogTitle`)}),(0,z.jsx)(w,{children:t.name})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:n(`marketplaceMcpServerName`)}),(0,z.jsx)(d,{value:s,onChange:e=>l(e.target.value),placeholder:o?.defaultName??`mcp-server`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:n(`marketplaceMcpAllAgents`)}),(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:n(`marketplaceMcpAllAgentsDescription`)})]}),(0,z.jsx)(_,{checked:u,onCheckedChange:f})]}),(o?.inputs??[]).map(e=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,z.jsx)(d,{type:e.secret?`password`:`text`,value:p[e.id]??``,onChange:t=>m(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,z.jsxs)(C,{children:[(0,z.jsx)(c,{variant:`outline`,onClick:()=>i(!1),disabled:r,children:n(`cancel`)}),(0,z.jsx)(c,{onClick:()=>void a({name:s,allAgents:u,inputs:p}),disabled:r||!s.trim(),children:n(r?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function ge(e){let{result:t,targetName:r,open:i,pending:a,onOpenChange:o}=e;return(0,z.jsx)(T,{open:i,onOpenChange:o,children:(0,z.jsxs)(D,{children:[(0,z.jsxs)(E,{children:[(0,z.jsx)(O,{children:n(`marketplaceMcpDoctorTitle`)}),(0,z.jsx)(w,{children:r??`-`})]}),a?(0,z.jsx)(`div`,{className:`text-sm text-gray-500`,children:n(`loading`)}):null,!a&&t?(0,z.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorAccessible`),`:`,` `,t.accessible?n(`statusReady`):n(`marketplaceOperationFailed`)]}),(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTransport`),`:`,` `,t.transport.toUpperCase()]}),(0,z.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTools`),`: `,t.toolCount]}),t.error?(0,z.jsx)(k,{tone:`danger`,description:t.error,className:`rounded-lg`}):null]}):null]})})}function _e(e){let t=L({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,K.useMemo)(()=>R(t.data),[t.data]);return{...t,data:n}}function ve(){return h({queryKey:[`marketplace-mcp-installed`],queryFn:()=>p(),staleTime:1e4})}function ye(){let e=f();return o({mutationFn:b,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||n(`marketplaceInstallSuccessMcp`))},onError:e=>{x.error(e.message||n(`marketplaceInstallFailed`))}})}function be(){let e=f();return o({mutationFn:m,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||n(`marketplaceMcpManageSuccess`))},onError:e=>{x.error(e.message||n(`marketplaceOperationFailed`))}})}var $=12;function xe(){let[t,r]=(0,K.useState)(`catalog`),[i,a]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(`relevance`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),{language:v}=ae(),y=ne(),{confirm:b,ConfirmDialog:x}=ie(),S=(0,K.useMemo)(()=>U(v),[v]);(0,K.useEffect)(()=>{let e=window.setTimeout(()=>{c(i.trim())},250);return()=>window.clearTimeout(e)},[i]);let C=_e({q:s||void 0,sort:l,pageSize:$}),w=ve(),{containerRef:T,sentinelRef:E}=q({disabled:t!==`catalog`||C.isError||!C.hasNextPage||C.isFetchingNextPage,onLoadMore:()=>C.fetchNextPage(),watchValue:`${t}:${s}:${l}:${C.data?.loadedItems??0}:${C.data?.loadedPages??0}`});(0,K.useEffect)(()=>{let e=T.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[T,s,t,l]);let D=ye(),O=be(),A=o({mutationFn:ee,onSuccess:(e,t)=>{h(t),_(e)}}),j=(0,K.useMemo)(()=>de(w.data?.records??[]),[w.data?.records]),M=(0,K.useMemo)(()=>(w.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return s?t.includes(s.toLowerCase()):!0}),[w.data?.records,s]),N=async(e,t)=>{let r=e?.name??t?.label??t?.id??`MCP`,i={title:r,kind:`content`,dedupeKey:e?`marketplace:mcp:${e.slug}`:`marketplace:mcp:${t?.id??t?.spec??r}`},a=Z(S,e,t);if(!e){let e=X(r,JSON.stringify(t??{},null,2),n(`marketplaceInstalledLocalSummary`),t?.docsUrl,a);y.open(e,i);return}try{let t=await te(e.slug),n=X(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,a);y.open(n,i)}catch(e){let t=X(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),a,void 0,a);y.open(t,i)}},P=async e=>{f&&(await D.mutateAsync({spec:f.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),p(null))},F=async(e,t)=>{let r=t.id||t.spec;r&&(e===`remove`&&!await b({title:`${n(`marketplaceMcpRemoveTitle`)} ${r}?`,description:n(`marketplaceMcpRemoveDescription`),confirmLabel:n(`marketplaceMcpRemove`),variant:`destructive`})||await O.mutateAsync({action:e,id:r,spec:t.spec}))},I=[{id:`catalog`,label:n(`marketplaceMcpTabCatalog`),icon:re},{id:`installed`,label:n(`marketplaceMcpTabInstalled`),icon:se,count:w.data?.total??0}];return(0,z.jsxs)(u,{className:`flex h-full min-h-0 flex-col pb-0 px-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-6 w-full max-w-[1400px] h-full min-h-0 mx-auto`,children:[(0,z.jsxs)(`div`,{className:`relative overflow-hidden rounded-[32px] bg-gradient-to-br from-[#0F172A] via-[#1E1B4B] to-[#312E81] px-10 py-14 text-white shadow-xl isolate`,children:[(0,z.jsx)(`div`,{className:`absolute top-0 right-0 -m-32 opacity-30 pointer-events-none mix-blend-screen scale-150 transform-gpu`,children:(0,z.jsx)(`div`,{className:`w-[500px] h-[500px] rounded-full bg-gradient-to-tl from-fuchsia-500/40 via-purple-500/30 to-indigo-500/20 blur-[80px]`})}),(0,z.jsx)(`div`,{className:`absolute bottom-0 left-0 -m-32 opacity-20 pointer-events-none mix-blend-screen transform-gpu`,children:(0,z.jsx)(`div`,{className:`w-[400px] h-[400px] rounded-full bg-gradient-to-tr from-blue-500/40 to-cyan-500/20 blur-[80px]`})}),(0,z.jsxs)(`div`,{className:`relative z-10 flex flex-col gap-3`,children:[(0,z.jsx)(`h1`,{className:`text-[38px] font-extrabold tracking-[-0.02em] leading-tight drop-shadow-sm text-transparent bg-clip-text bg-gradient-to-r from-white via-white to-white/70`,children:n(`marketplaceMcpPageTitle`)}),(0,z.jsx)(`p`,{className:`text-[17px] font-medium text-purple-100/70 max-w-2xl leading-relaxed tracking-wide`,children:n(`marketplaceMcpPageDescription`)})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 mt-2`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-gray-100/60 backdrop-blur-sm rounded-2xl w-fit border border-gray-200/50 shadow-inner`,children:I.map(n=>{let i=t===n.id,a=n.icon;return(0,z.jsxs)(`button`,{onClick:()=>r(n.id),className:e(`relative flex items-center gap-2 px-5 py-2.5 rounded-xl font-semibold text-[14px] transition-all duration-300`,i?`text-gray-900 bg-white shadow-[0_2px_10px_rgb(0,0,0,0.06)]`:`text-gray-500 hover:text-gray-700 hover:bg-gray-200/40`),children:[(0,z.jsx)(a,{className:e(`w-4 h-4`,i?`text-primary`:`text-gray-400`)}),n.label,n.id===`installed`&&typeof n.count==`number`&&(0,z.jsx)(`span`,{className:e(`ml-1 flex items-center justify-center h-5 px-1.5 min-w-5 rounded-full text-[11px] font-bold transition-colors`,i?`bg-primary/10 text-primary`:`bg-gray-200 text-gray-500`),children:n.count})]},n.id)})}),(0,z.jsx)(`div`,{className:`flex-1 w-full md:max-w-md`,children:(0,z.jsx)(B,{scope:t===`catalog`?`all`:`installed`,searchText:i,searchPlaceholder:n(`marketplaceMcpSearchPlaceholder`),sort:l,onSearchTextChange:a,onSortChange:d})})]}),(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col mt-2`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-1`,children:(0,z.jsxs)(`h3`,{className:`text-[18px] font-bold tracking-tight text-gray-900 flex items-center gap-2`,children:[n(t===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,z.jsx)(`span`,{className:`flex items-center justify-center h-6 px-2 rounded-lg bg-gray-100 text-[12px] font-semibold text-gray-500`,children:t===`catalog`?C.data?.total??0:w.data?.total??0})]})}),(0,z.jsxs)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-y-auto pr-3 pb-8 -mx-1 px-1 custom-scrollbar`,"aria-busy":C.isLoading||C.isFetchingNextPage,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-[22px] md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 items-stretch`,children:[t===`catalog`&&C.isLoading&&(0,z.jsx)(V,{count:$}),t===`catalog`&&!C.isLoading&&(C.data?.items??[]).map(e=>{let t=fe(e,j);return(0,z.jsx)(Q,{item:e,record:t,localeFallbacks:S,onOpen:()=>void N(e,t),onInstall:()=>p(e),onToggle:t?()=>void F(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{h(t.id??null),_(null),A.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void F(`remove`,t):void 0},e.id)}),t===`installed`&&M.map(e=>(0,z.jsx)(Q,{record:e,localeFallbacks:S,onOpen:()=>void N(void 0,e),onToggle:()=>void F(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{h(e.id??null),_(null),A.mutateAsync(e.id??``)},onRemove:()=>void F(`remove`,e)},e.id??e.spec))]}),t===`catalog`&&C.isError&&(0,z.jsx)(k,{tone:`danger`,title:n(`marketplaceMcpSectionCatalog`),description:C.error.message}),t===`installed`&&w.isError&&(0,z.jsx)(k,{tone:`danger`,title:n(`marketplaceMcpSectionInstalled`),description:w.error.message}),t===`catalog`&&!C.isLoading&&!C.isError&&(C.data?.items?.length??0)===0&&(0,z.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,z.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoMcp`)})}),t===`installed`&&!w.isError&&M.length===0&&(0,z.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,z.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoInstalledMcp`)})}),t===`catalog`&&!C.isError&&(0,z.jsx)(H,{hasMore:!!C.hasNextPage,loading:C.isFetchingNextPage,sentinelRef:E})]})]})]}),(0,z.jsx)(me,{item:f,open:!!f,pending:D.isPending,onOpenChange:e=>!e&&p(null),onSubmit:P}),(0,z.jsx)(ge,{open:!!m,targetName:m,result:g,pending:A.isPending,onOpenChange:e=>!e&&h(null)}),(0,z.jsx)(x,{})]})}export{B as a,R as c,G as i,L as l,q as n,H as o,U as r,V as s,xe as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./mcp-marketplace-page-B-GxKOqS.js";export{e as McpMarketplacePage};
@@ -1 +1 @@
1
- import{h as e,i as t,m as n,v as r}from"./react-oAHNoVya.js";import{Et as i,Ft as a,Mt as o,Nt as s,Pt as c,jt as l}from"./api-BAyyGaoz.js";import{n as u,t as d}from"./loader-circle-BI6HJDg5.js";import{t as f}from"./provider-scoped-model-input-C6xL7zSJ.js";import{l as p}from"./doc-browser-context-Cb1sEUT0.js";import{$ as m,Et as h,Nt as g,Z as _,gt as v,lt as y,u as b,ut as x}from"./index-Ccbswzt9.js";import{t as S}from"./config-hints-TmNgpFHv.js";import{n as C}from"./provider-models-CXUgDxGR.js";var w=r(e(),1),T=n(),E=`provider/model`;function D(e){let{initialModel:n,initialWorkspace:r,isPending:i,modelHelpText:o,modelLabel:l,modelPlaceholder:m,onSubmit:_,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(n),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_({model:x,workspace:C})},className:`space-y-8`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(h,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(s,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:l}),(0,T.jsx)(f,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:m}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:o}),(0,T.jsxs)(`a`,{href:`${p}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(g,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(s,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(c,{id:`workspace`,value:C,onChange:e=>E(e.target.value),placeholder:b,className:`rounded-xl`})]})]})]}),(0,T.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,T.jsx)(a,{type:`submit`,disabled:i,size:`lg`,children:i?(0,T.jsx)(d,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})}function O(){let{data:e,isLoading:n}=_(),{data:r}=x(),{data:a}=y(),{data:s}=m(),c=v(),u=s?.uiHints,d=S(`agents.defaults.model`,u),f=S(`agents.defaults.workspace`,u),p=(0,w.useMemo)(()=>C({providersView:r,templatesView:a,config:e,onlyConfigured:!0}),[e,r,a]),h=t(`modelIdentifierHelp`)||d?.help||``,g=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return n?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(b,{className:`h-8 w-32`}),(0,T.jsx)(b,{className:`h-4 w-48`})]}),(0,T.jsxs)(i,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,T.jsx)(b,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(b,{className:`h-5 w-24`}),(0,T.jsx)(b,{className:`h-3 w-32`})]})]}),(0,T.jsx)(b,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(b,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(i,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(b,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(b,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(o,{children:[(0,T.jsx)(l,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:g,initialWorkspace:O,isPending:c.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>c.mutate({model:e,workspace:t}),providerCatalog:p,workspaceLabel:f?.label??`Default Path`,workspacePlaceholder:f?.placeholder??`/path/to/workspace`},`${g}::${O}`)]})}export{O as ModelConfig};
1
+ import{g as e,i as t,m as n,y as r}from"./react-BqS8oMyM.js";import{Et as i,Ft as a,Mt as o,Nt as s,Pt as c,jt as l}from"./api-BCDb13Uv.js";import{n as u,t as d}from"./loader-circle-OpH4EErP.js";import{t as f}from"./provider-scoped-model-input-DKI9KN7N.js";import{l as p}from"./doc-browser-context-VHUOIUXL.js";import{$ as m,Et as h,Nt as g,Z as _,gt as v,lt as y,u as b,ut as x}from"./index-DTdPDqto.js";import{t as S}from"./config-hints-Ceiol9x4.js";import{n as C}from"./provider-models-C_yOh6DE.js";var w=r(e(),1),T=n(),E=`provider/model`;function D(e){let{initialModel:n,initialWorkspace:r,isPending:i,modelHelpText:o,modelLabel:l,modelPlaceholder:m,onSubmit:_,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(n),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_({model:x,workspace:C})},className:`space-y-8`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(h,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(s,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:l}),(0,T.jsx)(f,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:m}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:o}),(0,T.jsxs)(`a`,{href:`${p}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(g,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(s,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(c,{id:`workspace`,value:C,onChange:e=>E(e.target.value),placeholder:b,className:`rounded-xl`})]})]})]}),(0,T.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,T.jsx)(a,{type:`submit`,disabled:i,size:`lg`,children:i?(0,T.jsx)(d,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})}function O(){let{data:e,isLoading:n}=_(),{data:r}=x(),{data:a}=y(),{data:s}=m(),c=v(),u=s?.uiHints,d=S(`agents.defaults.model`,u),f=S(`agents.defaults.workspace`,u),p=(0,w.useMemo)(()=>C({providersView:r,templatesView:a,config:e,onlyConfigured:!0}),[e,r,a]),h=t(`modelIdentifierHelp`)||d?.help||``,g=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return n?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(b,{className:`h-8 w-32`}),(0,T.jsx)(b,{className:`h-4 w-48`})]}),(0,T.jsxs)(i,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,T.jsx)(b,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(b,{className:`h-5 w-24`}),(0,T.jsx)(b,{className:`h-3 w-32`})]})]}),(0,T.jsx)(b,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(b,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(i,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(b,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(b,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(o,{children:[(0,T.jsx)(l,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:g,initialWorkspace:O,isPending:c.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>c.mutate({model:e,workspace:t}),providerCatalog:p,workspaceLabel:f?.label??`Default Path`,workspacePlaceholder:f?.placeholder??`/path/to/workspace`},`${g}::${O}`)]})}export{O as ModelConfig};
@@ -1 +1 @@
1
- import{d as e,h as t,m as n,v as r}from"./react-oAHNoVya.js";import{It as i}from"./api-BAyyGaoz.js";var a=r(t(),1),o=n(),s=i(`rounded-2xl border px-4 py-3`,{variants:{tone:{neutral:`border-gray-200 bg-gray-50 text-gray-900`,success:`border-emerald-200 bg-emerald-50 text-emerald-900`,warning:`border-amber-200 bg-amber-50 text-amber-900`,danger:`border-rose-200 bg-rose-50 text-rose-700`,info:`border-primary/20 bg-primary/10 text-primary`},borderStyle:{solid:``,dashed:`border-dashed`}},defaultVariants:{tone:`neutral`,borderStyle:`solid`}}),c={neutral:`text-gray-900`,success:`text-emerald-800`,warning:`text-amber-900`,danger:`text-rose-700`,info:`text-primary`},l={neutral:`text-gray-600`,success:`text-emerald-700`,warning:`text-amber-800`,danger:`text-rose-700`,info:`text-primary/90`},u=a.forwardRef(({className:t,tone:n=`neutral`,borderStyle:r=`solid`,title:i,description:a,icon:u,actions:d,children:f,...p},m)=>{let h=n??`neutral`,g=!!i||!!a||!!u||!!d;return(0,o.jsxs)(`div`,{ref:m,className:e(s({tone:h,borderStyle:r}),t),...p,children:[g?(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u?(0,o.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:u}):null,(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i?(0,o.jsx)(`p`,{className:e(`text-sm font-medium`,c[h]),children:i}):null,a?(0,o.jsx)(`p`,{className:e(i?`mt-1`:``,`text-sm leading-6`,l[h]),children:a}):null]})]})}),d?(0,o.jsx)(`div`,{className:`shrink-0`,children:d}):null]}):null,f?(0,o.jsx)(`div`,{className:e(g?`mt-3`:``),children:f}):null]})});u.displayName=`NoticeCard`;export{u as t};
1
+ import{d as e,g as t,m as n,y as r}from"./react-BqS8oMyM.js";import{It as i}from"./api-BCDb13Uv.js";var a=r(t(),1),o=n(),s=i(`rounded-2xl border px-4 py-3`,{variants:{tone:{neutral:`border-gray-200 bg-gray-50 text-gray-900`,success:`border-emerald-200 bg-emerald-50 text-emerald-900`,warning:`border-amber-200 bg-amber-50 text-amber-900`,danger:`border-rose-200 bg-rose-50 text-rose-700`,info:`border-primary/20 bg-primary/10 text-primary`},borderStyle:{solid:``,dashed:`border-dashed`}},defaultVariants:{tone:`neutral`,borderStyle:`solid`}}),c={neutral:`text-gray-900`,success:`text-emerald-800`,warning:`text-amber-900`,danger:`text-rose-700`,info:`text-primary`},l={neutral:`text-gray-600`,success:`text-emerald-700`,warning:`text-amber-800`,danger:`text-rose-700`,info:`text-primary/90`},u=a.forwardRef(({className:t,tone:n=`neutral`,borderStyle:r=`solid`,title:i,description:a,icon:u,actions:d,children:f,...p},m)=>{let h=n??`neutral`,g=!!i||!!a||!!u||!!d;return(0,o.jsxs)(`div`,{ref:m,className:e(s({tone:h,borderStyle:r}),t),...p,children:[g?(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u?(0,o.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:u}):null,(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i?(0,o.jsx)(`p`,{className:e(`text-sm font-medium`,c[h]),children:i}):null,a?(0,o.jsx)(`p`,{className:e(i?`mt-1`:``,`text-sm leading-6`,l[h]),children:a}):null]})]})}),d?(0,o.jsx)(`div`,{className:`shrink-0`,children:d}):null]}):null,f?(0,o.jsx)(`div`,{className:e(g?`mt-3`:``),children:f}):null]})});u.displayName=`NoticeCard`;export{u as t};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-C8JRt-tf.js";var t=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-C8JRt-tf.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{d as e,g as t,m as n,y as r}from"./react-BqS8oMyM.js";import{a as i,b as a,f as o,g as s,h as c,i as l,l as u,o as d,p as f,r as p,s as m,u as h,x as g,y as ee}from"./dist-C8JRt-tf.js";import{i as te,n as _,r as v,t as y}from"./es2015-BCw3Q7nY.js";import{t as b}from"./dist-BI0bX8jv.js";var x=r(t(),1),S=n(),C=`Popover`,[w,ne]=ee(C,[m]),T=m(),[E,D]=w(C),O=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=T(t),u=x.useRef(null),[f,p]=x.useState(!1),[m,h]=c({prop:r,defaultProp:i??!1,onChange:a,caller:C});return(0,S.jsx)(d,{...l,children:(0,S.jsx)(E,{scope:t,contentId:s(),triggerRef:u,open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:f,onCustomAnchorAdd:x.useCallback(()=>p(!0),[]),onCustomAnchorRemove:x.useCallback(()=>p(!1),[]),modal:o,children:n})})};O.displayName=C;var k=`PopoverAnchor`,A=x.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=D(k,n),a=T(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return x.useEffect(()=>(o(),()=>s()),[o,s]),(0,S.jsx)(p,{...a,...r,ref:t})});A.displayName=k;var j=`PopoverTrigger`,M=x.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=D(j,n),s=T(n),c=a(t,i.triggerRef),l=(0,S.jsx)(o.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":q(i.open),...r,ref:c,onClick:g(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:(0,S.jsx)(p,{asChild:!0,...s,children:l})});M.displayName=j;var N=`PopoverPortal`,[P,F]=w(N,{forceMount:void 0}),I=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=D(N,t);return(0,S.jsx)(P,{scope:t,forceMount:n,children:(0,S.jsx)(b,{present:n||a.open,children:(0,S.jsx)(u,{asChild:!0,container:i,children:r})})})};I.displayName=N;var L=`PopoverContent`,R=x.forwardRef((e,t)=>{let n=F(L,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=D(L,e.__scopePopover);return(0,S.jsx)(b,{present:r||a.open,children:a.modal?(0,S.jsx)(B,{...i,ref:t}):(0,S.jsx)(V,{...i,ref:t})})});R.displayName=L;var z=f(`PopoverContent.RemoveScroll`),B=x.forwardRef((e,t)=>{let n=D(L,e.__scopePopover),r=x.useRef(null),i=a(t,r),o=x.useRef(!1);return x.useEffect(()=>{let e=r.current;if(e)return y(e)},[]),(0,S.jsx)(_,{as:z,allowPinchZoom:!0,children:(0,S.jsx)(H,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:g(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:g(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:g(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),V=x.forwardRef((e,t)=>{let n=D(L,e.__scopePopover),r=x.useRef(!1),i=x.useRef(!1);return(0,S.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=x.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,...f}=e,p=D(L,n),m=T(n);return v(),(0,S.jsx)(te,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:(0,S.jsx)(h,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:(0,S.jsx)(i,{"data-state":q(p.open),role:`dialog`,id:p.contentId,...m,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),U=`PopoverClose`,W=x.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=D(U,n);return(0,S.jsx)(o.button,{type:`button`,...r,ref:t,onClick:g(e.onClick,()=>i.onOpenChange(!1))})});W.displayName=U;var G=`PopoverArrow`,K=x.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=T(n);return(0,S.jsx)(l,{...i,...r,ref:t})});K.displayName=G;function q(e){return e?`open`:`closed`}var J=O,Y=A,X=M,Z=I,Q=R,re=J,ie=X,$=x.forwardRef(({className:t,sideOffset:n=8,align:r=`start`,...i},a)=>(0,S.jsx)(Z,{children:(0,S.jsx)(Q,{ref:a,sideOffset:n,align:r,className:e(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...i})}));$.displayName=Q.displayName;export{Q as a,X as c,Y as i,$ as n,Z as o,ie as r,J as s,re as t};
@@ -0,0 +1 @@
1
+ import{d as e,g as t,i as n,m as r,y as i}from"./react-BqS8oMyM.js";import{Pt as a}from"./api-BCDb13Uv.js";import{c as o}from"./dist-C8JRt-tf.js";import{J as s,K as c,Lt as l,X as u,Y as d,q as f}from"./index-DTdPDqto.js";import{i as p,l as m,r as h}from"./provider-models-C_yOh6DE.js";var g=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),_=i(t(),1),v=r();function y(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function b({id:t,value:n,onChange:r,options:i,disabled:o=!1,placeholder:s,className:c,inputClassName:u,emptyText:d,createText:f,maxItems:p=1/0,onEnter:m}){let[h,b]=(0,_.useState)(!1);(0,_.useEffect)(()=>{o&&h&&b(!1)},[o,h]);let x=(0,_.useMemo)(()=>y(i),[i]),S=n.trim().toLowerCase(),C=(0,_.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(p)?t.slice(0,Math.max(1,p)):t},[x,S,p]),w=n.trim().length>0&&x.some(e=>e===n.trim());return(0,v.jsxs)(`div`,{className:e(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,v.jsx)(a,{id:t,value:n,disabled:o,onFocus:()=>{o||b(!0)},onChange:e=>{r(e.target.value),!h&&!o&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(m&&(e.preventDefault(),m()),b(!1))},placeholder:s,className:e(`pr-10`,u)}),(0,v.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:o,className:e(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,o?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,v.jsx)(g,{className:`h-4 w-4`})}),h&&!o&&(0,v.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,v.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&n.trim().length>0&&(0,v.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(n.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,v.jsx)(l,{className:`h-4 w-4 text-transparent`}),(0,v.jsx)(`span`,{className:`truncate text-gray-700`,children:f?f.replace(`{value}`,n.trim()):n.trim()})]}),C.map(t=>(0,v.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(t),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,v.jsx)(l,{className:e(`h-4 w-4`,t===n.trim()?`text-primary`:`text-transparent`)}),(0,v.jsx)(`span`,{className:`truncate text-gray-700`,children:t})]},t)),C.length===0&&n.trim().length===0&&(0,v.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:d??`No models available`})]})})]})}var x=`provider/model`;function S(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function C({id:e,value:t,onChange:r,providerCatalog:i,disabled:o=!1,providerPlaceholder:l,modelPlaceholder:g,className:y}){let[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(``),D=i.length>0,O=g??x,k=(0,_.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),A=k.get(C),j=(0,_.useMemo)(()=>A?.aliases??[],[A]),M=(0,_.useMemo)(()=>S(A?.models??[]),[A]);return(0,_.useEffect)(()=>{let e=t.trim();if(!D){w(``),E(e);return}if(!e){E(``),w(e=>k.has(e)?e:``);return}let n=p(e,i)??``,r=k.get(n)?.aliases??[];w(n),E(n?m(e,r):e)},[D,i,k,t]),D?(0,v.jsxs)(`div`,{className:y,children:[(0,v.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,v.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,v.jsxs)(c,{value:C,onValueChange:e=>{let t=S(k.get(e)?.models??[])[0]??``;if(w(e),E(t),!t){r(``);return}r(h(k.get(e)?.prefix??e,t))},disabled:o,children:[(0,v.jsx)(d,{className:`h-10 w-full rounded-xl`,children:(0,v.jsx)(u,{placeholder:l??n(`providersSelectPlaceholder`)})}),(0,v.jsx)(f,{children:i.map(e=>(0,v.jsx)(s,{value:e.name,children:e.displayName},e.name))})]})}),(0,v.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,v.jsx)(b,{id:e,value:T,onChange:e=>{if(!A){let t=e.trim();E(t),r(t);return}let t=m(e,j);E(t),r(t?h(A.prefix,t):``)},options:M,disabled:o||!C,placeholder:O,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:n(`modelPickerNoOptions`),createText:n(`modelPickerUseCustom`)},C)]}),(0,v.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]}):(0,v.jsxs)(`div`,{className:y,children:[(0,v.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,v.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:n(`providersEmptyTitle`)}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:n(`providersEmptyDescription`)})]}),(0,v.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>r(e.target.value),placeholder:O,className:`mt-3 h-10 rounded-xl`}),(0,v.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]})}export{C as t};
@@ -0,0 +1 @@
1
+ import{d as e,g as t,i as n,m as r,o as i,y as a}from"./react-BqS8oMyM.js";import{Ft as o,Mt as s,Nt as c,Pt as l,Qt as u,jt as d,mt as f,zt as p}from"./api-BCDb13Uv.js";import{c as m}from"./dist-C8JRt-tf.js";import{t as h}from"./confirm-dialog-DBkKcQ1q.js";import{t as g}from"./ellipsis-C9VB2CxT.js";import{t as _}from"./key-round-Ccy6oND3.js";import{t as ee}from"./plus-DHcP-K1U.js";import{t as v}from"./search-COFh_SFI.js";import{t as te}from"./trash-2-D3psAGrz.js";import{t as y}from"./x-CHAxzyp2.js";import{t as b}from"./status-dot-oWBjTovo.js";import{n as x,r as S,t as C}from"./popover-BTLZE5Iz.js";import{$ as w,Ct as T,It as ne,J as E,K as D,U as O,X as k,Y as A,_t as re,at as ie,ct as ae,et as j,ft as oe,lt as se,pt as ce,q as M,rt as le,ut as ue}from"./index-DTdPDqto.js";import{t as N}from"./config-hints-Ceiol9x4.js";import{a as de,c as fe,i as pe,n as P,o as me,r as he,s as ge}from"./config-split-page-BwhGqmUS.js";import{a as _e,o as ve,s as ye,t as be}from"./provider-models-C_yOh6DE.js";var xe=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Se=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),F=m(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ce=m(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),I=a(t(),1),L=r();function we({isSet:t,className:n,value:r,onChange:i,placeholder:a,...s}){let[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,L.jsxs)(`div`,{className:`relative`,children:[t&&!p&&!d?(0,L.jsx)(`div`,{onClick:()=>f(!0),className:e(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,n),children:`••••••••••••`}):(0,L.jsx)(l,{type:c?`text`:`password`,className:e(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...s}),(0,L.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(t||p)&&(0,L.jsx)(o,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!c),children:c?(0,L.jsx)(Se,{className:`h-4 w-4`}):(0,L.jsx)(F,{className:`h-4 w-4`})})})]})}function R({value:t,onChange:r,className:i}){let a=t?Object.entries(t):[],s=(e,t,n)=>{let i=[...a];i[e]=[t,n],r(Object.fromEntries(i))},c=()=>{r({...t,"":``})},u=e=>{let t=a.filter((t,n)=>n!==e);r(Object.fromEntries(t))};return(0,L.jsxs)(`div`,{className:e(`space-y-2`,i),children:[a.map(([e,t],r)=>(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(l,{type:`text`,value:e,onChange:e=>s(r,e.target.value,t),placeholder:n(`headerName`),className:`flex-1`}),(0,L.jsx)(l,{type:`text`,value:t,onChange:t=>s(r,e,t.target.value),placeholder:n(`headerValue`),className:`flex-1`}),(0,L.jsx)(o,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>u(r),children:(0,L.jsx)(te,{className:`h-4 w-4 text-red-500`})})]},r)),(0,L.jsxs)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,L.jsx)(ee,{className:`h-4 w-4 mr-2`}),n(`add`)]})]})}function Te(e){let{value:t,onChange:n,options:r}=e;return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,L.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function Ee(e){let{showAdvanced:t,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:l,wireApiSelectOptions:u,extraHeadersLabel:d,extraHeaders:f,onExtraHeadersChange:p}=e;return(0,L.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(!t),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(Ce,{className:`h-3.5 w-3.5`}),n(`providerAdvancedSettings`)]}),(0,L.jsx)(ne,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,L.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),l?(0,L.jsx)(Te,{value:o,onChange:e=>s(e),options:u}):(0,L.jsxs)(D,{value:o,onValueChange:e=>s(e),children:[(0,L.jsx)(A,{className:`rounded-xl`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(M,{children:u.map(e=>(0,L.jsx)(E,{value:e.value,children:e.label},e.value))})]})]}):null,(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:d}),(0,L.jsx)(R,{value:f,onChange:p}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerExtraHeadersHelpShort`)})]})]}):null]})}function De(e){let{providerAuth:t,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:s,shouldUseAuthMethodPills:l,resolvedAuthMethodId:u,onAuthMethodChange:d,onStartProviderAuth:f,onImportProviderAuthFromCli:p,startPending:m,importPending:h,authSessionId:g,authStatusMessage:_}=e;return t?.kind===`device_code`?(0,L.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:t.displayName||n(`providerAuthSectionTitle`)}),r?(0,L.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`text-xs font-medium text-gray-700`,children:n(`providerAuthMethodLabel`)}),l?(0,L.jsx)(Te,{value:u,onChange:d,options:i}):(0,L.jsxs)(D,{value:u,onValueChange:d,children:[(0,L.jsx)(A,{className:`h-8 rounded-lg bg-white`,children:(0,L.jsx)(k,{placeholder:n(`providerAuthMethodPlaceholder`)})}),(0,L.jsx)(M,{children:i.map(e=>(0,L.jsx)(E,{value:e.value,children:e.label},e.value))})]}),s?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:s}):null]}):null,(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:f,disabled:m||!!g,children:n(m?`providerAuthStarting`:g?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,L.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:h,children:n(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,g?(0,L.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[n(`providerAuthSessionLabel`),`: `,g.slice(0,8),`…`]}):null]}),_?(0,L.jsx)(`p`,{className:`text-xs text-gray-600`,children:_}):null]}):null}var Oe={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function z(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function ke(e,t){let n=z(e),r=z(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function B(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Ae(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function je(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ae(n,t))}return n.trim()}function Me(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ne(e,t){return B(t)}function Pe(e,t){return B(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Fe(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=ve(i.thinking?.supported);if(a.length>0){let t=ye(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function Ie(e,t,n){return{..._e(e,n),..._e(t,n)}}function Le(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Me([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Re(e){return n(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function ze(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Be(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Ve(e){let{models:t,modelConfig:r,modelDraft:i,showModelInput:a,onModelDraftChange:s,onShowModelInputChange:u,onAddModel:d,onRemoveModel:p,onToggleModelThinkingLevel:m,onSetModelThinkingDefault:h,onSetModelVision:g,thinkingLevels:_,formatThinkingLevelLabel:v}=e;return(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:n(`providerModelsTitle`)}),a?null:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,L.jsx)(ee,{className:`h-3 w-3`}),n(`providerAddModel`)]})]}),a?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(l,{value:i,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(u(!1),s(``))},placeholder:n(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,L.jsx)(o,{type:`button`,size:`sm`,onClick:d,disabled:i.trim().length===0,children:n(`add`)}),(0,L.jsx)(o,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{u(!1),s(``)},children:(0,L.jsx)(y,{className:`h-4 w-4`})})]}):null,t.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm text-gray-500`,children:n(`providerModelsEmptyShort`)}),a?null:(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:n(`providerAddFirstModel`)})]}):(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=r[e],i=t?.thinking,a=i?.supported??[],o=i?.default??null,s=t?.vision===!0;return(0,L.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,L.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,L.jsxs)(C,{children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`providerModelThinkingTitle`),title:n(`providerModelThinkingTitle`),children:(0,L.jsx)(Ce,{className:`h-3 w-3`})})}),(0,L.jsxs)(x,{className:`w-80 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-100 bg-gray-50 px-3 py-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:n(`providerModelVisionTitle`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelVisionHint`)})]}),(0,L.jsx)(f,{checked:s,onCheckedChange:t=>g(e,t)})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:n(`providerModelThinkingTitle`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingHint`)})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(t=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>m(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${a.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:v(t)},t))}),(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(c,{className:`text-xs font-medium text-gray-700`,children:n(`providerModelThinkingDefault`)}),(0,L.jsxs)(D,{value:o??`__none__`,onValueChange:t=>h(e,t===`__none__`?null:t),disabled:a.length===0,children:[(0,L.jsx)(A,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,L.jsx)(k,{})}),(0,L.jsxs)(M,{children:[(0,L.jsx)(E,{value:`__none__`,children:n(`providerModelThinkingDefaultNone`)}),a.map(e=>(0,L.jsx)(E,{value:e,children:v(e)},e))]})]}),a.length===0?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`remove`),children:(0,L.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function He(e){return e.enabled?(0,L.jsx)(b,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?n(`statusReady`):n(`statusSetup`),className:e.className}):(0,L.jsx)(b,{status:`inactive`,label:n(`disabled`),className:e.className})}function V({providerName:e,onProviderDeleted:t}){let r=u(),{data:a}=ue(),{data:s}=se(),{data:d}=w(),f=re(),m=le(),h=ce(),g=oe(),_=ae(),ee=ie(),[v,y]=(0,I.useState)(``),[b,x]=(0,I.useState)(``),[S,C]=(0,I.useState)(null),[T,ne]=(0,I.useState)(`auto`),[E,D]=(0,I.useState)([]),[O,k]=(0,I.useState)({}),[A,j]=(0,I.useState)(``),[M,pe]=(0,I.useState)(``),[he,_e]=(0,I.useState)(!1),[ve,ye]=(0,I.useState)(!1),[Se,F]=(0,I.useState)(null),[Ce,R]=(0,I.useState)(``),[Te,Ae]=(0,I.useState)(``),V=(0,I.useRef)(null),H=e?a?.providers[e]:null,U=s?.providerTemplates.find(e=>e.providerType===H?.providerType),W=H??Oe,Ue=d?.uiHints,We=!!H?.isCustom,Ge=e?N(`providers.${e}.apiKey`,Ue):void 0,Ke=e?N(`providers.${e}.apiBase`,Ue):void 0,qe=e?N(`providers.${e}.extraHeaders`,Ue):void 0,Je=e?N(`providers.${e}.wireApi`,Ue):void 0,Ye=U?.displayName||H?.displayName||e||``,G=(W.displayName||``).trim()||Ye,Xe=W.enabled!==!1,Ze=M.trim()||G||e||n(`providersSelectPlaceholder`),K=(0,I.useMemo)(()=>B([U?.modelPrefix||U?.providerType||``,e||``]),[e,U?.modelPrefix,U?.providerType]),Qe=U?.defaultApiBase||``,q=W.apiBase||Qe,$e=z(W.extraHeaders||null),et=W.wireApi||U?.defaultWireApi||`auto`,tt=(0,I.useMemo)(()=>B((U?.defaultModels??[]).map(e=>je(e,K))),[U?.defaultModels,K]),nt=(0,I.useMemo)(()=>B((W.models??[]).map(e=>je(e,K))),[W.models,K]),J=(0,I.useMemo)(()=>Ne(tt,nt),[tt,nt]),rt=(0,I.useMemo)(()=>Fe(Ie(U?.modelConfig,W.modelConfig,K),J),[J,K,U?.modelConfig,W.modelConfig]),Y=i(),it=U?.apiBaseHelp?.[Y]||U?.apiBaseHelp?.en||Ke?.help||n(`providerApiBaseHelp`),X=U?.auth,Z=(0,I.useMemo)(()=>X?.methods??[],[X?.methods]),Q=!!U?.supportsWireApi||We,at=(0,I.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),ot=(0,I.useMemo)(()=>ze({providerName:U?.providerType??e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y,U?.providerType]),st=(0,I.useMemo)(()=>{if(!Z.length)return``;let e=Te.trim();return e&&Z.some(t=>t.id===e)?e:ot||Z[0]?.id||``},[Te,ot,Z]),ct=(0,I.useMemo)(()=>Z.find(e=>e.id===st),[Z,st]),lt=Be({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),ut=(U?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:n(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),dt=Be({required:Q,hasDefault:typeof U?.defaultWireApi==`string`&&U.defaultWireApi.length>0,optionCount:ut.length}),$=(0,I.useCallback)(()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},[]),ft=(0,I.useCallback)((t,i)=>{$(),V.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await _.mutateAsync({provider:e,data:{sessionId:t}});if(a.status===`pending`){R(n(`providerAuthWaitingBrowser`)),ft(t,a.nextPollMs??i);return}if(a.status===`authorized`){F(null),$(),R(n(`providerAuthCompleted`)),p.success(n(`providerAuthCompleted`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`providers`]});return}F(null),$(),R(a.message||`Authorization ${a.status}.`),p.error(a.message||`Authorization ${a.status}.`)}catch(e){F(null),$();let t=e instanceof Error?e.message:String(e);R(t),p.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,i))},[$,_,e,r]);(0,I.useEffect)(()=>{if(!e){y(``),x(``),C(null),ne(`auto`),D([]),k({}),j(``),pe(``),F(null),R(``),Ae(``),$();return}y(``),x(q),C(W.extraHeaders||null),ne(et),D(J),k(rt),j(``),pe(G),F(null),R(``),Ae(ot),$()},[e,q,W.extraHeaders,et,J,rt,G,ot,$]),(0,I.useEffect)(()=>()=>$(),[$]),(0,I.useEffect)(()=>k(e=>Fe(e,E)),[E]);let pt=(0,I.useMemo)(()=>e?v.trim().length>0||b.trim()!==q.trim()||!ke(S,$e)||Q&&T!==et||!Me(E,J)||!Le(O,rt)||M.trim()!==G:!1,[e,v,b,q,S,$e,Q,T,et,E,J,O,rt,M,G]);return!e||!H?(0,L.jsx)(P,{children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:n(`providersSelectTitle`)}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:n(`providersSelectDescription`)})]})}):(0,L.jsxs)(de,{children:[(0,L.jsx)(fe,{className:`px-6 py-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Ze}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:async()=>{if(e&&window.confirm(n(`providerDeleteConfirm`)))try{await m.mutateAsync({provider:e}),t?.(e)}catch{}},disabled:m.isPending,className:`text-gray-400 transition-colors hover:text-red-500`,title:n(`providerDelete`),children:(0,L.jsx)(te,{className:`h-4 w-4`})}),(0,L.jsx)(He,{enabled:Xe,apiKeySet:W.apiKeySet})]})]})}),(0,L.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=v.trim(),i=b.trim(),a=z(S),o=M.trim();o!==G&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),i!==q.trim()&&(n.apiBase=i.length>0&&i!==Qe?i:null),ke(a,$e)||(n.extraHeaders=a),Q&&T!==et&&(n.wireApi=T),Me(E,J)||(n.models=Pe(E,e)),Le(O,rt)||(n.modelConfig=Fe(O,E)),f.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(me,{className:`space-y-5 px-6 py-5`,children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:n(`providerDisplayName`)}),(0,L.jsx)(l,{id:`providerDisplayName`,type:`text`,value:M,onChange:e=>pe(e.target.value),placeholder:Ye||n(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerDisplayNameHelpShort`)})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:Ge?.label??n(`apiKey`)}),(0,L.jsx)(we,{id:`apiKey`,value:v,isSet:W.apiKeySet,onChange:e=>y(e.target.value),placeholder:Ge?.placeholder??n(`enterApiKey`),className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`leaveBlankToKeepUnchanged`)})]}),(0,L.jsx)(De,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:at,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:ct?.hint?.[Y]||ct?.hint?.en||``,shouldUseAuthMethodPills:lt,resolvedAuthMethodId:st,onAuthMethodChange:Ae,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{R(``);let t=await g.mutateAsync({provider:e,data:st?{methodId:st}:{}});if(!t.sessionId||!t.verificationUri)throw Error(n(`providerAuthStartFailed`));F(t.sessionId),R(`${n(`providerAuthOpenPrompt`)}${t.userCode}${n(`providerAuthOpenPromptSuffix`)}`),window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),ft(t.sessionId,t.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);F(null),$(),R(t),p.error(`${n(`providerAuthStartFailed`)}: ${t}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),F(null);let t=await ee.mutateAsync({provider:e});R(`${n(`providerAuthImportStatusPrefix`)}${t.expiresAt?` (expires: ${t.expiresAt})`:``}`),p.success(n(`providerAuthImportSuccess`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);R(t),p.error(`${n(`providerAuthImportFailed`)}: ${t}`)}},startPending:g.isPending,importPending:ee.isPending,authSessionId:Se,authStatusMessage:Ce}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Ke?.label??n(`apiBase`)}),(0,L.jsx)(l,{id:`apiBase`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:Qe||Ke?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:it})]}),(0,L.jsx)(Ve,{models:E,modelConfig:O,modelDraft:A,showModelInput:ve,onModelDraftChange:j,onShowModelInputChange:ye,onAddModel:()=>{let e=je(A,K);if(e){if(e.includes(`/`)){p.error(n(`providerModelInvalidProviderPrefix`));return}if(E.includes(e)){j(``);return}D(t=>[...t,e]),j(``)}},onRemoveModel:e=>{D(t=>t.filter(t=>t!==e)),k(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{k(n=>{let r=n[e],i=r?.thinking?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):be.filter(e=>e===t||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...n};return s.thinking||s.vision===!0?c[e]=s:delete c[e],c})},onSetModelThinkingDefault:(e,t)=>{k(n=>{let r=n[e],i=r?.thinking;return!i||i.supported.length===0||t&&!i.supported.includes(t)?n:{...n,[e]:{...r,thinking:t?{supported:i.supported,default:t}:{supported:i.supported}}}})},onSetModelVision:(e,t)=>{k(n=>{let r={...n[e],vision:t?!0:void 0},i={...n};return r.thinking||r.vision===!0?i[e]=r:delete i[e],i})},thinkingLevels:be,formatThinkingLevelLabel:Re}),(0,L.jsx)(Ee,{showAdvanced:he,onShowAdvancedChange:_e,supportsWireApi:Q,wireApiLabel:Je?.label??n(`wireApi`),wireApi:T,onWireApiChange:ne,shouldUseWireApiPills:dt,wireApiSelectOptions:ut,extraHeadersLabel:qe?.label??n(`extraHeaders`),extraHeaders:S,onExtraHeadersChange:C})]}),(0,L.jsxs)(ge,{className:`flex items-center justify-between px-6 py-4`,children:[(0,L.jsxs)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let t=je(E.find(e=>e.trim().length>0)??``,K),r={apiBase:b.trim(),extraHeaders:z(S),model:t||null};v.trim().length>0&&(r.apiKey=v.trim()),Q&&(r.wireApi=T);try{let t=await h.mutateAsync({provider:e,data:r});if(t.success){p.success(`${n(`providerTestConnectionSuccess`)} (${t.latencyMs}ms)`);return}let i=[`provider=${t.provider}`,`latency=${t.latencyMs}ms`];t.model&&i.push(`model=${t.model}`),p.error(`${n(`providerTestConnectionFailed`)}: ${t.message} | ${i.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);p.error(`${n(`providerTestConnectionFailed`)}: ${t}`)}},disabled:h.isPending,children:[(0,L.jsx)(xe,{className:`mr-1.5 h-4 w-4`}),h.isPending?n(`providerTestingConnection`):n(`providerTestConnection`)]}),(0,L.jsx)(o,{type:`submit`,disabled:f.isPending||!pt,children:f.isPending?n(`saving`):n(pt?`save`:`unchanged`)})]})]})]})}function H(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function U(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function W(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function Ue(){let{isMobile:t}=T(),{data:r}=ue(),{data:i}=se(),a=j(),c=le(),u=re(),[p,m]=(0,I.useState)(null),[y,w]=(0,I.useState)(null),[ne,E]=(0,I.useState)(!1),[D,k]=(0,I.useState)([]),[A,ie]=(0,I.useState)(``),ae=(0,I.useMemo)(()=>U(Object.values(r?.providers??{}),D),[r?.providers,D]),oe=(0,I.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),ce=(0,I.useMemo)(()=>W(oe),[oe]),M=(0,I.useMemo)(()=>new Map(oe.map(e=>[e.providerType,e])),[oe]),N=(0,I.useMemo)(()=>{let e=A.trim().toLowerCase();return ae.filter(t=>{if(!e)return!0;let n=t.providerType?M.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[ae,A,M]),P=(0,I.useMemo)(()=>p&&N.some(e=>e.providerId===p)?p:t?null:N[0]?.providerId??null,[N,t,p]);return!r||!i?(0,L.jsx)(`div`,{className:`p-8`,children:n(`providersLoading`)}):(0,L.jsxs)(s,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,L.jsx)(d,{title:n(`providersPageTitle`),description:n(`providersPageDescription`)}),(0,L.jsxs)(pe,{className:`xl:min-h-0`,mobileView:t?P?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:n(`providersPageTitle`),children:[(0,L.jsxs)(de,{children:[(0,L.jsx)(fe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,L.jsxs)(C,{open:ne,onOpenChange:E,children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsxs)(o,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,L.jsx)(ee,{className:`mr-2 h-4 w-4`}),a.isPending?n(`saving`):n(`providerAdd`)]})}),(0,L.jsxs)(x,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,L.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-gray-500`,children:n(`providerTemplatePickerTitle`)}),(0,L.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-gray-300 bg-white px-3 py-2 text-left hover:border-primary/40 hover:bg-gray-50`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});ie(``),m(e.providerId),k(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),E(!1)}catch{}},children:[(0,L.jsx)(O,{name:`custom`,className:`h-8 w-8 rounded-lg border border-gray-200 bg-white`}),(0,L.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-gray-800`,children:n(`providerAddCustom`)})]}),ce.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-left hover:border-primary/40 hover:bg-gray-50`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});ie(``),m(t.providerId),k(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),E(!1)}catch{}},children:[(0,L.jsx)(O,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-gray-200 bg-white`,imgClassName:`h-4 w-4 object-contain`}),(0,L.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-gray-800`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,L.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,L.jsx)(l,{value:A,onChange:e=>ie(e.target.value),placeholder:n(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,L.jsxs)(me,{className:`space-y-2 p-3`,children:[N.map(t=>{let r=t.providerType?M.get(t.providerType):null,i=t.enabled!==!1,a=!!(i&&t.apiKeySet),o=t.displayName?.trim()||r?.displayName||t.providerId,s=H(t.apiBase||r?.defaultApiBase||``)||n(`providersDefaultDescription`);return(0,L.jsx)(`div`,{onClick:()=>m(t.providerId),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m(t.providerId))},role:`button`,tabIndex:0,className:e(`w-full rounded-xl border p-2.5 text-left transition-all`,P===t.providerId?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,L.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,L.jsx)(O,{name:t.providerType??t.providerId,src:r?.logo?`/logos/${r.logo}`:null,className:e(`h-10 w-10 rounded-lg border`,a?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,L.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:t.providerId[0]})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:o}),(0,L.jsx)(`p`,{className:`truncate font-mono text-[10px] text-gray-400`,children:t.providerId}),(0,L.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:[s,` · `,t.models?.length??0]})]})]}),(0,L.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,L.jsx)(f,{checked:i,disabled:u.isPending,title:n(i?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:e=>{u.mutateAsync({provider:t.providerId,data:{enabled:e},silentSuccess:!0})}})}),(0,L.jsxs)(C,{children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 hover:bg-gray-100 hover:text-gray-700`,onClick:e=>e.stopPropagation(),title:n(`more`),children:(0,L.jsx)(g,{className:`h-4 w-4`})})}),(0,L.jsx)(x,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-sm text-red-600 hover:bg-red-50`,onClick:()=>w(t.providerId),children:[(0,L.jsx)(te,{className:`h-4 w-4`}),n(`providerDelete`)]})})]})]}),(0,L.jsx)(b,{status:i?a?`ready`:`setup`:`inactive`,label:n(i?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},t.providerId)}),N.length===0?(0,L.jsx)(he,{icon:_,title:n(`providersNoMatch`)}):null]})]}),(0,L.jsx)(V,{providerName:P??void 0,onProviderDeleted:e=>{k(t=>t.filter(t=>t!==e)),e===P&&m(null)}})]}),(0,L.jsx)(h,{open:!!y,onOpenChange:e=>{e||w(null)},title:n(`providerDelete`),description:y??void 0,confirmLabel:n(`delete`),variant:`destructive`,onCancel:()=>w(null),onConfirm:()=>{y&&c.mutateAsync({provider:y}).then(()=>{k(e=>e.filter(e=>e!==y)),y===P&&m(null),w(null)})}})]})}export{Ue as ProvidersList};