@nextclaw/ui 0.21.0 → 0.22.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 (98) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/assets/{api-DNLQPHfQ.js → api-m33O1Kb0.js} +3 -3
  3. package/dist/assets/{appearance-settings-page-BlAFMOGV.js → appearance-settings-page-x4Vjnfmz.js} +1 -1
  4. package/dist/assets/{book-open-BryfPTTa.js → book-open-BHiasMCg.js} +1 -1
  5. package/dist/assets/{channels-list-page-Cfbgubyv.js → channels-list-page-DOxJZeXq.js} +1 -1
  6. package/dist/assets/{config-split-page-Dd8xG0Jk.js → config-split-page-DBnMEP1o.js} +1 -1
  7. package/dist/assets/{confirm-dialog-CZIWjnJ6.js → confirm-dialog-f5NKLh5I.js} +2 -2
  8. package/dist/assets/{createLucideIcon-BxwVe8ZD.js → createLucideIcon-CHALGA42.js} +1 -1
  9. package/dist/assets/{desktop-capabilities-page-C6YxsHeV.js → desktop-capabilities-page-DixayAe6.js} +1 -1
  10. package/dist/assets/{desktop-update-config-BVN4QPJn.js → desktop-update-config-ChhfeOHj.js} +1 -1
  11. package/dist/assets/{dist-Cd8Nm3BW.js → dist-_UMsWSY0.js} +1 -1
  12. package/dist/assets/{dist-BRloKr3S.js → dist-sD6V4nHX.js} +1 -1
  13. package/dist/assets/doc-browser-Bq7LJsQY.js +1 -0
  14. package/dist/assets/doc-browser-BuDgpY2e.js +1 -0
  15. package/dist/assets/{doc-browser-context-3JGufiMA.js → doc-browser-context-Capim3og.js} +1 -1
  16. package/dist/assets/{extensions-Dedd2oDI.js → extensions-Bdclr3Wr.js} +1 -1
  17. package/dist/assets/{form-actions-FWCEof3V.js → form-actions-CH0kWhEt.js} +1 -1
  18. package/dist/assets/index-BjxnLYE3.js +109 -0
  19. package/dist/assets/index-CBmwJjwE.css +1 -0
  20. package/dist/assets/loader-circle-CH_0iPLy.js +1 -0
  21. package/dist/assets/{mcp-marketplace-page-e9Rmfz-d.js → mcp-marketplace-page-BUsxLVB5.js} +2 -2
  22. package/dist/assets/mcp-marketplace-page-GPRV3fB0.js +1 -0
  23. package/dist/assets/{model-config-page-C173Ssil.js → model-config-page-CIevwqp4.js} +1 -1
  24. package/dist/assets/{navigation-link-DTPOvGGL.js → navigation-link-CAUiM3zS.js} +1 -1
  25. package/dist/assets/plus-B3obD55V.js +1 -0
  26. package/dist/assets/{privacy-settings-page-CRserBVF.js → privacy-settings-page-CNKfZsYH.js} +1 -1
  27. package/dist/assets/{providers-config-page-C8jUtnZb.js → providers-config-page-DAah2NIS.js} +1 -1
  28. package/dist/assets/{react-BAzO6LZS.js → react-Co6JiC1n.js} +1 -1
  29. package/dist/assets/{refresh-cw-BCj-yjde.js → refresh-cw-BG_LX3SS.js} +1 -1
  30. package/dist/assets/remote-DuscgfvR.js +1 -0
  31. package/dist/assets/{rotate-cw-BPnW4qUl.js → rotate-cw-Cz7I_m7O.js} +1 -1
  32. package/dist/assets/{runtime-config-page-aeQ1Dryz.js → runtime-config-page-Cl1RpmSC.js} +1 -1
  33. package/dist/assets/{save-KT0MumfJ.js → save-BiHnb8ps.js} +1 -1
  34. package/dist/assets/{search-Cv1Hx_nx.js → search-C47TyRg0.js} +1 -1
  35. package/dist/assets/{search-config-page-b283V-fo.js → search-config-page-BAIzd6gN.js} +1 -1
  36. package/dist/assets/{secrets-config-page-ss7x3BOo.js → secrets-config-page-Ddi-n43R.js} +1 -1
  37. package/dist/assets/security-config-C8MHnE1r.js +1 -0
  38. package/dist/assets/{select-BVgD4EpG.js → select-BzQKfW1e.js} +2 -2
  39. package/dist/assets/skeleton-BXFAE9SE.js +1 -0
  40. package/dist/assets/{tag-chip-DZ4ircUB.js → tag-chip-C3K814HZ.js} +1 -1
  41. package/dist/assets/x-C1r9IXet.js +1 -0
  42. package/dist/index.html +29 -21
  43. package/dist/themes/island/island-atmosphere.webp +0 -0
  44. package/index.html +8 -0
  45. package/package.json +5 -5
  46. package/public/themes/island/island-atmosphere.webp +0 -0
  47. package/src/app/components/layout/header.tsx +4 -1
  48. package/src/app/components/layout/page-layout.tsx +4 -1
  49. package/src/app/components/layout/sidebar.tsx +1 -0
  50. package/src/app/styles/island-theme.css +542 -0
  51. package/src/features/chat/components/conversation/__tests__/chat-conversation-header.test.tsx +1 -0
  52. package/src/features/chat/components/conversation/chat-conversation-header.tsx +5 -1
  53. package/src/features/chat/components/conversation/chat-conversation-panel.tsx +4 -1
  54. package/src/features/chat/components/layout/__tests__/chat-sidebar-toolbar.test.tsx +10 -0
  55. package/src/features/chat/components/layout/chat-page-shell.tsx +4 -1
  56. package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +2 -0
  57. package/src/features/chat/components/layout/chat-sidebar.tsx +1 -0
  58. package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel.test.tsx +1 -0
  59. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +1 -0
  60. package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +1 -0
  61. package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +9 -0
  62. package/src/features/pwa/managers/pwa-shell-theme.manager.ts +1 -0
  63. package/src/features/service-apps/components/__tests__/service-apps-panel.test.tsx +35 -1
  64. package/src/features/service-apps/components/service-action-row.tsx +130 -0
  65. package/src/features/service-apps/components/service-app-list-item.tsx +11 -66
  66. package/src/features/service-apps/components/service-apps-panel.tsx +12 -0
  67. package/src/features/service-apps/hooks/use-service-apps.ts +20 -1
  68. package/src/features/settings/pages/__tests__/appearance-settings-page.test.tsx +2 -2
  69. package/src/features/side-dock/components/side-dock.tsx +1 -0
  70. package/src/index.css +1 -0
  71. package/src/platforms/desktop/components/__tests__/desktop-app-shell.test.tsx +8 -0
  72. package/src/platforms/desktop/components/desktop-app-shell.tsx +56 -2
  73. package/src/platforms/desktop/components/desktop-window-chrome.tsx +1 -0
  74. package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +3 -0
  75. package/src/shared/components/doc-browser/doc-browser.tsx +2 -0
  76. package/src/shared/components/ui/context-menu/context-menu.tsx +1 -0
  77. package/src/shared/components/ui/dialog.tsx +2 -0
  78. package/src/shared/components/ui/overlays/sheet.tsx +2 -0
  79. package/src/shared/components/ui/popover.tsx +1 -0
  80. package/src/shared/components/ui/select.tsx +1 -0
  81. package/src/shared/components/ui/tooltip.tsx +1 -0
  82. package/src/shared/lib/i18n/locales/en-US/core.json +1 -0
  83. package/src/shared/lib/i18n/locales/en-US/doc-browser.json +1 -0
  84. package/src/shared/lib/i18n/locales/zh-CN/core.json +1 -0
  85. package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +1 -0
  86. package/src/shared/lib/theme/index.test.ts +9 -0
  87. package/src/shared/lib/theme/index.ts +2 -0
  88. package/dist/assets/doc-browser-Bzgqmmiu.js +0 -1
  89. package/dist/assets/doc-browser-D0qI0Z_R.js +0 -1
  90. package/dist/assets/index-CXkHcESm.css +0 -1
  91. package/dist/assets/index-D25tRg1p.js +0 -109
  92. package/dist/assets/loader-circle-BoyCoFps.js +0 -1
  93. package/dist/assets/mcp-marketplace-page-Cn-9CDh3.js +0 -1
  94. package/dist/assets/plus-D1R4Vipq.js +0 -1
  95. package/dist/assets/remote-6BHWP5zi.js +0 -1
  96. package/dist/assets/security-config-HHz62oxH.js +0 -1
  97. package/dist/assets/skeleton-ChUmcyys.js +0 -1
  98. package/dist/assets/x-BWDRfVWL.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-BAzO6LZS.js";import{t as i}from"./navigation-link-DTPOvGGL.js";import{an as a,dn as o,fn as s,in as c,on as l,sn as u,un as d}from"./api-DNLQPHfQ.js";import{t as f}from"./book-open-BryfPTTa.js";import{t as p}from"./loader-circle-BoyCoFps.js";import{t as m}from"./skeleton-ChUmcyys.js";import{m as h}from"./doc-browser-context-3JGufiMA.js";import{A as g,E as _,L as v,T as y,g as b,m as x,t as S}from"./index-D25tRg1p.js";import{t as C}from"./form-actions-FWCEof3V.js";import{t as w}from"./config-hints-nV5HPOvq.js";var T=e(n(),1),E=t(),D=`provider/model`;function O(e){let{initialModel:t,initialWorkspace:n,isPending:u,modelHelpText:m,modelPlaceholder:g,onSubmit:_,providerCatalog:v,workspacePlaceholder:y}=e,[b,x]=(0,T.useState)(t),[w,D]=(0,T.useState)(n);return(0,E.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_({model:b,workspace:w})},className:`space-y-5`,children:[(0,E.jsx)(l,{children:(0,E.jsxs)(a,{children:[(0,E.jsx)(c,{title:r(`defaultModel`),description:m,layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(d,{htmlFor:`model`,className:`sr-only`,children:r(`defaultModel`)}),(0,E.jsx)(S,{id:`model`,value:b,onChange:x,providerCatalog:v,modelPlaceholder:g}),(0,E.jsx)(i,{href:h(`/guide/model-selection`),external:!0,icon:f,size:`xs`,children:r(`channelsGuideTitle`)})]})}),(0,E.jsx)(c,{title:r(`workspace`),layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(d,{htmlFor:`workspace`,className:`sr-only`,children:r(`workspace`)}),(0,E.jsx)(o,{id:`workspace`,value:w,onChange:e=>D(e.target.value),placeholder:y,className:`rounded-xl`})]})})]})}),(0,E.jsx)(C,{children:(0,E.jsx)(s,{type:`submit`,disabled:u,size:`sm`,children:u?(0,E.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`}):r(`saveChanges`)})})]})}function k(){let{data:e,isLoading:t}=x(),{data:n}=_(),{data:i}=y(),{data:a}=b(),o=g(),s=a?.uiHints,c=w(`agents.defaults.model`,s),l=w(`agents.defaults.workspace`,s),d=(0,T.useMemo)(()=>v({providersView:n,templatesView:i,config:e,onlyConfigured:!0}),[e,n,i]),f=r(`modelIdentifierHelp`)||c?.help||``,p=(e?.agents?.defaults?.model||``).trim(),h=e?.agents?.defaults?.workspace||``;return t?(0,E.jsx)(u,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsxs)(`div`,{className:`divide-y divide-border/55 overflow-hidden rounded-2xl bg-muted/45`,children:[(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]})]})}):(0,E.jsx)(u,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsx)(O,{initialModel:p,initialWorkspace:h,isPending:o.isPending,modelHelpText:f,modelPlaceholder:c?.placeholder??D,onSubmit:({model:e,workspace:t})=>o.mutate({model:e,workspace:t}),providerCatalog:d,workspacePlaceholder:l?.placeholder??`/path/to/workspace`},`${p}::${h}`)})}export{k as ModelConfigPage};
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-Co6JiC1n.js";import{t as i}from"./navigation-link-CAUiM3zS.js";import{an as a,dn as o,fn as s,in as c,on as l,sn as u,un as d}from"./api-m33O1Kb0.js";import{t as f}from"./book-open-BHiasMCg.js";import{t as p}from"./loader-circle-CH_0iPLy.js";import{t as m}from"./skeleton-BXFAE9SE.js";import{m as h}from"./doc-browser-context-Capim3og.js";import{A as g,E as _,L as v,T as y,g as b,m as x,t as S}from"./index-BjxnLYE3.js";import{t as C}from"./form-actions-CH0kWhEt.js";import{t as w}from"./config-hints-nV5HPOvq.js";var T=e(n(),1),E=t(),D=`provider/model`;function O(e){let{initialModel:t,initialWorkspace:n,isPending:u,modelHelpText:m,modelPlaceholder:g,onSubmit:_,providerCatalog:v,workspacePlaceholder:y}=e,[b,x]=(0,T.useState)(t),[w,D]=(0,T.useState)(n);return(0,E.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_({model:b,workspace:w})},className:`space-y-5`,children:[(0,E.jsx)(l,{children:(0,E.jsxs)(a,{children:[(0,E.jsx)(c,{title:r(`defaultModel`),description:m,layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(d,{htmlFor:`model`,className:`sr-only`,children:r(`defaultModel`)}),(0,E.jsx)(S,{id:`model`,value:b,onChange:x,providerCatalog:v,modelPlaceholder:g}),(0,E.jsx)(i,{href:h(`/guide/model-selection`),external:!0,icon:f,size:`xs`,children:r(`channelsGuideTitle`)})]})}),(0,E.jsx)(c,{title:r(`workspace`),layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(d,{htmlFor:`workspace`,className:`sr-only`,children:r(`workspace`)}),(0,E.jsx)(o,{id:`workspace`,value:w,onChange:e=>D(e.target.value),placeholder:y,className:`rounded-xl`})]})})]})}),(0,E.jsx)(C,{children:(0,E.jsx)(s,{type:`submit`,disabled:u,size:`sm`,children:u?(0,E.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`}):r(`saveChanges`)})})]})}function k(){let{data:e,isLoading:t}=x(),{data:n}=_(),{data:i}=y(),{data:a}=b(),o=g(),s=a?.uiHints,c=w(`agents.defaults.model`,s),l=w(`agents.defaults.workspace`,s),d=(0,T.useMemo)(()=>v({providersView:n,templatesView:i,config:e,onlyConfigured:!0}),[e,n,i]),f=r(`modelIdentifierHelp`)||c?.help||``,p=(e?.agents?.defaults?.model||``).trim(),h=e?.agents?.defaults?.workspace||``;return t?(0,E.jsx)(u,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsxs)(`div`,{className:`divide-y divide-border/55 overflow-hidden rounded-2xl bg-muted/45`,children:[(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]})]})}):(0,E.jsx)(u,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsx)(O,{initialModel:p,initialWorkspace:h,isPending:o.isPending,modelHelpText:f,modelPlaceholder:c?.placeholder??D,onSubmit:({model:e,workspace:t})=>o.mutate({model:e,workspace:t}),providerCatalog:d,workspacePlaceholder:l?.placeholder??`/path/to/workspace`},`${p}::${h}`)})}export{k as ModelConfigPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r}from"./react-BAzO6LZS.js";import{t as i}from"./preload-helper-D4M6sveU.js";import{t as a}from"./createLucideIcon-BxwVe8ZD.js";import{t as o}from"./host-capabilities-Tk038i04.js";var s=e(n(),1),c=`popstate`;function l(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=h(i?l().pathname:`/`,e,t,n);return f(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:g(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?_(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function u(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return h(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:g(t)}return v(t,n,null,e)}function d(e,t){if(e===!1||e==null)throw Error(t)}function f(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function p(){return Math.random().toString(36).substring(2,10)}function m(e,t){return{usr:e.state,key:e.key,idx:t}}function h(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?_(t):t,state:n,key:t&&t.key||r||p()}}function g({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function _(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function v(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,l=null,u=d();u??(u=0,o.replaceState({...o.state,idx:u},``));function d(){return(o.state||{idx:null}).idx}function f(){s=`POP`;let e=d(),t=e==null?null:e-u;u=e,l&&l({action:s,location:v.location,delta:t})}function p(e,t){s=`PUSH`;let r=h(v.location,e,t);n&&n(r,e),u=d()+1;let c=m(r,u),f=v.createHref(r);try{o.pushState(c,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&l&&l({action:s,location:v.location,delta:1})}function g(e,t){s=`REPLACE`;let r=h(v.location,e,t);n&&n(r,e),u=d();let i=m(r,u),c=v.createHref(r);o.replaceState(i,``,c),a&&l&&l({action:s,location:v.location,delta:0})}function _(e){return y(e)}let v={get action(){return s},get location(){return e(i,o)},listen(e){if(l)throw Error(`A history only accepts one active listener`);return i.addEventListener(c,f),l=e,()=>{i.removeEventListener(c,f),l=null}},createHref(e){return t(i,e)},createURL:_,encodeLocation(e){let t=_(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:p,replace:g,go(e){return o.go(e)}};return v}function y(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),d(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:g(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function b(e,t,n=`/`){return x(e,t,n,!1)}function x(e,t,n,r){let i=D((typeof t==`string`?_(t):t).pathname||`/`,n);if(i==null)return null;let a=C(e);T(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=de(i);o=le(a[e],t,r)}return o}function S(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function C(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;d(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=k([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(d(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),C(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:se(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of w(e.path))a(e,t,!0,n)}),t}function w(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=w(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function T(e){e.sort((e,t)=>e.score===t.score?ce(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ee=/^:[\w-]+$/,te=3,ne=2,re=1,ie=10,ae=-2,oe=e=>e===`*`;function se(e,t){let n=e.split(`/`),r=n.length;return n.some(oe)&&(r+=ae),t&&(r+=ne),n.filter(e=>!oe(e)).reduce((e,t)=>e+(ee.test(t)?te:t===``?re:ie),r)}function ce(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function le(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:k([a,u.pathname]),pathnameBase:ve(k([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=k([a,u.pathnameBase]))}return o}function E(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ue(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ue(e,t=!1,n=!0){f(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function de(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return f(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function D(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var fe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function pe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?_(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?me(n.substring(1),`/`):me(n,t)):a=t,{pathname:a,search:ye(r),hash:be(i)}}function me(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function he(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ge(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function O(e){let t=ge(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function _e(e,t,n,r=!1){let i;typeof e==`string`?i=_(e):(i={...e},d(!i.pathname||!i.pathname.includes(`?`),he(`?`,`pathname`,`search`,i)),d(!i.pathname||!i.pathname.includes(`#`),he(`#`,`pathname`,`hash`,i)),d(!i.search||!i.search.includes(`#`),he(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=pe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var k=e=>e.join(`/`).replace(/\/\/+/g,`/`),ve=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),ye=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,be=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,xe=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Se(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ce(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var we=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Te(e,t){let n=e;if(typeof n!=`string`||!fe.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(we)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=D(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{f(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ee=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ee);var De=[`GET`,...Ee];new Set(De);var A=s.createContext(null);A.displayName=`DataRouter`;var j=s.createContext(null);j.displayName=`DataRouterState`;var Oe=s.createContext(!1),ke=s.createContext({isTransitioning:!1});ke.displayName=`ViewTransition`;var Ae=s.createContext(new Map);Ae.displayName=`Fetchers`;var je=s.createContext(null);je.displayName=`Await`;var M=s.createContext(null);M.displayName=`Navigation`;var N=s.createContext(null);N.displayName=`Location`;var P=s.createContext({outlet:null,matches:[],isDataRoute:!1});P.displayName=`Route`;var Me=s.createContext(null);Me.displayName=`RouteError`;var Ne=`REACT_ROUTER_ERROR`,Pe=`REDIRECT`,Fe=`ROUTE_ERROR_RESPONSE`;function Ie(e){if(e.startsWith(`${Ne}:${Pe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Le(e){if(e.startsWith(`${Ne}:${Fe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new xe(t.status,t.statusText,t.data)}catch{}}function Re(e,{relative:t}={}){d(F(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=s.useContext(M),{hash:i,pathname:a,search:o}=R(e,{relative:t}),c=a;return n!==`/`&&(c=a===`/`?n:k([n,a])),r.createHref({pathname:c,search:o,hash:i})}function F(){return s.useContext(N)!=null}function I(){return d(F(),`useLocation() may be used only in the context of a <Router> component.`),s.useContext(N).location}var ze=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Be(e){s.useContext(M).static||s.useLayoutEffect(e)}function L(){let{isDataRoute:e}=s.useContext(P);return e?rt():Ve()}function Ve(){d(F(),`useNavigate() may be used only in the context of a <Router> component.`);let e=s.useContext(A),{basename:t,navigator:n}=s.useContext(M),{matches:r}=s.useContext(P),{pathname:i}=I(),a=JSON.stringify(O(r)),o=s.useRef(!1);return Be(()=>{o.current=!0}),s.useCallback((r,s={})=>{if(f(o.current,ze),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=_e(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:k([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}s.createContext(null);function He(){let{matches:e}=s.useContext(P),t=e[e.length-1];return t?t.params:{}}function R(e,{relative:t}={}){let{matches:n}=s.useContext(P),{pathname:r}=I(),i=JSON.stringify(O(n));return s.useMemo(()=>_e(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ue(e,t){return We(e,t)}function We(e,t,n,r,i){d(F(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=s.useContext(M),{matches:o}=s.useContext(P),c=o[o.length-1],l=c?c.params:{},u=c?c.pathname:`/`,p=c?c.pathnameBase:`/`,m=c&&c.route;{let e=m&&m.path||``;at(u,!m||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r}from"./react-Co6JiC1n.js";import{t as i}from"./preload-helper-D4M6sveU.js";import{t as a}from"./createLucideIcon-CHALGA42.js";import{t as o}from"./host-capabilities-Tk038i04.js";var s=e(n(),1),c=`popstate`;function l(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=h(i?l().pathname:`/`,e,t,n);return f(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:g(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?_(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function u(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return h(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:g(t)}return v(t,n,null,e)}function d(e,t){if(e===!1||e==null)throw Error(t)}function f(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function p(){return Math.random().toString(36).substring(2,10)}function m(e,t){return{usr:e.state,key:e.key,idx:t}}function h(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?_(t):t,state:n,key:t&&t.key||r||p()}}function g({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function _(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function v(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,l=null,u=d();u??(u=0,o.replaceState({...o.state,idx:u},``));function d(){return(o.state||{idx:null}).idx}function f(){s=`POP`;let e=d(),t=e==null?null:e-u;u=e,l&&l({action:s,location:v.location,delta:t})}function p(e,t){s=`PUSH`;let r=h(v.location,e,t);n&&n(r,e),u=d()+1;let c=m(r,u),f=v.createHref(r);try{o.pushState(c,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&l&&l({action:s,location:v.location,delta:1})}function g(e,t){s=`REPLACE`;let r=h(v.location,e,t);n&&n(r,e),u=d();let i=m(r,u),c=v.createHref(r);o.replaceState(i,``,c),a&&l&&l({action:s,location:v.location,delta:0})}function _(e){return y(e)}let v={get action(){return s},get location(){return e(i,o)},listen(e){if(l)throw Error(`A history only accepts one active listener`);return i.addEventListener(c,f),l=e,()=>{i.removeEventListener(c,f),l=null}},createHref(e){return t(i,e)},createURL:_,encodeLocation(e){let t=_(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:p,replace:g,go(e){return o.go(e)}};return v}function y(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),d(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:g(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function b(e,t,n=`/`){return x(e,t,n,!1)}function x(e,t,n,r){let i=D((typeof t==`string`?_(t):t).pathname||`/`,n);if(i==null)return null;let a=C(e);T(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=de(i);o=le(a[e],t,r)}return o}function S(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function C(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;d(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=k([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(d(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),C(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:se(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of w(e.path))a(e,t,!0,n)}),t}function w(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=w(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function T(e){e.sort((e,t)=>e.score===t.score?ce(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ee=/^:[\w-]+$/,te=3,ne=2,re=1,ie=10,ae=-2,oe=e=>e===`*`;function se(e,t){let n=e.split(`/`),r=n.length;return n.some(oe)&&(r+=ae),t&&(r+=ne),n.filter(e=>!oe(e)).reduce((e,t)=>e+(ee.test(t)?te:t===``?re:ie),r)}function ce(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function le(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:k([a,u.pathname]),pathnameBase:ve(k([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=k([a,u.pathnameBase]))}return o}function E(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ue(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ue(e,t=!1,n=!0){f(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function de(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return f(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function D(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var fe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function pe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?_(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?me(n.substring(1),`/`):me(n,t)):a=t,{pathname:a,search:ye(r),hash:be(i)}}function me(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function he(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ge(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function O(e){let t=ge(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function _e(e,t,n,r=!1){let i;typeof e==`string`?i=_(e):(i={...e},d(!i.pathname||!i.pathname.includes(`?`),he(`?`,`pathname`,`search`,i)),d(!i.pathname||!i.pathname.includes(`#`),he(`#`,`pathname`,`hash`,i)),d(!i.search||!i.search.includes(`#`),he(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=pe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var k=e=>e.join(`/`).replace(/\/\/+/g,`/`),ve=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),ye=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,be=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,xe=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Se(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ce(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var we=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Te(e,t){let n=e;if(typeof n!=`string`||!fe.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(we)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=D(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{f(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ee=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ee);var De=[`GET`,...Ee];new Set(De);var A=s.createContext(null);A.displayName=`DataRouter`;var j=s.createContext(null);j.displayName=`DataRouterState`;var Oe=s.createContext(!1),ke=s.createContext({isTransitioning:!1});ke.displayName=`ViewTransition`;var Ae=s.createContext(new Map);Ae.displayName=`Fetchers`;var je=s.createContext(null);je.displayName=`Await`;var M=s.createContext(null);M.displayName=`Navigation`;var N=s.createContext(null);N.displayName=`Location`;var P=s.createContext({outlet:null,matches:[],isDataRoute:!1});P.displayName=`Route`;var Me=s.createContext(null);Me.displayName=`RouteError`;var Ne=`REACT_ROUTER_ERROR`,Pe=`REDIRECT`,Fe=`ROUTE_ERROR_RESPONSE`;function Ie(e){if(e.startsWith(`${Ne}:${Pe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Le(e){if(e.startsWith(`${Ne}:${Fe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new xe(t.status,t.statusText,t.data)}catch{}}function Re(e,{relative:t}={}){d(F(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=s.useContext(M),{hash:i,pathname:a,search:o}=R(e,{relative:t}),c=a;return n!==`/`&&(c=a===`/`?n:k([n,a])),r.createHref({pathname:c,search:o,hash:i})}function F(){return s.useContext(N)!=null}function I(){return d(F(),`useLocation() may be used only in the context of a <Router> component.`),s.useContext(N).location}var ze=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Be(e){s.useContext(M).static||s.useLayoutEffect(e)}function L(){let{isDataRoute:e}=s.useContext(P);return e?rt():Ve()}function Ve(){d(F(),`useNavigate() may be used only in the context of a <Router> component.`);let e=s.useContext(A),{basename:t,navigator:n}=s.useContext(M),{matches:r}=s.useContext(P),{pathname:i}=I(),a=JSON.stringify(O(r)),o=s.useRef(!1);return Be(()=>{o.current=!0}),s.useCallback((r,s={})=>{if(f(o.current,ze),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=_e(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:k([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}s.createContext(null);function He(){let{matches:e}=s.useContext(P),t=e[e.length-1];return t?t.params:{}}function R(e,{relative:t}={}){let{matches:n}=s.useContext(P),{pathname:r}=I(),i=JSON.stringify(O(n));return s.useMemo(()=>_e(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ue(e,t){return We(e,t)}function We(e,t,n,r,i){d(F(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=s.useContext(M),{matches:o}=s.useContext(P),c=o[o.length-1],l=c?c.params:{},u=c?c.pathname:`/`,p=c?c.pathnameBase:`/`,m=c&&c.route;{let e=m&&m.path||``;at(u,!m||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
2
 
3
3
  Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let h=I(),g;if(t){let e=typeof t==`string`?_(t):t;d(p===`/`||e.pathname?.startsWith(p),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${e.pathname}" was given in the \`location\` prop.`),g=e}else g=h;let v=g.pathname||`/`,y=v;if(p!==`/`){let e=p.replace(/^\//,``).split(`/`);y=`/`+v.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let x=b(e,{pathname:y});f(m||x!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),f(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Xe(x&&x.map(e=>Object.assign({},e,{params:Object.assign({},l,e.params),pathname:k([p,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?p:k([p,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&S?s.createElement(N.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...g},navigationType:`POP`}},S):S}function Ge(){let e=nt(),t=Se(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=s.createElement(s.Fragment,null,s.createElement(`p`,null,`💿 Hey developer 👋`),s.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,s.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,s.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),s.createElement(s.Fragment,null,s.createElement(`h2`,null,`Unexpected Application Error!`),s.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?s.createElement(`pre`,{style:i},n):null,o)}var Ke=s.createElement(Ge,null),qe=class extends s.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Le(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:s.createElement(P.Provider,{value:this.props.routeContext},s.createElement(Me.Provider,{value:e,children:this.props.component}));return this.context?s.createElement(Je,{error:e},t):t}};qe.contextType=Oe;var z=new WeakMap;function Je({children:e,error:t}){let{basename:n}=s.useContext(M);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ie(t.digest);if(e){let r=z.get(t);if(r)throw r;let i=Te(e.location,n);if(we&&!z.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw z.set(t,n),n}return s.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Ye({routeContext:e,match:t,children:n}){let r=s.useContext(A);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),s.createElement(P.Provider,{value:e},n)}function Xe(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);d(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let c=!1,l=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(l=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){c=!0,a=l>=0?a.slice(0,l+1):[a[0]];break}}}let u=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Ce(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let d,f=!1,p=null,m=null;n&&(d=o&&r.route.id?o[r.route.id]:void 0,p=r.route.errorElement||Ke,c&&(l<0&&i===0?(at(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):l===i&&(f=!0,m=r.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,i+1)),g=()=>{let t;return t=d?p:f?m:r.route.Component?s.createElement(r.route.Component,null):r.route.element?r.route.element:e,s.createElement(Ye,{match:r,routeContext:{outlet:e,matches:h,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?s.createElement(qe,{location:n.location,revalidation:n.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function B(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ze(e){let t=s.useContext(A);return d(t,B(e)),t}function V(e){let t=s.useContext(j);return d(t,B(e)),t}function Qe(e){let t=s.useContext(P);return d(t,B(e)),t}function H(e){let t=Qe(e),n=t.matches[t.matches.length-1];return d(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function $e(){return H(`useRouteId`)}function et(){return V(`useNavigation`).navigation}function tt(){let{matches:e,loaderData:t}=V(`useMatches`);return s.useMemo(()=>e.map(e=>S(e,t)),[e,t])}function nt(){let e=s.useContext(Me),t=V(`useRouteError`),n=H(`useRouteError`);return e===void 0?t.errors?.[n]:e}function rt(){let{router:e}=Ze(`useNavigate`),t=H(`useNavigate`),n=s.useRef(!1);return Be(()=>{n.current=!0}),s.useCallback(async(r,i={})=>{f(n.current,ze),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var it={};function at(e,t,n){!t&&!it[e]&&(it[e]=!0,f(!1,n))}s.useOptimistic,s.memo(ot);function ot({routes:e,future:t,state:n,onError:r}){return We(e,void 0,n,r,t)}function st({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=s.useRef();a.current??=l({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[c,u]=s.useState({action:o.action,location:o.location}),d=s.useCallback(e=>{i===!1?u(e):s.startTransition(()=>u(e))},[i]);return s.useLayoutEffect(()=>o.listen(d),[o,d]),s.createElement(U,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:o,unstable_useTransitions:i})}function ct({to:e,replace:t,state:n,relative:r}){d(F(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=s.useContext(M);f(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=s.useContext(P),{pathname:o}=I(),c=L(),l=_e(e,O(a),o,r===`path`),u=JSON.stringify(l);return s.useEffect(()=>{c(JSON.parse(u),{replace:t,state:n,relative:r})},[c,u,r,t,n]),null}function lt(e){d(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function U({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){d(!F(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=s.useMemo(()=>({basename:c,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[c,i,a,o]);typeof n==`string`&&(n=_(n));let{pathname:u=`/`,search:p=``,hash:m=``,state:h=null,key:g=`default`}=n,v=s.useMemo(()=>{let e=D(u,c);return e==null?null:{location:{pathname:e,search:p,hash:m,state:h,key:g},navigationType:r}},[c,u,p,m,h,g,r]);return f(v!=null,`<Router basename="${c}"> is not able to match the URL "${u}${p}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:s.createElement(M.Provider,{value:l},s.createElement(N.Provider,{children:t,value:v}))}function ut({children:e,location:t}){return Ue(W(e),t)}s.Component;function W(e,t=[]){let n=[];return s.Children.forEach(e,(e,r)=>{if(!s.isValidElement(e))return;let i=[...t,r];if(e.type===s.Fragment){n.push.apply(n,W(e.props.children,i));return}d(e.type===lt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),d(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=W(e.props.children,i)),n.push(a)}),n}var G=`get`,K=`application/x-www-form-urlencoded`;function q(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function dt(e){return q(e)&&e.tagName.toLowerCase()===`button`}function ft(e){return q(e)&&e.tagName.toLowerCase()===`form`}function pt(e){return q(e)&&e.tagName.toLowerCase()===`input`}function mt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ht(e,t){return e.button===0&&(!t||t===`_self`)&&!mt(e)}var J=null;function gt(){if(J===null)try{new FormData(document.createElement(`form`),0),J=!1}catch{J=!0}return J}var _t=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function vt(e){return e!=null&&!_t.has(e)?(f(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${K}"`),null):e}function yt(e,t){let n,r,i,a,o;if(ft(e)){let o=e.getAttribute(`action`);r=o?D(o,t):null,n=e.getAttribute(`method`)||G,i=vt(e.getAttribute(`enctype`))||K,a=new FormData(e)}else if(dt(e)||pt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?D(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||G,i=vt(e.getAttribute(`formenctype`))||vt(o.getAttribute(`enctype`))||K,a=new FormData(o,e),!gt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(q(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=G,r=null,i=K,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var bt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},xt=/[&><\u2028\u2029]/g;function St(e){return e.replace(xt,e=>bt[e])}function Ct(e,t){if(e===!1||e==null)throw Error(t)}function wt(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&D(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function Tt(e,t){if(e.id in t)return t[e.id];try{let n=await i(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Et(e){return e!=null&&typeof e.page==`string`}function Dt(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Ot(e,t,n){return Nt((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Tt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Dt).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function kt(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function At(e,t,{includeHydrateFallback:n}={}){return jt(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function jt(e){return[...new Set(e)]}function Mt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Nt(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Et(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Mt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Pt(){let e=s.useContext(A);return Ct(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Ft(){let e=s.useContext(j);return Ct(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Y=s.createContext(void 0);Y.displayName=`FrameworkContext`;function It(){let e=s.useContext(Y);return Ct(e,`You must render this element inside a <HydratedRouter> element`),e}function Lt(e,t){let n=s.useContext(Y),[r,i]=s.useState(!1),[a,o]=s.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=t,p=s.useRef(null);s.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),s.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:X(c,m),onBlur:X(l,h),onMouseEnter:X(u,m),onMouseLeave:X(d,h),onTouchStart:X(f,m)}]:[a,p,{}]:[!1,p,{}]}function X(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Rt({page:e,...t}){let{router:n}=Pt(),r=s.useMemo(()=>b(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?s.createElement(Bt,{page:e,matches:r,...t}):null}function zt(e){let{manifest:t,routeModules:n}=It(),[r,i]=s.useState([]);return s.useEffect(()=>{let r=!1;return Ot(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Bt({page:e,matches:t,...n}){let r=I(),{future:i,manifest:a,routeModules:o}=It(),{basename:c}=Pt(),{loaderData:l,matches:u}=Ft(),d=s.useMemo(()=>kt(e,t,u,a,r,`data`),[e,t,u,a,r]),f=s.useMemo(()=>kt(e,t,u,a,r,`assets`),[e,t,u,a,r]),p=s.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,s=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!d.some(t=>t.route.id===e.route.id)&&e.route.id in l&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?s=!0:n.add(e.route.id))}),n.size===0)return[];let u=wt(e,c,i.unstable_trailingSlashAwareDataRequests,`data`);return s&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,i.unstable_trailingSlashAwareDataRequests,l,r,a,d,t,e,o]),m=s.useMemo(()=>At(f,a),[f,a]),h=zt(f);return s.createElement(s.Fragment,null,p.map(e=>s.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>s.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>s.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Vt(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}s.Component;var Ht=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Ht&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Ut({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=s.useRef();i.current??=u({window:r,v5Compat:!0});let a=i.current,[o,c]=s.useState({action:a.action,location:a.location}),l=s.useCallback(e=>{n===!1?c(e):s.startTransition(()=>c(e))},[n]);return s.useLayoutEffect(()=>a.listen(l),[a,l]),s.createElement(U,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Wt({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=s.useState({action:n.action,location:n.location}),o=s.useCallback(e=>{r===!1?a(e):s.startTransition(()=>a(e))},[r]);return s.useLayoutEffect(()=>n.listen(o),[n,o]),s.createElement(U,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Wt.displayName=`unstable_HistoryRouter`;var Gt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Z=s.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,unstable_useTransitions:g}=s.useContext(M),_=typeof l==`string`&&Gt.test(l),v=Te(l,h);l=v.to;let y=Re(l,{relative:r}),[b,x,S]=Lt(n,p),C=Qt(l,{replace:a,state:o,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:g});function w(t){e&&e(t),t.defaultPrevented||C(t)}let T=s.createElement(`a`,{...p,...S,href:v.absoluteURL||y,onClick:v.isExternal||i?e:w,ref:Vt(m,x),target:c,"data-discover":!_&&t===`render`?`true`:void 0});return b&&!_?s.createElement(s.Fragment,null,T,s.createElement(Rt,{page:y})):T});Z.displayName=`Link`;var Kt=s.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:c,...l},u){let d=R(a,{relative:l.relative}),f=I(),p=s.useContext(j),{navigator:m,basename:h}=s.useContext(M),g=p!=null&&cn(d)&&o===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=D(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let ee=typeof i==`function`?i(C):i;return s.createElement(Z,{...l,"aria-current":w,className:T,ref:u,style:ee,to:a,viewTransition:o},typeof c==`function`?c(C):c)});Kt.displayName=`NavLink`;var qt=s.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=G,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},h)=>{let{unstable_useTransitions:g}=s.useContext(M),_=tn(),v=nn(c,{relative:u}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof c==`string`&&Gt.test(c);return s.createElement(`form`,{ref:h,method:y,action:v,onSubmit:r?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,c=r?.getAttribute(`formmethod`)||o,m=()=>_(r||e.currentTarget,{fetcherKey:t,method:c,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});g&&n!==!1?s.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});qt.displayName=`Form`;function Jt({getKey:e,storageKey:t,...n}){let r=s.useContext(Y),{basename:i}=s.useContext(M),a=I(),o=tt();on({getKey:e,storageKey:t});let c=s.useMemo(()=>{if(!r||!e)return null;let t=an(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return s.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${St(JSON.stringify(t||rn))}, ${St(JSON.stringify(c))})`}})}Jt.displayName=`ScrollRestoration`;function Yt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xt(e){let t=s.useContext(A);return d(t,Yt(e)),t}function Zt(e){let t=s.useContext(j);return d(t,Yt(e)),t}function Qt(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=L(),d=I(),f=R(e,{relative:a});return s.useCallback(p=>{if(ht(p,t)){p.preventDefault();let t=n===void 0?g(d)===g(f):n,m=()=>u(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:c});l?s.startTransition(()=>m()):m()}},[d,u,f,n,r,t,e,i,a,o,c,l])}var $t=0,en=()=>`__${String(++$t)}__`;function tn(){let{router:e}=Xt(`useSubmit`),{basename:t}=s.useContext(M),n=$e(),r=e.fetch,i=e.navigate;return s.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=yt(e,t);a.navigate===!1?await r(a.fetcherKey||en(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function nn(e,{relative:t}={}){let{basename:n}=s.useContext(M),r=s.useContext(P);d(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...R(e||`.`,{relative:t})},o=I();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:k([n,a.pathname])),g(a)}var rn=`react-router-scroll-positions`,Q={};function an(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:D(e.pathname,n)||e.pathname},t)),i??=e.key,i}function on({getKey:e,storageKey:t}={}){let{router:n}=Xt(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Zt(`useScrollRestoration`),{basename:a}=s.useContext(M),o=I(),c=tt(),l=et();s.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),sn(s.useCallback(()=>{if(l.state===`idle`){let t=an(o,c,a,e);Q[t]=window.scrollY}try{sessionStorage.setItem(t||rn,JSON.stringify(Q))}catch(e){f(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,a,o,c,t])),typeof document<`u`&&(s.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||rn);e&&(Q=JSON.parse(e))}catch{}},[t]),s.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Q,()=>window.scrollY,e?(t,n)=>an(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),s.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{f(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function sn(e,t){let{capture:n}=t||{};s.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function cn(e,{relative:t}={}){let n=s.useContext(ke);d(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Xt(`useViewTransitionState`),i=R(e,{relative:t});if(!n.isTransitioning)return!1;let a=D(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=D(n.nextLocation.pathname,r)||n.nextLocation.pathname;return E(i.pathname,o)!=null||E(i.pathname,a)!=null}var ln=a(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),$=t(),un={xs:`gap-1.5 text-xs`,sm:`gap-1.5 text-sm`},dn={xs:`h-3.5 w-3.5`,sm:`h-4 w-4`};function fn(e){return e.button===0&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey}function pn(e){return Array.from(new Set(`${e??``} noopener noreferrer`.trim().split(/\s+/))).join(` `)}function mn(e){try{let t=new URL(e,window.location.href);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}}var hn=(0,s.forwardRef)(function({children:e,className:t,external:n=!1,href:i,icon:a,iconPosition:s=`leading`,onClick:c,rel:l,size:u=`sm`,target:d,...f},p){let m=a===void 0&&n?ln:a,h=r(`inline-flex items-center rounded-sm font-medium text-primary underline-offset-4 transition-colors hover:text-primary-hover hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,un[u],t),g=m?(0,$.jsx)(m,{"aria-hidden":`true`,className:r(`shrink-0`,dn[u])}):null,_=(0,$.jsxs)($.Fragment,{children:[s===`leading`?g:null,e,s===`trailing`?g:null]});return n?(0,$.jsx)(`a`,{ref:p,...f,href:i,target:d??`_blank`,rel:pn(l),className:h,onClick:e=>{c?.(e);let t=mn(i);t&&!e.defaultPrevented&&fn(e)&&(e.preventDefault(),o.openExternalUrl(t))},children:_}):(0,$.jsx)(Z,{ref:p,...f,to:i,target:d,rel:l,className:h,onClick:c,children:_})});export{st as a,lt as c,L as d,He as f,Z as i,ut as l,ln as n,Kt as o,Ut as r,ct as s,hn as t,I as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-CHALGA42.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +1 @@
1
- import{B as e,a as t}from"./react-BAzO6LZS.js";import{Ht as n,an as r,in as i,on as a,sn as o}from"./api-DNLQPHfQ.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-BVgD4EpG.js";import{C as f,j as p,m}from"./index-D25tRg1p.js";var h=e();function g(){let e=m(),g=f(),v=p(),y=e.data?.productAnalytics.enabled??!0,b=e.data?.productAnalytics.audience??`external`,x=e=>{v.mutate({data:{enabled:e}})},S=e=>{let t=e;v.mutate({data:{audience:t}})};return(0,h.jsxs)(o,{title:t(`privacyPageTitle`),description:t(`privacyPageDescription`),children:[(0,h.jsx)(a,{title:t(`productAnalyticsSectionTitle`),description:t(`productAnalyticsSectionDescription`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{title:t(`productAnalyticsEnabledTitle`),description:t(`productAnalyticsEnabledDescription`),control:(0,h.jsx)(n,{"aria-label":t(`productAnalyticsEnabledTitle`),checked:y,disabled:e.isLoading||v.isPending,onCheckedChange:x})}),(0,h.jsx)(i,{title:t(`productAnalyticsAudienceTitle`),description:t(`productAnalyticsAudienceDescription`),control:(0,h.jsxs)(d,{value:b,onValueChange:S,disabled:e.isLoading||v.isPending,children:[(0,h.jsx)(c,{"aria-label":t(`productAnalyticsAudienceTitle`),className:`w-40 sm:w-48`,children:(0,h.jsx)(s,{})}),(0,h.jsxs)(l,{children:[(0,h.jsx)(u,{value:`external`,children:t(`productAnalyticsAudienceExternal`)}),(0,h.jsx)(u,{value:`internal`,children:t(`productAnalyticsAudienceInternal`)}),(0,h.jsx)(u,{value:`qa`,children:t(`productAnalyticsAudienceQa`)})]})]})})]})}),(0,h.jsx)(a,{title:t(`productAnalyticsDataTitle`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsCollectedTitle`),description:t(`productAnalyticsCollectedDescription`)}),(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsExcludedTitle`),description:t(`productAnalyticsExcludedDescription`)}),(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsAnonymousTitle`),description:t(`productAnalyticsAnonymousDescription`)})]})}),(0,h.jsx)(a,{title:t(`productAnalyticsStatusSectionTitle`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsStatusTitle`),description:_(g.data,g.isLoading)}),g.data?.lastError?(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsLastErrorTitle`),description:g.data.lastError}):null]})})]})}function _(e,n){if(n)return t(`productAnalyticsStatusLoading`);if(!e?.lastAttemptAt)return t(`productAnalyticsStatusNever`);let r=new Date(e.lastAttemptAt).toLocaleString();if(!e.lastSuccessAt)return`${t(`productAnalyticsLastAttemptLabel`)} ${r} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`;let i=new Date(e.lastSuccessAt).toLocaleString();return`${t(`productAnalyticsLastSuccessLabel`)} ${i} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`}export{g as PrivacySettingsPage};
1
+ import{B as e,a as t}from"./react-Co6JiC1n.js";import{Ht as n,an as r,in as i,on as a,sn as o}from"./api-m33O1Kb0.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-BzQKfW1e.js";import{C as f,j as p,m}from"./index-BjxnLYE3.js";var h=e();function g(){let e=m(),g=f(),v=p(),y=e.data?.productAnalytics.enabled??!0,b=e.data?.productAnalytics.audience??`external`,x=e=>{v.mutate({data:{enabled:e}})},S=e=>{let t=e;v.mutate({data:{audience:t}})};return(0,h.jsxs)(o,{title:t(`privacyPageTitle`),description:t(`privacyPageDescription`),children:[(0,h.jsx)(a,{title:t(`productAnalyticsSectionTitle`),description:t(`productAnalyticsSectionDescription`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{title:t(`productAnalyticsEnabledTitle`),description:t(`productAnalyticsEnabledDescription`),control:(0,h.jsx)(n,{"aria-label":t(`productAnalyticsEnabledTitle`),checked:y,disabled:e.isLoading||v.isPending,onCheckedChange:x})}),(0,h.jsx)(i,{title:t(`productAnalyticsAudienceTitle`),description:t(`productAnalyticsAudienceDescription`),control:(0,h.jsxs)(d,{value:b,onValueChange:S,disabled:e.isLoading||v.isPending,children:[(0,h.jsx)(c,{"aria-label":t(`productAnalyticsAudienceTitle`),className:`w-40 sm:w-48`,children:(0,h.jsx)(s,{})}),(0,h.jsxs)(l,{children:[(0,h.jsx)(u,{value:`external`,children:t(`productAnalyticsAudienceExternal`)}),(0,h.jsx)(u,{value:`internal`,children:t(`productAnalyticsAudienceInternal`)}),(0,h.jsx)(u,{value:`qa`,children:t(`productAnalyticsAudienceQa`)})]})]})})]})}),(0,h.jsx)(a,{title:t(`productAnalyticsDataTitle`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsCollectedTitle`),description:t(`productAnalyticsCollectedDescription`)}),(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsExcludedTitle`),description:t(`productAnalyticsExcludedDescription`)}),(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsAnonymousTitle`),description:t(`productAnalyticsAnonymousDescription`)})]})}),(0,h.jsx)(a,{title:t(`productAnalyticsStatusSectionTitle`),children:(0,h.jsxs)(r,{children:[(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsStatusTitle`),description:_(g.data,g.isLoading)}),g.data?.lastError?(0,h.jsx)(i,{layout:`stacked`,title:t(`productAnalyticsLastErrorTitle`),description:g.data.lastError}):null]})})]})}function _(e,n){if(n)return t(`productAnalyticsStatusLoading`);if(!e?.lastAttemptAt)return t(`productAnalyticsStatusNever`);let r=new Date(e.lastAttemptAt).toLocaleString();if(!e.lastSuccessAt)return`${t(`productAnalyticsLastAttemptLabel`)} ${r} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`;let i=new Date(e.lastSuccessAt).toLocaleString();return`${t(`productAnalyticsLastSuccessLabel`)} ${i} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`}export{g as PrivacySettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,s as a}from"./react-BAzO6LZS.js";import{An as o,Ht as s,_n as c,dn as l,fn as u,rn as d,sn as f,un as p}from"./api-DNLQPHfQ.js";import{C as m,a as h,i as g,n as _,r as v,t as y}from"./select-BVgD4EpG.js";import{c as b,l as x,t as S}from"./confirm-dialog-CZIWjnJ6.js";import{t as C}from"./createLucideIcon-BxwVe8ZD.js";import{t as w}from"./search-Cv1Hx_nx.js";import{t as T}from"./loader-circle-BoyCoFps.js";import{t as E}from"./plus-D1R4Vipq.js";import{t as D}from"./refresh-cw-BCj-yjde.js";import{t as O}from"./x-BWDRfVWL.js";import{t as k}from"./host-capabilities-Tk038i04.js";import{B as A,D as j,Dt as M,E as N,Et as P,I as F,M as I,O as L,R,S as ee,St as te,T as z,Tt as ne,V as B,X as V,Y as H,Z as U,_ as re,g as W,ht as G,mt as K,p as ie,q,v as ae,vt as J,w as oe,x as se,y as ce,z as le}from"./index-D25tRg1p.js";import{t as ue}from"./form-actions-FWCEof3V.js";import{t as de}from"./config-hints-nV5HPOvq.js";import{a as fe,c as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye}from"./config-split-page-Dd8xG0Jk.js";var be=C(`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`}]]),xe=C(`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`}]]),Y=e(n(),1),Se={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(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 Ce(e,t){let n=X(e),r=X(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 Z(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 we(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 Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=we(n,t))}return n.trim()}function Te(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ee(e,t){return Z(t)}function De(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Oe(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=A(i.thinking?.supported);if(a.length>0){let t=B(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 ke(e,t,n){return{...le(e,n),...le(t,n)}}function Ae(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||!Te([...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 je(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Ce(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!Te(e.models,e.currentEditableModels)||!Ae(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Me(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(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),Ce(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),Te(e.models,e.currentEditableModels)||(t.models=De(e.models,e.providerName??``)),Ae(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Oe(e.modelConfig,e.models)),t}function Ne(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Pe(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Pe(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Fe(e){return i(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ie(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 Le(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Re(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function ze(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function Be(e,t,n){return ze(e,t,n).models.slice(e.length)}function Ve(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function He(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):F.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 Ue(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 We(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 Ge(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:Ie({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:Le({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Ke(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:i(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:Le({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function qe(e){let{providerName:t,providersView:n,templatesView:r,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=r?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??Se,u=a?.uiHints,d=!!s?.isCustom,f=t?de(`providers.${t}.apiKey`,u):void 0,p=t?de(`providers.${t}.apiBase`,u):void 0,m=t?de(`providers.${t}.extraHeaders`,u):void 0,h=t?de(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=d||c?.supportsModelDiscovery===!0,b=Z([c?.modelPrefix||c?.providerType||``,t||``]),x=c?.defaultApiBase||``,S=l.apiBase||x,C=X(l.extraHeaders||null),w=l.wireApi||c?.defaultWireApi||`auto`,T=Ee(Z((c?.defaultModels??[]).map(e=>Q(e,b))),Z((l.models??[]).map(e=>Q(e,b)))),E=Oe(ke(c?.modelConfig,l.modelConfig,b),T),D=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||i(`providerApiBaseHelp`),O=Ge({providerName:t,providerSpec:c,language:o}),k=Ke(c,d);return{apiBaseHelpText:D,apiBaseHint:p,apiKeyHint:f,currentApiBase:S,currentEditableModels:T,currentEnabled:v,currentHeaders:C,currentModelConfig:E,currentWireApi:w,defaultApiBase:x,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...O,providerConfig:s,providerModelAliases:b,resolvedProviderConfig:l,supportsModelDiscovery:y,wireApiHint:h,...k}}function Je(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=o(),s=j(),l=ee(),u=se(),[d,f]=(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 r=await l.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){g(i(`providerAuthWaitingBrowser`)),y(e,r.nextPollMs??n);return}if(r.status===`authorized`){m(null),v(),g(i(`providerAuthCompleted`)),c.success(i(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(r.message||`Authorization ${r.status}.`),c.error(r.message||`Authorization ${r.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),c.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,l,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),g(``);let e=await s.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(i(`providerAuthStartFailed`));m(e.sessionId),g(`${i(`providerAuthOpenPrompt`)}${e.userCode}${i(`providerAuthOpenPromptSuffix`)}`),await k.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),c.error(`${i(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,r,y,s]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),v(),m(null);let e=await u.mutateAsync({provider:t});g(`${i(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),c.success(i(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),c.error(`${i(`providerAuthImportFailed`)}: ${t}`)}},[v,u,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:d===t?p:null,authStatusMessage:d===t?h:``,importAuthFromCli:x,importPending:u.isPending,startAuth:b,startPending:s.isPending}}function Ye(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:f,providerModelAliases:p}=e,m=L(),h=ce(),g=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[_,v]=(0,Y.useState)(null),y=(0,Y.useCallback)(async()=>{if(t)try{let e=await m.mutateAsync({provider:t,data:Ne({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:f,providerModelAliases:p})});if(e.success){c.success(`${i(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),c.error(`${i(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);c.error(`${i(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,f,p,t,l,m,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return c.error(i(`providerModelsApiKeyRequired`)),null;try{let e=await h.mutateAsync({provider:t,data:Pe({apiKey:n,apiBase:o,extraHeaders:s})});return v({key:g,models:e.models}),c.success(i(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof d&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return c.error(i(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return c.error(`${i(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,h,g,s,t]),fetchedModels:_?.key===g?_.models:[],isDiscoveringModels:h.isPending,isTestPending:m.isPending,testConnection:y}}var $=t();function Xe({value:e,onChange:t,className:n}){let a=e?Object.entries(e):[],o=(e,n,r)=>{let i=[...a];i[e]=[n,r],t(Object.fromEntries(i))},s=()=>{t({...e,"":``})},c=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,$.jsxs)(`div`,{className:r(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(l,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:i(`headerName`),className:`flex-1`}),(0,$.jsx)(l,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:i(`headerValue`),className:`flex-1`}),(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>c(n),children:(0,$.jsx)(G,{className:`h-4 w-4 text-red-500`})})]},n)),(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),i(`add`)]})]})}function Ze(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.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-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:e.label},e.value)})})}function Qe(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:r,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.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,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`h-3.5 w-3.5`}),i(`providerAdvancedSettings`)]}),(0,$.jsx)(m,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[r?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)(Ze,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(y,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(g,{className:`rounded-xl`,children:(0,$.jsx)(h,{})}),(0,$.jsx)(_,{children:l.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Xe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerExtraHeadersHelpShort`)})]})]}):null]})}function $e({isSet:e,className:t,value:n,onChange:i,placeholder:a,...o}){let[s,c]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:r(`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,$.jsx)(l,{type:s?`text`:`password`,className:r(`pr-12`,t),value:n,onChange:i,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...o}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>c(!s),children:s?(0,$.jsx)(xe,{className:`h-4 w-4`}):(0,$.jsx)(ne,{className:`h-4 w-4`})})})]})}function et(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:r,apiKeyPlaceholder:a,providerAuth:o,providerAuthNote:s,providerAuthMethodOptions:c,providerAuthMethodsCount:l,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:m,onAuthMethodChange:b,onStartProviderAuth:x,onImportProviderAuthFromCli:S,startPending:C,importPending:w,authSessionId:T,authStatusMessage:E,onApiKeyChange:D}=e,O=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:i(`apiKey`)}),(0,$.jsx)($e,{id:`apiKey`,value:t,isSet:r,onChange:e=>D(e.target.value),placeholder:a,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`leaveBlankToKeepUnchanged`)})]}):null;return o?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[O,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:o.displayName||i(`providerAuthSectionTitle`)}),s?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}):null,l>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{className:`text-xs font-medium text-foreground`,children:i(`providerAuthMethodLabel`)}),f?(0,$.jsx)(Ze,{value:m,onChange:b,options:c}):(0,$.jsxs)(y,{value:m,onValueChange:b,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg`,children:(0,$.jsx)(h,{placeholder:i(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(_,{children:c.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:x,disabled:C||!!T,children:i(C?`providerAuthStarting`:T?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),o.supportsCliImport?(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:S,disabled:w,children:i(w?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,T?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i(`providerAuthSessionLabel`),`: `,T.slice(0,8),`…`]}):null]}),E?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E}):null]})]}):O}function tt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=oe({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>Be(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=ze(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function nt(e){let{models:t,modelConfig:n,onModelsChange:r,onRemoveModel:a,onToggleModelThinkingLevel:o,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,m]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(()=>new Set),S=(0,Y.useMemo)(()=>t.filter(e=>b.has(e)),[t,b]),C=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=()=>{m(!1),x(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(S.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>x(S.length===t.length?new Set:new Set(t)),children:i(S.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:w,children:i(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:S.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{S.length!==0&&(r(t.filter(e=>!b.has(e))),w())},children:[(0,$.jsx)(G,{className:`h-3 w-3`}),i(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>m(!0),children:[(0,$.jsx)(G,{className:`h-3 w-3`}),i(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b.has(e),onChange:()=>C(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=n[e],r=t?.thinking,m=r?.supported??[],x=r?.default??null,S=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.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-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`providerModelThinkingTitle`),title:i(`providerModelThinkingTitle`),children:(0,$.jsx)(J,{className:`h-3 w-3`})})}),(0,$.jsxs)(V,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelVisionHint`)})]}),(0,$.jsx)(s,{checked:S,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m.includes(t)?`border-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(p,{className:`text-xs font-medium text-foreground`,children:i(`providerModelThinkingDefault`)}),(0,$.jsxs)(y,{value:x??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:m.length===0,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(h,{})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(v,{value:`__none__`,children:i(`providerModelThinkingDefaultNone`)}),m.map(e=>(0,$.jsx)(v,{value:e,children:d(e)},e))]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`remove`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelsRemoveSaveHint`)}):null]})}var rt=20,it=50,at=50;function ot(e){let{expanded:t,fetchedTotal:n,models:r,source:a,onExpandedChange:o,onAddModels:s}=e,[c,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(()=>new Set),p=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.toLowerCase().includes(e)):r},[r,c]),m=p.slice(0,at),h=(0,Y.useMemo)(()=>r.filter(e=>d.has(e)),[r,d]),g=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),u(``),f(new Set))},v=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&r.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:i(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(n))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground`,onClick:()=>o(!t),children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i(v).replace(`{count}`,String(r.length))}),(0,$.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${t?`rotate-90`:``}`})]}),r.length<=it?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10`,onClick:()=>_(r),children:i(`providerModelsSuggestionsAddAll`)}):null]}),t?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[r.length>rt?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(l,{value:c,onChange:e=>u(e.target.value),placeholder:i(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto overscroll-contain`,children:[m.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d.has(e),onChange:()=>g(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),p.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSearchEmpty`)}):null]}),p.length>m.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(m.length)).replace(`{count}`,String(p.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(h.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:h.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(h),children:i(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSaveHint`)})]}):null]})}function st({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(x,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),i(`providerModelsSuggestionsFailed`)]})}function ct(e){let{providerName:t,providerModelAliases:n,models:r,modelConfig:a,modelDraft:o,showModelInput:s,onModelDraftChange:c,onShowModelInputChange:d,onAddModel:f,onModelsChange:m,supportsModelDiscovery:h,onDiscoverModels:g,isDiscoveringModels:_,fetchedModels:v,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w}=e,[k,A]=(0,Y.useState)(!1),j=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=tt({providerName:t,models:r,aliases:n,fetchedModels:v,onModelsChange:m}),L=async()=>{await g()&&(A(!0),window.requestAnimationFrame(()=>{let e=j.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=v.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:i(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:_,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${_?`animate-spin`:``}`}),i(_?`providerModelsFetching`:`providerModelsFetch`)]}):null,s?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),i(`providerAddModel`)]})]})]}),s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),c(``))},placeholder:i(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(u,{type:`button`,size:`sm`,onClick:f,disabled:o.trim().length===0,children:i(`add`)}),(0,$.jsx)(u,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),c(``)},children:(0,$.jsx)(O,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(st,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:h}),h&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),i(`providerModelsSuggestionsChecking`)]}):h&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:j,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ot,{expanded:k,fetchedTotal:v.length,models:F,source:I,onExpandedChange:A,onAddModels:M})}):null,r.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`providerModelsEmptyShort`)}),s?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:i(`providerAddFirstModel`)})]}):(0,$.jsx)(nt,{models:r,modelConfig:a,onModelsChange:m,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w})]})}function lt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(K,{status:`inactive`,label:i(`disabled`),className:n});let a=!e||t;return(0,$.jsx)(K,{status:a?`ready`:`setup`,label:i(a?`statusReady`:`statusSetup`),className:n})}function ut(e){let{context:t,language:n,providerTitle:r,providerDisplayName:a,apiKey:o,apiBase:s,extraHeaders:c,wireApi:d,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,connectivity:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:ee,onSetModelThinkingDefault:te,onSetModelVision:z,onShowAdvancedChange:ne,onWireApiChange:B,onExtraHeadersChange:V,onDeleteProvider:H,onSubmit:U,onTestConnection:re}=e,W=t.providerAuthMethods.find(e=>e.id===v);return(0,$.jsxs)(ge,{children:[(0,$.jsx)(pe,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:r}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:H,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:i(`providerDelete`),children:(0,$.jsx)(G,{className:`h-4 w-4`})}),(0,$.jsx)(lt,{enabled:t.currentEnabled,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:U,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(_e,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:i(`providerDisplayName`)}),(0,$.jsx)(l,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||i(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(et,{apiKey:o,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:t.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:t.apiKeyHint?.placeholder??i(`enterApiKey`),providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:W?.hint?.[n]||W?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b,onApiKeyChange:O}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:i(`apiBase`)}),(0,$.jsx)(l,{id:`apiBase`,type:`text`,value:s,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,$.jsx)(ct,{providerName:t.providerConfig?.providerId??``,providerModelAliases:t.providerModelAliases,models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:I,onModelsChange:L,supportsModelDiscovery:t.supportsModelDiscovery,onDiscoverModels:w.discoverModels,isDiscoveringModels:w.isDiscoveringModels,fetchedModels:w.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:ee,onSetModelThinkingDefault:te,onSetModelVision:z,thinkingLevels:F,formatThinkingLevelLabel:Fe},t.providerConfig?.providerId),(0,$.jsx)(Qe,{showAdvanced:g,onShowAdvancedChange:ne,supportsWireApi:t.supportsWireApi,wireApiLabel:i(`wireApi`),wireApi:d,onWireApiChange:B,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:i(`extraHeaders`),extraHeaders:c,onExtraHeadersChange:V})]}),(0,$.jsx)(ye,{children:(0,$.jsxs)(ue,{align:`between`,children:[(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:re,disabled:w.isTestPending,children:[(0,$.jsx)(be,{className:`mr-1.5 h-3.5 w-3.5`}),w.isTestPending?i(`providerTestingConnection`):i(`providerTestConnection`)]}),(0,$.jsx)(u,{type:`submit`,size:`sm`,disabled:C||!x,children:i(C?`saving`:x?`save`:`unchanged`)})]})})]})]})}function dt({providerName:e,onProviderDeleted:t}){let{data:n}=N(),{data:r}=z(),{data:o}=W(),s=a(),c=(0,Y.useMemo)(()=>qe({providerName:e,providersView:n,templatesView:r,schema:o,language:s}),[s,e,n,o,r]);if(!e||!c.providerConfig)return(0,$.jsx)(ve,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:i(`providersSelectDescription`)})]})});let l=JSON.stringify({providerConfig:c.providerConfig,currentApiBase:c.currentApiBase,currentEditableModels:c.currentEditableModels,currentModelConfig:c.currentModelConfig,currentWireApi:c.currentWireApi,effectiveDisplayName:c.effectiveDisplayName,preferredAuthMethodId:c.preferredAuthMethodId});return(0,$.jsx)(ft,{providerName:e,onProviderDeleted:t,context:c,language:s},l)}function ft({providerName:e,onProviderDeleted:t,context:n,language:r}){let a=I(),o=ae(),{currentApiBase:s,currentEditableModels:c,currentHeaders:l,currentModelConfig:u,currentWireApi:d,defaultApiBase:f,effectiveDisplayName:p,providerAuth:m,providerAuthMethods:h,providerModelAliases:g,resolvedProviderConfig:_,preferredAuthMethodId:v,supportsWireApi:y}=n,[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(s),[w,T]=(0,Y.useState)(_.extraHeaders||null),[E,D]=(0,Y.useState)(d),[O,k]=(0,Y.useState)(c),[A,j]=(0,Y.useState)(u),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(p),[L,R]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1),[z,ne]=(0,Y.useState)(v),B=Ye({providerName:e,apiKey:b,apiKeyRequired:_.apiKeyRequired!==!1,apiKeySet:_.apiKeySet,apiBase:S,extraHeaders:w,supportsWireApi:y,wireApi:E,models:O,providerModelAliases:g}),V=P.trim()||p||e||i(`providersSelectPlaceholder`),H=(0,Y.useMemo)(()=>{if(!h.length)return``;let e=z.trim();return e&&h.some(t=>t.id===e)?e:v||h[0]?.id||``},[z,v,h]),{authSessionId:U,authStatusMessage:re,importAuthFromCli:W,importPending:G,startAuth:K,startPending:ie}=Je({providerName:e,providerAuth:m,resolvedAuthMethodId:H}),q=(0,Y.useMemo)(()=>je({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p}),[e,b,S,s,w,l,y,E,d,O,c,A,u,P,p]),J=e=>{k(e),j(t=>Oe(t,e))};return(0,$.jsx)(ut,{context:n,language:r,providerTitle:V,providerDisplayName:P,apiKey:b,apiBase:S,extraHeaders:w,wireApi:E,models:O,modelConfig:A,modelDraft:M,showAdvanced:L,showModelInput:ee,resolvedAuthMethodId:H,authSessionId:U,authStatusMessage:re,hasChanges:q,isDeletePending:o.isPending,isUpdatePending:a.isPending,connectivity:B,startPending:ie,importPending:G,onProviderDisplayNameChange:F,onApiKeyChange:x,onApiBaseChange:C,onAuthMethodChange:ne,onStartProviderAuth:K,onImportProviderAuthFromCli:W,onModelDraftChange:N,onShowModelInputChange:te,onAddModel:()=>{let e=Re(O,M,g);J(e.models),N(e.draft)},onModelsChange:J,onRemoveModel:e=>{let t=Ve(O,A,e);k(t.models),j(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{j(n=>He(n,e,t))},onSetModelThinkingDefault:(e,t)=>{j(n=>Ue(n,e,t))},onSetModelVision:(e,t)=>{j(n=>We(n,e,t))},onShowAdvancedChange:R,onWireApiChange:D,onExtraHeadersChange:T,onDeleteProvider:async()=>{if(e&&window.confirm(i(`providerDeleteConfirm`)))try{await o.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&a.mutate({provider:e,data:Me({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,defaultApiBase:f,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p})})},onTestConnection:B.testConnection})}function pt(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 mt(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 ht(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 gt(){let{isMobile:e}=ie(),{data:t}=N(),{data:n}=z(),a=re(),o=ae(),c=I(),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(``),C=(0,Y.useMemo)(()=>mt(Object.values(t?.providers??{}),v),[t?.providers,v]),T=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),D=(0,Y.useMemo)(()=>ht(T),[T]),O=(0,Y.useMemo)(()=>new Map(T.map(e=>[e.providerType,e])),[T]),k=(0,Y.useMemo)(()=>{let e=b.trim().toLowerCase();return C.filter(t=>{if(!e)return!0;let n=t.providerType?O.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[C,b,O]),A=(0,Y.useMemo)(()=>d&&k.some(e=>e.providerId===d)?d:e?null:k[0]?.providerId??null,[k,e,d]);return!t||!n?(0,$.jsx)(f,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:i(`providersLoading`)})}):(0,$.jsxs)(f,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(fe,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>p(null),mobileListLabel:i(`providersPageTitle`),children:[(0,$.jsxs)(he,{children:[(0,$.jsx)(pe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(H,{open:g,onOpenChange:_,children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.jsxs)(u,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),a.isPending?i(`saving`):i(`providerAdd`)]})}),(0,$.jsxs)(V,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:i(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-muted/45`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});x(``),p(e.providerId),y(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(q,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:i(`providerAddCustom`)})]}),D.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-muted/40`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});x(``),p(t.providerId),y(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(q,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.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,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(l,{value:b,onChange:e=>x(e.target.value),placeholder:i(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(_e,{className:`space-y-2 p-3`,children:[k.map(e=>{let t=e.providerType?O.get(e.providerType):null,n=e.enabled!==!1,a=R(e),o=e.displayName?.trim()||t?.displayName||e.providerId,l=pt(e.apiBase||t?.defaultApiBase||``)||i(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>p(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p(e.providerId))},role:`button`,tabIndex:0,className:r(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,A===e.providerId?`bg-background/95 text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-background/65 hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(q,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:o}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[l,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(s,{checked:n,disabled:c.isPending,title:i(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{c.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),title:i(`more`),children:(0,$.jsx)(P,{className:`h-4 w-4`})})}),(0,$.jsx)(V,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.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:()=>h(e.providerId),children:[(0,$.jsx)(G,{className:`h-4 w-4`}),i(`providerDelete`)]})})]})]}),(0,$.jsx)(K,{status:n?a?`ready`:`setup`:`inactive`,label:i(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),k.length===0?(0,$.jsx)(me,{icon:te,title:i(`providersNoMatch`)}):null]})]}),(0,$.jsx)(dt,{providerName:A??void 0,onProviderDeleted:e=>{y(t=>t.filter(t=>t!==e)),e===A&&p(null)}})]}),(0,$.jsx)(S,{open:!!m,onOpenChange:e=>{e||h(null)},title:i(`providerDelete`),description:m??void 0,confirmLabel:i(`delete`),variant:`destructive`,onCancel:()=>h(null),onConfirm:()=>{m&&o.mutateAsync({provider:m}).then(()=>{y(e=>e.filter(e=>e!==m)),m===A&&p(null),h(null)})}})]})}export{gt as ProvidersConfigPage};
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,s as a}from"./react-Co6JiC1n.js";import{An as o,Ht as s,_n as c,dn as l,fn as u,rn as d,sn as f,un as p}from"./api-m33O1Kb0.js";import{C as m,a as h,i as g,n as _,r as v,t as y}from"./select-BzQKfW1e.js";import{c as b,l as x,t as S}from"./confirm-dialog-f5NKLh5I.js";import{t as C}from"./createLucideIcon-CHALGA42.js";import{t as w}from"./search-C47TyRg0.js";import{t as T}from"./loader-circle-CH_0iPLy.js";import{t as E}from"./plus-B3obD55V.js";import{t as D}from"./refresh-cw-BG_LX3SS.js";import{t as O}from"./x-C1r9IXet.js";import{t as k}from"./host-capabilities-Tk038i04.js";import{B as A,D as j,Dt as M,E as N,Et as P,I as F,M as I,O as L,R,S as ee,St as te,T as z,Tt as ne,V as B,X as V,Y as H,Z as U,_ as re,g as W,ht as G,mt as K,p as ie,q,v as ae,vt as J,w as oe,x as se,y as ce,z as le}from"./index-BjxnLYE3.js";import{t as ue}from"./form-actions-CH0kWhEt.js";import{t as de}from"./config-hints-nV5HPOvq.js";import{a as fe,c as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye}from"./config-split-page-DBnMEP1o.js";var be=C(`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`}]]),xe=C(`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`}]]),Y=e(n(),1),Se={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(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 Ce(e,t){let n=X(e),r=X(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 Z(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 we(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 Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=we(n,t))}return n.trim()}function Te(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ee(e,t){return Z(t)}function De(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Oe(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=A(i.thinking?.supported);if(a.length>0){let t=B(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 ke(e,t,n){return{...le(e,n),...le(t,n)}}function Ae(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||!Te([...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 je(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Ce(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!Te(e.models,e.currentEditableModels)||!Ae(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Me(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(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),Ce(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),Te(e.models,e.currentEditableModels)||(t.models=De(e.models,e.providerName??``)),Ae(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Oe(e.modelConfig,e.models)),t}function Ne(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Pe(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Pe(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Fe(e){return i(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ie(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 Le(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Re(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function ze(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function Be(e,t,n){return ze(e,t,n).models.slice(e.length)}function Ve(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function He(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):F.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 Ue(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 We(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 Ge(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:Ie({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:Le({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Ke(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:i(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:Le({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function qe(e){let{providerName:t,providersView:n,templatesView:r,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=r?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??Se,u=a?.uiHints,d=!!s?.isCustom,f=t?de(`providers.${t}.apiKey`,u):void 0,p=t?de(`providers.${t}.apiBase`,u):void 0,m=t?de(`providers.${t}.extraHeaders`,u):void 0,h=t?de(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=d||c?.supportsModelDiscovery===!0,b=Z([c?.modelPrefix||c?.providerType||``,t||``]),x=c?.defaultApiBase||``,S=l.apiBase||x,C=X(l.extraHeaders||null),w=l.wireApi||c?.defaultWireApi||`auto`,T=Ee(Z((c?.defaultModels??[]).map(e=>Q(e,b))),Z((l.models??[]).map(e=>Q(e,b)))),E=Oe(ke(c?.modelConfig,l.modelConfig,b),T),D=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||i(`providerApiBaseHelp`),O=Ge({providerName:t,providerSpec:c,language:o}),k=Ke(c,d);return{apiBaseHelpText:D,apiBaseHint:p,apiKeyHint:f,currentApiBase:S,currentEditableModels:T,currentEnabled:v,currentHeaders:C,currentModelConfig:E,currentWireApi:w,defaultApiBase:x,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...O,providerConfig:s,providerModelAliases:b,resolvedProviderConfig:l,supportsModelDiscovery:y,wireApiHint:h,...k}}function Je(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=o(),s=j(),l=ee(),u=se(),[d,f]=(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 r=await l.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){g(i(`providerAuthWaitingBrowser`)),y(e,r.nextPollMs??n);return}if(r.status===`authorized`){m(null),v(),g(i(`providerAuthCompleted`)),c.success(i(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(r.message||`Authorization ${r.status}.`),c.error(r.message||`Authorization ${r.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),c.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,l,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),g(``);let e=await s.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(i(`providerAuthStartFailed`));m(e.sessionId),g(`${i(`providerAuthOpenPrompt`)}${e.userCode}${i(`providerAuthOpenPromptSuffix`)}`),await k.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),c.error(`${i(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,r,y,s]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),v(),m(null);let e=await u.mutateAsync({provider:t});g(`${i(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),c.success(i(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),c.error(`${i(`providerAuthImportFailed`)}: ${t}`)}},[v,u,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:d===t?p:null,authStatusMessage:d===t?h:``,importAuthFromCli:x,importPending:u.isPending,startAuth:b,startPending:s.isPending}}function Ye(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:f,providerModelAliases:p}=e,m=L(),h=ce(),g=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[_,v]=(0,Y.useState)(null),y=(0,Y.useCallback)(async()=>{if(t)try{let e=await m.mutateAsync({provider:t,data:Ne({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:f,providerModelAliases:p})});if(e.success){c.success(`${i(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),c.error(`${i(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);c.error(`${i(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,f,p,t,l,m,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return c.error(i(`providerModelsApiKeyRequired`)),null;try{let e=await h.mutateAsync({provider:t,data:Pe({apiKey:n,apiBase:o,extraHeaders:s})});return v({key:g,models:e.models}),c.success(i(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof d&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return c.error(i(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return c.error(`${i(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,h,g,s,t]),fetchedModels:_?.key===g?_.models:[],isDiscoveringModels:h.isPending,isTestPending:m.isPending,testConnection:y}}var $=t();function Xe({value:e,onChange:t,className:n}){let a=e?Object.entries(e):[],o=(e,n,r)=>{let i=[...a];i[e]=[n,r],t(Object.fromEntries(i))},s=()=>{t({...e,"":``})},c=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,$.jsxs)(`div`,{className:r(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(l,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:i(`headerName`),className:`flex-1`}),(0,$.jsx)(l,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:i(`headerValue`),className:`flex-1`}),(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>c(n),children:(0,$.jsx)(G,{className:`h-4 w-4 text-red-500`})})]},n)),(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),i(`add`)]})]})}function Ze(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.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-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:e.label},e.value)})})}function Qe(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:r,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.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,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`h-3.5 w-3.5`}),i(`providerAdvancedSettings`)]}),(0,$.jsx)(m,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[r?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)(Ze,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(y,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(g,{className:`rounded-xl`,children:(0,$.jsx)(h,{})}),(0,$.jsx)(_,{children:l.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Xe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerExtraHeadersHelpShort`)})]})]}):null]})}function $e({isSet:e,className:t,value:n,onChange:i,placeholder:a,...o}){let[s,c]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:r(`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,$.jsx)(l,{type:s?`text`:`password`,className:r(`pr-12`,t),value:n,onChange:i,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...o}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>c(!s),children:s?(0,$.jsx)(xe,{className:`h-4 w-4`}):(0,$.jsx)(ne,{className:`h-4 w-4`})})})]})}function et(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:r,apiKeyPlaceholder:a,providerAuth:o,providerAuthNote:s,providerAuthMethodOptions:c,providerAuthMethodsCount:l,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:m,onAuthMethodChange:b,onStartProviderAuth:x,onImportProviderAuthFromCli:S,startPending:C,importPending:w,authSessionId:T,authStatusMessage:E,onApiKeyChange:D}=e,O=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:i(`apiKey`)}),(0,$.jsx)($e,{id:`apiKey`,value:t,isSet:r,onChange:e=>D(e.target.value),placeholder:a,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`leaveBlankToKeepUnchanged`)})]}):null;return o?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[O,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:o.displayName||i(`providerAuthSectionTitle`)}),s?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}):null,l>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{className:`text-xs font-medium text-foreground`,children:i(`providerAuthMethodLabel`)}),f?(0,$.jsx)(Ze,{value:m,onChange:b,options:c}):(0,$.jsxs)(y,{value:m,onValueChange:b,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg`,children:(0,$.jsx)(h,{placeholder:i(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(_,{children:c.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:x,disabled:C||!!T,children:i(C?`providerAuthStarting`:T?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),o.supportsCliImport?(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:S,disabled:w,children:i(w?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,T?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i(`providerAuthSessionLabel`),`: `,T.slice(0,8),`…`]}):null]}),E?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E}):null]})]}):O}function tt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=oe({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>Be(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=ze(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function nt(e){let{models:t,modelConfig:n,onModelsChange:r,onRemoveModel:a,onToggleModelThinkingLevel:o,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,m]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(()=>new Set),S=(0,Y.useMemo)(()=>t.filter(e=>b.has(e)),[t,b]),C=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=()=>{m(!1),x(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(S.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>x(S.length===t.length?new Set:new Set(t)),children:i(S.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:w,children:i(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:S.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{S.length!==0&&(r(t.filter(e=>!b.has(e))),w())},children:[(0,$.jsx)(G,{className:`h-3 w-3`}),i(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>m(!0),children:[(0,$.jsx)(G,{className:`h-3 w-3`}),i(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b.has(e),onChange:()=>C(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=n[e],r=t?.thinking,m=r?.supported??[],x=r?.default??null,S=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.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-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`providerModelThinkingTitle`),title:i(`providerModelThinkingTitle`),children:(0,$.jsx)(J,{className:`h-3 w-3`})})}),(0,$.jsxs)(V,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelVisionHint`)})]}),(0,$.jsx)(s,{checked:S,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m.includes(t)?`border-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(p,{className:`text-xs font-medium text-foreground`,children:i(`providerModelThinkingDefault`)}),(0,$.jsxs)(y,{value:x??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:m.length===0,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(h,{})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(v,{value:`__none__`,children:i(`providerModelThinkingDefaultNone`)}),m.map(e=>(0,$.jsx)(v,{value:e,children:d(e)},e))]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`remove`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelsRemoveSaveHint`)}):null]})}var rt=20,it=50,at=50;function ot(e){let{expanded:t,fetchedTotal:n,models:r,source:a,onExpandedChange:o,onAddModels:s}=e,[c,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(()=>new Set),p=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.toLowerCase().includes(e)):r},[r,c]),m=p.slice(0,at),h=(0,Y.useMemo)(()=>r.filter(e=>d.has(e)),[r,d]),g=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),u(``),f(new Set))},v=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&r.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:i(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(n))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground`,onClick:()=>o(!t),children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i(v).replace(`{count}`,String(r.length))}),(0,$.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${t?`rotate-90`:``}`})]}),r.length<=it?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10`,onClick:()=>_(r),children:i(`providerModelsSuggestionsAddAll`)}):null]}),t?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[r.length>rt?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(l,{value:c,onChange:e=>u(e.target.value),placeholder:i(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto overscroll-contain`,children:[m.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d.has(e),onChange:()=>g(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),p.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSearchEmpty`)}):null]}),p.length>m.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(m.length)).replace(`{count}`,String(p.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(h.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:h.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(h),children:i(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSaveHint`)})]}):null]})}function st({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(x,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),i(`providerModelsSuggestionsFailed`)]})}function ct(e){let{providerName:t,providerModelAliases:n,models:r,modelConfig:a,modelDraft:o,showModelInput:s,onModelDraftChange:c,onShowModelInputChange:d,onAddModel:f,onModelsChange:m,supportsModelDiscovery:h,onDiscoverModels:g,isDiscoveringModels:_,fetchedModels:v,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w}=e,[k,A]=(0,Y.useState)(!1),j=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=tt({providerName:t,models:r,aliases:n,fetchedModels:v,onModelsChange:m}),L=async()=>{await g()&&(A(!0),window.requestAnimationFrame(()=>{let e=j.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=v.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(p,{className:`text-sm font-medium text-foreground`,children:i(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:_,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${_?`animate-spin`:``}`}),i(_?`providerModelsFetching`:`providerModelsFetch`)]}):null,s?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),i(`providerAddModel`)]})]})]}),s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),c(``))},placeholder:i(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(u,{type:`button`,size:`sm`,onClick:f,disabled:o.trim().length===0,children:i(`add`)}),(0,$.jsx)(u,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),c(``)},children:(0,$.jsx)(O,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(st,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:h}),h&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),i(`providerModelsSuggestionsChecking`)]}):h&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:j,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ot,{expanded:k,fetchedTotal:v.length,models:F,source:I,onExpandedChange:A,onAddModels:M})}):null,r.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`providerModelsEmptyShort`)}),s?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:i(`providerAddFirstModel`)})]}):(0,$.jsx)(nt,{models:r,modelConfig:a,onModelsChange:m,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w})]})}function lt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(K,{status:`inactive`,label:i(`disabled`),className:n});let a=!e||t;return(0,$.jsx)(K,{status:a?`ready`:`setup`,label:i(a?`statusReady`:`statusSetup`),className:n})}function ut(e){let{context:t,language:n,providerTitle:r,providerDisplayName:a,apiKey:o,apiBase:s,extraHeaders:c,wireApi:d,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,connectivity:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:ee,onSetModelThinkingDefault:te,onSetModelVision:z,onShowAdvancedChange:ne,onWireApiChange:B,onExtraHeadersChange:V,onDeleteProvider:H,onSubmit:U,onTestConnection:re}=e,W=t.providerAuthMethods.find(e=>e.id===v);return(0,$.jsxs)(ge,{children:[(0,$.jsx)(pe,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:r}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:H,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:i(`providerDelete`),children:(0,$.jsx)(G,{className:`h-4 w-4`})}),(0,$.jsx)(lt,{enabled:t.currentEnabled,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:U,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(_e,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:i(`providerDisplayName`)}),(0,$.jsx)(l,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||i(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(et,{apiKey:o,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:t.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:t.apiKeyHint?.placeholder??i(`enterApiKey`),providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:W?.hint?.[n]||W?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b,onApiKeyChange:O}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(p,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:i(`apiBase`)}),(0,$.jsx)(l,{id:`apiBase`,type:`text`,value:s,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,$.jsx)(ct,{providerName:t.providerConfig?.providerId??``,providerModelAliases:t.providerModelAliases,models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:I,onModelsChange:L,supportsModelDiscovery:t.supportsModelDiscovery,onDiscoverModels:w.discoverModels,isDiscoveringModels:w.isDiscoveringModels,fetchedModels:w.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:ee,onSetModelThinkingDefault:te,onSetModelVision:z,thinkingLevels:F,formatThinkingLevelLabel:Fe},t.providerConfig?.providerId),(0,$.jsx)(Qe,{showAdvanced:g,onShowAdvancedChange:ne,supportsWireApi:t.supportsWireApi,wireApiLabel:i(`wireApi`),wireApi:d,onWireApiChange:B,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:i(`extraHeaders`),extraHeaders:c,onExtraHeadersChange:V})]}),(0,$.jsx)(ye,{children:(0,$.jsxs)(ue,{align:`between`,children:[(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:re,disabled:w.isTestPending,children:[(0,$.jsx)(be,{className:`mr-1.5 h-3.5 w-3.5`}),w.isTestPending?i(`providerTestingConnection`):i(`providerTestConnection`)]}),(0,$.jsx)(u,{type:`submit`,size:`sm`,disabled:C||!x,children:i(C?`saving`:x?`save`:`unchanged`)})]})})]})]})}function dt({providerName:e,onProviderDeleted:t}){let{data:n}=N(),{data:r}=z(),{data:o}=W(),s=a(),c=(0,Y.useMemo)(()=>qe({providerName:e,providersView:n,templatesView:r,schema:o,language:s}),[s,e,n,o,r]);if(!e||!c.providerConfig)return(0,$.jsx)(ve,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:i(`providersSelectDescription`)})]})});let l=JSON.stringify({providerConfig:c.providerConfig,currentApiBase:c.currentApiBase,currentEditableModels:c.currentEditableModels,currentModelConfig:c.currentModelConfig,currentWireApi:c.currentWireApi,effectiveDisplayName:c.effectiveDisplayName,preferredAuthMethodId:c.preferredAuthMethodId});return(0,$.jsx)(ft,{providerName:e,onProviderDeleted:t,context:c,language:s},l)}function ft({providerName:e,onProviderDeleted:t,context:n,language:r}){let a=I(),o=ae(),{currentApiBase:s,currentEditableModels:c,currentHeaders:l,currentModelConfig:u,currentWireApi:d,defaultApiBase:f,effectiveDisplayName:p,providerAuth:m,providerAuthMethods:h,providerModelAliases:g,resolvedProviderConfig:_,preferredAuthMethodId:v,supportsWireApi:y}=n,[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(s),[w,T]=(0,Y.useState)(_.extraHeaders||null),[E,D]=(0,Y.useState)(d),[O,k]=(0,Y.useState)(c),[A,j]=(0,Y.useState)(u),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(p),[L,R]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1),[z,ne]=(0,Y.useState)(v),B=Ye({providerName:e,apiKey:b,apiKeyRequired:_.apiKeyRequired!==!1,apiKeySet:_.apiKeySet,apiBase:S,extraHeaders:w,supportsWireApi:y,wireApi:E,models:O,providerModelAliases:g}),V=P.trim()||p||e||i(`providersSelectPlaceholder`),H=(0,Y.useMemo)(()=>{if(!h.length)return``;let e=z.trim();return e&&h.some(t=>t.id===e)?e:v||h[0]?.id||``},[z,v,h]),{authSessionId:U,authStatusMessage:re,importAuthFromCli:W,importPending:G,startAuth:K,startPending:ie}=Je({providerName:e,providerAuth:m,resolvedAuthMethodId:H}),q=(0,Y.useMemo)(()=>je({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p}),[e,b,S,s,w,l,y,E,d,O,c,A,u,P,p]),J=e=>{k(e),j(t=>Oe(t,e))};return(0,$.jsx)(ut,{context:n,language:r,providerTitle:V,providerDisplayName:P,apiKey:b,apiBase:S,extraHeaders:w,wireApi:E,models:O,modelConfig:A,modelDraft:M,showAdvanced:L,showModelInput:ee,resolvedAuthMethodId:H,authSessionId:U,authStatusMessage:re,hasChanges:q,isDeletePending:o.isPending,isUpdatePending:a.isPending,connectivity:B,startPending:ie,importPending:G,onProviderDisplayNameChange:F,onApiKeyChange:x,onApiBaseChange:C,onAuthMethodChange:ne,onStartProviderAuth:K,onImportProviderAuthFromCli:W,onModelDraftChange:N,onShowModelInputChange:te,onAddModel:()=>{let e=Re(O,M,g);J(e.models),N(e.draft)},onModelsChange:J,onRemoveModel:e=>{let t=Ve(O,A,e);k(t.models),j(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{j(n=>He(n,e,t))},onSetModelThinkingDefault:(e,t)=>{j(n=>Ue(n,e,t))},onSetModelVision:(e,t)=>{j(n=>We(n,e,t))},onShowAdvancedChange:R,onWireApiChange:D,onExtraHeadersChange:T,onDeleteProvider:async()=>{if(e&&window.confirm(i(`providerDeleteConfirm`)))try{await o.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&a.mutate({provider:e,data:Me({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,defaultApiBase:f,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p})})},onTestConnection:B.testConnection})}function pt(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 mt(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 ht(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 gt(){let{isMobile:e}=ie(),{data:t}=N(),{data:n}=z(),a=re(),o=ae(),c=I(),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(``),C=(0,Y.useMemo)(()=>mt(Object.values(t?.providers??{}),v),[t?.providers,v]),T=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),D=(0,Y.useMemo)(()=>ht(T),[T]),O=(0,Y.useMemo)(()=>new Map(T.map(e=>[e.providerType,e])),[T]),k=(0,Y.useMemo)(()=>{let e=b.trim().toLowerCase();return C.filter(t=>{if(!e)return!0;let n=t.providerType?O.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[C,b,O]),A=(0,Y.useMemo)(()=>d&&k.some(e=>e.providerId===d)?d:e?null:k[0]?.providerId??null,[k,e,d]);return!t||!n?(0,$.jsx)(f,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:i(`providersLoading`)})}):(0,$.jsxs)(f,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(fe,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>p(null),mobileListLabel:i(`providersPageTitle`),children:[(0,$.jsxs)(he,{children:[(0,$.jsx)(pe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(H,{open:g,onOpenChange:_,children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.jsxs)(u,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),a.isPending?i(`saving`):i(`providerAdd`)]})}),(0,$.jsxs)(V,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:i(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-muted/45`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});x(``),p(e.providerId),y(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(q,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:i(`providerAddCustom`)})]}),D.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-muted/40`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});x(``),p(t.providerId),y(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(q,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.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,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(l,{value:b,onChange:e=>x(e.target.value),placeholder:i(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(_e,{className:`space-y-2 p-3`,children:[k.map(e=>{let t=e.providerType?O.get(e.providerType):null,n=e.enabled!==!1,a=R(e),o=e.displayName?.trim()||t?.displayName||e.providerId,l=pt(e.apiBase||t?.defaultApiBase||``)||i(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>p(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p(e.providerId))},role:`button`,tabIndex:0,className:r(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,A===e.providerId?`bg-background/95 text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-background/65 hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(q,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:o}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[l,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(s,{checked:n,disabled:c.isPending,title:i(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{c.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),title:i(`more`),children:(0,$.jsx)(P,{className:`h-4 w-4`})})}),(0,$.jsx)(V,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.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:()=>h(e.providerId),children:[(0,$.jsx)(G,{className:`h-4 w-4`}),i(`providerDelete`)]})})]})]}),(0,$.jsx)(K,{status:n?a?`ready`:`setup`:`inactive`,label:i(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),k.length===0?(0,$.jsx)(me,{icon:te,title:i(`providersNoMatch`)}):null]})]}),(0,$.jsx)(dt,{providerName:A??void 0,onProviderDeleted:e=>{y(t=>t.filter(t=>t!==e)),e===A&&p(null)}})]}),(0,$.jsx)(S,{open:!!m,onOpenChange:e=>{e||h(null)},title:i(`providerDelete`),description:m??void 0,confirmLabel:i(`delete`),variant:`destructive`,onCancel:()=>h(null),onConfirm:()=>{m&&o.mutateAsync({provider:m}).then(()=>{y(e=>e.filter(e=>e!==m)),m===A&&p(null),h(null)})}})]})}export{gt as ProvidersConfigPage};