@nextclaw/ui 0.14.2 → 0.14.3

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 (129) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/assets/{api-a14tR_z1.js → api-BP_8IaxB.js} +3 -3
  3. package/dist/assets/{channels-list-page-CFGkm4DT.js → channels-list-page-DEh5Jjqx.js} +1 -1
  4. package/dist/assets/chat-page-BRB0N5WW.js +105 -0
  5. package/dist/assets/config-split-page-CRhlZ_pH.js +1 -0
  6. package/dist/assets/{confirm-dialog-ClH_Ec7n.js → confirm-dialog-DsivFJ4r.js} +2 -2
  7. package/dist/assets/{desktop-update-config-DPNDnVpk.js → desktop-update-config-B0w9p2ep.js} +1 -1
  8. package/dist/assets/{dist-BtCS2Ucq.js → dist-CikkhOlq.js} +1 -1
  9. package/dist/assets/{dist-CLGGLm8b.js → dist-PVA_xL1D.js} +1 -1
  10. package/dist/assets/doc-browser-BoNJ7-tE.js +1 -0
  11. package/dist/assets/doc-browser-CdJ_d4ik.js +1 -0
  12. package/dist/assets/{doc-browser-context-D4JwMMxK.js → doc-browser-context-MTw4EvKd.js} +1 -1
  13. package/dist/assets/{ellipsis-CtJXjIol.js → ellipsis-y6vDtq4M.js} +1 -1
  14. package/dist/assets/{external-link-CdJiG13p.js → external-link-DVJIQf_G.js} +1 -1
  15. package/dist/assets/index-BiE-K8-q.css +1 -0
  16. package/dist/assets/index-D9BAE_L_.js +105 -0
  17. package/dist/assets/{mcp-marketplace-page-BU0kIjhR.js → mcp-marketplace-page-B1SZNY5m.js} +1 -1
  18. package/dist/assets/mcp-marketplace-page-Cq_Tw42T.js +1 -0
  19. package/dist/assets/{model-config-page-D6hYXROd.js → model-config-page-DotaTUHb.js} +1 -1
  20. package/dist/assets/plus-BbZqquJe.js +1 -0
  21. package/dist/assets/{provider-scoped-model-input-DAX2HgmR.js → provider-scoped-model-input-DsFRuWJH.js} +1 -1
  22. package/dist/assets/providers-config-page-DW4tQSLN.js +1 -0
  23. package/dist/assets/{react-C6cZgP44.js → react-VNqT5Zp7.js} +1 -1
  24. package/dist/assets/remote-B8TiUfwW.js +1 -0
  25. package/dist/assets/rotate-cw-DjHDTkCv.js +1 -0
  26. package/dist/assets/{runtime-config-page-C5xKaV3i.js → runtime-config-page-S6ErRHR8.js} +1 -1
  27. package/dist/assets/{save-DKA0x4zk.js → save-BOJ477H-.js} +1 -1
  28. package/dist/assets/{search-BNlcoj5c.js → search-BEti5beA.js} +1 -1
  29. package/dist/assets/{search-config-page-Cq9uJ-N8.js → search-config-page-DGj5am03.js} +1 -1
  30. package/dist/assets/{secrets-config-page-CxSbZLBo.js → secrets-config-page--IzrIOid.js} +1 -1
  31. package/dist/assets/{select-CvTlDZTQ.js → select-hoj8dK4K.js} +2 -2
  32. package/dist/assets/{tag-chip-8ffF2y2C.js → tag-chip-T8-h-die.js} +1 -1
  33. package/dist/assets/{use-config-DmT0o1gv.js → use-config-CjRV2hwL.js} +1 -1
  34. package/dist/assets/x-D9PXs_xP.js +1 -0
  35. package/dist/index.html +69 -19
  36. package/index.html +55 -5
  37. package/package.json +7 -7
  38. package/src/app/components/layout/__tests__/sidebar.layout.test.tsx +3 -3
  39. package/src/app/components/layout/header.tsx +3 -3
  40. package/src/app/components/layout/page-layout.tsx +2 -2
  41. package/src/app/components/layout/runtime-status-entry.tsx +7 -7
  42. package/src/app/components/layout/sidebar-items.tsx +10 -10
  43. package/src/app/components/layout/sidebar-rail.styles.ts +2 -2
  44. package/src/app/components/layout/sidebar.tsx +6 -6
  45. package/src/app/styles/design-system.css +388 -26
  46. package/src/app/test/vitest-setup.ts +31 -0
  47. package/src/features/chat/components/chat-sidebar-list-mode-switch.tsx +3 -3
  48. package/src/features/chat/components/conversation/__tests__/chat-conversation-header.test.tsx +4 -2
  49. package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +1 -1
  50. package/src/features/chat/components/conversation/chat-conversation-header.tsx +7 -6
  51. package/src/features/chat/components/conversation/chat-conversation-panel.tsx +1 -1
  52. package/src/features/chat/components/conversation/chat-conversation-skeleton.tsx +13 -13
  53. package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +2 -2
  54. package/src/features/chat/components/layout/chat-page-shell.tsx +1 -1
  55. package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +3 -3
  56. package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +14 -14
  57. package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +15 -15
  58. package/src/features/chat/components/layout/chat-sidebar.tsx +3 -3
  59. package/src/features/chat/features/conversation/components/__tests__/session-conversation-area.test.tsx +225 -0
  60. package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +199 -0
  61. package/src/features/chat/features/conversation/components/session-conversation-area.tsx +28 -9
  62. package/src/features/chat/features/conversation/components/session-conversation-input.tsx +18 -6
  63. package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +3 -13
  64. package/src/features/chat/features/conversation/hooks/use-session-conversation-input-query.ts +19 -3
  65. package/src/features/chat/features/message/components/chat-inline-panel-app-card.tsx +7 -7
  66. package/src/features/chat/features/message/components/chat-message-list.container.tsx +6 -6
  67. package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +5 -5
  68. package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +4 -4
  69. package/src/features/chat/features/session/components/session-context-icon.tsx +2 -2
  70. package/src/features/chat/features/session/components/session-header/__tests__/chat-session-project-badge.test.tsx +2 -2
  71. package/src/features/chat/features/session/components/session-header/chat-session-header-actions.tsx +1 -1
  72. package/src/features/chat/features/session/components/session-header/chat-session-header-menu-item.tsx +1 -1
  73. package/src/features/chat/features/session/components/session-header/chat-session-metadata-dialog.tsx +1 -1
  74. package/src/features/chat/features/session/components/session-header/chat-session-project-badge.tsx +3 -3
  75. package/src/features/chat/features/session/components/session-run-badge.tsx +1 -1
  76. package/src/features/chat/features/session-type/hooks/use-chat-session-type-state.ts +10 -2
  77. package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +0 -7
  78. package/src/features/chat/features/welcome/components/chat-welcome-agent-picker.tsx +3 -3
  79. package/src/features/chat/features/welcome/components/chat-welcome-capability-grid.tsx +4 -4
  80. package/src/features/chat/features/welcome/components/chat-welcome-project-picker.tsx +14 -19
  81. package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +3 -3
  82. package/src/features/chat/features/welcome/components/chat-welcome.tsx +4 -4
  83. package/src/features/chat/features/welcome/utils/__tests__/chat-welcome-project-options.utils.test.ts +6 -8
  84. package/src/features/chat/features/welcome/utils/chat-welcome-project-options.utils.ts +1 -16
  85. package/src/features/panel-apps/components/panel-app-list-item.tsx +8 -8
  86. package/src/features/panel-apps/components/panel-app-toolbar.tsx +4 -4
  87. package/src/features/panel-apps/components/panel-apps-list.tsx +20 -20
  88. package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +70 -6
  89. package/src/features/pwa/managers/pwa-shell-theme.manager.ts +10 -5
  90. package/src/features/service-apps/components/service-action-authorization-dialog.tsx +8 -8
  91. package/src/features/service-apps/components/service-apps-panel.tsx +24 -24
  92. package/src/features/settings/components/config/provider-advanced-settings-section.tsx +5 -5
  93. package/src/features/settings/components/config/provider-auth-section.tsx +7 -7
  94. package/src/features/settings/components/config/provider-form.tsx +10 -10
  95. package/src/features/settings/components/config/provider-models-section.tsx +16 -16
  96. package/src/features/settings/components/config/provider-pill-selector.tsx +1 -1
  97. package/src/features/settings/pages/providers-config-page.tsx +17 -17
  98. package/src/shared/components/config-split-page.tsx +11 -11
  99. package/src/shared/components/doc-browser/doc-browser-home-page.tsx +2 -2
  100. package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +4 -4
  101. package/src/shared/components/doc-browser/doc-browser-tab-strip.tsx +4 -4
  102. package/src/shared/components/doc-browser/doc-browser.tsx +3 -3
  103. package/src/shared/components/resizable-right-panel/resizable-right-panel.tsx +1 -1
  104. package/src/shared/components/ui/actions/icon-action-button.tsx +1 -1
  105. package/src/shared/components/ui/button.tsx +4 -4
  106. package/src/shared/components/ui/card.tsx +4 -4
  107. package/src/shared/components/ui/dialog.tsx +5 -5
  108. package/src/shared/components/ui/input.tsx +1 -1
  109. package/src/shared/components/ui/label.tsx +1 -1
  110. package/src/shared/components/ui/popover.tsx +1 -1
  111. package/src/shared/components/ui/select.tsx +3 -3
  112. package/src/shared/components/ui/switch.tsx +3 -3
  113. package/src/shared/components/ui/tabs.tsx +4 -4
  114. package/src/shared/components/ui/textarea.tsx +1 -1
  115. package/src/shared/lib/i18n/locales/en-US/core.json +7 -2
  116. package/src/shared/lib/i18n/locales/zh-CN/core.json +7 -2
  117. package/src/shared/lib/theme/index.ts +94 -52
  118. package/dist/assets/chat-page-CEdavJXc.js +0 -105
  119. package/dist/assets/config-split-page-B5b9B0uE.js +0 -1
  120. package/dist/assets/doc-browser-5nMWYKBD.js +0 -1
  121. package/dist/assets/doc-browser-BJRLhztv.js +0 -1
  122. package/dist/assets/index-BDN1zzMQ.js +0 -105
  123. package/dist/assets/index-g3uSZXoc.css +0 -1
  124. package/dist/assets/mcp-marketplace-page-sMNFSq_T.js +0 -1
  125. package/dist/assets/plus-DPjb0piO.js +0 -1
  126. package/dist/assets/providers-config-page-BzAeaACA.js +0 -1
  127. package/dist/assets/remote-B0G80uPr.js +0 -1
  128. package/dist/assets/rotate-cw-DnEB1Rju.js +0 -1
  129. package/dist/assets/x-BiSSpgqB.js +0 -1
@@ -1,4 +1,4 @@
1
- import{h as e,p as t,r as n,u as r,v as i}from"./react-C6cZgP44.js";import{Bt as a,C as o,D as s,E as c,Gt as l,Jt as u,Kt as d,O as f,Rt as p,T as m,Vt as h,_t as g,an as _,cn as v,in as y,on as b,qt as x,sn as S,w as ee}from"./api-a14tR_z1.js";import{c as C}from"./dist-CLGGLm8b.js";import{a as w,i as T,n as E,r as D,t as O}from"./select-CvTlDZTQ.js";import{a as k,i as A,n as j,o as M,r as N,s as P}from"./confirm-dialog-ClH_Ec7n.js";import{n as te}from"./doc-browser-context-D4JwMMxK.js";import{D as F,L as ne,_t as re,b as ie,lt as ae,ot as I}from"./index-BDN1zzMQ.js";import{t as L}from"./tag-chip-8ffF2y2C.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:S()})}getOptimisticResult(e){return e.behavior=S(),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:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_(t,n.data),hasPreviousPage:b(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function R(e,t){return u(e,oe,t)}var se=C(`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=C(`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 z(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 B=t();function V({scope:e,isRefreshing:t,searchText:r,searchPlaceholder:i,sort:a,onSearchTextChange:o,onSortChange:s}){return(0,B.jsx)(`div`,{className:`mb-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(ce,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,B.jsx)(`input`,{value:r,onChange:e=>o(e.target.value),placeholder:i,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-9 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`}),t&&(0,B.jsx)(re,{className:`absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-primary`,"aria-label":n(`marketplaceRefreshingResults`)})]}),e===`all`&&(0,B.jsxs)(O,{value:a,onValueChange:e=>s(e),children:[(0,B.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,B.jsx)(w,{})}),(0,B.jsxs)(E,{children:[(0,B.jsx)(D,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,B.jsx)(D,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function H({count:e}){return(0,B.jsx)(B.Fragment,{children:Array.from({length:e},(e,t)=>(0,B.jsx)(`article`,{className:`h-full rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-2.5`,children:[(0,B.jsx)(F,{className:`h-9 w-9 shrink-0 rounded-lg`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,B.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(F,{className:`h-3 w-12`}),(0,B.jsx)(F,{className:`h-3 w-24`})]}),(0,B.jsx)(F,{className:`h-3 w-full`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 pt-0.5`,children:[(0,B.jsx)(F,{className:`h-5 w-14 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-16 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-12 rounded-md`})]})]})]}),(0,B.jsx)(F,{className:`h-7 w-16 shrink-0 rounded-md`})]})},`marketplace-skeleton-${t}`))})}function U({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,B.jsxs)(`div`,{className:`py-4`,children:[e&&(0,B.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,B.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function W(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function G(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function K(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:G(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=G(t),r=e.get(n);if(r)return r}for(let e of n){let n=G(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(G(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 q=i(e(),1),ue=160;function J({disabled:e,onLoadMore:t,thresholdPx:n=ue,watchValue:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(t),s=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{o.current=t},[t]),(0,q.useEffect)(()=>{e&&(s.current=!1)},[e]),(0,q.useEffect)(()=>{let t=i.current,r=a.current;if(e||!t||!r)return;let c=()=>{s.current||e||(s.current=!0,Promise.resolve(o.current()).finally(()=>{s.current=!1}))},l=()=>{r.getBoundingClientRect().top-t.getBoundingClientRect().bottom<=n&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:t,rootMargin:`0px 0px ${n}px 0px`});return e.observe(r),l(),()=>{e.disconnect()}}return t.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{t.removeEventListener(`scroll`,l)}},[e,n,r]),{containerRef:i,sentinelRef:a}}function Y(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=Y(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=Y(e);if(!n)continue;let r=t.get(n);if(r)return r}}function X(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Z(e,t,n,r,i){let a=`<!doctype html>
1
+ import{h as e,p as t,r as n,u as r,v as i}from"./react-VNqT5Zp7.js";import{Bt as a,C as o,D as s,E as c,Gt as l,Jt as u,Kt as d,O as f,Rt as p,T as m,Vt as h,_t as g,an as _,cn as v,in as y,on as b,qt as x,sn as S,w as ee}from"./api-BP_8IaxB.js";import{c as C}from"./dist-PVA_xL1D.js";import{a as w,i as T,n as E,r as D,t as O}from"./select-hoj8dK4K.js";import{a as k,i as A,n as j,o as M,r as N,s as P}from"./confirm-dialog-DsivFJ4r.js";import{n as te}from"./doc-browser-context-MTw4EvKd.js";import{D as F,L as ne,_t as re,b as ie,lt as ae,ot as I}from"./index-D9BAE_L_.js";import{t as L}from"./tag-chip-T8-h-die.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:S()})}getOptimisticResult(e){return e.behavior=S(),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:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_(t,n.data),hasPreviousPage:b(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function R(e,t){return u(e,oe,t)}var se=C(`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=C(`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 z(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 B=t();function V({scope:e,isRefreshing:t,searchText:r,searchPlaceholder:i,sort:a,onSearchTextChange:o,onSortChange:s}){return(0,B.jsx)(`div`,{className:`mb-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(ce,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,B.jsx)(`input`,{value:r,onChange:e=>o(e.target.value),placeholder:i,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-9 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`}),t&&(0,B.jsx)(re,{className:`absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-primary`,"aria-label":n(`marketplaceRefreshingResults`)})]}),e===`all`&&(0,B.jsxs)(O,{value:a,onValueChange:e=>s(e),children:[(0,B.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,B.jsx)(w,{})}),(0,B.jsxs)(E,{children:[(0,B.jsx)(D,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,B.jsx)(D,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function H({count:e}){return(0,B.jsx)(B.Fragment,{children:Array.from({length:e},(e,t)=>(0,B.jsx)(`article`,{className:`h-full rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-2.5`,children:[(0,B.jsx)(F,{className:`h-9 w-9 shrink-0 rounded-lg`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,B.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(F,{className:`h-3 w-12`}),(0,B.jsx)(F,{className:`h-3 w-24`})]}),(0,B.jsx)(F,{className:`h-3 w-full`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 pt-0.5`,children:[(0,B.jsx)(F,{className:`h-5 w-14 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-16 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-12 rounded-md`})]})]})]}),(0,B.jsx)(F,{className:`h-7 w-16 shrink-0 rounded-md`})]})},`marketplace-skeleton-${t}`))})}function U({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,B.jsxs)(`div`,{className:`py-4`,children:[e&&(0,B.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,B.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function W(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function G(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function K(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:G(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=G(t),r=e.get(n);if(r)return r}for(let e of n){let n=G(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(G(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 q=i(e(),1),ue=160;function J({disabled:e,onLoadMore:t,thresholdPx:n=ue,watchValue:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(t),s=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{o.current=t},[t]),(0,q.useEffect)(()=>{e&&(s.current=!1)},[e]),(0,q.useEffect)(()=>{let t=i.current,r=a.current;if(e||!t||!r)return;let c=()=>{s.current||e||(s.current=!0,Promise.resolve(o.current()).finally(()=>{s.current=!1}))},l=()=>{r.getBoundingClientRect().top-t.getBoundingClientRect().bottom<=n&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:t,rootMargin:`0px 0px ${n}px 0px`});return e.observe(r),l(),()=>{e.disconnect()}}return t.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{t.removeEventListener(`scroll`,l)}},[e,n,r]),{containerRef:i,sentinelRef:a}}function Y(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=Y(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=Y(e);if(!n)continue;let r=t.get(n);if(r)return r}}function X(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Z(e,t,n,r,i){let a=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -0,0 +1 @@
1
+ import{t as e}from"./mcp-marketplace-page-B1SZNY5m.js";export{e as McpMarketplacePage};
@@ -1 +1 @@
1
- import{h as e,p as t,r as n,v as r}from"./react-C6cZgP44.js";import{Bt as i,Lt as a,Mt as o,Rt as s,Vt as c,zt as l}from"./api-a14tR_z1.js";import{t as u}from"./provider-scoped-model-input-DAX2HgmR.js";import{s as d}from"./doc-browser-context-D4JwMMxK.js";import{D as f,Dt as p,_t as m,lt as h,p as g,xt as _}from"./index-BDN1zzMQ.js";import{l as v,m as y,r as b,t as x,u as S}from"./use-config-DmT0o1gv.js";import{t as C}from"./config-hints-BkYBc7z0.js";var w=r(e(),1),T=t(),E=`provider/model`;function D(e){let{initialModel:t,initialWorkspace:r,isPending:a,modelHelpText:o,modelLabel:s,modelPlaceholder:f,onSubmit:g,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(t),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g({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:n(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:s}),(0,T.jsx)(u,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:f}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:o}),(0,T.jsxs)(`a`,{href:`${d}/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)(p,{className:`h-3.5 w-3.5`}),n(`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)(_,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(i,{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)(c,{type:`submit`,disabled:a,size:`lg`,children:a?(0,T.jsx)(m,{className:`h-5 w-5 animate-spin`}):n(`saveChanges`)})})]})}function O(){let{data:e,isLoading:t}=x(),{data:r}=S(),{data:i}=v(),{data:c}=b(),l=y(),u=c?.uiHints,d=C(`agents.defaults.model`,u),p=C(`agents.defaults.workspace`,u),m=(0,w.useMemo)(()=>g({providersView:r,templatesView:i,config:e,onlyConfigured:!0}),[e,r,i]),h=n(`modelIdentifierHelp`)||d?.help||``,_=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return t?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-8 w-32`}),(0,T.jsx)(f,{className:`h-4 w-48`})]}),(0,T.jsxs)(o,{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)(f,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-5 w-24`}),(0,T.jsx)(f,{className:`h-3 w-32`})]})]}),(0,T.jsx)(f,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(o,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(f,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(s,{children:[(0,T.jsx)(a,{title:n(`modelPageTitle`),description:n(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:_,initialWorkspace:O,isPending:l.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>l.mutate({model:e,workspace:t}),providerCatalog:m,workspaceLabel:p?.label??`Default Path`,workspacePlaceholder:p?.placeholder??`/path/to/workspace`},`${_}::${O}`)]})}export{O as ModelConfigPage};
1
+ import{h as e,p as t,r as n,v as r}from"./react-VNqT5Zp7.js";import{Bt as i,Lt as a,Mt as o,Rt as s,Vt as c,zt as l}from"./api-BP_8IaxB.js";import{t as u}from"./provider-scoped-model-input-DsFRuWJH.js";import{s as d}from"./doc-browser-context-MTw4EvKd.js";import{D as f,Dt as p,_t as m,lt as h,p as g,xt as _}from"./index-D9BAE_L_.js";import{l as v,m as y,r as b,t as x,u as S}from"./use-config-CjRV2hwL.js";import{t as C}from"./config-hints-BkYBc7z0.js";var w=r(e(),1),T=t(),E=`provider/model`;function D(e){let{initialModel:t,initialWorkspace:r,isPending:a,modelHelpText:o,modelLabel:s,modelPlaceholder:f,onSubmit:g,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(t),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g({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:n(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:s}),(0,T.jsx)(u,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:f}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:o}),(0,T.jsxs)(`a`,{href:`${d}/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)(p,{className:`h-3.5 w-3.5`}),n(`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)(_,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(i,{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)(c,{type:`submit`,disabled:a,size:`lg`,children:a?(0,T.jsx)(m,{className:`h-5 w-5 animate-spin`}):n(`saveChanges`)})})]})}function O(){let{data:e,isLoading:t}=x(),{data:r}=S(),{data:i}=v(),{data:c}=b(),l=y(),u=c?.uiHints,d=C(`agents.defaults.model`,u),p=C(`agents.defaults.workspace`,u),m=(0,w.useMemo)(()=>g({providersView:r,templatesView:i,config:e,onlyConfigured:!0}),[e,r,i]),h=n(`modelIdentifierHelp`)||d?.help||``,_=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return t?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-8 w-32`}),(0,T.jsx)(f,{className:`h-4 w-48`})]}),(0,T.jsxs)(o,{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)(f,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-5 w-24`}),(0,T.jsx)(f,{className:`h-3 w-32`})]})]}),(0,T.jsx)(f,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(o,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(f,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(s,{children:[(0,T.jsx)(a,{title:n(`modelPageTitle`),description:n(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:_,initialWorkspace:O,isPending:l.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>l.mutate({model:e,workspace:t}),providerCatalog:m,workspaceLabel:p?.label??`Default Path`,workspacePlaceholder:p?.placeholder??`/path/to/workspace`},`${_}::${O}`)]})}export{O as ModelConfigPage};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-PVA_xL1D.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +1 @@
1
- import{h as e,p as t,r as n,u as r,v as i}from"./react-C6cZgP44.js";import{Bt as a}from"./api-a14tR_z1.js";import{c as o}from"./dist-CLGGLm8b.js";import{a as s,i as c,n as l,r as u,t as d,w as f}from"./select-CvTlDZTQ.js";import{H as p,K as m,U as h,W as g,h as _,m as v,y}from"./index-BDN1zzMQ.js";var b=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),x=i(e(),1),S=t(),C=m(`15rem`);function w(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function T({id:e,value:t,onChange:n,options:i,disabled:o=!1,placeholder:s,className:c,inputClassName:l,emptyText:u,createText:d,toggleLabel:m,maxItems:_=1/0,onEnter:v}){let[y,T]=(0,x.useState)(!1);(0,x.useEffect)(()=>{o&&y&&T(!1)},[o,y]);let E=(0,x.useMemo)(()=>w(i),[i]),D=t.trim().toLowerCase(),O=(0,x.useMemo)(()=>{let e=E.map((e,t)=>({option:e,index:t}));D.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===D?0:n.startsWith(D)?1:n.includes(D)?2:3,a=r===D?0:r.startsWith(D)?1:r.includes(D)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(_)?t.slice(0,Math.max(1,_)):t},[E,D,_]),k=t.trim().length>0&&E.some(e=>e===t.trim()),A=()=>T(!1);return(0,S.jsxs)(p,{open:y&&!o,onOpenChange:e=>T(!o&&e),children:[(0,S.jsx)(h,{asChild:!0,children:(0,S.jsxs)(`div`,{className:r(`relative`,c),children:[(0,S.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||T(!0)},onChange:e=>{n(e.target.value),!y&&!o&&T(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),A())},placeholder:s,className:r(`pr-10`,l)}),(0,S.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e=>!e),disabled:o,className:r(`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":m,children:(0,S.jsx)(b,{className:`h-4 w-4`})})]})}),(0,S.jsx)(g,{align:`start`,className:`flex w-[var(--radix-popover-trigger-width)] min-w-[12rem] flex-col overflow-hidden rounded-xl border border-gray-200 p-0 shadow-lg`,onOpenAutoFocus:e=>e.preventDefault(),style:{maxHeight:C},children:(0,S.jsxs)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto py-1`,children:[!k&&t.trim().length>0&&(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:`h-4 w-4 text-transparent`}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:d.replace(`{value}`,t.trim())})]}),O.map(e=>(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:r(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),O.length===0&&t.trim().length===0&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u})]})})]})}var E=`provider/model`;function D(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function O({id:e,value:t,onChange:r,providerCatalog:i,disabled:o=!1,providerPlaceholder:f,modelPlaceholder:p,className:m}){let[h,g]=(0,x.useState)(``),[b,C]=(0,x.useState)(``),w=i.length>0,O=p??E,k=(0,x.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),A=k.get(h),j=(0,x.useMemo)(()=>A?.aliases??[],[A]),M=(0,x.useMemo)(()=>D(A?.models??[]),[A]);return(0,x.useEffect)(()=>{let e=t.trim();if(!w){g(``),C(e);return}if(!e){C(``),g(e=>k.has(e)?e:``);return}let n=_(e,i)??``,r=k.get(n)?.aliases??[];g(n),C(n?y(e,r):e)},[w,i,k,t]),w?(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,S.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,S.jsxs)(d,{value:h,onValueChange:e=>{let t=D(k.get(e)?.models??[])[0]??``;if(g(e),C(t),!t){r(``);return}r(v(k.get(e)?.prefix??e,t))},disabled:o,children:[(0,S.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,S.jsx)(s,{placeholder:f??n(`providersSelectPlaceholder`)})}),(0,S.jsx)(l,{children:i.map(e=>(0,S.jsx)(u,{value:e.name,children:e.displayName},e.name))})]})}),(0,S.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,S.jsx)(T,{id:e,value:b,onChange:e=>{if(!A){let t=e.trim();C(t),r(t);return}let t=y(e,j);C(t),r(t?v(A.prefix,t):``)},options:M,disabled:o||!h,placeholder:O,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:n(`modelPickerNoOptions`),createText:n(`modelPickerUseCustom`),toggleLabel:n(`modelPickerToggleOptions`)},h)]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]}):(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:n(`providersEmptyTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:n(`providersEmptyDescription`)})]}),(0,S.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>r(e.target.value),placeholder:O,className:`mt-3 h-10 rounded-xl`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]})}export{O as t};
1
+ import{h as e,p as t,r as n,u as r,v as i}from"./react-VNqT5Zp7.js";import{Bt as a}from"./api-BP_8IaxB.js";import{c as o}from"./dist-PVA_xL1D.js";import{a as s,i as c,n as l,r as u,t as d,w as f}from"./select-hoj8dK4K.js";import{H as p,K as m,U as h,W as g,h as _,m as v,y}from"./index-D9BAE_L_.js";var b=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),x=i(e(),1),S=t(),C=m(`15rem`);function w(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function T({id:e,value:t,onChange:n,options:i,disabled:o=!1,placeholder:s,className:c,inputClassName:l,emptyText:u,createText:d,toggleLabel:m,maxItems:_=1/0,onEnter:v}){let[y,T]=(0,x.useState)(!1);(0,x.useEffect)(()=>{o&&y&&T(!1)},[o,y]);let E=(0,x.useMemo)(()=>w(i),[i]),D=t.trim().toLowerCase(),O=(0,x.useMemo)(()=>{let e=E.map((e,t)=>({option:e,index:t}));D.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===D?0:n.startsWith(D)?1:n.includes(D)?2:3,a=r===D?0:r.startsWith(D)?1:r.includes(D)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(_)?t.slice(0,Math.max(1,_)):t},[E,D,_]),k=t.trim().length>0&&E.some(e=>e===t.trim()),A=()=>T(!1);return(0,S.jsxs)(p,{open:y&&!o,onOpenChange:e=>T(!o&&e),children:[(0,S.jsx)(h,{asChild:!0,children:(0,S.jsxs)(`div`,{className:r(`relative`,c),children:[(0,S.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||T(!0)},onChange:e=>{n(e.target.value),!y&&!o&&T(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),A())},placeholder:s,className:r(`pr-10`,l)}),(0,S.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e=>!e),disabled:o,className:r(`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":m,children:(0,S.jsx)(b,{className:`h-4 w-4`})})]})}),(0,S.jsx)(g,{align:`start`,className:`flex w-[var(--radix-popover-trigger-width)] min-w-[12rem] flex-col overflow-hidden rounded-xl border border-gray-200 p-0 shadow-lg`,onOpenAutoFocus:e=>e.preventDefault(),style:{maxHeight:C},children:(0,S.jsxs)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto py-1`,children:[!k&&t.trim().length>0&&(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:`h-4 w-4 text-transparent`}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:d.replace(`{value}`,t.trim())})]}),O.map(e=>(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:r(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),O.length===0&&t.trim().length===0&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u})]})})]})}var E=`provider/model`;function D(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function O({id:e,value:t,onChange:r,providerCatalog:i,disabled:o=!1,providerPlaceholder:f,modelPlaceholder:p,className:m}){let[h,g]=(0,x.useState)(``),[b,C]=(0,x.useState)(``),w=i.length>0,O=p??E,k=(0,x.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),A=k.get(h),j=(0,x.useMemo)(()=>A?.aliases??[],[A]),M=(0,x.useMemo)(()=>D(A?.models??[]),[A]);return(0,x.useEffect)(()=>{let e=t.trim();if(!w){g(``),C(e);return}if(!e){C(``),g(e=>k.has(e)?e:``);return}let n=_(e,i)??``,r=k.get(n)?.aliases??[];g(n),C(n?y(e,r):e)},[w,i,k,t]),w?(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,S.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,S.jsxs)(d,{value:h,onValueChange:e=>{let t=D(k.get(e)?.models??[])[0]??``;if(g(e),C(t),!t){r(``);return}r(v(k.get(e)?.prefix??e,t))},disabled:o,children:[(0,S.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,S.jsx)(s,{placeholder:f??n(`providersSelectPlaceholder`)})}),(0,S.jsx)(l,{children:i.map(e=>(0,S.jsx)(u,{value:e.name,children:e.displayName},e.name))})]})}),(0,S.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,S.jsx)(T,{id:e,value:b,onChange:e=>{if(!A){let t=e.trim();C(t),r(t);return}let t=y(e,j);C(t),r(t?v(A.prefix,t):``)},options:M,disabled:o||!h,placeholder:O,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:n(`modelPickerNoOptions`),createText:n(`modelPickerUseCustom`),toggleLabel:n(`modelPickerToggleOptions`)},h)]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]}):(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:n(`providersEmptyTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:n(`providersEmptyDescription`)})]}),(0,S.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>r(e.target.value),placeholder:O,className:`mt-3 h-10 rounded-xl`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]})}export{O as t};
@@ -0,0 +1 @@
1
+ import{a as e,h as t,p as n,r,u as i,v as a}from"./react-VNqT5Zp7.js";import{Bt as o,Gt as s,Lt as c,Rt as l,Vt as u,_t as d,in as f,zt as p}from"./api-BP_8IaxB.js";import{c as m}from"./dist-PVA_xL1D.js";import{C as h,a as g,i as _,n as v,r as y,t as b}from"./select-hoj8dK4K.js";import{t as x}from"./confirm-dialog-DsivFJ4r.js";import{t as S}from"./search-BEti5beA.js";import{t as C}from"./ellipsis-y6vDtq4M.js";import{t as w}from"./plus-BbZqquJe.js";import{t as T}from"./x-D9PXs_xP.js";import{G as E,H as D,R as O,St as k,W as A,_ as j,at as M,d as N,f as P,g as F,q as I,st as L,v as R,vt as z}from"./index-D9BAE_L_.js";import{a as ee,c as B,d as V,f as te,h as ne,i as re,l as ie,r as ae,s as H,u as oe}from"./use-config-CjRV2hwL.js";import{t as U}from"./config-hints-BkYBc7z0.js";import{a as W,c as G,i as K,n as se,o as q,r as ce,s as J}from"./config-split-page-CRhlZ_pH.js";var le=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`}]]),ue=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`}]]),de=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`}]]),Y=a(t(),1),X=n();function fe({isSet:e,className:t,value:n,onChange:r,placeholder:a,...s}){let[c,l]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,X.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,X.jsx)(`div`,{onClick:()=>f(!0),className:i(`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`,t),children:`••••••••••••`}):(0,X.jsx)(o,{type:c?`text`:`password`,className:i(`pr-12`,t),value:n,onChange:r,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...s}),(0,X.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,X.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,X.jsx)(ue,{className:`h-4 w-4`}):(0,X.jsx)(k,{className:`h-4 w-4`})})})]})}function pe({value:e,onChange:t,className:n}){let a=e?Object.entries(e):[],s=(e,n,r)=>{let i=[...a];i[e]=[n,r],t(Object.fromEntries(i))},c=()=>{t({...e,"":``})},l=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,X.jsxs)(`div`,{className:i(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(o,{type:`text`,value:e,onChange:e=>s(n,e.target.value,t),placeholder:r(`headerName`),className:`flex-1`}),(0,X.jsx)(o,{type:`text`,value:t,onChange:t=>s(n,e,t.target.value),placeholder:r(`headerValue`),className:`flex-1`}),(0,X.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(n),children:(0,X.jsx)(L,{className:`h-4 w-4 text-red-500`})})]},n)),(0,X.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,X.jsx)(w,{className:`h-4 w-4 mr-2`}),r(`add`)]})]})}function me(e){let{value:t,onChange:n,options:r}=e;return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,X.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-primary-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:e.label},e.value)})})}function he(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,X.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(de,{className:`h-3.5 w-3.5`}),r(`providerAdvancedSettings`)]}),(0,X.jsx)(h,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,X.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,X.jsx)(me,{value:o,onChange:e=>s(e),options:l}):(0,X.jsxs)(b,{value:o,onValueChange:e=>s(e),children:[(0,X.jsx)(_,{className:`rounded-xl`,children:(0,X.jsx)(g,{})}),(0,X.jsx)(v,{children:l.map(e=>(0,X.jsx)(y,{value:e.value,children:e.label},e.value))})]})]}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:u}),(0,X.jsx)(pe,{value:d,onChange:f}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerExtraHeadersHelpShort`)})]})]}):null]})}function ge(e){let{providerAuth:t,providerAuthNote:n,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:s,resolvedAuthMethodId:c,onAuthMethodChange:l,onStartProviderAuth:d,onImportProviderAuthFromCli:f,startPending:m,importPending:h,authSessionId:x,authStatusMessage:S}=e;return t?.kind===`device_code`?(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:t.displayName||r(`providerAuthSectionTitle`)}),n?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}):null,a>1?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{className:`text-xs font-medium text-foreground`,children:r(`providerAuthMethodLabel`)}),s?(0,X.jsx)(me,{value:c,onChange:l,options:i}):(0,X.jsxs)(b,{value:c,onValueChange:l,children:[(0,X.jsx)(_,{className:`h-8 rounded-lg`,children:(0,X.jsx)(g,{placeholder:r(`providerAuthMethodPlaceholder`)})}),(0,X.jsx)(v,{children:i.map(e=>(0,X.jsx)(y,{value:e.value,children:e.label},e.value))})]}),o?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o}):null]}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:d,disabled:m||!!x,children:r(m?`providerAuthStarting`:x?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,X.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:f,disabled:h,children:r(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,x?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[r(`providerAuthSessionLabel`),`: `,x.slice(0,8),`…`]}):null]}),S?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:S}):null]}):null}var _e={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 ve(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 Q(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 ye(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 $(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ye(n,t))}return n.trim()}function be(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function xe(e,t){return Q(t)}function Se(e,t){return Q(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ce(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=j(i.thinking?.supported);if(a.length>0){let t=R(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 we(e,t,n){return{...F(e,n),...F(t,n)}}function Te(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||!be([...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 Ee(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!ve(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!be(e.models,e.currentEditableModels)||!Te(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function De(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=Z(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),ve(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),be(e.models,e.currentEditableModels)||(t.models=Se(e.models,e.providerName??``)),Te(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ce(e.modelConfig,e.models)),t}function Oe(e){let t=$(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={apiBase:e.apiBase.trim(),extraHeaders:Z(e.extraHeaders),model:t||null};return e.apiKey.trim().length>0&&(n.apiKey=e.apiKey.trim()),e.supportsWireApi&&(n.wireApi=e.wireApi),n}function ke(e){return r(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ae(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 je(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Me(e,t,n){let r=$(t,n);return r?r.includes(`/`)?{models:e,draft:t,errorKey:`providerModelInvalidProviderPrefix`}:e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ne(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function Pe(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):P.filter(e=>e===n||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={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Fe(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ie(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function Le(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Ae({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:je({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Re(e,t){let n=!!e?.supportsWireApi||t,i=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:r(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:je({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:i.length}),supportsWireApi:n,wireApiSelectOptions:i}}function ze(e){let{providerName:t,providersView:n,templatesView:i,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=i?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??_e,u=a?.uiHints,d=!!s?.isCustom,f=t?U(`providers.${t}.apiKey`,u):void 0,p=t?U(`providers.${t}.apiBase`,u):void 0,m=t?U(`providers.${t}.extraHeaders`,u):void 0,h=t?U(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=Q([c?.modelPrefix||c?.providerType||``,t||``]),b=c?.defaultApiBase||``,x=l.apiBase||b,S=Z(l.extraHeaders||null),C=l.wireApi||c?.defaultWireApi||`auto`,w=xe(Q((c?.defaultModels??[]).map(e=>$(e,y))),Q((l.models??[]).map(e=>$(e,y)))),T=Ce(we(c?.modelConfig,l.modelConfig,y),w),E=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||r(`providerApiBaseHelp`),D=Le({providerName:t,providerSpec:c,language:o}),O=Re(c,d);return{apiBaseHelpText:E,apiBaseHint:p,apiKeyHint:f,currentApiBase:x,currentEditableModels:w,currentEnabled:v,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...D,providerConfig:s,providerModelAliases:y,resolvedProviderConfig:l,wireApiHint:h,...O}}function Be(e){let{models:t,modelConfig:n,modelDraft:i,showModelInput:a,onModelDraftChange:s,onShowModelInputChange:c,onAddModel:l,onRemoveModel:f,onToggleModelThinkingLevel:m,onSetModelThinkingDefault:h,onSetModelVision:x,thinkingLevels:S,formatThinkingLevelLabel:C}=e;return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:r(`providerModelsTitle`)}),a?null:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,X.jsx)(w,{className:`h-3 w-3`}),r(`providerAddModel`)]})]}),a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(o,{value:i,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),s(``))},placeholder:r(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,X.jsx)(u,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:r(`add`)}),(0,X.jsx)(u,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),s(``)},children:(0,X.jsx)(T,{className:`h-4 w-4`})})]}):null,t.length===0?(0,X.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-muted/60 px-4 py-6 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`providerModelsEmptyShort`)}),a?null:(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:r(`providerAddFirstModel`)})]}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=n[e],i=t?.thinking,a=i?.supported??[],o=i?.default??null,s=t?.vision===!0;return(0,X.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-card px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,X.jsxs)(D,{children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`providerModelThinkingTitle`),title:r(`providerModelThinkingTitle`),children:(0,X.jsx)(de,{className:`h-3 w-3`})})}),(0,X.jsxs)(A,{className:`w-80 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/60 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelVisionTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelVisionHint`)})]}),(0,X.jsx)(d,{checked:s,onCheckedChange:t=>x(e,t)})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelThinkingTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingHint`)})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:S.map(t=>(0,X.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-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:C(t)},t))}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`text-xs font-medium text-foreground`,children:r(`providerModelThinkingDefault`)}),(0,X.jsxs)(b,{value:o??`__none__`,onValueChange:t=>h(e,t===`__none__`?null:t),disabled:a.length===0,children:[(0,X.jsx)(_,{className:`h-8 rounded-lg text-xs`,children:(0,X.jsx)(g,{})}),(0,X.jsxs)(v,{children:[(0,X.jsx)(y,{value:`__none__`,children:r(`providerModelThinkingDefaultNone`)}),a.map(e=>(0,X.jsx)(y,{value:e,children:C(e)},e))]})]}),a.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`remove`),children:(0,X.jsx)(T,{className:`h-3 w-3`})})]},e)})})]})}function Ve({apiKeySet:e,className:t,enabled:n}){return n?(0,X.jsx)(M,{status:e?`ready`:`setup`,label:r(e?`statusReady`:`statusSetup`),className:t}):(0,X.jsx)(M,{status:`inactive`,label:r(`disabled`),className:t})}function He(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:i}=e,a=f(),o=V(),c=B(),l=H(),[u,d]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]),y=(0,Y.useCallback)((e,n)=>{v(),_.current=window.setTimeout(()=>{(async()=>{if(t)try{let i=await c.mutateAsync({provider:t,data:{sessionId:e}});if(i.status===`pending`){g(r(`providerAuthWaitingBrowser`)),y(e,i.nextPollMs??n);return}if(i.status===`authorized`){m(null),v(),g(r(`providerAuthCompleted`)),s.success(r(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(i.message||`Authorization ${i.status}.`),s.error(i.message||`Authorization ${i.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),s.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,c,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),g(``);let e=await o.mutateAsync({provider:t,data:i?{methodId:i}:{}});if(!e.sessionId||!e.verificationUri)throw Error(r(`providerAuthStartFailed`));m(e.sessionId),g(`${r(`providerAuthOpenPrompt`)}${e.userCode}${r(`providerAuthOpenPromptSuffix`)}`),await I.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),s.error(`${r(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,i,y,o]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),v(),m(null);let e=await l.mutateAsync({provider:t});g(`${r(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),s.success(r(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),s.error(`${r(`providerAuthImportFailed`)}: ${t}`)}},[v,l,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:u===t?p:null,authStatusMessage:u===t?h:``,importAuthFromCli:x,importPending:l.isPending,startAuth:b,startPending:o.isPending}}function Ue({providerName:t,onProviderDeleted:n}){let{data:i}=oe(),{data:a}=ie(),{data:o}=ae(),c=ne(),l=ee(),u=te(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(`auto`),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)({}),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(``),N=e(),P=(0,Y.useMemo)(()=>ze({providerName:t,providersView:i,templatesView:a,schema:o,language:N}),[N,t,i,o,a]),{currentApiBase:F,currentEditableModels:I,currentHeaders:L,currentModelConfig:R,currentWireApi:z,defaultApiBase:B,effectiveDisplayName:V,providerAuth:re,providerAuthMethods:H,providerConfig:U,providerModelAliases:W,resolvedProviderConfig:G,preferredAuthMethodId:K,supportsWireApi:q}=P,ce=T.trim()||V||t||r(`providersSelectPlaceholder`),J=(0,Y.useMemo)(()=>{if(!H.length)return``;let e=j.trim();return e&&H.some(t=>t.id===e)?e:K||H[0]?.id||``},[j,K,H]),{authSessionId:le,authStatusMessage:ue,importAuthFromCli:de,importPending:fe,startAuth:pe,startPending:me}=He({providerName:t,providerAuth:re,resolvedAuthMethodId:J});(0,Y.useEffect)(()=>{if(!t){f(``),m(``),g(null),v(`auto`),b([]),S({}),w(``),E(``),M(``);return}f(``),m(F),g(G.extraHeaders||null),v(z),b(I),S(R),w(``),E(V),M(K)},[t,F,G.extraHeaders,z,I,R,V,K]),(0,Y.useEffect)(()=>S(e=>Ce(e,y)),[y]);let he=(0,Y.useMemo)(()=>Ee({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V}),[t,d,p,F,h,L,q,_,z,y,I,x,R,T,V]);return!t||!U?(0,X.jsx)(se,{children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(`providersSelectTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:r(`providersSelectDescription`)})]})}):(0,X.jsx)(We,{context:P,language:N,providerTitle:ce,providerDisplayName:T,apiKey:d,apiBase:p,extraHeaders:h,wireApi:_,models:y,modelConfig:x,modelDraft:C,showAdvanced:D,showModelInput:k,resolvedAuthMethodId:J,authSessionId:le,authStatusMessage:ue,hasChanges:he,isDeletePending:l.isPending,isUpdatePending:c.isPending,isTestPending:u.isPending,startPending:me,importPending:fe,onProviderDisplayNameChange:E,onApiKeyChange:f,onApiBaseChange:m,onAuthMethodChange:M,onStartProviderAuth:pe,onImportProviderAuthFromCli:de,onModelDraftChange:w,onShowModelInputChange:A,onAddModel:()=>{let e=Me(y,C,W);if(e.errorKey){s.error(r(`providerModelInvalidProviderPrefix`));return}b(e.models),w(e.draft)},onRemoveModel:e=>{let t=Ne(y,x,e);b(t.models),S(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{S(n=>Pe(n,e,t))},onSetModelThinkingDefault:(e,t)=>{S(n=>Fe(n,e,t))},onSetModelVision:(e,t)=>{S(n=>Ie(n,e,t))},onShowAdvancedChange:O,onWireApiChange:v,onExtraHeadersChange:g,onDeleteProvider:async()=>{if(t&&window.confirm(r(`providerDeleteConfirm`)))try{await l.mutateAsync({provider:t}),n?.(t)}catch{}},onSubmit:e=>{e.preventDefault(),t&&c.mutate({provider:t,data:De({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,defaultApiBase:B,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V})})},onTestConnection:async()=>{if(t)try{let e=await u.mutateAsync({provider:t,data:Oe({apiKey:d,apiBase:p,extraHeaders:h,supportsWireApi:q,wireApi:_,models:y,providerModelAliases:W})});if(e.success){s.success(`${r(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let n=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&n.push(`model=${e.model}`),s.error(`${r(`providerTestConnectionFailed`)}: ${e.message} | ${n.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);s.error(`${r(`providerTestConnectionFailed`)}: ${t}`)}}})}function We(e){let{context:t,language:n,providerTitle:i,providerDisplayName:a,apiKey:s,apiBase:c,extraHeaders:l,wireApi:d,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,isTestPending:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:F,onAddModel:I,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,onShowAdvancedChange:V,onWireApiChange:te,onExtraHeadersChange:ne,onDeleteProvider:re,onSubmit:ie,onTestConnection:ae}=e,H=t.providerAuthMethods.find(e=>e.id===v);return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`px-6 py-4`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:i}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:re,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:r(`providerDelete`),children:(0,X.jsx)(L,{className:`h-4 w-4`})}),(0,X.jsx)(Ve,{enabled:t.currentEnabled,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,X.jsxs)(`form`,{onSubmit:ie,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(q,{className:`space-y-5 px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:r(`providerDisplayName`)}),(0,X.jsx)(o,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||r(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerDisplayNameHelpShort`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:t.apiKeyHint?.label??r(`apiKey`)}),(0,X.jsx)(fe,{id:`apiKey`,value:s,isSet:t.resolvedProviderConfig.apiKeySet,onChange:e=>O(e.target.value),placeholder:t.apiKeyHint?.placeholder??r(`enterApiKey`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`leaveBlankToKeepUnchanged`)})]}),(0,X.jsx)(ge,{providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:H?.hint?.[n]||H?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:t.apiBaseHint?.label??r(`apiBase`)}),(0,X.jsx)(o,{id:`apiBase`,type:`text`,value:c,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,X.jsx)(Be,{models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:F,onAddModel:I,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,thinkingLevels:P,formatThinkingLevelLabel:ke}),(0,X.jsx)(he,{showAdvanced:g,onShowAdvancedChange:V,supportsWireApi:t.supportsWireApi,wireApiLabel:t.wireApiHint?.label??r(`wireApi`),wireApi:d,onWireApiChange:te,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:t.extraHeadersHint?.label??r(`extraHeaders`),extraHeaders:l,onExtraHeadersChange:ne})]}),(0,X.jsxs)(J,{className:`flex items-center justify-between px-6 py-4`,children:[(0,X.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:ae,disabled:w,children:[(0,X.jsx)(le,{className:`mr-1.5 h-4 w-4`}),r(w?`providerTestingConnection`:`providerTestConnection`)]}),(0,X.jsx)(u,{type:`submit`,disabled:C||!x,children:r(C?`saving`:x?`save`:`unchanged`)})]})]})]})}function Ge(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 Ke(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 qe(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 Je(){let{isMobile:e}=N(),{data:t}=oe(),{data:n}=ie(),a=re(),s=ee(),f=ne(),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)([]),[T,k]=(0,Y.useState)(``),j=(0,Y.useMemo)(()=>Ke(Object.values(t?.providers??{}),y),[t?.providers,y]),P=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),F=(0,Y.useMemo)(()=>qe(P),[P]),I=(0,Y.useMemo)(()=>new Map(P.map(e=>[e.providerType,e])),[P]),R=(0,Y.useMemo)(()=>{let e=T.trim().toLowerCase();return j.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[j,T,I]),B=(0,Y.useMemo)(()=>p&&R.some(e=>e.providerId===p)?p:e?null:R[0]?.providerId??null,[R,e,p]);return!t||!n?(0,X.jsx)(`div`,{className:`p-8`,children:r(`providersLoading`)}):(0,X.jsxs)(l,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,X.jsx)(c,{title:r(`providersPageTitle`),description:r(`providersPageDescription`)}),(0,X.jsxs)(K,{className:`xl:min-h-0`,mobileView:e?B?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:r(`providersPageTitle`),children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,X.jsxs)(D,{open:_,onOpenChange:v,children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsxs)(u,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,X.jsx)(w,{className:`mr-2 h-4 w-4`}),a.isPending?r(`saving`):r(`providerAdd`)]})}),(0,X.jsxs)(A,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,X.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:r(`providerTemplatePickerTitle`)}),(0,X.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});k(``),m(e.providerId),b(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),v(!1)}catch{}},children:[(0,X.jsx)(O,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border bg-background`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:r(`providerAddCustom`)})]}),F.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});k(``),m(t.providerId),b(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),v(!1)}catch{}},children:[(0,X.jsx)(O,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,X.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,X.jsx)(o,{value:T,onChange:e=>k(e.target.value),placeholder:r(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,X.jsxs)(q,{className:`space-y-2 p-3`,children:[R.map(e=>{let t=e.providerType?I.get(e.providerType):null,n=e.enabled!==!1,a=!!(n&&e.apiKeySet),o=e.displayName?.trim()||t?.displayName||e.providerId,s=Ge(e.apiBase||t?.defaultApiBase||``)||r(`providersDefaultDescription`);return(0,X.jsx)(`div`,{onClick:()=>m(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.providerId))},role:`button`,tabIndex:0,className:i(`w-full rounded-xl border p-2.5 text-left transition-all`,B===e.providerId?`border-primary/35 bg-primary-50/45 text-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/35 hover:bg-accent/70 hover:text-accent-foreground`),children:(0,X.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,X.jsx)(O,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:i(`h-10 w-10 rounded-lg border`,a?`border-primary/35 bg-background`:`border-border bg-background`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,X.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:o}),(0,X.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,X.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[s,` · `,e.models?.length??0]})]})]}),(0,X.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5`,children:[(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,X.jsx)(d,{checked:n,disabled:f.isPending,title:r(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{f.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,X.jsxs)(D,{children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-accent hover:text-accent-foreground`,onClick:e=>e.stopPropagation(),title:r(`more`),children:(0,X.jsx)(C,{className:`h-4 w-4`})})}),(0,X.jsx)(A,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,X.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:()=>g(e.providerId),children:[(0,X.jsx)(L,{className:`h-4 w-4`}),r(`providerDelete`)]})})]})]}),(0,X.jsx)(M,{status:n?a?`ready`:`setup`:`inactive`,label:r(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),R.length===0?(0,X.jsx)(ce,{icon:z,title:r(`providersNoMatch`)}):null]})]}),(0,X.jsx)(Ue,{providerName:B??void 0,onProviderDeleted:e=>{b(t=>t.filter(t=>t!==e)),e===B&&m(null)}})]}),(0,X.jsx)(x,{open:!!h,onOpenChange:e=>{e||g(null)},title:r(`providerDelete`),description:h??void 0,confirmLabel:r(`delete`),variant:`destructive`,onCancel:()=>g(null),onConfirm:()=>{h&&s.mutateAsync({provider:h}).then(()=>{b(e=>e.filter(e=>e!==h)),h===B&&m(null),g(null)})}})]})}export{Je as ProvidersConfigPage};