nextclaw 0.16.26 → 0.16.27

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 (83) hide show
  1. package/package.json +12 -12
  2. package/ui-dist/assets/ChannelsList-askIl_uW.js +8 -0
  3. package/ui-dist/assets/ChatPage-C47h6sfA.js +36 -0
  4. package/ui-dist/assets/DocBrowser-C_C7daBv.js +1 -0
  5. package/ui-dist/assets/DocBrowser-Cf7uSIoM.js +1 -0
  6. package/ui-dist/assets/DocBrowserContext-CJ-YKtWh.js +1 -0
  7. package/ui-dist/assets/LogoBadge-DRDmIa7o.js +1 -0
  8. package/ui-dist/assets/MarketplacePage-DaSRsFUA.js +49 -0
  9. package/ui-dist/assets/MarketplacePage-q12sRrvZ.js +1 -0
  10. package/ui-dist/assets/McpMarketplacePage-B7HZn8zG.js +40 -0
  11. package/ui-dist/assets/ModelConfig-MSi8VF9p.js +1 -0
  12. package/ui-dist/assets/ProvidersList-_NBpSQWn.js +1 -0
  13. package/ui-dist/assets/RemoteAccessPage-DSmdSsCJ.js +1 -0
  14. package/ui-dist/assets/RuntimeConfig-msA8NZOj.js +1 -0
  15. package/ui-dist/assets/SearchConfig-BBtxHIN_.js +1 -0
  16. package/ui-dist/assets/SecretsConfig-BMAqj52o.js +3 -0
  17. package/ui-dist/assets/SessionsConfig-CEJqgz8F.js +2 -0
  18. package/ui-dist/assets/book-open-1agbn9dT.js +1 -0
  19. package/ui-dist/assets/chat-session-display-DBBUJOYN.js +1 -0
  20. package/ui-dist/assets/chunk-JZWAC4HX-BUooP92l.js +3 -0
  21. package/ui-dist/assets/config-hints-fGnUjDe9.js +1 -0
  22. package/ui-dist/assets/config-jOAXZWun.js +1 -0
  23. package/ui-dist/assets/config-layout-B-7erZRN.js +1 -0
  24. package/ui-dist/assets/createLucideIcon-B8FV3fzy.js +1 -0
  25. package/ui-dist/assets/dist-Cy668qFZ.js +15 -0
  26. package/ui-dist/assets/dist-D3OJg9V0.js +1 -0
  27. package/ui-dist/assets/external-link-DI4ZmR3r.js +1 -0
  28. package/ui-dist/assets/hash-DoXBhX9w.js +1 -0
  29. package/ui-dist/assets/i18n-Cn8SErDV.js +1 -0
  30. package/ui-dist/assets/index-B2VeWxfm.css +1 -0
  31. package/ui-dist/assets/index-bAeWRAyo.js +6 -0
  32. package/ui-dist/assets/label-Cz0q8fx4.js +1 -0
  33. package/ui-dist/assets/loader-circle-d_mzMi2S.js +1 -0
  34. package/ui-dist/assets/logos-DjrINZ7P.js +1 -0
  35. package/ui-dist/assets/marketplace-localization-CXeGRf6E.js +1 -0
  36. package/ui-dist/assets/page-layout-Hr-Dvq4o.js +1 -0
  37. package/ui-dist/assets/plus-BnGg0mB-.js +1 -0
  38. package/ui-dist/assets/popover-_nEUAtWY.js +1 -0
  39. package/ui-dist/assets/provider-models-C8JQUd1E.js +1 -0
  40. package/ui-dist/assets/react-Bsr_GLhi.js +1 -0
  41. package/ui-dist/assets/save-Caodcm4q.js +1 -0
  42. package/ui-dist/assets/search-CQCQaN4Z.js +1 -0
  43. package/ui-dist/assets/security-config-Zf1RBeS1.js +1 -0
  44. package/ui-dist/assets/select-D60QRHg9.js +41 -0
  45. package/ui-dist/assets/skeleton-BvV_2nf3.js +1 -0
  46. package/ui-dist/assets/status-dot-D43lBF1a.js +1 -0
  47. package/ui-dist/assets/switch-CcBS0F3U.js +1 -0
  48. package/ui-dist/assets/tabs-custom-UTbefkqB.js +1 -0
  49. package/ui-dist/assets/trash-2-DvPrU1xO.js +1 -0
  50. package/ui-dist/assets/useConfirmDialog-B89bxcd6.js +1 -0
  51. package/ui-dist/assets/useMutation-BpXHE2OV.js +1 -0
  52. package/ui-dist/assets/x-C8AWDn7c.js +1 -0
  53. package/ui-dist/index.html +18 -3
  54. package/ui-dist/assets/ChannelsList-UKA-5t02.js +0 -8
  55. package/ui-dist/assets/ChatPage-xdBp-ddG.js +0 -37
  56. package/ui-dist/assets/DocBrowser-DBUIWJer.js +0 -1
  57. package/ui-dist/assets/LogoBadge-CsSBHZeV.js +0 -1
  58. package/ui-dist/assets/MarketplacePage-BSH836_G.js +0 -49
  59. package/ui-dist/assets/McpMarketplacePage-B9_kPnnM.js +0 -40
  60. package/ui-dist/assets/ModelConfig-DbEKVVg4.js +0 -1
  61. package/ui-dist/assets/ProvidersList-Ck5PgTF2.js +0 -1
  62. package/ui-dist/assets/RemoteAccessPage-4JED9IcK.js +0 -1
  63. package/ui-dist/assets/RuntimeConfig-CB04ug9v.js +0 -1
  64. package/ui-dist/assets/SearchConfig-DmuvL9Pn.js +0 -1
  65. package/ui-dist/assets/SecretsConfig-Dw2sRiSs.js +0 -3
  66. package/ui-dist/assets/SessionsConfig-c-Z9X3xH.js +0 -2
  67. package/ui-dist/assets/chat-session-display-z9RvX-D3.js +0 -1
  68. package/ui-dist/assets/config-hints-CApS3K_7.js +0 -1
  69. package/ui-dist/assets/config-layout-BHnOoweL.js +0 -1
  70. package/ui-dist/assets/index-CfVmBgkf.css +0 -1
  71. package/ui-dist/assets/index-DqzLj8Sw.js +0 -8
  72. package/ui-dist/assets/label-DPGDZvhm.js +0 -1
  73. package/ui-dist/assets/marketplace-localization-Dk31LJJJ.js +0 -1
  74. package/ui-dist/assets/page-layout-DMA_ZiHj.js +0 -1
  75. package/ui-dist/assets/popover-BBLXwfva.js +0 -1
  76. package/ui-dist/assets/provider-models-BOeNnjk9.js +0 -1
  77. package/ui-dist/assets/security-config-FYNEE2eR.js +0 -1
  78. package/ui-dist/assets/skeleton-DLM_39_P.js +0 -1
  79. package/ui-dist/assets/status-dot-BOzEprxw.js +0 -1
  80. package/ui-dist/assets/switch-rE_Ew8fl.js +0 -1
  81. package/ui-dist/assets/tabs-custom-BkfMUTHE.js +0 -1
  82. package/ui-dist/assets/useConfirmDialog-0owrqZcT.js +0 -1
  83. package/ui-dist/assets/vendor-MCpnpiKt.js +0 -461
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,m as n,p as r,u as i}from"./i18n-Cn8SErDV.js";import{t as a}from"./createLucideIcon-B8FV3fzy.js";import{t as o}from"./book-open-1agbn9dT.js";import{t as s}from"./external-link-DI4ZmR3r.js";import{t as c}from"./plus-BnGg0mB-.js";import{t as l}from"./search-CQCQaN4Z.js";import{t as u}from"./x-C8AWDn7c.js";import{i as d,r as f,t as p}from"./DocBrowserContext-CJ-YKtWh.js";var m=a(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ee=a(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),h=a(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),g=a(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),_=a(`PanelRightOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),v=e(n(),1),y=r();function b(){let{isOpen:e,mode:n,tabs:r,activeTabId:a,currentTab:b,currentUrl:x,navVersion:S,close:C,toggleMode:w,goBack:T,goForward:E,canGoBack:te,canGoForward:D,navigate:O,syncUrl:k,setActiveTab:A,closeTab:j,openNewTab:M}=d(),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[V,H]=(0,v.useState)({w:480,h:600}),[U,W]=(0,v.useState)(420),G=(0,v.useRef)(null),K=(0,v.useRef)(null),q=(0,v.useRef)(null),J=(0,v.useRef)(null),Y=(0,v.useRef)(S),X=b?.kind===`docs`;(0,v.useEffect)(()=>{if(!X){P(``);return}try{P(new URL(x).pathname)}catch{P(x)}},[x,a,X]),(0,v.useEffect)(()=>{if(X){if(S!==Y.current){Y.current=S;return}if(J.current?.contentWindow)try{let e=new URL(x).pathname;J.current.contentWindow.postMessage({type:`docs-navigate`,path:e},`*`)}catch{}}},[x,S,X]),(0,v.useEffect)(()=>{n===`floating`&&B(e=>({x:Math.max(40,window.innerWidth-V.w-40),y:e.y}))},[n,V.w]),(0,v.useEffect)(()=>{let e=e=>{X&&e.data?.type===`docs-route-change`&&typeof e.data.url==`string`&&k(e.data.url)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[k,X]);let Z=(0,v.useCallback)(e=>{if(e.preventDefault(),!X)return;let t=N.trim();t&&(t.startsWith(`/`)?O(`${p}${t}`):t.startsWith(`http`)?O(t):O(`${p}/${t}`))},[N,O,X]),ne=(0,v.useCallback)(e=>{n===`floating`&&(I(!0),G.current={startX:e.clientX,startY:e.clientY,startPosX:z.x,startPosY:z.y})},[n,z]);(0,v.useEffect)(()=>{if(!F)return;let e=e=>{G.current&&B({x:G.current.startPosX+(e.clientX-G.current.startX),y:G.current.startPosY+(e.clientY-G.current.startY)})},t=()=>{I(!1),G.current=null};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[F]);let Q=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0);let t=e.currentTarget.dataset.axis;K.current={startX:e.clientX,startY:e.clientY,startW:V.w,startH:V.h};let n=e=>{K.current&&H(n=>({w:t===`y`?n.w:Math.max(360,K.current.startW+(e.clientX-K.current.startX)),h:t===`x`?n.h:Math.max(400,K.current.startH+(e.clientY-K.current.startY))}))},r=()=>{R(!1),K.current=null,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r)},[V]),re=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0),q.current={startX:e.clientX,startW:U};let t=e=>{if(!q.current)return;let t=q.current.startX-e.clientX;W(Math.max(320,Math.min(860,q.current.startW+t)))},n=()=>{R(!1),q.current=null,window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)};window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n)},[U]),ie=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0);let t=e.clientX,n=V.w,r=z.x,i=e=>{let i=t-e.clientX,a=Math.max(360,n+i);H(e=>({...e,w:a})),B(e=>({...e,x:r-(a-n)}))},a=()=>{R(!1),window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[V.w,z.x]);if(!e)return null;let $=n===`docked`;return(0,y.jsxs)(`div`,{className:i(`flex flex-col bg-white overflow-hidden relative`,$?`h-full border-l border-gray-200 shrink-0`:`rounded-2xl shadow-2xl border border-gray-200`),style:$?{width:U}:{position:`fixed`,left:z.x,top:z.y,width:V.w,height:V.h,zIndex:9999},children:[$&&(0,y.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:re}),(0,y.jsxs)(`div`,{className:i(`flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none`,!$&&`cursor-grab active:cursor-grabbing`),onMouseDown:$?void 0:ne,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,y.jsx)(o,{className:`w-4 h-4 text-primary shrink-0`}),(0,y.jsx)(`span`,{className:`text-sm font-semibold text-gray-900 truncate`,children:t(`docBrowserTitle`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,y.jsx)(`button`,{onClick:w,className:`hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors`,title:t($?`docBrowserFloatMode`:`docBrowserDockMode`),children:$?(0,y.jsx)(g,{className:`w-3.5 h-3.5`}):(0,y.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{onClick:C,className:`hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors`,title:t(`docBrowserClose`),children:(0,y.jsx)(u,{className:`w-3.5 h-3.5`})})]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar`,children:[r.map(e=>(0,y.jsxs)(`div`,{className:i(`inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors`,e.id===a?`bg-blue-50 border-blue-300 text-blue-700`:`bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100`),children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>A(e.id),className:`truncate text-left px-1`,title:e.title,children:e.title||t(`docBrowserTabUntitled`)}),(0,y.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),j(e.id)},className:`rounded p-0.5 hover:bg-black/10`,"aria-label":t(`docBrowserCloseTab`),children:(0,y.jsx)(u,{className:`w-3 h-3`})})]},e.id)),(0,y.jsx)(`button`,{onClick:()=>M(void 0,{kind:`docs`,title:`Docs`}),className:`inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0`,title:t(`docBrowserNewTab`),children:(0,y.jsx)(c,{className:`w-3.5 h-3.5`})})]}),X&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,y.jsx)(`button`,{onClick:T,disabled:!te,className:`p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors`,children:(0,y.jsx)(m,{className:`w-4 h-4`})}),(0,y.jsx)(`button`,{onClick:E,disabled:!D,className:`p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors`,children:(0,y.jsx)(ee,{className:`w-4 h-4`})}),(0,y.jsxs)(`form`,{onSubmit:Z,className:`flex-1 relative`,children:[(0,y.jsx)(l,{className:`w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400`}),(0,y.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:t(`docBrowserSearchPlaceholder`),className:`w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400`})]})]}),(0,y.jsxs)(`div`,{className:`flex-1 relative overflow-hidden`,children:[(0,y.jsx)(`iframe`,{ref:J,src:x,className:`absolute inset-0 w-full h-full border-0`,title:b?.title||`NextClaw Docs`,sandbox:`allow-same-origin allow-scripts allow-popups allow-forms`,allow:`clipboard-read; clipboard-write`},`${a}:${S}`),(L||F)&&(0,y.jsx)(`div`,{className:`absolute inset-0 z-10`})]}),X&&f(x)&&(0,y.jsx)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0`,children:(0,y.jsxs)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,"data-doc-external":!0,className:`flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors`,children:[t(`docBrowserOpenExternal`),(0,y.jsx)(s,{className:`w-3 h-3`})]})}),!$&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:ie}),(0,y.jsx)(`div`,{className:`absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:Q,"data-axis":`x`}),(0,y.jsx)(`div`,{className:`absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:Q,"data-axis":`y`}),(0,y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors`,onMouseDown:Q,children:(0,y.jsx)(h,{className:`w-3 h-3 rotate-[-45deg]`})})]})]})}export{m as n,b as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./DocBrowser-C_C7daBv.js";export{e as DocBrowser};
@@ -0,0 +1 @@
1
+ import{_ as e,a as t,m as n,p as r}from"./i18n-Cn8SErDV.js";var i=e(n(),1),a=r(),o=`docs.nextclaw.io`,s=`nextclaw-docs.pages.dev`,c=new Set([o,`www.${o}`,s,`www.${s}`]),l=`https://${o}`,u=`/guide/getting-started`,d=(0,i.createContext)(null),f=0;function p(){return f+=1,`doc-tab-${Date.now()}-${f}`}function m(e){try{return new URL(e).pathname.replace(/\.html$/,``).replace(/\/$/,``)}catch{return e}}function h(e){return e===`zh`?`zh`:`en`}function g(e,t){let n=e.startsWith(`/`)?e:`/${e}`;return n===`/`||n===``?`/${t}/`:/^\/(en|zh)(\/|$)/.test(n)?n:`/${t}${n}`}function _(e){let n=h(t());try{let t=new URL(e,l);return c.has(t.hostname)&&(t.pathname=g(t.pathname,n)),t.toString()}catch{return new URL(`/${n}${u}`,l).toString()}}function v(){return _(u)}function y(e,t,n=`Docs`){try{let r=new URL(e,l);if(r.protocol===`data:`)return t===`docs`?n:`Detail`;let i=r.pathname.split(`/`).filter(Boolean),a=i[i.length-1]??n;return decodeURIComponent(a).replace(/[-_]/g,` `).slice(0,40)||n}catch{return n}}function b(e,t,n){let r=n?.trim()||y(e,t,t===`docs`?`Docs`:`Detail`);return{id:p(),kind:t,title:r,currentUrl:e,history:[e],historyIndex:0,navVersion:0}}function x(e,t){return{...e,tabs:e.tabs.map(n=>n.id===e.activeTabId?t(n):n)}}function S(){let e=(0,i.useContext)(d);if(!e)throw Error(`useDocBrowser must be used within DocBrowserProvider`);return e}function C(e){try{let t=new URL(e,window.location.origin);return c.has(t.hostname)}catch{return!1}}function w(e){return C(e)?`docs`:`content`}function T(e,t){return t===`docs`?_(e):e}function E(e){return e.url&&e.url.trim().length>0?T(e.url,e.kind):e.kind===`docs`?v():e.activeTab?.currentUrl??v()}function D({children:e}){let t=b(v(),`docs`,`Docs`),[n,r]=(0,i.useState)({isOpen:!1,mode:`docked`,tabs:[t],activeTabId:t.id}),o=(0,i.useMemo)(()=>n.tabs.find(e=>e.id===n.activeTabId)??n.tabs[0],[n.tabs,n.activeTabId]),s=(0,i.useCallback)((e,t)=>{r(n=>{let r=n.tabs.find(e=>e.id===n.activeTabId)??n.tabs[0],i=t?.kind??(e?w(e):r?.kind??`docs`),a=E({url:e,kind:i,activeTab:r});if(t?.newTab||!r||r.kind!==i){let e=b(a,i,t?.title);return{...n,isOpen:!0,tabs:[...n.tabs,e],activeTabId:e.id}}return{...x(n,e=>m(a)===m(e.currentUrl)?t?.title?{...e,title:t.title}:e:{...e,title:t?.title||e.title,kind:i,currentUrl:a,history:[...e.history.slice(0,e.historyIndex+1),a],historyIndex:e.historyIndex+1,navVersion:e.navVersion+1}),isOpen:!0}})},[]),c=(0,i.useCallback)(()=>{r(e=>({...e,isOpen:!1}))},[]),l=(0,i.useCallback)(()=>{r(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},[]),u=(0,i.useCallback)(e=>{r(t=>({...t,mode:e}))},[]),f=(0,i.useCallback)(e=>{r(t=>{if(!t.tabs.length){let e=b(v(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}return x(t,t=>{if(t.kind!==`docs`)return t;let n=T(e,`docs`);return m(n)===m(t.currentUrl)?t:{...t,currentUrl:n,history:[...t.history.slice(0,t.historyIndex+1),n],historyIndex:t.historyIndex+1,navVersion:t.navVersion+1}})})},[]),p=(0,i.useCallback)(e=>{r(t=>{if(!t.tabs.length){let e=b(v(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}return x(t,t=>t.kind!==`docs`||m(e)===m(t.currentUrl)?t:{...t,currentUrl:e,history:[...t.history.slice(0,t.historyIndex+1),e],historyIndex:t.historyIndex+1})})},[]),h=(0,i.useCallback)(()=>{r(e=>x(e,e=>{if(e.kind!==`docs`||e.historyIndex<=0)return e;let t=e.historyIndex-1;return{...e,historyIndex:t,currentUrl:e.history[t]}}))},[]),g=(0,i.useCallback)(()=>{r(e=>x(e,e=>{if(e.kind!==`docs`||e.historyIndex>=e.history.length-1)return e;let t=e.historyIndex+1;return{...e,historyIndex:t,currentUrl:e.history[t]}}))},[]),_=(0,i.useCallback)((e,t)=>{s(e,{...t??{},newTab:!0})},[s]),y=(0,i.useCallback)(e=>{r(t=>{if(t.tabs.length<=1){let e=b(v(),`docs`,`Docs`);return{...t,isOpen:!1,tabs:[e],activeTabId:e.id}}let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId;return{...t,tabs:r,activeTabId:i}})},[]),S=(0,i.useCallback)(e=>{r(t=>t.tabs.some(t=>t.id===e)?{...t,activeTabId:e,isOpen:!0}:t)},[]),C=!!(o&&o.kind===`docs`&&o.historyIndex>0),D=!!(o&&o.kind===`docs`&&o.historyIndex<o.history.length-1),O=(0,i.useMemo)(()=>({...n,currentTab:o,currentUrl:o?.currentUrl??v(),navVersion:o?.navVersion??0,open:s,close:c,toggleMode:l,setMode:u,navigate:f,syncUrl:p,goBack:h,goForward:g,openNewTab:_,closeTab:y,setActiveTab:S,canGoBack:C,canGoForward:D}),[n,o,s,c,l,u,f,p,h,g,_,y,S,C,D]);return(0,a.jsx)(d.Provider,{value:O,children:e})}export{S as i,D as n,C as r,l as t};
@@ -0,0 +1 @@
1
+ import{_ as e,m as t,p as n,u as r}from"./i18n-Cn8SErDV.js";var i=e(t(),1),a=n();function o({name:e,src:t,className:n,imgClassName:o,fallback:s}){let[c,l]=(0,i.useState)(!1),u=!!t&&!c;return(0,a.jsx)(`div`,{className:r(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:u?(0,a.jsx)(`img`,{src:t,alt:`${e} logo`,className:r(`block h-6 w-6 object-contain`,o),onError:()=>l(!0),draggable:!1}):s??(0,a.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}export{o as t};
@@ -0,0 +1,49 @@
1
+ import{_ as e,l as t,m as n,p as r,u as i}from"./i18n-Cn8SErDV.js";import{c as a,n as o,r as s,u as c}from"./dist-Cy668qFZ.js";import{c as l,s as u}from"./chunk-JZWAC4HX-BUooP92l.js";import{t as d}from"./useMutation-BpXHE2OV.js";import{B as f,C as p,E as m,F as h,G as g,I as _,N as v,R as y,S as b,T as x,U as S,W as C,a as w,i as T,n as ee,r as E,t as D,w as te,x as ne,z as re}from"./select-D60QRHg9.js";import{t as ie}from"./dist-D3OJg9V0.js";import{t as O}from"./createLucideIcon-B8FV3fzy.js";import{i as ae}from"./DocBrowserContext-CJ-YKtWh.js";import{r as oe}from"./index-bAeWRAyo.js";import{t as se}from"./useConfirmDialog-B89bxcd6.js";import{n as ce,t as le}from"./page-layout-Hr-Dvq4o.js";import{t as ue}from"./tabs-custom-UTbefkqB.js";import{t as k}from"./skeleton-BvV_2nf3.js";import{r as A,t as de}from"./marketplace-localization-CXeGRf6E.js";var j=O(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]),M=e(n(),1),N=r(),[P,F]=S(`Tooltip`,[m]),I=m(),L=`TooltipProvider`,fe=700,R=`tooltip.open`,[z,B]=P(L),V=e=>{let{__scopeTooltip:t,delayDuration:n=fe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=M.useRef(!0),s=M.useRef(!1),c=M.useRef(0);return M.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,N.jsx)(z,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:M.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:M.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:M.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};V.displayName=L;var H=`Tooltip`,[pe,U]=P(H),W=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=B(H,e.__scopeTooltip),l=I(t),[u,d]=M.useState(null),p=f(),m=M.useRef(0),h=o??c.disableHoverableContent,g=s??c.delayDuration,_=M.useRef(!1),[v,y]=re({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(R))):c.onClose(),a?.(e)},caller:H}),b=M.useMemo(()=>v?_.current?`delayed-open`:`instant-open`:`closed`,[v]),S=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,_.current=!1,y(!0)},[y]),C=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),w=M.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{_.current=!0,y(!0),m.current=0},g)},[g,y]);return M.useEffect(()=>()=>{m.current&&=(window.clearTimeout(m.current),0)},[]),(0,N.jsx)(x,{...l,children:(0,N.jsx)(pe,{scope:t,contentId:p,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:M.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:M.useCallback(()=>{h?C():(window.clearTimeout(m.current),m.current=0)},[C,h]),onOpen:S,onClose:C,disableHoverableContent:h,children:n})})};W.displayName=H;var G=`TooltipTrigger`,me=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=U(G,n),a=B(G,n),o=I(n),s=C(t,M.useRef(null),i.onTriggerChange),c=M.useRef(!1),l=M.useRef(!1),u=M.useCallback(()=>c.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,N.jsx)(b,{asChild:!0,...o,children:(0,N.jsx)(_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:g(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:g(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:g(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:g(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:g(e.onBlur,i.onClose),onClick:g(e.onClick,i.onClose)})})});me.displayName=G;var he=`TooltipPortal`,[ge,_e]=P(he,{forceMount:void 0}),ve=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=U(he,t);return(0,N.jsx)(ge,{scope:t,forceMount:n,children:(0,N.jsx)(ie,{present:n||a.open,children:(0,N.jsx)(v,{asChild:!0,container:i,children:r})})})};ve.displayName=he;var K=`TooltipContent`,ye=M.forwardRef((e,t)=>{let n=_e(K,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=U(K,e.__scopeTooltip);return(0,N.jsx)(ie,{present:r||o.open,children:o.disableHoverableContent?(0,N.jsx)(we,{side:i,...a,ref:t}):(0,N.jsx)(be,{side:i,...a,ref:t})})}),be=M.forwardRef((e,t)=>{let n=U(K,e.__scopeTooltip),r=B(K,e.__scopeTooltip),i=M.useRef(null),a=C(t,i),[o,s]=M.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=M.useCallback(()=>{s(null),d(!1)},[d]),p=M.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Oe(r,De(r,n.getBoundingClientRect())),a=ke(t.getBoundingClientRect());s(je([...i,...a])),d(!0)},[d]);return M.useEffect(()=>()=>f(),[f]),M.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),M.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Ae(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,N.jsx)(we,{...e,ref:a})}),[xe,Se]=P(H,{isInside:!1}),Ce=y(`TooltipContent`),we=M.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=U(K,n),l=I(n),{onClose:u}=c;return M.useEffect(()=>(document.addEventListener(R,u),()=>document.removeEventListener(R,u)),[u]),M.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,N.jsx)(h,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,N.jsxs)(te,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,N.jsx)(Ce,{children:r}),(0,N.jsx)(xe,{scope:n,isInside:!0,children:(0,N.jsx)(ne,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ye.displayName=K;var Te=`TooltipArrow`,Ee=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=I(n);return Se(Te,n).isInside?null:(0,N.jsx)(p,{...i,...r,ref:t})});Ee.displayName=Te;function De(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Oe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ke(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Ae(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function je(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Me(t)}function Me(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Ne=V,Pe=W,Fe=me,Ie=ve,Le=ye,Re=Ne,q=Pe,J=Fe,Y=M.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,N.jsx)(Ie,{children:(0,N.jsx)(Le,{ref:r,sideOffset:t,className:i(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));Y.displayName=Le.displayName;function X(e){return e===`plugin`?`plugins`:e===`skill`?`skills`:`mcp`}async function ze(e){let t=new URLSearchParams,n=X(e.type);e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.trim()&&t.set(`tag`,e.tag.trim()),e.sort&&t.set(`sort`,e.sort),typeof e.page==`number`&&Number.isFinite(e.page)&&t.set(`page`,String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize==`number`&&Number.isFinite(e.pageSize)&&t.set(`pageSize`,String(Math.max(1,Math.trunc(e.pageSize))));let r=t.toString(),i=await s.get(r?`/api/marketplace/${n}/items?${r}`:`/api/marketplace/${n}/items`);if(!i.ok)throw Error(i.error.message);return i.data}async function Be(e){let t=await s.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function Ve(e){let t=await s.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function He(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw Error(n.error.message);return n.data}async function Ue(e){let t=X(e),n=await s.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw Error(n.error.message);return n.data}async function We(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw Error(n.error.message);return n.data}function Ge(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function Ke(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function qe(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Je(e,t){return t??{type:e,total:0,specs:[],records:[]}}function Ye(e){let t=Je(e.result.type,e.view),n=Ke(e),r=t.records.findIndex(e=>qe(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:Ge(i),total:i.length}}function Xe(e){let t=Je(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!qe(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:Ge(n),total:n.length}}let n=t.records.map(t=>qe(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:Ge(n),total:n.length}}function Ze(e){return a({queryKey:[`marketplace-items`,e],queryFn:()=>ze(e),placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Qe(e){return a({queryKey:[`marketplace-installed`,e],queryFn:()=>Ue(e),staleTime:1e4})}function $e(){let e=c();return d({mutationFn:e=>He(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Ye({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.type===`plugin`?t(`marketplaceInstallSuccessPlugin`):t(`marketplaceInstallSuccessSkill`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceInstallFailed`))}})}function et(){let e=c();return d({mutationFn:e=>We(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Xe({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.action===`enable`?t(`marketplaceEnableSuccess`):n.action===`disable`?t(`marketplaceDisableSuccess`):t(`marketplaceUninstallSuccess`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceOperationFailed`))}})}function tt(e){return(0,N.jsx)(`div`,{className:`mb-4`,children:(0,N.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,children:[(0,N.jsx)(j,{className:`h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2`}),(0,N.jsx)(`input`,{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:`w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e.scope===`all`&&(0,N.jsxs)(D,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[(0,N.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,N.jsx)(w,{})}),(0,N.jsxs)(ee,{children:[(0,N.jsx)(E,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,N.jsx)(E,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]})})}function nt(e){return(0,N.jsx)(N.Fragment,{children:Array.from({length:e.count},(e,t)=>(0,N.jsx)(`article`,{className:`rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3.5 justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,N.jsx)(k,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,N.jsx)(k,{className:`h-4 w-32 max-w-[70%]`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(k,{className:`h-3 w-12`}),(0,N.jsx)(k,{className:`h-3 w-24`})]}),(0,N.jsx)(k,{className:`h-3 w-full`})]})]}),(0,N.jsx)(k,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function rt(e){return(0,N.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onPrev,disabled:e.page<=1||e.busy,children:t(`prev`)}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 min-w-20 text-center`,children:e.totalPages===0?`0 / 0`:`${e.page} / ${e.totalPages}`}),(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:t(`next`)})]})}var it=12,at=it;function ot(e){return(e??``).trim().toLowerCase()}function Z(e,t){let n=ot(t);return n.length>0?`${e}:${n}`:``}function st(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ct(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function lt(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Z(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function ut(e,t){return t.get(Z(e.type,e.spec))||t.get(Z(e.type,e.id))||t.get(Z(e.type,e.label))}function dt(e,t,n,r){let i=ot(n);if(!i)return!0;let a=A(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>ot(e)).filter(Boolean).some(e=>e.includes(i))}function ft(e){let t=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`],n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+((n<<5)-n);return t[Math.abs(n)%t.length]}function pt({name:e,fallback:t}){let n=e||t,r=n.substring(0,2).toUpperCase();return(0,N.jsx)(`div`,{className:i(`flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0`,ft(n)),children:r})}function Q(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function $(e){let t=e.metadataRaw?.trim()||`-`,n=e.contentRaw?.trim()||`-`,r=e.summary?.trim(),i=e.description?.trim(),a=!!i&&i!==r,o=`<!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>${Q(e.title)}</title>
7
+ <style>
8
+ :root { color-scheme: light; }
9
+ body { margin: 0; background: #f7f9fc; color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
10
+ .wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 40px; }
11
+ .hero { border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #eff6ff, #ffffff); padding: 20px; box-shadow: 0 6px 20px rgba(30, 64, 175, 0.08); }
12
+ .hero h1 { margin: 0; font-size: 26px; }
13
+ .meta { margin-top: 8px; color: #475569; font-size: 13px; overflow-wrap: anywhere; word-break: break-word; }
14
+ .summary { margin-top: 14px; font-size: 14px; line-height: 1.7; color: #334155; }
15
+ .grid { display: grid; grid-template-columns: 260px 1fr; gap: 14px; margin-top: 16px; }
16
+ .card { border: 1px solid #e2e8f0; background: #fff; border-radius: 14px; overflow: hidden; }
17
+ .card h2 { margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 700; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
18
+ .card .body { padding: 12px 14px; font-size: 13px; color: #334155; line-height: 1.7; }
19
+ .code { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6; margin: 0; }
20
+ .tags { margin-top: 10px; }
21
+ .tag { display: inline-block; margin: 0 6px 6px 0; padding: 4px 9px; border-radius: 999px; background: #e0e7ff; color: #3730a3; font-size: 11px; }
22
+ .source { color: #2563eb; text-decoration: none; overflow-wrap: anywhere; word-break: break-all; }
23
+ @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <main class="wrap">
28
+ <section class="hero">
29
+ <h1>${Q(e.title)}</h1>
30
+ <div class="meta">${Q(e.typeLabel)} · ${Q(e.spec)}${e.author?` · ${Q(e.author)}`:``}</div>
31
+ ${r?`<p class="summary">${Q(r)}</p>`:``}
32
+ ${a?`<p class="summary">${Q(i)}</p>`:``}
33
+ ${e.tags&&e.tags.length>0?`<div class="tags">${e.tags.map(e=>`<span class="tag">${Q(e)}</span>`).join(``)}</div>`:``}
34
+ ${e.sourceUrl?`<p class="meta" style="margin-top:12px;">${Q(e.sourceLabel??`Source`)}: <a class="source" href="${Q(e.sourceUrl)}" target="_blank" rel="noopener noreferrer">${Q(e.sourceUrl)}</a></p>`:``}
35
+ </section>
36
+
37
+ <section class="grid">
38
+ <article class="card">
39
+ <h2>Metadata</h2>
40
+ <div class="body"><pre class="code">${Q(t)}</pre></div>
41
+ </article>
42
+ <article class="card">
43
+ <h2>Content</h2>
44
+ <div class="body"><pre class="code">${Q(n)}</pre></div>
45
+ </article>
46
+ </section>
47
+ </main>
48
+ </body>
49
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(o)}`}function mt(e){let{item:n,record:r,localeFallbacks:i,installState:a,manageState:o,onOpen:s,onInstall:c,onManage:l}=e,u=r?.type===`plugin`?r:void 0,d=n?.name??r?.label??r?.id??r?.spec??t(`marketplaceUnknownItem`),f=A(n?.summaryI18n,n?.summary,i)||(r?t(`marketplaceInstalledLocalSummary`):``),p=n?.install.spec??r?.spec??``,m=r?.id||r?.spec,h=m?o.actionsByTarget.get(m):void 0,g=!!h,_=!!u,v=r?.type===`plugin`&&r.origin!==`bundled`,y=r?.type===`skill`&&r.source===`workspace`,b=!!(v||y),x=r?r.enabled===!1||r.runtimeStatus===`disabled`:!1,S=n?.install.spec,C=typeof S==`string`&&a.installingSpecs.has(S);return(0,N.jsxs)(`article`,{onClick:s,className:`group bg-white border border-gray-200/40 hover:border-blue-300/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-pointer`,children:[(0,N.jsxs)(`div`,{className:`flex gap-3 min-w-0 flex-1 h-full items-start`,children:[(0,N.jsx)(pt,{name:d,fallback:p||t(`marketplaceTypeExtension`)}),(0,N.jsx)(`div`,{className:`min-w-0 flex-1 flex flex-col justify-center h-full`,children:(0,N.jsxs)(Re,{delayDuration:400,children:[(0,N.jsxs)(q,{children:[(0,N.jsx)(J,{asChild:!0,children:(0,N.jsx)(`div`,{className:`text-[14px] font-semibold text-gray-900 truncate leading-tight`,children:d})}),(0,N.jsx)(Y,{className:`max-w-[300px] text-xs`,children:d})]}),(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 mt-0.5 mb-1.5`,children:p&&(0,N.jsxs)(q,{children:[(0,N.jsx)(J,{asChild:!0,children:(0,N.jsx)(`span`,{className:`text-[11px] text-gray-400 truncate max-w-full font-mono`,children:p})}),(0,N.jsx)(Y,{className:`max-w-[300px] text-xs font-mono break-all`,children:p})]})}),(0,N.jsxs)(q,{children:[(0,N.jsx)(J,{asChild:!0,children:(0,N.jsx)(`p`,{className:`text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left`,children:f})}),f&&(0,N.jsx)(Y,{className:`max-w-[400px] text-xs leading-relaxed`,children:f})]})]})})]}),(0,N.jsxs)(`div`,{className:`shrink-0 flex items-center h-full`,children:[n&&!r&&(0,N.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c(n)},disabled:C,className:`inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors`,children:t(C?`marketplaceInstalling`:`marketplaceInstall`)}),u&&_&&(0,N.jsx)(`button`,{disabled:g,onClick:e=>{e.stopPropagation(),l(x?`enable`:`disable`,u)},className:`inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors`,children:t(h&&h!==`uninstall`?h===`enable`?`marketplaceEnabling`:`marketplaceDisabling`:x?`marketplaceEnable`:`marketplaceDisable`)}),r&&b&&(0,N.jsx)(`button`,{disabled:g,onClick:e=>{e.stopPropagation(),l(`uninstall`,r)},className:`inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors`,children:t(h===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)})]})]})}function ht(e={}){let{forcedType:n}=e,r=u(),i=l(),{language:a}=oe(),o=ae(),s=(0,M.useMemo)(()=>n===`plugins`||n===`skills`?n:i.type===`plugins`||i.type===`skills`?i.type:null,[n,i.type]);(0,M.useEffect)(()=>{n||s||r(`/marketplace/plugins`,{replace:!0})},[n,s,r]);let c=s===`skills`?`skill`:`plugin`,d=(0,M.useMemo)(()=>de(a),[a]),f=c===`plugin`?{pageTitle:`marketplacePluginsPageTitle`,pageDescription:`marketplacePluginsPageDescription`,tabMarketplace:`marketplaceTabMarketplacePlugins`,tabInstalled:`marketplaceTabInstalledPlugins`,searchPlaceholder:`marketplaceSearchPlaceholderPlugins`,sectionCatalog:`marketplaceSectionPlugins`,sectionInstalled:`marketplaceSectionInstalledPlugins`,errorLoadData:`marketplaceErrorLoadingPluginsData`,errorLoadInstalled:`marketplaceErrorLoadingInstalledPlugins`,emptyData:`marketplaceNoPlugins`,emptyInstalled:`marketplaceNoInstalledPlugins`,installedCountSuffix:`marketplaceInstalledPluginsCountSuffix`}:{pageTitle:`marketplaceSkillsPageTitle`,pageDescription:`marketplaceSkillsPageDescription`,tabMarketplace:`marketplaceTabMarketplaceSkills`,tabInstalled:`marketplaceTabInstalledSkills`,searchPlaceholder:`marketplaceSearchPlaceholderSkills`,sectionCatalog:`marketplaceSectionSkills`,sectionInstalled:`marketplaceSectionInstalledSkills`,errorLoadData:`marketplaceErrorLoadingSkillsData`,errorLoadInstalled:`marketplaceErrorLoadingInstalledSkills`,emptyData:`marketplaceNoSkills`,emptyInstalled:`marketplaceNoInstalledSkills`,installedCountSuffix:`marketplaceInstalledSkillsCountSuffix`},[p,m]=(0,M.useState)(``),[h,g]=(0,M.useState)(``),[_,v]=(0,M.useState)(`all`),[y,b]=(0,M.useState)(`relevance`),[x,S]=(0,M.useState)(1),[C,w]=(0,M.useState)(new Set),[T,ee]=(0,M.useState)(new Map);(0,M.useEffect)(()=>{let e=setTimeout(()=>{S(1),g(p.trim())},250);return()=>clearTimeout(e)},[p]),(0,M.useEffect)(()=>{S(1)},[c]);let E=Qe(c),D=Ze({q:h||void 0,type:c,sort:y,page:x,pageSize:it}),te=$e(),ne=et(),{confirm:re,ConfirmDialog:ie}=se(),O=(0,M.useMemo)(()=>E.data?.records??[],[E.data?.records]),k=(0,M.useMemo)(()=>D.data?.items??[],[D.data?.items]),j=(0,M.useMemo)(()=>st(k),[k]),P=(0,M.useMemo)(()=>ct(O),[O]),F=(0,M.useMemo)(()=>{let e=O.filter(e=>e.type===c).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:ut(e,j)})).filter(e=>dt(e.record,e.item,h,d));return e.sort((e,t)=>{let n=e.record.installedAt?Date.parse(e.record.installedAt):NaN,r=t.record.installedAt?Date.parse(t.record.installedAt):NaN;return!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r?r-n:e.record.spec.localeCompare(t.record.spec)}),e},[O,c,j,h,d]),I=_===`installed`?F.length:D.data?.total??0,L=_===`installed`?1:D.data?.totalPages??0,fe=_===`all`&&D.isLoading&&!D.data,R=_===`installed`&&E.isLoading&&!E.data,z=fe||R,B=(0,M.useMemo)(()=>_===`installed`?E.isLoading&&!E.data?t(`loading`):`${F.length} ${t(f.installedCountSuffix)}`:D.data?`${k.length} / ${I}`:t(`loading`),[_,E.data,E.isLoading,F.length,D.data,k.length,I,f.installedCountSuffix]),V={installingSpecs:C},H={actionsByTarget:T},pe=[{id:`all`,label:t(f.tabMarketplace)},{id:`installed`,label:t(f.tabInstalled),count:E.data?.total??0}],U=async e=>{let t=e.install.spec;if(!C.has(t)){w(e=>{let n=new Set(e);return n.add(t),n});try{await te.mutateAsync({type:e.type,spec:t,kind:e.install.kind,...e.type===`skill`?{skill:e.slug,installPath:`skills/${e.slug}`}:{}})}catch{}finally{w(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n})}}},W=async(e,n)=>{let r=n.id||n.spec;if(r&&!T.has(r)&&!(e===`uninstall`&&!await re({title:`${t(`marketplaceUninstallTitle`)} ${r}?`,description:t(`marketplaceUninstallDescription`),confirmLabel:t(`marketplaceUninstall`),variant:`destructive`}))){ee(t=>{let n=new Map(t);return n.set(r,e),n});try{await ne.mutateAsync({type:n.type,action:e,id:r,spec:n.spec})}finally{ee(e=>{if(!e.has(r))return e;let t=new Map(e);return t.delete(r),t})}}},G=async(e,n)=>{let r=e?.name??n?.label??n?.id??n?.spec??t(`marketplaceUnknownItem`);if(!e){let e=$({title:r,typeLabel:n?.type===`plugin`?t(`marketplaceTypePlugin`):t(`marketplaceTypeSkill`),spec:n?.spec??`-`,summary:t(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(n??{},null,2),contentRaw:`-`});o.open(e,{newTab:!0,title:r,kind:`content`});return}let i=A(e.summaryI18n,e.summary,d);if(e.type===`skill`){try{let n=await Be(e.slug),a=$({title:r,typeLabel:t(`marketplaceTypeSkill`),spec:e.install.spec,summary:i,metadataRaw:n.metadataRaw,contentRaw:n.bodyRaw||n.raw,sourceUrl:n.sourceUrl,sourceLabel:`Source (${n.source})`,tags:e.tags,author:e.author});o.open(a,{newTab:!0,title:r,kind:`content`})}catch(n){let a=$({title:r,typeLabel:t(`marketplaceTypeSkill`),spec:e.install.spec,summary:i,metadataRaw:JSON.stringify({error:n instanceof Error?n.message:String(n)},null,2),contentRaw:t(`marketplaceOperationFailed`)});o.open(a,{newTab:!0,title:r,kind:`content`})}return}try{let n=await Ve(e.slug),a=$({title:r,typeLabel:t(`marketplaceTypePlugin`),spec:e.install.spec,summary:i,metadataRaw:n.metadataRaw,contentRaw:n.bodyRaw||n.raw||e.summary,sourceUrl:n.sourceUrl,sourceLabel:`Source (${n.source})`,tags:e.tags,author:e.author});o.open(a,{newTab:!0,title:r,kind:`content`})}catch(n){let a=$({title:r,typeLabel:t(`marketplaceTypePlugin`),spec:e.install.spec,summary:i,metadataRaw:JSON.stringify({error:n instanceof Error?n.message:String(n)},null,2),contentRaw:`-`});o.open(a,{newTab:!0,title:r,kind:`content`})}};return(0,N.jsxs)(ce,{className:`flex h-full min-h-0 flex-col pb-0`,children:[(0,N.jsx)(le,{title:t(f.pageTitle),description:t(f.pageDescription)}),(0,N.jsx)(ue,{tabs:pe,activeTab:_,onChange:e=>{v(e),S(1)},className:`mb-4`}),(0,N.jsx)(tt,{scope:_,searchText:p,searchPlaceholder:t(f.searchPlaceholder),sort:y,onSearchTextChange:m,onSortChange:e=>{S(1),b(e)}}),(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,N.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-900`,children:t(_===`installed`?f.sectionInstalled:f.sectionCatalog)}),(0,N.jsx)(`span`,{className:`text-[12px] text-gray-500`,children:B})]}),_===`all`&&D.isError&&(0,N.jsxs)(`div`,{className:`p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm`,children:[t(f.errorLoadData),`: `,D.error.message]}),_===`installed`&&E.isError&&(0,N.jsxs)(`div`,{className:`p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm`,children:[t(f.errorLoadInstalled),`: `,E.error.message]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":z,children:[(0,N.jsxs)(`div`,{"data-testid":z?`marketplace-list-skeleton`:void 0,className:`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:[z&&(0,N.jsx)(nt,{count:at}),!z&&_===`all`&&k.map(e=>(0,N.jsx)(mt,{item:e,record:lt(e,P),localeFallbacks:d,installState:V,manageState:H,onOpen:()=>void G(e,lt(e,P)),onInstall:U,onManage:W},e.id)),!z&&_===`installed`&&F.map(e=>(0,N.jsx)(mt,{item:e.item,record:e.record,localeFallbacks:d,installState:V,manageState:H,onOpen:()=>void G(e.item,e.record),onInstall:U,onManage:W},e.key))]}),_===`all`&&!z&&!D.isError&&k.length===0&&(0,N.jsx)(`div`,{className:`text-[13px] text-gray-500 py-8 text-center`,children:t(f.emptyData)}),_===`installed`&&!z&&!E.isError&&F.length===0&&(0,N.jsx)(`div`,{className:`text-[13px] text-gray-500 py-8 text-center`,children:t(f.emptyInstalled)})]})]}),_===`all`&&!fe&&(0,N.jsx)(`div`,{className:`shrink-0`,children:(0,N.jsx)(rt,{page:x,totalPages:L,busy:D.isFetching,onPrev:()=>S(e=>Math.max(1,e-1)),onNext:()=>S(e=>L>0?Math.min(L,e+1):e+1)})}),(0,N.jsx)(ie,{})]})}export{Re as a,Ie as c,Fe as d,Y as i,Ne as l,Qe as n,J as o,q as r,Le as s,ht as t,Pe as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./MarketplacePage-DaSRsFUA.js";export{e as MarketplacePage};
@@ -0,0 +1,40 @@
1
+ import{_ as e,l as t,m as n,p as r,u as i}from"./i18n-Cn8SErDV.js";import{c as a,n as o,o as s,r as c,u as l}from"./dist-Cy668qFZ.js";import{t as u}from"./useMutation-BpXHE2OV.js";import{a as d,i as f,n as ee,r as p,t as m}from"./select-D60QRHg9.js";import{i as h}from"./DocBrowserContext-CJ-YKtWh.js";import{$ as g,U as _,et as v,it as y,nt as b,r as te,rt as x,tt as S}from"./index-bAeWRAyo.js";import{t as C}from"./useConfirmDialog-B89bxcd6.js";import{n as w,t as ne}from"./page-layout-Hr-Dvq4o.js";import{t as re}from"./tabs-custom-UTbefkqB.js";import{t as T}from"./skeleton-BvV_2nf3.js";import{n as E,r as D,t as ie}from"./marketplace-localization-CXeGRf6E.js";import{t as O}from"./switch-CcBS0F3U.js";var k=e(n(),1);async function A(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.trim()&&t.set(`tag`,e.tag.trim()),e.sort&&t.set(`sort`,e.sort),typeof e.page==`number`&&Number.isFinite(e.page)&&t.set(`page`,String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize==`number`&&Number.isFinite(e.pageSize)&&t.set(`pageSize`,String(Math.max(1,Math.trunc(e.pageSize))));let n=t.toString(),r=await c.get(n?`/api/marketplace/mcp/items?${n}`:`/api/marketplace/mcp/items`);if(!r.ok)throw Error(r.error.message);return r.data}async function j(){let e=await c.get(`/api/marketplace/mcp/installed`);if(!e.ok)throw Error(e.error.message);return e.data}async function ae(e){let t=await c.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function M(e){let t=await c.post(`/api/marketplace/mcp/install`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function N(e){let t=await c.post(`/api/marketplace/mcp/manage`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function P(e){let t=await c.post(`/api/marketplace/mcp/doctor`,{name:e});if(!t.ok)throw Error(t.error.message);return t.data}function F(e){return a({queryKey:[`marketplace-mcp-items`,e],queryFn:()=>A(e),staleTime:15e3})}function I(){return a({queryKey:[`marketplace-mcp-installed`],queryFn:()=>j(),staleTime:1e4})}function L(){let e=l();return u({mutationFn:M,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),o.success(n.message||t(`marketplaceInstallSuccessMcp`))},onError:e=>{o.error(e.message||t(`marketplaceInstallFailed`))}})}function R(){let e=l();return u({mutationFn:N,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),o.success(n.message||t(`marketplaceMcpManageSuccess`))},onError:e=>{o.error(e.message||t(`marketplaceOperationFailed`))}})}var z=r(),B=12;function V(e){return(e??``).trim().toLowerCase()}function H(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=V(r);!e||t.has(e)||t.set(e,n)}}return t}function U(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=V(e);if(!n)continue;let r=t.get(n);if(r)return r}}function W(e,t,n,r,i){let a=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),o=`<!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>${a(e)}</title>
7
+ <style>
8
+ body { margin: 0; background: #f8fafc; color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
9
+ .wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 40px; }
10
+ .hero { border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #eff6ff, #ffffff); padding: 20px; }
11
+ .hero h1 { margin: 0; font-size: 26px; }
12
+ .grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; margin-top: 16px; }
13
+ .card { border: 1px solid #e2e8f0; background: #fff; border-radius: 14px; overflow: hidden; }
14
+ .card h2 { margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 700; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
15
+ .body { padding: 12px 14px; }
16
+ pre { margin: 0; white-space: pre-wrap; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
17
+ a { color: #2563eb; text-decoration: none; }
18
+ @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <main class="wrap">
23
+ <section class="hero">
24
+ <h1>${a(e)}</h1>
25
+ ${i?`<p>${a(i)}</p>`:``}
26
+ ${r?`<p><a href="${a(r)}" target="_blank" rel="noopener noreferrer">${a(r)}</a></p>`:``}
27
+ </section>
28
+ <section class="grid">
29
+ <article class="card">
30
+ <h2>Metadata</h2>
31
+ <div class="body"><pre>${a(t)}</pre></div>
32
+ </article>
33
+ <article class="card">
34
+ <h2>Content</h2>
35
+ <div class="body"><pre>${a(n)}</pre></div>
36
+ </article>
37
+ </section>
38
+ </main>
39
+ </body>
40
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(o)}`}function G(e,n,r){return D(n?.summaryI18n,n?.summary,e)||E(r,e)||t(`marketplaceInstalledLocalSummary`)}function K(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function q(e){let n=e.item?.install,[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(!0),[c,l]=(0,k.useState)({});return(0,k.useEffect)(()=>{i(n?.defaultName??``),o(!0),l(Object.fromEntries((n?.inputs??[]).map(e=>[e.id,e.defaultValue??``])))},[n,e.open]),(0,z.jsx)(g,{open:e.open,onOpenChange:e.onOpenChange,children:(0,z.jsxs)(v,{children:[(0,z.jsxs)(x,{children:[(0,z.jsx)(y,{children:t(`marketplaceMcpInstallDialogTitle`)}),(0,z.jsx)(S,{children:e.item?.name??`-`})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:t(`marketplaceMcpServerName`)}),(0,z.jsx)(_,{value:r,onChange:e=>i(e.target.value),placeholder:n?.defaultName??`mcp-server`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:t(`marketplaceMcpAllAgents`)}),(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:t(`marketplaceMcpAllAgentsDescription`)})]}),(0,z.jsx)(O,{checked:a,onCheckedChange:o})]}),(n?.inputs??[]).map(e=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description&&(0,z.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}),(0,z.jsx)(_,{type:e.secret?`password`:`text`,value:c[e.id]??``,onChange:t=>l(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,z.jsxs)(b,{children:[(0,z.jsx)(s,{variant:`outline`,onClick:()=>e.onOpenChange(!1),disabled:e.pending,children:t(`cancel`)}),(0,z.jsx)(s,{onClick:()=>void e.onSubmit({name:r,allAgents:a,inputs:c}),disabled:e.pending||!r.trim(),children:e.pending?t(`marketplaceInstalling`):t(`marketplaceInstall`)})]})]})})}function oe(e){return(0,z.jsx)(g,{open:e.open,onOpenChange:e.onOpenChange,children:(0,z.jsxs)(v,{children:[(0,z.jsxs)(x,{children:[(0,z.jsx)(y,{children:t(`marketplaceMcpDoctorTitle`)}),(0,z.jsx)(S,{children:e.targetName??`-`})]}),e.pending&&(0,z.jsx)(`div`,{className:`text-sm text-gray-500`,children:t(`loading`)}),!e.pending&&e.result&&(0,z.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,z.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorAccessible`),`: `,e.result.accessible?t(`statusReady`):t(`marketplaceOperationFailed`)]}),(0,z.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTransport`),`: `,e.result.transport.toUpperCase()]}),(0,z.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTools`),`: `,e.result.toolCount]}),e.result.error&&(0,z.jsx)(`div`,{className:`rounded-lg bg-rose-50 px-3 py-2 text-rose-600`,children:e.result.error})]})]})})}function J(){let[e,n]=(0,k.useState)(`catalog`),[r,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(``),[c,l]=(0,k.useState)(`relevance`),[g,v]=(0,k.useState)(1),[y,b]=(0,k.useState)(null),[x,S]=(0,k.useState)(null),[E,D]=(0,k.useState)(null),{language:O}=te(),A=h(),{confirm:j,ConfirmDialog:M}=C(),N=(0,k.useMemo)(()=>ie(O),[O]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>{v(1),s(r.trim())},250);return()=>window.clearTimeout(e)},[r]);let V=F({q:o||void 0,sort:c,page:g,pageSize:B}),J=I(),Y=L(),se=R(),X=u({mutationFn:P,onSuccess:(e,t)=>{S(t),D(e)}}),ce=(0,k.useMemo)(()=>H(J.data?.records??[]),[J.data?.records]),Z=(0,k.useMemo)(()=>(J.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return o?t.includes(o.toLowerCase()):!0}),[J.data?.records,o]),le=async(e,n)=>{let r=e?.name??n?.label??n?.id??`MCP`,i=G(N,e,n);if(!e){let e=W(r,JSON.stringify(n??{},null,2),t(`marketplaceInstalledLocalSummary`),n?.docsUrl,i);A.open(e,{newTab:!0,title:r,kind:`content`});return}try{let t=await ae(e.slug),n=W(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,i);A.open(n,{newTab:!0,title:r,kind:`content`})}catch(e){let t=W(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),i,void 0,i);A.open(t,{newTab:!0,title:r,kind:`content`})}},ue=async e=>{y&&(await Y.mutateAsync({spec:y.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),b(null))},Q=async(e,n)=>{let r=n.id||n.spec;r&&(e===`remove`&&!await j({title:`${t(`marketplaceMcpRemoveTitle`)} ${r}?`,description:t(`marketplaceMcpRemoveDescription`),confirmLabel:t(`marketplaceMcpRemove`),variant:`destructive`})||await se.mutateAsync({action:e,id:r,spec:n.spec}))},$=(e,n)=>{let r=n??(e?U(e,ce):void 0),i=e?.name??n?.label??n?.id??`MCP`,a=G(N,e,n),o=K(e,n),s=r?r.enabled===!1?t(`marketplaceDisable`):t(`statusReady`):null;return(0,z.jsx)(`article`,{onClick:()=>void le(e,n),className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:i}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:o}),(0,z.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:a}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(e?.tags??[]).map(e=>(0,z.jsx)(`span`,{className:`rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-600`,children:e},e)),s&&(0,z.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] text-emerald-700`,children:s})]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!r&&e&&(0,z.jsx)(`button`,{className:`rounded-xl bg-primary px-3 py-1.5 text-xs font-medium text-white`,onClick:t=>{t.stopPropagation(),b(e)},children:t(`marketplaceInstall`)}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{className:`rounded-xl border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700`,onClick:e=>{e.stopPropagation(),Q(r.enabled===!1?`enable`:`disable`,r)},children:r.enabled===!1?t(`marketplaceEnable`):t(`marketplaceDisable`)}),(0,z.jsx)(`button`,{className:`rounded-xl border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700`,onClick:e=>{e.stopPropagation(),S(r.id??null),D(null),X.mutateAsync(r.id??``)},children:t(`marketplaceMcpDoctor`)}),(0,z.jsx)(`button`,{className:`rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600`,onClick:e=>{e.stopPropagation(),Q(`remove`,r)},children:t(`marketplaceMcpRemove`)})]})]})]})},`${e?.id??n?.id??n?.spec}`)};return(0,z.jsxs)(w,{className:`flex h-full min-h-0 flex-col pb-0`,children:[(0,z.jsx)(ne,{title:t(`marketplaceMcpPageTitle`),description:t(`marketplaceMcpPageDescription`)}),(0,z.jsx)(re,{tabs:[{id:`catalog`,label:t(`marketplaceMcpTabCatalog`)},{id:`installed`,label:t(`marketplaceMcpTabInstalled`),count:J.data?.total??0}],activeTab:e,onChange:e=>n(e),className:`mb-4`}),(0,z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between`,children:[(0,z.jsx)(_,{value:r,onChange:e=>a(e.target.value),placeholder:t(`marketplaceMcpSearchPlaceholder`),className:`md:max-w-sm`}),(0,z.jsxs)(m,{value:c,onValueChange:e=>l(e),children:[(0,z.jsx)(f,{className:`h-9 w-[180px] rounded-lg`,children:(0,z.jsx)(d,{})}),(0,z.jsxs)(ee,{children:[(0,z.jsx)(p,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,z.jsx)(p,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]}),(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:t(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`)}),(0,z.jsx)(`span`,{className:`text-xs text-gray-500`,children:e===`catalog`?V.data?.total??0:J.data?.total??0})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[(0,z.jsxs)(`div`,{className:i(`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`),children:[e===`catalog`&&V.isLoading&&Array.from({length:6},(e,t)=>(0,z.jsxs)(`div`,{className:`rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm`,children:[(0,z.jsx)(T,{className:`h-4 w-32`}),(0,z.jsx)(T,{className:`mt-2 h-3 w-20`}),(0,z.jsx)(T,{className:`mt-3 h-3 w-full`}),(0,z.jsx)(T,{className:`mt-2 h-3 w-2/3`})]},t)),e===`catalog`&&!V.isLoading&&(V.data?.items??[]).map(e=>$(e)),e===`installed`&&Z.map(e=>$(void 0,e))]}),e===`catalog`&&V.isError&&(0,z.jsx)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:V.error.message}),e===`installed`&&J.isError&&(0,z.jsx)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:J.error.message}),e===`catalog`&&!V.isLoading&&(V.data?.items?.length??0)===0&&(0,z.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:t(`marketplaceNoMcp`)}),e===`installed`&&Z.length===0&&(0,z.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:t(`marketplaceNoInstalledMcp`)})]})]}),e===`catalog`&&(0,z.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,z.jsx)(`button`,{className:`h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40`,onClick:()=>v(e=>Math.max(1,e-1)),disabled:g<=1||V.isFetching,children:t(`prev`)}),(0,z.jsx)(`div`,{className:`min-w-20 text-center text-sm text-gray-600`,children:V.data?.totalPages?`${g} / ${V.data.totalPages}`:`0 / 0`}),(0,z.jsx)(`button`,{className:`h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40`,onClick:()=>v(e=>e+1),disabled:!V.data?.totalPages||g>=V.data.totalPages||V.isFetching,children:t(`next`)})]}),(0,z.jsx)(q,{item:y,open:!!y,pending:Y.isPending,onOpenChange:e=>!e&&b(null),onSubmit:ue}),(0,z.jsx)(oe,{open:!!x,targetName:x,result:E,pending:X.isPending,onOpenChange:e=>!e&&S(null)}),(0,z.jsx)(M,{})]})}export{J as McpMarketplacePage};
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,m as n,p as r,u as i}from"./i18n-Cn8SErDV.js";import{o as a}from"./dist-Cy668qFZ.js";import{a as o,i as s,k as c,n as l,r as u,t as d}from"./select-D60QRHg9.js";import{t as f}from"./createLucideIcon-B8FV3fzy.js";import{t as p}from"./book-open-1agbn9dT.js";import{t as m}from"./loader-circle-d_mzMi2S.js";import{t as h}from"./DocBrowserContext-CJ-YKtWh.js";import{E as g,U as _,W as v,c as y,l as b,st as x,u as S}from"./index-bAeWRAyo.js";import{n as C,t as w}from"./page-layout-Hr-Dvq4o.js";import{t as T}from"./skeleton-BvV_2nf3.js";import{a as E,n as D,r as O,t as k}from"./provider-models-C8JQUd1E.js";import{t as A}from"./config-hints-fGnUjDe9.js";import{t as j}from"./label-Cz0q8fx4.js";var M=f(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),N=f(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),P=e(n(),1),F=r();function I(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function L({id:e,value:t,onChange:n,options:r,disabled:a=!1,placeholder:o,className:s,inputClassName:l,emptyText:u,createText:d,maxItems:f=1/0,onEnter:p}){let[m,h]=(0,P.useState)(!1);(0,P.useEffect)(()=>{a&&m&&h(!1)},[a,m]);let g=(0,P.useMemo)(()=>I(r),[r]),v=t.trim().toLowerCase(),y=(0,P.useMemo)(()=>{let e=g.map((e,t)=>({option:e,index:t}));v.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===v?0:n.startsWith(v)?1:n.includes(v)?2:3,a=r===v?0:r.startsWith(v)?1:r.includes(v)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(f)?t.slice(0,Math.max(1,f)):t},[g,v,f]),b=t.trim().length>0&&g.some(e=>e===t.trim());return(0,F.jsxs)(`div`,{className:i(`relative`,s),onBlur:()=>{setTimeout(()=>h(!1),120)},children:[(0,F.jsx)(_,{id:e,value:t,disabled:a,onFocus:()=>{a||h(!0)},onChange:e=>{n(e.target.value),!m&&!a&&h(!0)},onKeyDown:e=>{e.key===`Enter`&&(p&&(e.preventDefault(),p()),h(!1))},placeholder:o,className:i(`pr-10`,l)}),(0,F.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>h(e=>!e),disabled:a,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,a?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,F.jsx)(M,{className:`h-4 w-4`})}),m&&!a&&(0,F.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,F.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!b&&t.trim().length>0&&(0,F.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),h(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,F.jsx)(c,{className:`h-4 w-4 text-transparent`}),(0,F.jsx)(`span`,{className:`truncate text-gray-700`,children:d?d.replace(`{value}`,t.trim()):t.trim()})]}),y.map(e=>(0,F.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),h(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,F.jsx)(c,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,F.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),y.length===0&&t.trim().length===0&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u??`No models available`})]})})]})}function R(){let{data:e,isLoading:n}=y(),{data:r}=b(),{data:i}=S(),c=g(),[f,M]=(0,P.useState)(``),[I,R]=(0,P.useState)(``),[z,B]=(0,P.useState)(``),V=i?.uiHints,H=A(`agents.defaults.model`,V),U=A(`agents.defaults.workspace`,V),W=(0,P.useMemo)(()=>k({meta:r,config:e,onlyConfigured:!0}),[e,r]),G=(0,P.useMemo)(()=>new Map(W.map(e=>[e.name,e])),[W]),K=G.get(f),q=K?.name??``,J=(0,P.useMemo)(()=>K?.aliases??[],[K]),Y=(0,P.useMemo)(()=>K?.models??[],[K]);(0,P.useEffect)(()=>{if(!e?.agents?.defaults)return;let t=(e.agents.defaults.model||``).trim(),n=O(t,W)??``,r=G.get(n)?.aliases??[];M(n),R(n?E(t,r):``),B(e.agents.defaults.workspace||``)},[e,W,G]);let X=(0,P.useMemo)(()=>{let e=new Set;for(let t of Y){let n=t.trim();n&&e.add(n)}return[...e]},[Y]),Z=(0,P.useMemo)(()=>{if(!K)return``;let e=E(I,J);return e?D(K.prefix,e):``},[I,K,J]),Q=t(`modelIdentifierHelp`)||H?.help||``;return n?(0,F.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`h-8 w-32`}),(0,F.jsx)(T,{className:`h-4 w-48`})]}),(0,F.jsxs)(v,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mb-6`,children:[(0,F.jsx)(T,{className:`h-12 w-12 rounded-xl`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`h-5 w-24`}),(0,F.jsx)(T,{className:`h-3 w-32`})]})]}),(0,F.jsx)(T,{className:`h-4 w-20 mb-2`}),(0,F.jsx)(T,{className:`h-10 w-full rounded-xl`})]}),(0,F.jsxs)(v,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,F.jsx)(T,{className:`h-5 w-24 mb-2`}),(0,F.jsx)(T,{className:`h-10 w-full rounded-xl`})]})]}):(0,F.jsxs)(C,{children:[(0,F.jsx)(w,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,F.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c.mutate({model:Z,workspace:z})},className:`space-y-8`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-8`,children:[(0,F.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,F.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,F.jsx)(x,{className:`h-5 w-5`})}),(0,F.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`model`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:H?.label??`Model Name`}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,F.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,F.jsxs)(d,{value:q,onValueChange:e=>{M(e),R(``)},children:[(0,F.jsx)(s,{className:`h-10 w-full rounded-xl`,children:(0,F.jsx)(o,{placeholder:t(`providersSelectPlaceholder`)})}),(0,F.jsx)(l,{children:W.map(e=>(0,F.jsx)(u,{value:e.name,children:e.displayName},e.name))})]})}),(0,F.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,F.jsx)(L,{id:`model`,value:I,onChange:e=>{if(!K){R(``);return}R(E(e,J))},options:X,disabled:!q,placeholder:H?.placeholder??`gpt-5.1`,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:t(`modelPickerNoOptions`),createText:t(`modelPickerUseCustom`)},q)]}),(0,F.jsx)(`p`,{className:`text-xs text-gray-400`,children:Q}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`modelInputCustomHint`)}),(0,F.jsxs)(`a`,{href:`${h}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors`,children:[(0,F.jsx)(p,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,F.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,F.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,F.jsx)(N,{className:`h-5 w-5`})}),(0,F.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`workspace`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:U?.label??`Default Path`}),(0,F.jsx)(_,{id:`workspace`,value:z,onChange:e=>B(e.target.value),placeholder:U?.placeholder??`/path/to/workspace`,className:`rounded-xl`})]})]})]}),(0,F.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,F.jsx)(a,{type:`submit`,disabled:c.isPending,size:`lg`,children:c.isPending?(0,F.jsx)(m,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})]})}export{R as ModelConfig};
@@ -0,0 +1 @@
1
+ import{_ as e,a as t,l as n,m as r,p as i,u as a}from"./i18n-Cn8SErDV.js";import{n as o,o as s,u as c}from"./dist-Cy668qFZ.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-D60QRHg9.js";import{t as h}from"./createLucideIcon-B8FV3fzy.js";import{t as g}from"./plus-BnGg0mB-.js";import{t as _}from"./search-CQCQaN4Z.js";import{t as v}from"./trash-2-DvPrU1xO.js";import{t as y}from"./x-C8AWDn7c.js";import{C as b,O as x,S as ee,U as S,_ as te,b as ne,c as re,d as ie,h as ae,l as oe,pt as se,u as ce}from"./index-bAeWRAyo.js";import{n as C,r as le,t as w}from"./popover-_nEUAtWY.js";import{t as ue}from"./LogoBadge-DRDmIa7o.js";import{n as T,t as de}from"./page-layout-Hr-Dvq4o.js";import{t as E}from"./tabs-custom-UTbefkqB.js";import{t as D}from"./status-dot-D43lBF1a.js";import{t as O}from"./config-hints-fGnUjDe9.js";import{i as k,n as fe,r as A,t as pe}from"./config-layout-B-7erZRN.js";import{t as j}from"./label-Cz0q8fx4.js";import{t as me}from"./switch-CcBS0F3U.js";var he=h(`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`}]]),M=h(`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`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(r(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`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,F.jsx)(S,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:t,className:r}){let i=e?Object.entries(e):[],o=(e,n,r)=>{let a=[...i];a[e]=[n,r],t(Object.fromEntries(a))},c=()=>{t({...e,"":``})},l=e=>{let n=i.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,t],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(S,{type:`text`,value:e,onChange:e=>o(r,e.target.value,t),placeholder:n(`headerName`),className:`flex-1`}),(0,F.jsx)(S,{type:`text`,value:t,onChange:t=>o(r,e,t.target.value),placeholder:n(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),n(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:t,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!t),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),n(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:t,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return t?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(j,{className:`text-sm font-medium text-gray-900`,children:t.displayName||n(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{className:`text-xs font-medium text-gray-700`,children:n(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:n(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:n(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:n(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[n(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(j,{className:`text-sm font-medium text-gray-900`,children:n(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?n(`enabled`):n(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function I(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 Ee(e,t){let n=I(e),r=I(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 De(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 Oe(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 L(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Oe(n,t))}return n.trim()}function ke(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ae(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function je(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?Ae(e,t):t}function Me(e,t){return ke(e,t)?[]:e}function Ne(e,t,n){t!==n&&(e.enabled=t)}function R(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Pe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=R(n);!e||t.includes(e)||t.push(e)}return t}function Fe(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=L(r,t);if(!e)continue;let a=Pe(i?.supported);if(a.length===0)continue;let o=R(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Ie(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=Pe(i.supported);if(e.length===0)continue;let a=R(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Le(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!ke([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function Re(e){return n(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function ze(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Be(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ve(e){let{models:t,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:x}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(j,{className:`text-sm font-medium text-gray-900`,children:n(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),n(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(S,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:n(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:n(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,t.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:n(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:n(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=r[e],i=t?.supported??[],a=t?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(w,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`providerModelThinkingTitle`),title:n(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(C,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:n(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:x(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(j,{className:`text-xs font-medium text-gray-700`,children:n(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:n(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:x(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function He(e){return e.enabled?(0,F.jsx)(D,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?n(`statusReady`):n(`statusSetup`),className:e.className}):(0,F.jsx)(D,{status:`inactive`,label:n(`disabled`),className:e.className})}function z({providerName:e,onProviderDeleted:r}){let i=c(),{data:a}=re(),{data:l}=oe(),{data:u}=ce(),d=x(),f=ae(),p=b(),m=ee(),h=ne(),g=te(),[_,y]=(0,P.useState)(``),[ie,se]=(0,P.useState)(!0),[C,le]=(0,P.useState)(``),[w,ue]=(0,P.useState)(null),[T,de]=(0,P.useState)(`auto`),[E,D]=(0,P.useState)([]),[k,A]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,Oe]=(0,P.useState)(!1),[Ae,R]=(0,P.useState)(null),[Pe,z]=(0,P.useState)(``),[Ue,We]=(0,P.useState)(``),Ge=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?O(`providers.${e}.apiKey`,Ke):void 0,Je=e?O(`providers.${e}.apiBase`,Ke):void 0,Ye=e?O(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?O(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||n(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>De([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=I(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>De((B?.defaultModels??[]).map(e=>L(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>De((V.models??[]).map(e=>L(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>je(nt,rt),[nt,rt]),Y=(0,P.useMemo)(()=>Ie(Fe(V.modelThinking,G),J),[J,G,V.modelThinking]),X=t(),it=B?.apiBaseHelp?.[X]||B?.apiBaseHelp?.en||Je?.help||n(`providerApiBaseHelp`),Z=B?.auth,Q=(0,P.useMemo)(()=>Z?.methods??[],[Z?.methods]),at=(0,P.useMemo)(()=>Q.map(e=>({value:e.id,label:e.label?.[X]||e.label?.en||e.id})),[Q,X]),ot=(0,P.useMemo)(()=>ze({providerName:e,methods:Q,defaultMethodId:Z?.defaultMethodId,language:X}),[e,Z?.defaultMethodId,Q,X]),st=(0,P.useMemo)(()=>{if(!Q.length)return``;let e=Ue.trim();return e&&Q.some(t=>t.id===e)?e:ot||Q[0]?.id||``},[Ue,ot,Q]),ct=(0,P.useMemo)(()=>Q.find(e=>e.id===st),[Q,st]),lt=ct?.hint?.[X]||ct?.hint?.en||``,ut=Be({required:Z?.kind===`device_code`,hasDefault:!!Z?.defaultMethodId?.trim(),optionCount:Q.length}),dt=Z?.note?.[X]||Z?.note?.en||Z?.displayName||``,ft=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:n(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),pt=Be({required:!!B?.supportsWireApi,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:ft.length}),$=(0,P.useCallback)(()=>{Ge.current!==null&&(window.clearTimeout(Ge.current),Ge.current=null)},[]),mt=(0,P.useCallback)((t,r)=>{$(),Ge.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:t}});if(a.status===`pending`){z(n(`providerAuthWaitingBrowser`)),mt(t,a.nextPollMs??r);return}if(a.status===`authorized`){R(null),$(),z(n(`providerAuthCompleted`)),o.success(n(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}R(null),$(),z(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){R(null),$();let t=e instanceof Error?e.message:String(e);z(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),se(!0),le(``),ue(null),de(`auto`),D([]),A({}),M(``),ge(``),R(null),z(``),We(``),$();return}y(``),se(W),le(K),ue(V.extraHeaders||null),de(q),D(J),A(Y),M(``),ge(U),R(null),z(``),We(ot),$()},[e,K,W,V.extraHeaders,q,J,Y,U,ot,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{A(e=>Ie(e,E))},[E]);let ht=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=C.trim()!==K.trim(),r=!Ee(w,tt),i=B?.supportsWireApi?T!==q:!1,a=!ke(E,J),o=!Le(k,Y),s=H?N.trim()!==U:!1;return t||ie!==W||n||r||i||a||o||s},[e,H,N,U,_,ie,W,C,K,w,tt,B?.supportsWireApi,T,q,E,J,k,Y]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:n(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:n(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(n(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),r?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:n(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(He,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=C.trim(),a=I(w),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Ne(n,ie,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),Ee(a,tt)||(n.extraHeaders=a),B?.supportsWireApi&&T!==q&&(n.wireApi=T),ke(E,J)||(n.models=Me(E,nt)),Le(k,Y)||(n.modelThinking=Ie(k,E)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:ie,onChange:se}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:n(`providerDisplayName`)}),(0,F.jsx)(S,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||n(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??n(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??n(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:Z,providerAuthNote:dt,providerAuthMethodOptions:at,providerAuthMethodsCount:Q.length,selectedAuthMethodHint:lt,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:st,onAuthMethodChange:We,onStartProviderAuth:async()=>{if(!(!e||Z?.kind!==`device_code`))try{z(``);let t=await m.mutateAsync({provider:e,data:st?{methodId:st}:{}});if(!t.sessionId||!t.verificationUri)throw Error(n(`providerAuthStartFailed`));R(t.sessionId),z(`${n(`providerAuthOpenPrompt`)}${t.userCode}${n(`providerAuthOpenPromptSuffix`)}`),window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),mt(t.sessionId,t.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);R(null),$(),z(t),o.error(`${n(`providerAuthStartFailed`)}: ${t}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||Z?.kind!==`device_code`))try{$(),R(null);let t=await g.mutateAsync({provider:e}),r=t.expiresAt?` (expires: ${t.expiresAt})`:``;z(`${n(`providerAuthImportStatusPrefix`)}${r}`),o.success(n(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let t=e instanceof Error?e.message:String(e);z(t),o.error(`${n(`providerAuthImportFailed`)}: ${t}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:Ae,authStatusMessage:Pe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(j,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??n(`apiBase`)}),(0,F.jsx)(S,{id:`apiBase`,type:`text`,value:C,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:it})]}),(0,F.jsx)(Ve,{models:E,modelThinking:k,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:Oe,onAddModel:()=>{let e=L(me,G);if(e){if(E.includes(e)){M(``);return}D(t=>[...t,e]),M(``)}},onRemoveModel:e=>{D(t=>t.filter(t=>t!==e)),A(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{A(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{A(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:Re}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:!!B.supportsWireApi,wireApiLabel:Xe?.label??n(`wireApi`),wireApi:T,onWireApiChange:de,shouldUseWireApiPills:pt,wireApiSelectOptions:ft,extraHeadersLabel:Ye?.label??n(`extraHeaders`),extraHeaders:w,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let t=L(E.find(e=>e.trim().length>0)??``,G),r={apiBase:C.trim(),extraHeaders:I(w),model:t||null};_.trim().length>0&&(r.apiKey=_.trim()),B?.supportsWireApi&&(r.wireApi=T);try{let t=await p.mutateAsync({provider:e,data:r});if(t.success){o.success(`${n(`providerTestConnectionSuccess`)} (${t.latencyMs}ms)`);return}let i=[`provider=${t.provider}`,`latency=${t.latencyMs}ms`];t.model&&i.push(`model=${t.model}`),o.error(`${n(`providerTestConnectionFailed`)}: ${t.message} | ${i.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);o.error(`${n(`providerTestConnectionFailed`)}: ${t}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?n(`providerTestingConnection`):n(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!ht,children:d.isPending?n(`saving`):n(ht?`save`:`unchanged`)})]})]})]})}function Ue(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function We(){let{data:e}=re(),{data:t}=oe(),{data:r}=ce(),i=ie(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=t?.providers??[],h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:n(`providersTabConfigured`),count:v},{id:`all`,label:n(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let n=t?.providers??[],r=e?.providers??{},i=d.trim().toLowerCase();return n.filter(e=>{if(o===`installed`){let t=r[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>i?(r[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(i)||e.name.toLowerCase().includes(i):!0)},[t,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let x=l;return!e||!t?(0,F.jsx)(`div`,{className:`p-8`,children:n(`providersLoading`)}):(0,F.jsxs)(T,{children:[(0,F.jsx)(de,{title:n(`providersPageTitle`),description:n(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:k,children:[(0,F.jsxs)(`section`,{className:A,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(E,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?n(`saving`):n(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(S,{value:d,onChange:e=>f(e.target.value),placeholder:n(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(t=>{let r=e.providers[t.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=x===t.name,c=r?.displayName?.trim()||t.displayName||t.name,l=O(`providers.${t.name}`,p),d=Ue(r?.apiBase||t.defaultApiBase||``)||l?.help||n(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(t.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:t.name,src:t.logo?`/logos/${t.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:t.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(D,{status:i?o?`ready`:`setup`:`inactive`,label:n(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},t.name)}),b.length===0&&(0,F.jsxs)(`div`,{className:`flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(se,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:n(`providersNoMatch`)})]})]})]}),(0,F.jsx)(z,{providerName:x,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{We as ProvidersList};
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,m as n,p as r,r as i}from"./i18n-Cn8SErDV.js";import{o as a}from"./dist-Cy668qFZ.js";import{t as o}from"./createLucideIcon-B8FV3fzy.js";import{G as s,J as c,K as l,Q as u,W as d,X as f,Y as p,Z as m,ot as h,q as g}from"./index-bAeWRAyo.js";import{n as _,t as v}from"./page-layout-Hr-Dvq4o.js";import{t as y}from"./status-dot-D43lBF1a.js";var b=o(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),x=o(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),S=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function C(e){return e?.runtime?.lastError?.trim()||``}function w(e){if(!e?.settings.enabled)return!1;let t=C(e);return S.some(e=>e.test(t))}function T(e){return w(e)?{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateReauthorizationRequired`),title:t(`remoteStatusReauthorizationTitle`),description:t(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:t(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:t(`statusReady`),title:t(`remoteStatusReadyTitle`),description:t(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:t(`connecting`),title:t(`remoteStatusConnectingTitle`),description:t(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateDisconnected`),title:t(`remoteStatusIssueTitle`),description:t(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailGeneric`)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteServiceStopped`),title:t(`remoteStatusNeedsServiceTitle`),description:t(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:t(`statusInactive`),title:t(`remoteStatusNeedsEnable`),description:t(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:t(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:t(`statusSetup`),title:t(`remoteStatusNeedsSignIn`),description:t(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:t(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var E=e(n(),1),D=r();function O(e){let{label:t,muted:n,value:r}=e;return(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,D.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,D.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function k(){let e=p(),n=m(),r=n.data,o=f(e=>e.actionLabel),S=(0,E.useMemo)(()=>T(r),[r]),C=!!o,w=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),k=!!(r?.account.loggedIn&&u(r)),{hero:A,issueHint:j}=S;return(0,E.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),n.isLoading&&!r?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,D.jsxs)(_,{className:`space-y-6`,children:[(0,D.jsx)(v,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,D.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,D.jsxs)(d,{children:[(0,D.jsxs)(g,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(c,{children:A.title}),(0,D.jsx)(y,{status:A.badgeStatus,label:A.badgeLabel})]}),(0,D.jsx)(l,{children:A.description})]}),(0,D.jsxs)(s,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,D.jsx)(O,{label:t(`remoteSignedInAccount`),value:r?.account.email}),(0,D.jsx)(O,{label:t(`remoteDeviceName`),value:w}),(0,D.jsx)(O,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,D.jsx)(O,{label:t(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[S.primaryAction?(0,D.jsxs)(a,{onClick:()=>{if(S.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(r);return}if(S.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(r);return}e.remoteAccessManager.enableRemoteAccess(r)},disabled:C,children:[S.primaryAction.showRefreshIcon?(0,D.jsx)(x,{className:`mr-2 h-4 w-4`}):null,o||S.primaryAction.label]}):null,(0,D.jsxs)(a,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:C||!k,children:[(0,D.jsx)(h,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,D.jsx)(a,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:C,children:t(`remoteDisable`)}):null]}),S.shouldShowIssueHint&&j?(0,D.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-amber-900`,children:j.title}),(0,D.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-amber-800`,children:j.body})]}):null,(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,D.jsxs)(d,{children:[(0,D.jsxs)(g,{children:[(0,D.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,D.jsx)(b,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,D.jsx)(l,{children:t(`remoteDeviceSectionDescription`)})]}),(0,D.jsxs)(s,{className:`space-y-5`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(y,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,D.jsx)(y,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,D.jsx)(y,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,D.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,D.jsx)(O,{label:t(`remoteDeviceName`),value:w}),(0,D.jsx)(O,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,D.jsx)(O,{label:t(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,D.jsx)(`div`,{className:`rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600`,children:r?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`)})]})]})]})]})}export{k as RemoteAccessPage};
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,m as n,p as r}from"./i18n-Cn8SErDV.js";import{n as i,o as a}from"./dist-Cy668qFZ.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-D60QRHg9.js";import{t as d}from"./plus-BnGg0mB-.js";import{t as f}from"./save-Caodcm4q.js";import{t as p}from"./trash-2-DvPrU1xO.js";import{G as m,J as h,K as g,U as _,W as v,c as ee,k as y,q as b,u as x}from"./index-bAeWRAyo.js";import{n as te,t as ne}from"./page-layout-Hr-Dvq4o.js";import{t as S}from"./config-hints-fGnUjDe9.js";import{t as C}from"./switch-CcBS0F3U.js";var w=e(n(),1),T=r(),E=[{value:`main`,label:`main`},{value:`per-peer`,label:`per-peer`},{value:`per-channel-peer`,label:`per-channel-peer`},{value:`per-account-channel-peer`,label:`per-account-channel-peer`}];function D(){return{id:``,default:!1,workspace:``,model:``,engine:``,contextTokens:void 0,maxToolIterations:void 0}}function O(){return{agentId:``,match:{channel:``,accountId:``}}}function k(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function A(){let{data:e,isLoading:n}=ee(),{data:r}=x(),A=y(),[j,M]=(0,w.useState)([]),[N,P]=(0,w.useState)([]),[F,I]=(0,w.useState)(`per-channel-peer`),[L,R]=(0,w.useState)(0),[z,B]=(0,w.useState)(2e5),[V,H]=(0,w.useState)(`native`);(0,w.useEffect)(()=>{e&&(M((e.agents.list??[]).map(e=>({id:e.id??``,default:!!e.default,workspace:e.workspace??``,model:e.model??``,engine:e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}))),P((e.bindings??[]).map(e=>({agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}))),I(e.session?.dmScope??`per-channel-peer`),R(e.session?.agentToAgent?.maxPingPongTurns??0),B(e.agents.defaults.contextTokens??2e5),H(e.agents.defaults.engine??`native`))},[e]);let U=r?.uiHints,W=S(`session.dmScope`,U),G=S(`session.agentToAgent.maxPingPongTurns`,U),K=S(`agents.defaults.contextTokens`,U),q=S(`agents.defaults.engine`,U),J=S(`agents.list.*.contextTokens`,U),Y=S(`agents.list.*.engine`,U),X=S(`agents.list`,U),Z=S(`bindings`,U),re=(0,w.useMemo)(()=>{let e=new Set([`main`]);return j.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[j]),Q=(e,t)=>{M(n=>n.map((n,r)=>r===e?{...n,...t}:n))},$=(e,t)=>{P(n=>n.map((n,r)=>r===e?t:n))};return n||!e?(0,T.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,T.jsxs)(te,{className:`space-y-6`,children:[(0,T.jsx)(ne,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,T.jsxs)(v,{children:[(0,T.jsxs)(b,{children:[(0,T.jsx)(h,{children:W?.label??t(`dmScope`)}),(0,T.jsx)(g,{children:W?.help??t(`dmScopeHelp`)})]}),(0,T.jsxs)(m,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:K?.label??t(`defaultContextTokens`)}),(0,T.jsx)(_,{type:`number`,min:1e3,step:1e3,value:z,onChange:e=>B(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3))}),(0,T.jsx)(`p`,{className:`text-xs text-gray-500`,children:K?.help??t(`defaultContextTokensHelp`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:q?.label??t(`defaultEngine`)}),(0,T.jsx)(_,{value:V,onChange:e=>H(e.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,T.jsx)(`p`,{className:`text-xs text-gray-500`,children:q?.help??t(`defaultEngineHelp`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:W?.label??t(`dmScope`)}),(0,T.jsxs)(u,{value:F,onValueChange:e=>I(e),children:[(0,T.jsx)(s,{children:(0,T.jsx)(o,{})}),(0,T.jsx)(c,{children:E.map(e=>(0,T.jsx)(l,{value:e.value,children:e.label},e.value))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:G?.label??t(`maxPingPongTurns`)}),(0,T.jsx)(_,{type:`number`,min:0,max:5,value:L,onChange:e=>R(Math.max(0,Number.parseInt(e.target.value,10)||0))}),(0,T.jsx)(`p`,{className:`text-xs text-gray-500`,children:G?.help??t(`maxPingPongTurnsHelp`)})]})]})]}),(0,T.jsxs)(v,{children:[(0,T.jsxs)(b,{children:[(0,T.jsx)(h,{children:X?.label??t(`agentList`)}),(0,T.jsx)(g,{children:X?.help??t(`agentListHelp`)})]}),(0,T.jsxs)(m,{className:`space-y-3`,children:[j.map((e,n)=>(0,T.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,T.jsx)(_,{value:e.id,onChange:e=>Q(n,{id:e.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,T.jsx)(_,{value:e.workspace??``,onChange:e=>Q(n,{workspace:e.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,T.jsx)(_,{value:e.model??``,onChange:e=>Q(n,{model:e.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,T.jsx)(_,{value:e.engine??``,onChange:e=>Q(n,{engine:e.target.value}),placeholder:Y?.label??t(`engineOverridePlaceholder`)}),(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,T.jsx)(_,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>Q(n,{contextTokens:k(e.target.value)}),placeholder:J?.label??t(`contextTokensPlaceholder`)}),(0,T.jsx)(_,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>Q(n,{maxToolIterations:k(e.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,T.jsx)(C,{checked:!!e.default,onCheckedChange:e=>{if(!e){Q(n,{default:!1});return}M(e=>e.map((e,t)=>({...e,default:t===n})))}}),(0,T.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,T.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>M(e=>e.filter((e,t)=>t!==n)),children:[(0,T.jsx)(p,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${n}-${e.id}`)),(0,T.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>M(e=>[...e,D()]),children:[(0,T.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]}),(0,T.jsxs)(v,{children:[(0,T.jsxs)(b,{children:[(0,T.jsx)(h,{children:Z?.label??t(`bindings`)}),(0,T.jsx)(g,{children:Z?.help??t(`bindingsHelp`)})]}),(0,T.jsxs)(m,{className:`space-y-3`,children:[N.map((e,n)=>{let r=e.match.peer?.kind??``;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,T.jsx)(_,{value:e.agentId,onChange:t=>$(n,{...e,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,T.jsx)(_,{value:e.match.channel,onChange:t=>$(n,{...e,match:{...e.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,T.jsx)(_,{value:e.match.accountId??``,onChange:t=>$(n,{...e,match:{...e.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,T.jsxs)(u,{value:r||`__none__`,onValueChange:t=>{let r=t===`__none__`?``:t;if(!r){$(n,{...e,match:{...e.match,peer:void 0}});return}$(n,{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}})},children:[(0,T.jsx)(s,{children:(0,T.jsx)(o,{})}),(0,T.jsxs)(c,{children:[(0,T.jsx)(l,{value:`__none__`,children:t(`peerKindOptional`)}),(0,T.jsx)(l,{value:`direct`,children:`direct`}),(0,T.jsx)(l,{value:`group`,children:`group`}),(0,T.jsx)(l,{value:`channel`,children:`channel`})]})]}),(0,T.jsx)(_,{value:e.match.peer?.id??``,onChange:t=>$(n,{...e,match:{...e.match,peer:r?{kind:r,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,T.jsx)(`div`,{className:`flex justify-end`,children:(0,T.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>P(e=>e.filter((e,t)=>t!==n)),children:[(0,T.jsx)(p,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${n}-${e.agentId}`)}),(0,T.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>P(e=>[...e,O()]),children:[(0,T.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]}),(0,T.jsx)(`div`,{className:`flex justify-end`,children:(0,T.jsxs)(a,{type:`button`,onClick:()=>{try{let e=j.map((e,n)=>{let r=e.id.trim();if(!r)throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));let i={id:r};return e.default&&(i.default=!0),e.workspace?.trim()&&(i.workspace=e.workspace.trim()),e.model?.trim()&&(i.model=e.model.trim()),e.engine?.trim()&&(i.engine=e.engine.trim()),typeof e.contextTokens==`number`&&(i.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(i.maxToolIterations=e.maxToolIterations),i}),n=e.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0){i.error(`${t(`duplicateAgentId`)}: ${n[0]}`);return}let r=N.map((e,n)=>{let r=e.agentId.trim(),i=e.match.channel.trim(),a=e.match.accountId?.trim()??``,o=e.match.peer?.kind,s=e.match.peer?.id?.trim()??``;if(!r)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!re.has(r))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,z),engine:V.trim()||`native`},list:e},bindings:r,session:{dmScope:F,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,L))}}}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:A.isPending,children:[(0,T.jsx)(f,{className:`h-4 w-4 mr-2`}),A.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}export{A as RuntimeConfig};
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,m as n,p as r,u as i}from"./i18n-Cn8SErDV.js";import{o as a}from"./dist-Cy668qFZ.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-D60QRHg9.js";import{t as d}from"./external-link-DI4ZmR3r.js";import{t as f}from"./search-CQCQaN4Z.js";import{A as p,U as m,c as h,l as g,pt as ee}from"./index-bAeWRAyo.js";import{n as _,t as v}from"./page-layout-Hr-Dvq4o.js";import{i as y,r as b,t as x}from"./config-layout-B-7erZRN.js";import{t as S}from"./label-Cz0q8fx4.js";var C=e(n(),1),w=r(),T=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}];function E(){let{data:e}=h(),{data:n}=g(),r=p(),E=n?.search??[],D=e?.search,[O,k]=(0,C.useState)(`bocha`),[A,j]=(0,C.useState)(`bocha`),[M,N]=(0,C.useState)([`bocha`]),[P,F]=(0,C.useState)(`10`),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(`https://api.bocha.cn/v1/web-search`),[B,V]=(0,C.useState)(!0),[H,U]=(0,C.useState)(`noLimit`),[W,G]=(0,C.useState)(``),[K,q]=(0,C.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,C.useEffect)(()=>{D&&(k(D.provider),j(D.provider),N(D.enabledProviders),F(String(D.defaults.maxResults)),z(D.providers.bocha.baseUrl),V(!!D.providers.bocha.summary),U(D.providers.bocha.freshness??`noLimit`),q(D.providers.brave.baseUrl))},[D]);let J=(0,C.useMemo)(()=>E.find(e=>e.name===O),[E,O]),Y=D?.providers[O],X=M.includes(O),Z=D?.providers.bocha.docsUrl??n?.search.find(e=>e.name===`bocha`)?.docsUrl??`https://open.bocha.cn`,Q=t(X?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=M,t=A)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(P)||10},providers:{bocha:{apiKey:I||void 0,baseUrl:R,summary:B,freshness:H},brave:{apiKey:W||void 0,baseUrl:K}}});return!D||E.length===0?(0,w.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,w.jsxs)(_,{children:[(0,w.jsx)(v,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,w.jsxs)(`div`,{className:y,children:[(0,w.jsxs)(`section`,{className:b,children:[(0,w.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:E.map(e=>{let n=D.providers[e.name],r=M.includes(e.name);return(0,w.jsx)(`button`,{type:`button`,onClick:()=>k(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,O===e.name?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,w.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:e.name===`bocha`?t(`searchProviderBochaDescription`):t(`searchProviderBraveDescription`)})]}),(0,w.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,w.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,w.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,w.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(x,`p-6`),children:!J||!Y?(0,w.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,w.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,w.jsx)(f,{className:`h-5 w-5`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:J.displayName}),(0,w.jsx)(`p`,{className:`text-sm text-gray-500`,children:J.description})]})]}),(0,w.jsx)(a,{type:`button`,variant:X?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=X?M.filter(e=>e!==O):[...M,O];N(e),r.mutate({data:$(e)})},children:Q})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchActiveProvider`)}),(0,w.jsxs)(u,{value:A,onValueChange:e=>{j(e)},children:[(0,w.jsx)(s,{className:`rounded-xl`,children:(0,w.jsx)(o,{})}),(0,w.jsx)(c,{children:E.map(e=>(0,w.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchDefaultMaxResults`)}),(0,w.jsx)(m,{value:P,onChange:e=>F(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),O===`bocha`?(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`apiKey`)}),(0,w.jsx)(m,{type:`password`,value:I,onChange:e=>L(e.target.value),placeholder:D.providers.bocha.apiKeyMasked||t(`enterApiKey`),className:`rounded-xl`})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchProviderBaseUrl`)}),(0,w.jsx)(m,{value:R,onChange:e=>z(e.target.value),className:`rounded-xl`})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchProviderSummary`)}),(0,w.jsxs)(u,{value:B?`true`:`false`,onValueChange:e=>V(e===`true`),children:[(0,w.jsx)(s,{className:`rounded-xl`,children:(0,w.jsx)(o,{})}),(0,w.jsxs)(c,{children:[(0,w.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,w.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchProviderFreshness`)}),(0,w.jsxs)(u,{value:H,onValueChange:U,children:[(0,w.jsx)(s,{className:`rounded-xl`,children:(0,w.jsx)(o,{})}),(0,w.jsx)(c,{children:T.map(e=>(0,w.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,w.jsx)(`div`,{className:`space-y-2`,children:(0,w.jsx)(`a`,{href:Z,target:`_blank`,rel:`noreferrer`,children:(0,w.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,w.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]}):(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`apiKey`)}),(0,w.jsx)(m,{type:`password`,value:W,onChange:e=>G(e.target.value),placeholder:D.providers.brave.apiKeyMasked||t(`enterApiKey`),className:`rounded-xl`})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(S,{children:t(`searchProviderBaseUrl`)}),(0,w.jsx)(m,{value:K,onChange:e=>q(e.target.value),className:`rounded-xl`})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,w.jsx)(ee,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{E as SearchConfig};
@@ -0,0 +1,3 @@
1
+ import{_ as e,l as t,m as n,p as r}from"./i18n-Cn8SErDV.js";import{n as i,o as a}from"./dist-Cy668qFZ.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-D60QRHg9.js";import{t as d}from"./plus-BnGg0mB-.js";import{t as f}from"./save-Caodcm4q.js";import{t as p}from"./trash-2-DvPrU1xO.js";import{G as m,J as h,K as g,U as _,W as v,c as y,j as b,q as x}from"./index-bAeWRAyo.js";import{n as S,t as C}from"./page-layout-Hr-Dvq4o.js";import{t as w}from"./label-Cz0q8fx4.js";import{t as T}from"./switch-CcBS0F3U.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
+ `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
3
+ `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=y(),r=b(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(S,{className:`space-y-6`,children:[(0,D.jsx)(C,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secrets`)}),(0,D.jsx)(g,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(m,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(w,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(w,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(w,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(g,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(m,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(_,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(_,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(_,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(_,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(_,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(_,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secretRefsTitle`)}),(0,D.jsx)(g,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(m,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(_,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(_,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
@@ -0,0 +1,2 @@
1
+ import{_ as e,l as t,m as n,n as r,p as i,r as a,u as o}from"./i18n-Cn8SErDV.js";import{o as s}from"./dist-Cy668qFZ.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-D60QRHg9.js";import{t as p}from"./createLucideIcon-B8FV3fzy.js";import{c as m,i as h,l as g,n as _,o as v,s as y,t as b}from"./chat-session-display-DBBUJOYN.js";import{t as x}from"./hash-DoXBhX9w.js";import{t as S}from"./search-CQCQaN4Z.js";import{D as C,U as w,ct as ee,dt as T,m as te,v as ne,y as E}from"./index-bAeWRAyo.js";import{t as D}from"./useConfirmDialog-B89bxcd6.js";import{n as O,t as k}from"./page-layout-Hr-Dvq4o.js";var A=p(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),j=p(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),M=e(n(),1),N=i(),P=`__unknown_channel__`;function F(e){return a(e)}function I(e){let t=e.indexOf(`:`);return t<=0?P:e.slice(0,t).trim()||P}function L(e){return e===P?t(`sessionsUnknownChannel`):e}function R(e){return e===`service`?`system`:e===`tool`?`tool`:e}function z(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type===`tool-invocation`){let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}}return t.join(`
2
+ `).trim()}function B({session:e,summary:t,channel:n,isSelected:i,onSelect:a}){let s=L(n),c=b(e);return(0,N.jsxs)(`button`,{onClick:a,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,i?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,N.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,i?`text-brand-800`:`text-gray-900`),children:c}),(0,N.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,i?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:s})]}),(0,N.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,i?`text-brand-600/80`:`text-gray-400`),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:t.status===`running`?(0,N.jsx)(v,{status:`running`}):null}),(0,N.jsx)(A,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{className:`truncate max-w-[100px]`,children:r(t.updatedAt)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(T,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{children:t.messageCount})]})]})]})}function V({message:e}){let t=R(e.role),n=t===`user`,r=z(e);return(0,N.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,N.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,N.jsx)(y,{className:`w-4 h-4 text-primary-100`}):(0,N.jsx)(g,{className:`w-4 h-4 text-gray-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,N.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,N.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:F(e.timestamp)})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:r||`-`})]})]})})}function H(){let[e,n]=(0,M.useState)(``),[r]=(0,M.useState)(100),[i,a]=(0,M.useState)(null),[p,g]=(0,M.useState)(`all`),[y,A]=(0,M.useState)(``),[F,R]=(0,M.useState)(``),[z,H]=(0,M.useState)(!1),U=E({limit:r}),W=ne(i,300),G=C(),K=te(),{confirm:q,ConfirmDialog:re}=D(),J=(0,M.useMemo)(()=>U.data?.sessions??[],[U.data?.sessions]),Y=(0,M.useMemo)(()=>h(J),[J]),X=(0,M.useMemo)(()=>new Map(J.map(e=>[e.sessionId,e])),[J]),Z=(0,M.useMemo)(()=>Y.filter(t=>p!==`all`&&I(t.key)!==p?!1:_(t,e)),[e,p,Y]),Q=(0,M.useMemo)(()=>Y.find(e=>e.key===i)??null,[i,Y]),$=(0,M.useMemo)(()=>i?X.get(i)??null:null,[i,X]),ie=(0,M.useMemo)(()=>{let e=new Set;for(let t of Y)e.add(I(t.key));return Array.from(e).sort((e,t)=>e===P?1:t===P?-1:e.localeCompare(t))},[Y]);return(0,M.useEffect)(()=>{i&&!X.has(i)&&a(null)},[i,X]),(0,M.useEffect)(()=>{Q?(A(Q.label||``),R(Q.preferredModel||``)):(A(``),R(``)),H(!1)},[Q]),(0,N.jsxs)(O,{fullHeight:!0,children:[(0,N.jsx)(k,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,N.jsxs)(`div`,{className:`flex-1 flex gap-6 min-h-0 relative`,children:[(0,N.jsxs)(`div`,{className:`w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[Y.length,` `,t(`sessionsListTitle`)]}),(0,N.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>U.refetch(),children:(0,N.jsx)(m,{className:o(`h-3.5 w-3.5`,U.isFetching&&`animate-spin`)})})]}),(0,N.jsxs)(f,{value:p,onValueChange:g,children:[(0,N.jsx)(l,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,N.jsx)(c,{placeholder:t(`sessionsAllChannels`)})}),(0,N.jsxs)(u,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,N.jsx)(d,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),ie.map(e=>(0,N.jsx)(d,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:L(e)},e))]})]}),(0,N.jsxs)(`div`,{className:`relative w-full`,children:[(0,N.jsx)(S,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,N.jsx)(w,{value:e,onChange:e=>n(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative`,children:U.isLoading?(0,N.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):Z.length===0?(0,N.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,N.jsx)(j,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):Z.map(e=>{let t=X.get(e.key);return t?(0,N.jsx)(B,{session:e,summary:t,channel:I(e.key),isSelected:i===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[(G.isPending||K.isPending)&&(0,N.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,N.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}),i&&Q&&$?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,N.jsx)(x,{className:`h-6 w-6`})}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:b(Q)}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:L(I(Q.key))}),$.status===`running`?(0,N.jsx)(v,{status:`running`,className:`h-4 w-4`}):null]}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:i,children:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,N.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>H(!z),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,z?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,N.jsx)(ee,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),(0,N.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{i&&await q({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&K.mutate({sessionId:i},{onSuccess:()=>a(null)})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]}),z&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,N.jsx)(w,{placeholder:t(`sessionsLabelPlaceholder`),value:y,onChange:e=>A(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(w,{placeholder:t(`sessionsModelPlaceholder`),value:F,onChange:e=>R(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(s,{size:`sm`,onClick:()=>{i&&(G.mutate({sessionId:i,data:{label:y.trim()||null,preferredModel:F.trim()||null}}),H(!1))},className:`h-8 px-4 shrink-0 shadow-none`,disabled:G.isPending,children:t(`sessionsSaveMeta`)})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[W.isLoading&&(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,N.jsx)(m,{className:`w-6 h-6 text-primary animate-spin`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}),W.error&&(0,N.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:W.error.message}),!W.isLoading&&W.data?.messages.length===0&&(0,N.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,N.jsx)(T,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,N.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}),(0,N.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(W.data?.messages??[]).map(e=>(0,N.jsx)(V,{message:e},e.id))})]})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,N.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,N.jsx)(j,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,N.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})]})]}),(0,N.jsx)(re,{})]})}export{H as SessionsConfig};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-B8FV3fzy.js";var t=e(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{l as e,p as t,u as n}from"./i18n-Cn8SErDV.js";import{t as r}from"./createLucideIcon-B8FV3fzy.js";import{t as i}from"./loader-circle-d_mzMi2S.js";var a=r(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),o=r(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),s=r(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),c=t();function l({status:t,className:r}){let a=e(t===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,c.jsxs)(`span`,{className:n(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,r),title:a,"aria-label":a,children:[(0,c.jsx)(i,{className:`h-3 w-3 animate-spin`}),(0,c.jsx)(`span`,{className:`sr-only`,children:a})]})}var u=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({}),d=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function f(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function p(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function m(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function h(e){let t=m(e);return t?p(t.preferred_model)??p(t.preferredModel)??p(t.model):null}function g(e){let t=m(e);if(!t)return null;let n=p(t.preferred_thinking)??p(t.thinking)??p(t.thinking_level)??p(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return d.has(r)?r:null}function _(e){let t=m(e);return t?p(t.label):null}function v(e){let t=m(e);return t?p(t.session_type)??p(t.sessionType)??`native`:`native`}function y(e){if(e===`heartbeat`)return{type:`heartbeat`};if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function b(e){return e.state===`result`?u.RESULT:e.state===`partial-call`?u.PARTIAL_CALL:u.CALL}function x(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:b(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:f(n.args),result:n.result}})}return t}function S(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function C(e){return{id:e.id,role:S(e.role),parts:x(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function w(e){let t=_(e),n=h(e),r=g(e),i=y(e.sessionId);return{key:e.sessionId,createdAt:e.updatedAt,updatedAt:e.updatedAt,...t?{label:t}:{},...i,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},sessionType:v(e),sessionTypeMutable:!1,messageCount:e.messageCount}}function T(e){return e.map(w)}function E(){return`ncp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function D(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}function O(e){return e.trim().toLowerCase()}function k(e,t){let n=O(t);return n?[e.key,D(e)].map(O).some(e=>e.includes(n)):!0}export{E as a,o as c,T as i,a as l,k as n,l as o,C as r,s,D as t};
@@ -0,0 +1,3 @@
1
+ import{_ as e,m as t}from"./i18n-Cn8SErDV.js";var n=`modulepreload`,r=function(e){return`/`+e},i={},a=function(e,t,a){let o=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),s=document.querySelector(`meta[property=csp-nonce]`),c=s?.nonce||s?.getAttribute(`nonce`);function l(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}o=l(t.map(t=>{if(t=r(t,a),t in i)return;i[t]=!0;let o=t.endsWith(`.css`),s=o?`[rel="stylesheet"]`:``;if(a)for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.href===t&&(!o||r.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${s}`))return;let l=document.createElement(`link`);if(l.rel=o?`stylesheet`:n,o||(l.as=`script`),l.crossOrigin=``,l.href=t,c&&l.setAttribute(`nonce`,c),document.head.appendChild(l),o)return new Promise((e,n)=>{l.addEventListener(`load`,e),l.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function s(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return o.then(t=>{for(let e of t||[])e.status===`rejected`&&s(e.reason);return e().catch(s)})},o=e(t(),1),s=`popstate`;function c(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return p(``,{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:m(t)}return g(t,n,null,e)}function l(e,t){if(e===!1||e==null)throw Error(t)}function u(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function d(){return Math.random().toString(36).substring(2,10)}function f(e,t){return{usr:e.state,key:e.key,idx:t}}function p(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?h(t):t,state:n,key:t&&t.key||r||d()}}function m({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 h(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 g(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,c=`POP`,l=null,u=d();u??(u=0,o.replaceState({...o.state,idx:u},``));function d(){return(o.state||{idx:null}).idx}function m(){c=`POP`;let e=d(),t=e==null?null:e-u;u=e,l&&l({action:c,location:y.location,delta:t})}function h(e,t){c=`PUSH`;let r=p(y.location,e,t);n&&n(r,e),u=d()+1;let s=f(r,u),m=y.createHref(r);try{o.pushState(s,``,m)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(m)}a&&l&&l({action:c,location:y.location,delta:1})}function g(e,t){c=`REPLACE`;let r=p(y.location,e,t);n&&n(r,e),u=d();let i=f(r,u),s=y.createHref(r);o.replaceState(i,``,s),a&&l&&l({action:c,location:y.location,delta:0})}function v(e){return _(e)}let y={get action(){return c},get location(){return e(i,o)},listen(e){if(l)throw Error(`A history only accepts one active listener`);return i.addEventListener(s,m),l=e,()=>{i.removeEventListener(s,m),l=null}},createHref(e){return t(i,e)},createURL:v,encodeLocation(e){let t=v(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:h,replace:g,go(e){return o.go(e)}};return y}function _(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),l(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:m(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function v(e,t,n=`/`){return y(e,t,n,!1)}function y(e,t,n,r){let i=D((typeof t==`string`?h(t):t).pathname||`/`,n);if(i==null)return null;let a=x(e);C(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=le(i);o=se(a[e],t,r)}return o}function b(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 x(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;l(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 u=j([r,c.relativePath]),d=n.concat(c);e.children&&e.children.length>0&&(l(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),x(e.children,t,d,u,o)),!(e.path==null&&!e.index)&&t.push({path:u,score:ae(u,e.index),routesMeta:d})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of S(e.path))a(e,t,!0,n)}),t}function S(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=S(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 C(e){e.sort((e,t)=>e.score===t.score?oe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var w=/^:[\w-]+$/,T=3,ee=2,te=1,ne=10,re=-2,ie=e=>e===`*`;function ae(e,t){let n=e.split(`/`),r=n.length;return n.some(ie)&&(r+=re),t&&(r+=ee),n.filter(e=>!ie(e)).reduce((e,t)=>e+(w.test(t)?T:t===``?te:ne),r)}function oe(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 se(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:j([a,u.pathname]),pathnameBase:me(j([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=j([a,u.pathnameBase]))}return o}function E(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ce(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 ce(e,t=!1,n=!0){u(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 le(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return u(!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 ue=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function de(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?h(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?fe(n.substring(1),`/`):fe(n,t)):a=t,{pathname:a,search:he(r),hash:ge(i)}}function fe(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 O(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 pe(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function k(e){let t=pe(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function A(e,t,n,r=!1){let i;typeof e==`string`?i=h(e):(i={...e},l(!i.pathname||!i.pathname.includes(`?`),O(`?`,`pathname`,`search`,i)),l(!i.pathname||!i.pathname.includes(`#`),O(`#`,`pathname`,`hash`,i)),l(!i.search||!i.search.includes(`#`),O(`#`,`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=de(i,s),u=o&&o!==`/`&&o.endsWith(`/`),d=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(u||d)&&(c.pathname+=`/`),c}var j=e=>e.join(`/`).replace(/\/\/+/g,`/`),me=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),he=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,ge=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,_e=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 ve(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ye(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var be=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function xe(e,t){let n=e;if(typeof n!=`string`||!ue.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(be)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{u(!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 Se=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Se);var Ce=[`GET`,...Se];new Set(Ce);var M=o.createContext(null);M.displayName=`DataRouter`;var N=o.createContext(null);N.displayName=`DataRouterState`;var we=o.createContext(!1),Te=o.createContext({isTransitioning:!1});Te.displayName=`ViewTransition`;var Ee=o.createContext(new Map);Ee.displayName=`Fetchers`;var De=o.createContext(null);De.displayName=`Await`;var P=o.createContext(null);P.displayName=`Navigation`;var F=o.createContext(null);F.displayName=`Location`;var I=o.createContext({outlet:null,matches:[],isDataRoute:!1});I.displayName=`Route`;var L=o.createContext(null);L.displayName=`RouteError`;var Oe=`REACT_ROUTER_ERROR`,ke=`REDIRECT`,Ae=`ROUTE_ERROR_RESPONSE`;function je(e){if(e.startsWith(`${Oe}:${ke}:{`))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 Me(e){if(e.startsWith(`${Oe}:${Ae}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new _e(t.status,t.statusText,t.data)}catch{}}function Ne(e,{relative:t}={}){l(R(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=o.useContext(P),{hash:i,pathname:a,search:s}=V(e,{relative:t}),c=a;return n!==`/`&&(c=a===`/`?n:j([n,a])),r.createHref({pathname:c,search:s,hash:i})}function R(){return o.useContext(F)!=null}function z(){return l(R(),`useLocation() may be used only in the context of a <Router> component.`),o.useContext(F).location}var Pe=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Fe(e){o.useContext(P).static||o.useLayoutEffect(e)}function B(){let{isDataRoute:e}=o.useContext(I);return e?et():Ie()}function Ie(){l(R(),`useNavigate() may be used only in the context of a <Router> component.`);let e=o.useContext(M),{basename:t,navigator:n}=o.useContext(P),{matches:r}=o.useContext(I),{pathname:i}=z(),a=JSON.stringify(k(r)),s=o.useRef(!1);return Fe(()=>{s.current=!0}),o.useCallback((r,o={})=>{if(u(s.current,Pe),!s.current)return;if(typeof r==`number`){n.go(r);return}let c=A(r,JSON.parse(a),i,o.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:j([t,c.pathname])),(o.replace?n.replace:n.push)(c,o.state,o)},[t,n,a,i,e])}o.createContext(null);function Le(){let{matches:e}=o.useContext(I),t=e[e.length-1];return t?t.params:{}}function V(e,{relative:t}={}){let{matches:n}=o.useContext(I),{pathname:r}=z(),i=JSON.stringify(k(n));return o.useMemo(()=>A(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Re(e,t){return ze(e,t)}function ze(e,t,n,r,i){l(R(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=o.useContext(P),{matches:s}=o.useContext(I),c=s[s.length-1],d=c?c.params:{},f=c?c.pathname:`/`,p=c?c.pathnameBase:`/`,m=c&&c.route;{let e=m&&m.path||``;nt(f,!m||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (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
+
3
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let g=z(),_;if(t){let e=typeof t==`string`?h(t):t;l(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.`),_=e}else _=g;let y=_.pathname||`/`,b=y;if(p!==`/`){let e=p.replace(/^\//,``).split(`/`);b=`/`+y.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let x=v(e,{pathname:b});u(m||x!=null,`No routes matched location "${_.pathname}${_.search}${_.hash}" `),u(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 "${_.pathname}${_.search}${_.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=Ge(x&&x.map(e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:j([p,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?p:j([p,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),s,n,r,i);return t&&S?o.createElement(F.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,..._},navigationType:`POP`}},S):S}function Be(){let e=$e(),t=ve(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},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=o.createElement(o.Fragment,null,o.createElement(`p`,null,`💿 Hey developer 👋`),o.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,o.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,o.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),o.createElement(o.Fragment,null,o.createElement(`h2`,null,`Unexpected Application Error!`),o.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?o.createElement(`pre`,{style:i},n):null,s)}var Ve=o.createElement(Be,null),He=class extends o.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=Me(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:o.createElement(I.Provider,{value:this.props.routeContext},o.createElement(L.Provider,{value:e,children:this.props.component}));return this.context?o.createElement(Ue,{error:e},t):t}};He.contextType=we;var H=new WeakMap;function Ue({children:e,error:t}){let{basename:n}=o.useContext(P);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=je(t.digest);if(e){let r=H.get(t);if(r)throw r;let i=xe(e.location,n);if(be&&!H.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 H.set(t,n),n}return o.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function We({routeContext:e,match:t,children:n}){let r=o.useContext(M);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),o.createElement(I.Provider,{value:e},n)}function Ge(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,s=n?.errors;if(s!=null){let e=a.findIndex(e=>e.route.id&&s?.[e.route.id]!==void 0);l(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let c=!1,u=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(u=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=u>=0?a.slice(0,u+1):[a[0]];break}}}let d=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:ye(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let l,f=!1,p=null,m=null;n&&(l=s&&r.route.id?s[r.route.id]:void 0,p=r.route.errorElement||Ve,c&&(u<0&&i===0?(nt(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):u===i&&(f=!0,m=r.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,i+1)),g=()=>{let t;return t=l?p:f?m:r.route.Component?o.createElement(r.route.Component,null):r.route.element?r.route.element:e,o.createElement(We,{match:r,routeContext:{outlet:e,matches:h,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?o.createElement(He,{location:n.location,revalidation:n.revalidation,component:p,error:l,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function U(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ke(e){let t=o.useContext(M);return l(t,U(e)),t}function qe(e){let t=o.useContext(N);return l(t,U(e)),t}function Je(e){let t=o.useContext(I);return l(t,U(e)),t}function Ye(e){let t=Je(e),n=t.matches[t.matches.length-1];return l(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Xe(){return Ye(`useRouteId`)}function Ze(){return qe(`useNavigation`).navigation}function Qe(){let{matches:e,loaderData:t}=qe(`useMatches`);return o.useMemo(()=>e.map(e=>b(e,t)),[e,t])}function $e(){let e=o.useContext(L),t=qe(`useRouteError`),n=Ye(`useRouteError`);return e===void 0?t.errors?.[n]:e}function et(){let{router:e}=Ke(`useNavigate`),t=Ye(`useNavigate`),n=o.useRef(!1);return Fe(()=>{n.current=!0}),o.useCallback(async(r,i={})=>{u(n.current,Pe),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var tt={};function nt(e,t,n){!t&&!tt[e]&&(tt[e]=!0,u(!1,n))}o.useOptimistic,o.memo(rt);function rt({routes:e,future:t,state:n,onError:r}){return ze(e,void 0,n,r,t)}function it({to:e,replace:t,state:n,relative:r}){l(R(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=o.useContext(P);u(!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}=o.useContext(I),{pathname:s}=z(),c=B(),d=A(e,k(a),s,r===`path`),f=JSON.stringify(d);return o.useEffect(()=>{c(JSON.parse(f),{replace:t,state:n,relative:r})},[c,f,r,t,n]),null}function at(e){l(!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 ot({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:s}){l(!R(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),d=o.useMemo(()=>({basename:c,navigator:i,static:a,unstable_useTransitions:s,future:{}}),[c,i,a,s]);typeof n==`string`&&(n=h(n));let{pathname:f=`/`,search:p=``,hash:m=``,state:g=null,key:_=`default`}=n,v=o.useMemo(()=>{let e=D(f,c);return e==null?null:{location:{pathname:e,search:p,hash:m,state:g,key:_},navigationType:r}},[c,f,p,m,g,_,r]);return u(v!=null,`<Router basename="${c}"> is not able to match the URL "${f}${p}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:o.createElement(P.Provider,{value:d},o.createElement(F.Provider,{children:t,value:v}))}function st({children:e,location:t}){return Re(W(e),t)}o.Component;function W(e,t=[]){let n=[];return o.Children.forEach(e,(e,r)=>{if(!o.isValidElement(e))return;let i=[...t,r];if(e.type===o.Fragment){n.push.apply(n,W(e.props.children,i));return}l(e.type===at,`[${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>`),l(!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 ct(e){return q(e)&&e.tagName.toLowerCase()===`button`}function lt(e){return q(e)&&e.tagName.toLowerCase()===`form`}function ut(e){return q(e)&&e.tagName.toLowerCase()===`input`}function dt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ft(e,t){return e.button===0&&(!t||t===`_self`)&&!dt(e)}var J=null;function pt(){if(J===null)try{new FormData(document.createElement(`form`),0),J=!1}catch{J=!0}return J}var mt=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Y(e){return e!=null&&!mt.has(e)?(u(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${K}"`),null):e}function ht(e,t){let n,r,i,a,o;if(lt(e)){let o=e.getAttribute(`action`);r=o?D(o,t):null,n=e.getAttribute(`method`)||G,i=Y(e.getAttribute(`enctype`))||K,a=new FormData(e)}else if(ct(e)||ut(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=Y(e.getAttribute(`formenctype`))||Y(o.getAttribute(`enctype`))||K,a=new FormData(o,e),!pt()){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 gt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},_t=/[&><\u2028\u2029]/g;function vt(e){return e.replace(_t,e=>gt[e])}function X(e,t){if(e===!1||e==null)throw Error(t)}function yt(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 bt(e,t){if(e.id in t)return t[e.id];try{let n=await a(()=>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 xt(e){return e!=null&&typeof e.page==`string`}function St(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 Ct(e,t,n){return Ot((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await bt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(St).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function wt(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 Tt(e,t,{includeHydrateFallback:n}={}){return Et(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 Et(e){return[...new Set(e)]}function Dt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ot(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!xt(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Dt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function kt(){let e=o.useContext(M);return X(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function At(){let e=o.useContext(N);return X(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Z=o.createContext(void 0);Z.displayName=`FrameworkContext`;function jt(){let e=o.useContext(Z);return X(e,`You must render this element inside a <HydratedRouter> element`),e}function Mt(e,t){let n=o.useContext(Z),[r,i]=o.useState(!1),[a,s]=o.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=t,p=o.useRef(null);o.useEffect(()=>{if(e===`render`&&s(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{s(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),o.useEffect(()=>{if(r){let e=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),s(!1)};return n?e===`intent`?[a,p,{onFocus:Q(c,m),onBlur:Q(l,h),onMouseEnter:Q(u,m),onMouseLeave:Q(d,h),onTouchStart:Q(f,m)}]:[a,p,{}]:[!1,p,{}]}function Q(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Nt({page:e,...t}){let{router:n}=kt(),r=o.useMemo(()=>v(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?o.createElement(Ft,{page:e,matches:r,...t}):null}function Pt(e){let{manifest:t,routeModules:n}=jt(),[r,i]=o.useState([]);return o.useEffect(()=>{let r=!1;return Ct(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Ft({page:e,matches:t,...n}){let r=z(),{future:i,manifest:a,routeModules:s}=jt(),{basename:c}=kt(),{loaderData:l,matches:u}=At(),d=o.useMemo(()=>wt(e,t,u,a,r,`data`),[e,t,u,a,r]),f=o.useMemo(()=>wt(e,t,u,a,r,`assets`),[e,t,u,a,r]),p=o.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,o=!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&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?o=!0:n.add(e.route.id))}),n.size===0)return[];let u=yt(e,c,i.unstable_trailingSlashAwareDataRequests,`data`);return o&&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,s]),m=o.useMemo(()=>Tt(f,a),[f,a]),h=Pt(f);return o.createElement(o.Fragment,null,p.map(e=>o.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>o.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>o.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function It(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}o.Component;var Lt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Lt&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Rt({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=o.useRef();i.current??=c({window:r,v5Compat:!0});let a=i.current,[s,l]=o.useState({action:a.action,location:a.location}),u=o.useCallback(e=>{n===!1?l(e):o.startTransition(()=>l(e))},[n]);return o.useLayoutEffect(()=>a.listen(u),[a,u]),o.createElement(ot,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:a,unstable_useTransitions:n})}function zt({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=o.useState({action:n.action,location:n.location}),s=o.useCallback(e=>{r===!1?a(e):o.startTransition(()=>a(e))},[r]);return o.useLayoutEffect(()=>n.listen(s),[n,s]),o.createElement(ot,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}zt.displayName=`unstable_HistoryRouter`;var Bt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vt=o.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,unstable_useTransitions:g}=o.useContext(P),_=typeof l==`string`&&Bt.test(l),v=xe(l,h);l=v.to;let y=Ne(l,{relative:r}),[b,x,S]=Mt(n,p),C=Jt(l,{replace:a,state:s,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=o.createElement(`a`,{...p,...S,href:v.absoluteURL||y,onClick:v.isExternal||i?e:w,ref:It(m,x),target:c,"data-discover":!_&&t===`render`?`true`:void 0});return b&&!_?o.createElement(o.Fragment,null,T,o.createElement(Nt,{page:y})):T});Vt.displayName=`Link`;var Ht=o.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:s,children:c,...l},u){let d=V(a,{relative:l.relative}),f=z(),p=o.useContext(N),{navigator:m,basename:h}=o.useContext(P),g=p!=null&&rn(d)&&s===!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 o.createElement(Vt,{...l,"aria-current":w,className:T,ref:u,style:ee,to:a,viewTransition:s},typeof c==`function`?c(C):c)});Ht.displayName=`NavLink`;var Ut=o.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:s=G,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},h)=>{let{unstable_useTransitions:g}=o.useContext(P),_=Zt(),v=Qt(c,{relative:u}),y=s.toLowerCase()===`get`?`get`:`post`,b=typeof c==`string`&&Bt.test(c);return o.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`)||s,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?o.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});Ut.displayName=`Form`;function Wt({getKey:e,storageKey:t,...n}){let r=o.useContext(Z),{basename:i}=o.useContext(P),a=z(),s=Qe();tn({getKey:e,storageKey:t});let c=o.useMemo(()=>{if(!r||!e)return null;let t=en(a,s,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 o.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${vt(JSON.stringify(t||$t))}, ${vt(JSON.stringify(c))})`}})}Wt.displayName=`ScrollRestoration`;function Gt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kt(e){let t=o.useContext(M);return l(t,Gt(e)),t}function qt(e){let t=o.useContext(N);return l(t,Gt(e)),t}function Jt(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=B(),d=z(),f=V(e,{relative:a});return o.useCallback(p=>{if(ft(p,t)){p.preventDefault();let t=n===void 0?m(d)===m(f):n,h=()=>u(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:s,unstable_defaultShouldRevalidate:c});l?o.startTransition(()=>h()):h()}},[d,u,f,n,r,t,e,i,a,s,c,l])}var Yt=0,Xt=()=>`__${String(++Yt)}__`;function Zt(){let{router:e}=Kt(`useSubmit`),{basename:t}=o.useContext(P),n=Xe(),r=e.fetch,i=e.navigate;return o.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=ht(e,t);a.navigate===!1?await r(a.fetcherKey||Xt(),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 Qt(e,{relative:t}={}){let{basename:n}=o.useContext(P),r=o.useContext(I);l(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...V(e||`.`,{relative:t})},s=z();if(e==null){a.search=s.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:j([n,a.pathname])),m(a)}var $t=`react-router-scroll-positions`,$={};function en(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 tn({getKey:e,storageKey:t}={}){let{router:n}=Kt(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=qt(`useScrollRestoration`),{basename:a}=o.useContext(P),s=z(),c=Qe(),l=Ze();o.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),nn(o.useCallback(()=>{if(l.state===`idle`){let t=en(s,c,a,e);$[t]=window.scrollY}try{sessionStorage.setItem(t||$t,JSON.stringify($))}catch(e){u(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,a,s,c,t])),typeof document<`u`&&(o.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||$t);e&&($=JSON.parse(e))}catch{}},[t]),o.useLayoutEffect(()=>{let t=n?.enableScrollRestoration($,()=>window.scrollY,e?(t,n)=>en(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),o.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(s.hash){let e=document.getElementById(decodeURIComponent(s.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{u(!1,`"${s.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[s,r,i]))}function nn(e,t){let{capture:n}=t||{};o.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function rn(e,{relative:t}={}){let n=o.useContext(Te);l(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Kt(`useViewTransitionState`),i=V(e,{relative:t});if(!n.isTransitioning)return!1;let a=D(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=D(n.nextLocation.pathname,r)||n.nextLocation.pathname;return E(i.pathname,s)!=null||E(i.pathname,a)!=null}export{st as a,Le as c,at as i,a as l,Ht as n,z as o,it as r,B as s,Rt as t};
@@ -0,0 +1 @@
1
+ function e(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`.`):e}function t(t,n){if(!n)return;let r=e(t),i=n[r];if(i)return i;let a=r.split(`.`);for(let[e,t]of Object.entries(n)){if(!e.includes(`*`))continue;let n=e.split(`.`);if(n.length!==a.length)continue;let r=!0;for(let e=0;e<a.length;e+=1)if(n[e]!==`*`&&n[e]!==a[e]){r=!1;break}if(r)return t}}export{t};