@nextclaw/ui 0.11.0 → 0.11.2

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 (87) hide show
  1. package/CHANGELOG.md +16 -2
  2. package/dist/assets/{ChannelsList-BqsOYnXz.js → ChannelsList-CKl1Zg8f.js} +3 -3
  3. package/dist/assets/ChatPage-BJgO27mk.js +37 -0
  4. package/dist/assets/{DocBrowser-BmL0QXBZ.js → DocBrowser-DYRBs4-z.js} +1 -1
  5. package/dist/assets/{LogoBadge-C1HiPZPf.js → LogoBadge-33Qlv3Hg.js} +1 -1
  6. package/dist/assets/MarketplacePage-B8BZVtjV.js +49 -0
  7. package/dist/assets/{McpMarketplacePage-CLHFnNBd.js → McpMarketplacePage-BRuE5fJJ.js} +2 -2
  8. package/dist/assets/{ModelConfig-LQSR58tc.js → ModelConfig-BiFblwO-.js} +1 -1
  9. package/dist/assets/ProvidersList-9goRgHE4.js +1 -0
  10. package/dist/assets/RemoteAccessPage-5vCxZPS6.js +1 -0
  11. package/dist/assets/RuntimeConfig-BmDFHBdW.js +1 -0
  12. package/dist/assets/{SearchConfig-Chzo_JGs.js → SearchConfig-CJx5CKwG.js} +1 -1
  13. package/dist/assets/{SecretsConfig-CEIbjZYA.js → SecretsConfig-B91efXoK.js} +2 -2
  14. package/dist/assets/SessionsConfig-CbFPVmx3.js +2 -0
  15. package/dist/assets/index-BtAuUyww.css +1 -0
  16. package/dist/assets/index-COJomMe9.js +8 -0
  17. package/dist/assets/{label-GACO2RzW.js → label-BnSDpjhL.js} +1 -1
  18. package/dist/assets/ncp-session-adapter-w8ZHprab.js +1 -0
  19. package/dist/assets/{page-layout-DjXaK3A3.js → page-layout-B1RIu5-r.js} +1 -1
  20. package/dist/assets/popover-ChzbCIfO.js +1 -0
  21. package/dist/assets/security-config-eYa6Ovfa.js +1 -0
  22. package/dist/assets/skeleton-D4Eyop0R.js +1 -0
  23. package/dist/assets/{status-dot-IWEBezqb.js → status-dot-CrCw5tkJ.js} +1 -1
  24. package/dist/assets/{switch-DCHAJSrA.js → switch-C3vVTpfU.js} +1 -1
  25. package/dist/assets/tabs-custom-Ilrgt6n1.js +1 -0
  26. package/dist/assets/useConfirmDialog-BeaFLDO8.js +1 -0
  27. package/dist/assets/{vendor-CNhxtHCf.js → vendor-waGu-koL.js} +101 -86
  28. package/dist/index.html +3 -3
  29. package/package.json +5 -5
  30. package/src/App.test.tsx +42 -10
  31. package/src/App.tsx +5 -40
  32. package/src/api/api-base.test.ts +37 -0
  33. package/src/api/api-base.ts +0 -4
  34. package/src/api/config.ts +2 -270
  35. package/src/api/types.ts +0 -117
  36. package/src/components/chat/ChatPage.tsx +1 -11
  37. package/src/components/chat/ChatSidebar.test.tsx +1 -50
  38. package/src/components/chat/ChatSidebar.tsx +0 -5
  39. package/src/components/chat/README.md +2 -0
  40. package/src/components/chat/adapters/chat-message.adapter.test.ts +71 -4
  41. package/src/components/chat/adapters/chat-message.adapter.ts +195 -78
  42. package/src/components/chat/chat-attachment-upload-limit.test.ts +41 -0
  43. package/src/components/chat/chat-session-display.ts +9 -0
  44. package/src/components/chat/chat-session-label.service.ts +3 -12
  45. package/src/components/chat/chat-session-preference-sync.test.ts +10 -13
  46. package/src/components/chat/chat-stream/types.ts +4 -57
  47. package/src/components/chat/containers/chat-message-list.container.tsx +7 -0
  48. package/src/components/chat/ncp/NcpChatPage.tsx +3 -3
  49. package/src/components/chat/useHydratedNcpAgent.test.tsx +77 -0
  50. package/src/components/config/README.md +2 -0
  51. package/src/components/config/SessionsConfig.tsx +152 -132
  52. package/src/hooks/use-auth.test.ts +3 -3
  53. package/src/hooks/use-auth.ts +16 -4
  54. package/src/hooks/use-realtime-query-bridge.ts +0 -24
  55. package/src/hooks/useConfig.ts +10 -137
  56. package/src/lib/i18n.chat.ts +7 -0
  57. package/src/lib/session-run-status.ts +1 -63
  58. package/src/vite-env.d.ts +1 -0
  59. package/vite.config.ts +4 -4
  60. package/dist/assets/ChatPage-CJBYKR-Y.js +0 -38
  61. package/dist/assets/MarketplacePage-BIRP0NRS.js +0 -49
  62. package/dist/assets/ProvidersList-CwI-mxah.js +0 -1
  63. package/dist/assets/RemoteAccessPage-Cw5BqZb6.js +0 -1
  64. package/dist/assets/RuntimeConfig-DbowSRAb.js +0 -1
  65. package/dist/assets/SessionsConfig-BR8GfGWL.js +0 -2
  66. package/dist/assets/chat-message-CPG7zxRR.js +0 -3
  67. package/dist/assets/index-j6A_-1b6.js +0 -8
  68. package/dist/assets/index-kaPUhd-8.css +0 -1
  69. package/dist/assets/popover-DTaFiTmU.js +0 -1
  70. package/dist/assets/security-config-Dk-yoKvK.js +0 -1
  71. package/dist/assets/skeleton-Dm2xOBSA.js +0 -1
  72. package/dist/assets/tabs-custom-DKSbDSB9.js +0 -1
  73. package/dist/assets/useConfirmDialog-ByJ8A8n7.js +0 -1
  74. package/src/api/config.stream.test.ts +0 -115
  75. package/src/components/chat/chat-chain.test.ts +0 -22
  76. package/src/components/chat/chat-chain.ts +0 -23
  77. package/src/components/chat/chat-page-data.ts +0 -171
  78. package/src/components/chat/chat-page-runtime.ts +0 -190
  79. package/src/components/chat/chat-stream/nextbot-parsers.ts +0 -52
  80. package/src/components/chat/chat-stream/nextbot-runtime-agent.ts +0 -413
  81. package/src/components/chat/chat-stream/stream-event-adapter.ts +0 -98
  82. package/src/components/chat/chat-stream/transport.ts +0 -253
  83. package/src/components/chat/legacy/LegacyChatPage.tsx +0 -223
  84. package/src/components/chat/managers/chat-input.manager.ts +0 -228
  85. package/src/components/chat/managers/chat-thread.manager.ts +0 -87
  86. package/src/components/chat/presenter/chat.presenter.ts +0 -32
  87. package/src/components/chat/useChatRuntimeController.ts +0 -134
@@ -1 +1 @@
1
- import{r as s,j as t,a3 as oe,be as ae,bf as ne,X as W,au as ie,$ as le,bg as ce,G as de,ai as ue,bh as me}from"./vendor-CNhxtHCf.js";import{q as we,D as Y,t as i,c as X,at as xe}from"./index-j6A_-1b6.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:$,toggleMode:A,goBack:I,goForward:O,canGoBack:G,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(x==null?void 0:x.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=w=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(w.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(w.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const w=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+w)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,w=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",w),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.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:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.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:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(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:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("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"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(x==null?void 0:x.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&xe(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,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:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.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:te}),t.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:M,"data-axis":"x"}),t.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:M,"data-axis":"y"}),t.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:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
1
+ import{r as s,j as t,a3 as oe,bd as ae,be as ne,X as W,ax as ie,$ as le,bf as ce,G as de,ai as ue,bg as me}from"./vendor-waGu-koL.js";import{k as xe,D as Y,t as i,c as X,ak as we}from"./index-COJomMe9.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:w,currentUrl:l,navVersion:p,close:$,toggleMode:A,goBack:I,goForward:O,canGoBack:G,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=xe(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(w==null?void 0:w.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=x=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(x.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(x.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const x=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+x)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,x=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.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:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.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:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(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:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("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"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(w==null?void 0:w.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&we(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,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:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.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:te}),t.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:M,"data-axis":"x"}),t.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:M,"data-axis":"y"}),t.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:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
@@ -1 +1 @@
1
- import{r as d,j as e}from"./vendor-CNhxtHCf.js";import{c as t}from"./index-j6A_-1b6.js";function x({name:s,src:o,className:a,imgClassName:r,fallback:l}){const[n,i]=d.useState(!1),c=!!o&&!n;return e.jsx("div",{className:t("inline-flex shrink-0 items-center justify-center overflow-hidden",a),children:c?e.jsx("img",{src:o,alt:`${s} logo`,className:t("block h-6 w-6 object-contain",r),onError:()=>i(!0),draggable:!1}):l??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{x as L};
1
+ import{r as d,j as e}from"./vendor-waGu-koL.js";import{c as t}from"./index-COJomMe9.js";function x({name:s,src:o,className:a,imgClassName:r,fallback:l}){const[n,i]=d.useState(!1),c=!!o&&!n;return e.jsx("div",{className:t("inline-flex shrink-0 items-center justify-center overflow-hidden",a),children:c?e.jsx("img",{src:o,alt:`${s} logo`,className:t("block h-6 w-6 object-contain",r),onError:()=>i(!0),draggable:!1}):l??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{x as L};
@@ -0,0 +1,49 @@
1
+ import{r as i,j as s,aL as et,aJ as tt,aK as nt,aM as Ie,aP as at,aN as st,aO as A,aQ as Ne,aR as Re,aS as rt,aT as lt,aZ as ot,a_ as it,ba as ct,bb as ut,a$ as dt,u as Me,f as Ee,g as Le,e as J,bc as pt,aD as gt,aE as ft}from"./vendor-waGu-koL.js";import{c as De,U as z,t as c,S as mt,e as xt,f as ht,g as yt,h as Ce,m as bt,k as kt}from"./index-COJomMe9.js";import{T as vt}from"./tabs-custom-Ilrgt6n1.js";import{u as wt}from"./useConfirmDialog-BeaFLDO8.js";import{S as U}from"./skeleton-D4Eyop0R.js";import{b as Tt,p as oe}from"./marketplace-localization-Dk31LJJJ.js";import{P as St,a as Ct}from"./page-layout-B1RIu5-r.js";var[Y]=lt("Tooltip",[Ne]),X=Ne(),$e="TooltipProvider",Pt=700,ne="tooltip.open",[jt,ie]=Y($e),_e=e=>{const{__scopeTooltip:t,delayDuration:n=Pt,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=e,g=i.useRef(!0),f=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const k=d.current;return()=>window.clearTimeout(k)},[]),s.jsx(jt,{scope:t,isOpenDelayedRef:g,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),g.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>g.current=!0,a)},[a]),isPointerInTransitRef:f,onPointerInTransitChange:i.useCallback(k=>{f.current=k},[]),disableHoverableContent:r,children:l})};_e.displayName=$e;var K="Tooltip",[It,G]=Y(K),Oe=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:g,delayDuration:f}=e,d=ie(K,e.__scopeTooltip),k=X(t),[u,b]=i.useState(null),v=et(),h=i.useRef(0),w=g??d.disableHoverableContent,m=f??d.delayDuration,S=i.useRef(!1),[j,P]=tt({prop:a,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),l==null||l(E)},caller:K}),L=i.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),C=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S.current=!1,P(!0)},[P]),M=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,P(!1)},[P]),$=i.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{S.current=!0,P(!0),h.current=0},m)},[m,P]);return i.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(nt,{...k,children:s.jsx(It,{scope:t,contentId:v,open:j,stateAttribute:L,trigger:u,onTriggerChange:b,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?$():C()},[d.isOpenDelayedRef,$,C]),onTriggerLeave:i.useCallback(()=>{w?M():(window.clearTimeout(h.current),h.current=0)},[M,w]),onOpen:C,onClose:M,disableHoverableContent:w,children:n})})};Oe.displayName=K;var ae="TooltipTrigger",Ae=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=G(ae,n),l=ie(ae,n),g=X(n),f=i.useRef(null),d=Ie(t,f,r.onTriggerChange),k=i.useRef(!1),u=i.useRef(!1),b=i.useCallback(()=>k.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",b),[b]),s.jsx(at,{asChild:!0,...g,children:s.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!u.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),k.current=!0,document.addEventListener("pointerup",b,{once:!0})}),onFocus:A(e.onFocus,()=>{k.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ae.displayName=ae;var ce="TooltipPortal",[Nt,Rt]=Y(ce,{forceMount:void 0}),Ue=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,l=G(ce,t);return s.jsx(Nt,{scope:t,forceMount:n,children:s.jsx(Re,{present:n||l.open,children:s.jsx(rt,{asChild:!0,container:r,children:a})})})};Ue.displayName=ce;var q="TooltipContent",Fe=i.forwardRef((e,t)=>{const n=Rt(q,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=e,g=G(q,e.__scopeTooltip);return s.jsx(Re,{present:a||g.open,children:g.disableHoverableContent?s.jsx(qe,{side:r,...l,ref:t}):s.jsx(Mt,{side:r,...l,ref:t})})}),Mt=i.forwardRef((e,t)=>{const n=G(q,e.__scopeTooltip),a=ie(q,e.__scopeTooltip),r=i.useRef(null),l=Ie(t,r),[g,f]=i.useState(null),{trigger:d,onClose:k}=n,u=r.current,{onPointerInTransitChange:b}=a,v=i.useCallback(()=>{f(null),b(!1)},[b]),h=i.useCallback((w,m)=>{const S=w.currentTarget,j={x:w.clientX,y:w.clientY},P=_t(j,S.getBoundingClientRect()),L=Ot(j,P),C=At(m.getBoundingClientRect()),M=Ft([...L,...C]);f(M),b(!0)},[b]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&u){const w=S=>h(S,u),m=S=>h(S,d);return d.addEventListener("pointerleave",w),u.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",w),u.removeEventListener("pointerleave",m)}}},[d,u,h,v]),i.useEffect(()=>{if(g){const w=m=>{const S=m.target,j={x:m.clientX,y:m.clientY},P=(d==null?void 0:d.contains(S))||(u==null?void 0:u.contains(S)),L=!Ut(j,g);P?v():L&&(v(),k())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,u,g,k,v]),s.jsx(qe,{...e,ref:l})}),[Et,Lt]=Y(K,{isInside:!1}),Dt=ut("TooltipContent"),qe=i.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:g,...f}=e,d=G(q,n),k=X(n),{onClose:u}=d;return i.useEffect(()=>(document.addEventListener(ne,u),()=>document.removeEventListener(ne,u)),[u]),i.useEffect(()=>{if(d.trigger){const b=v=>{const h=v.target;h!=null&&h.contains(d.trigger)&&u()};return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[d.trigger,u]),s.jsx(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:b=>b.preventDefault(),onDismiss:u,children:s.jsxs(it,{"data-state":d.stateAttribute,...k,...f,ref:t,style:{...f.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:[s.jsx(Dt,{children:a}),s.jsx(Et,{scope:n,isInside:!0,children:s.jsx(ct,{id:d.contentId,role:"tooltip",children:r||a})})]})})});Fe.displayName=q;var ze="TooltipArrow",$t=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=X(n);return Lt(ze,n).isInside?null:s.jsx(dt,{...r,...a,ref:t})});$t.displayName=ze;function _t(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Ot(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function At(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Ut(e,t){const{x:n,y:a}=e;let r=!1;for(let l=0,g=t.length-1;l<t.length;g=l++){const f=t[l],d=t[g],k=f.x,u=f.y,b=d.x,v=d.y;u>a!=v>a&&n<(b-k)*(a-u)/(v-u)+k&&(r=!r)}return r}function Ft(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),qt(t)}function qt(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const l=t[t.length-1],g=t[t.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const l=n[n.length-1],g=n[n.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.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 zt=_e,Ht=Oe,Bt=Ae,Kt=Ue,He=Fe;const Gt=zt,ee=Ht,te=Bt,Q=i.forwardRef(({className:e,sideOffset:t=4,...n},a)=>s.jsx(Kt,{children:s.jsx(He,{ref:a,sideOffset:t,className:De("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})}));Q.displayName=He.displayName;function Z(e){return e==="plugin"?"plugins":e==="skill"?"skills":"mcp"}async function Vt(e){var l,g;const t=new URLSearchParams,n=Z(e.type);(l=e.q)!=null&&l.trim()&&t.set("q",e.q.trim()),(g=e.tag)!=null&&g.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))));const a=t.toString(),r=await z.get(a?`/api/marketplace/${n}/items?${a}`:`/api/marketplace/${n}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Qt(e){const t=await z.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Jt(e){const t=await z.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Yt(e){const t=Z(e.type),n=await z.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw new Error(n.error.message);return n.data}async function Xt(e){const t=Z(e),n=await z.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw new Error(n.error.message);return n.data}async function Zt(e){const t=Z(e.type),n=await z.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw new Error(n.error.message);return n.data}function se(e){return Array.from(new Set(e.map(t=>t.spec).filter(Boolean)))}function Wt(e){const 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 re(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Be(e,t){return t??{type:e,total:0,specs:[],records:[]}}function en(e){const t=Be(e.result.type,e.view),n=Wt(e),a=t.records.findIndex(l=>re(l,{id:n.id,spec:n.spec})),r=[...t.records];return a>=0?r[a]={...r[a],...n}:r.unshift(n),{...t,type:e.result.type,records:r,specs:se(r),total:r.length}}function tn(e){const t=Be(e.result.type,e.view);if(e.result.action==="uninstall"||e.result.action==="remove"){const a=t.records.filter(r=>!re(r,{id:e.result.id,spec:e.request.spec}));return{...t,records:a,specs:se(a),total:a.length}}const n=t.records.map(a=>re(a,{id:e.result.id,spec:e.request.spec})?e.result.action==="disable"?{...a,enabled:!1,runtimeStatus:"disabled"}:{...a,enabled:!0,runtimeStatus:"ready"}:a);return{...t,records:n,specs:se(n),total:n.length}}function nn(e){return Me({queryKey:["marketplace-items",e],queryFn:()=>Vt(e),placeholderData:(t,n)=>{var l;const a=(l=n==null?void 0:n.queryKey)==null?void 0:l[1];return!a||typeof a!="object"||a===null?void 0:("type"in a?a.type:void 0)===e.type?t:void 0},staleTime:15e3})}function an(e){return Me({queryKey:["marketplace-installed",e],queryFn:()=>Xt(e),staleTime:1e4})}function sn(){const e=Ee();return Le({mutationFn:t=>Yt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>en({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceInstallFailed"))}})}function rn(){const e=Ee();return Le({mutationFn:t=>Zt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>tn({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceOperationFailed"))}})}function ln(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(pt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.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"&&s.jsxs(mt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(xt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(ht,{})}),s.jsxs(yt,{children:[s.jsx(Ce,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(Ce,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function on(e){return s.jsx(s.Fragment,{children:Array.from({length:e.count},(t,n)=>s.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:s.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[s.jsx(U,{className:"h-10 w-10 shrink-0 rounded-xl"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[s.jsx(U,{className:"h-4 w-32 max-w-[70%]"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(U,{className:"h-3 w-12"}),s.jsx(U,{className:"h-3 w-24"})]}),s.jsx(U,{className:"h-3 w-full"})]})]}),s.jsx(U,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${n}`))})}function cn(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.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:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.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:c("next")})]})}const Ke=12,un=Ke;function le(e){return(e??"").trim().toLowerCase()}function F(e,t){const n=le(t);return n.length>0?`${e}:${n}`:""}function dn(e){const t=new Map;for(const n of e){const a=[n.install.spec,n.slug,n.id];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function pn(e){const t=new Map;for(const n of e){const a=[n.spec,n.id,n.label];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function Pe(e,t){const n=[e.install.spec,e.slug,e.id];for(const a of n){const r=F(e.type,a);if(!r)continue;const l=t.get(r);if(l)return l}}function gn(e,t){const n=t.get(F(e.type,e.spec));if(n)return n;const a=t.get(F(e.type,e.id));return a||t.get(F(e.type,e.label))}function fn(e,t,n,a){const r=le(n);if(!r)return!0;const l=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,l,...(t==null?void 0:t.tags)??[]].map(f=>le(f)).filter(Boolean).some(f=>f.includes(r))}function mn(e){const 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"];let n=0;for(let a=0;a<e.length;a++)n=e.charCodeAt(a)+((n<<5)-n);return t[Math.abs(n)%t.length]}function xn({name:e,fallback:t}){const n=e||t,a=n.substring(0,2).toUpperCase(),r=mn(n);return s.jsx("div",{className:De("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:a})}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(e){var f,d,k,u;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",n=((d=e.contentRaw)==null?void 0:d.trim())||"-",a=(k=e.summary)==null?void 0:k.trim(),r=(u=e.description)==null?void 0:u.trim(),l=!!r&&r!==a,g=`<!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>${I(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>${I(e.title)}</h1>
30
+ <div class="meta">${I(e.typeLabel)} · ${I(e.spec)}${e.author?` · ${I(e.author)}`:""}</div>
31
+ ${a?`<p class="summary">${I(a)}</p>`:""}
32
+ ${l?`<p class="summary">${I(r)}</p>`:""}
33
+ ${e.tags&&e.tags.length>0?`<div class="tags">${e.tags.map(b=>`<span class="tag">${I(b)}</span>`).join("")}</div>`:""}
34
+ ${e.sourceUrl?`<p class="meta" style="margin-top:12px;">${I(e.sourceLabel??"Source")}: <a class="source" href="${I(e.sourceUrl)}" target="_blank" rel="noopener noreferrer">${I(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">${I(t)}</pre></div>
41
+ </article>
42
+ <article class="card">
43
+ <h2>Content</h2>
44
+ <div class="body"><pre class="code">${I(n)}</pre></div>
45
+ </article>
46
+ </section>
47
+ </main>
48
+ </body>
49
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(g)}`}function je(e){const{item:t,record:n,localeFallbacks:a,installState:r,manageState:l,onOpen:g,onInstall:f,onManage:d}=e,k=(n==null?void 0:n.type)==="plugin"?n:void 0,u=(t==null?void 0:t.name)??(n==null?void 0:n.label)??(n==null?void 0:n.id)??(n==null?void 0:n.spec)??c("marketplaceUnknownItem"),b=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a)||(n?c("marketplaceInstalledLocalSummary"):""),v=(t==null?void 0:t.install.spec)??(n==null?void 0:n.spec)??"",h=(n==null?void 0:n.id)||(n==null?void 0:n.spec),w=h?l.actionsByTarget.get(h):void 0,m=!!w,S=!!k,j=(n==null?void 0:n.type)==="plugin"&&n.origin!=="bundled",P=(n==null?void 0:n.type)==="skill"&&n.source==="workspace",L=!!(j||P),C=n?n.enabled===!1||n.runtimeStatus==="disabled":!1,M=t==null?void 0:t.install.spec,$=typeof M=="string"&&r.installingSpecs.has(M);return s.jsxs("article",{onClick:g,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:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(xn,{name:u,fallback:v||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(Gt,{delayDuration:400,children:[s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:u})}),s.jsx(Q,{className:"max-w-[300px] text-xs",children:u})]}),s.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:v&&s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:v})}),s.jsx(Q,{className:"max-w-[300px] text-xs font-mono break-all",children:v})]})}),s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:b})}),b&&s.jsx(Q,{className:"max-w-[400px] text-xs leading-relaxed",children:b})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[t&&!n&&s.jsx("button",{onClick:E=>{E.stopPropagation(),f(t)},disabled:$,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:$?c("marketplaceInstalling"):c("marketplaceInstall")}),k&&S&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d(C?"enable":"disable",k)},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:w&&w!=="uninstall"?w==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):C?c("marketplaceEnable"):c("marketplaceDisable")}),n&&L&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d("uninstall",n)},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:w==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function hn(e={}){var ke,ve,we,Te,Se;const{forcedType:t}=e,n=gt(),a=ft(),{language:r}=bt(),l=kt(),g=i.useMemo(()=>t==="plugins"||t==="skills"?t:a.type==="plugins"||a.type==="skills"?a.type:null,[t,a.type]);i.useEffect(()=>{t||g||n("/marketplace/plugins",{replace:!0})},[t,g,n]);const f=g==="skills"?"skill":"plugin",d=i.useMemo(()=>Tt(r),[r]),u=f==="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"},[b,v]=i.useState(""),[h,w]=i.useState(""),[m,S]=i.useState("all"),[j,P]=i.useState("relevance"),[L,C]=i.useState(1),[M,$]=i.useState(new Set),[E,ue]=i.useState(new Map);i.useEffect(()=>{const o=setTimeout(()=>{C(1),w(b.trim())},250);return()=>clearTimeout(o)},[b]),i.useEffect(()=>{C(1)},[f]);const N=an(f),R=nn({q:h||void 0,type:f,sort:j,page:L,pageSize:Ke}),Ge=sn(),Ve=rn(),{confirm:Qe,ConfirmDialog:Je}=wt(),V=i.useMemo(()=>{var o;return((o=N.data)==null?void 0:o.records)??[]},[(ke=N.data)==null?void 0:ke.records]),O=i.useMemo(()=>{var o;return((o=R.data)==null?void 0:o.items)??[]},[(ve=R.data)==null?void 0:ve.items]),de=i.useMemo(()=>dn(O),[O]),pe=i.useMemo(()=>pn(V),[V]),H=i.useMemo(()=>{const o=V.filter(p=>p.type===f).map(p=>({key:`${p.type}:${p.spec}:${p.id??""}`,record:p,item:gn(p,de)})).filter(p=>fn(p.record,p.item,h,d));return o.sort((p,y)=>{const T=p.record.installedAt?Date.parse(p.record.installedAt):Number.NaN,x=y.record.installedAt?Date.parse(y.record.installedAt):Number.NaN,D=!Number.isNaN(T),We=!Number.isNaN(x);return D&&We&&T!==x?x-T:p.record.spec.localeCompare(y.record.spec)}),o},[V,f,de,h,d]),ge=m==="installed"?H.length:((we=R.data)==null?void 0:we.total)??0,W=m==="installed"?1:((Te=R.data)==null?void 0:Te.totalPages)??0,fe=m==="all"&&R.isLoading&&!R.data,Ye=m==="installed"&&N.isLoading&&!N.data,_=fe||Ye,Xe=i.useMemo(()=>m==="installed"?N.isLoading&&!N.data?c("loading"):`${H.length} ${c(u.installedCountSuffix)}`:R.data?`${O.length} / ${ge}`:c("loading"),[m,N.data,N.isLoading,H.length,R.data,O.length,ge,u.installedCountSuffix]),me={installingSpecs:M},xe={actionsByTarget:E},Ze=[{id:"all",label:c(u.tabMarketplace)},{id:"installed",label:c(u.tabInstalled),count:((Se=N.data)==null?void 0:Se.total)??0}],he=async o=>{const p=o.install.spec;if(!M.has(p)){$(y=>{const T=new Set(y);return T.add(p),T});try{await Ge.mutateAsync({type:o.type,spec:p,kind:o.install.kind,...o.type==="skill"?{skill:o.slug,installPath:`skills/${o.slug}`}:{}})}catch{}finally{$(y=>{if(!y.has(p))return y;const T=new Set(y);return T.delete(p),T})}}},ye=async(o,p)=>{const y=p.id||p.spec;if(y&&!E.has(y)&&!(o==="uninstall"&&!await Qe({title:`${c("marketplaceUninstallTitle")} ${y}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"}))){ue(T=>{const x=new Map(T);return x.set(y,o),x});try{await Ve.mutateAsync({type:p.type,action:o,id:y,spec:p.spec})}finally{ue(T=>{if(!T.has(y))return T;const x=new Map(T);return x.delete(y),x})}}},be=async(o,p)=>{const y=(o==null?void 0:o.name)??(p==null?void 0:p.label)??(p==null?void 0:p.id)??(p==null?void 0:p.spec)??c("marketplaceUnknownItem");if(!o){const x=B({title:y,typeLabel:(p==null?void 0:p.type)==="plugin"?c("marketplaceTypePlugin"):c("marketplaceTypeSkill"),spec:(p==null?void 0:p.spec)??"-",summary:c("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(p??{},null,2),contentRaw:"-"});l.open(x,{newTab:!0,title:y,kind:"content"});return}const T=oe(o.summaryI18n,o.summary,d);if(o.type==="skill"){try{const x=await Qt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:c("marketplaceOperationFailed")});l.open(D,{newTab:!0,title:y,kind:"content"})}return}try{const x=await Jt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw||o.summary,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:"-"});l.open(D,{newTab:!0,title:y,kind:"content"})}};return s.jsxs(St,{className:"flex h-full min-h-0 flex-col pb-0",children:[s.jsx(Ct,{title:c(u.pageTitle),description:c(u.pageDescription)}),s.jsx(vt,{tabs:Ze,activeTab:m,onChange:o=>{S(o),C(1)},className:"mb-4"}),s.jsx(ln,{scope:m,searchText:b,searchPlaceholder:c(u.searchPlaceholder),sort:j,onSearchTextChange:v,onSortChange:o=>{C(1),P(o)}}),s.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:m==="installed"?c(u.sectionInstalled):c(u.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:Xe})]}),m==="all"&&R.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadData),": ",R.error.message]}),m==="installed"&&N.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadInstalled),": ",N.error.message]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1","aria-busy":_,children:[s.jsxs("div",{"data-testid":_?"marketplace-list-skeleton":void 0,className:"grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:[_&&s.jsx(on,{count:un}),!_&&m==="all"&&O.map(o=>s.jsx(je,{item:o,record:Pe(o,pe),localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o,Pe(o,pe)),onInstall:he,onManage:ye},o.id)),!_&&m==="installed"&&H.map(o=>s.jsx(je,{item:o.item,record:o.record,localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o.item,o.record),onInstall:he,onManage:ye},o.key))]}),m==="all"&&!_&&!R.isError&&O.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyData)}),m==="installed"&&!_&&!N.isError&&H.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyInstalled)})]})]}),m==="all"&&!fe&&s.jsx("div",{className:"shrink-0",children:s.jsx(cn,{page:L,totalPages:W,busy:R.isFetching,onPrev:()=>C(o=>Math.max(1,o-1)),onNext:()=>C(o=>W>0?Math.min(W,o+1):o+1)})}),s.jsx(Je,{})]})}const Cn=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:hn},Symbol.toStringTag,{value:"Module"}));export{He as C,hn as M,zt as P,Ht as R,Gt as T,ee as a,te as b,Q as c,Bt as d,Kt as e,Cn as f,an as u};
@@ -1,4 +1,4 @@
1
- import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-CNhxtHCf.js";import{P as he,a as fe}from"./page-layout-DjXaK3A3.js";import{T as ye}from"./tabs-custom-DKSbDSB9.js";import{a2 as v,t as n,s as be,q as ke,I as P,S as je,e as ve,f as we,g as Me,h as X,c as Ne,am as se,an as ne,ao as re,ap as le,aq as ce,ar as Se,B as Y}from"./index-j6A_-1b6.js";import{S as Ce}from"./switch-DCHAJSrA.js";import{S}from"./skeleton-Dm2xOBSA.js";import{u as Ie}from"./useConfirmDialog-ByJ8A8n7.js";import{b as De,p as Te,a as Pe}from"./marketplace-localization-Dk31LJJJ.js";async function Re(e){var d,o;const t=new URLSearchParams;(d=e.q)!=null&&d.trim()&&t.set("q",e.q.trim()),(o=e.tag)!=null&&o.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))));const c=t.toString(),i=await v.get(c?`/api/marketplace/mcp/items?${c}`:"/api/marketplace/mcp/items");if(!i.ok)throw new Error(i.error.message);return i.data}async function qe(){const e=await v.get("/api/marketplace/mcp/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Ee(e){const t=await v.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Fe(e){const t=await v.post("/api/marketplace/mcp/install",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function $e(e){const t=await v.post("/api/marketplace/mcp/manage",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function Le(e){const t=await v.post("/api/marketplace/mcp/doctor",{name:e});if(!t.ok)throw new Error(t.error.message);return t.data}function ze(e){return ae({queryKey:["marketplace-mcp-items",e],queryFn:()=>Re(e),staleTime:15e3})}function Ae(){return ae({queryKey:["marketplace-mcp-installed"],queryFn:()=>qe(),staleTime:1e4})}function Oe(){const e=te();return R({mutationFn:Fe,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceInstallSuccessMcp"))},onError:t=>{C.error(t.message||n("marketplaceInstallFailed"))}})}function Qe(){const e=te();return R({mutationFn:$e,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceMcpManageSuccess"))},onError:t=>{C.error(t.message||n("marketplaceOperationFailed"))}})}const Ke=12;function oe(e){return(e??"").trim().toLowerCase()}function Ue(e){const t=new Map;for(const c of e){const i=[c.catalogSlug,c.spec,c.id,c.label];for(const d of i){const o=oe(d);!o||t.has(o)||t.set(o,c)}}return t}function Be(e,t){const c=[e.slug,e.install.spec,e.id,e.name];for(const i of c){const d=oe(i);if(!d)continue;const o=t.get(d);if(o)return o}}function T(e,t,c,i,d){const o=k=>k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),y=`<!doctype html>
1
+ import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-waGu-koL.js";import{P as he,a as fe}from"./page-layout-B1RIu5-r.js";import{T as ye}from"./tabs-custom-Ilrgt6n1.js";import{U as v,t as n,m as be,k as ke,I as P,S as je,e as ve,f as we,g as Me,h as X,c as Ne,ad as se,ae as ne,af as re,ag as le,ah as ce,ai as Se,B as Y}from"./index-COJomMe9.js";import{S as Ce}from"./switch-C3vVTpfU.js";import{S}from"./skeleton-D4Eyop0R.js";import{u as Ie}from"./useConfirmDialog-BeaFLDO8.js";import{b as De,p as Te,a as Pe}from"./marketplace-localization-Dk31LJJJ.js";async function Re(e){var d,o;const t=new URLSearchParams;(d=e.q)!=null&&d.trim()&&t.set("q",e.q.trim()),(o=e.tag)!=null&&o.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))));const c=t.toString(),i=await v.get(c?`/api/marketplace/mcp/items?${c}`:"/api/marketplace/mcp/items");if(!i.ok)throw new Error(i.error.message);return i.data}async function qe(){const e=await v.get("/api/marketplace/mcp/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Ee(e){const t=await v.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Fe(e){const t=await v.post("/api/marketplace/mcp/install",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function $e(e){const t=await v.post("/api/marketplace/mcp/manage",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function Le(e){const t=await v.post("/api/marketplace/mcp/doctor",{name:e});if(!t.ok)throw new Error(t.error.message);return t.data}function ze(e){return ae({queryKey:["marketplace-mcp-items",e],queryFn:()=>Re(e),staleTime:15e3})}function Ae(){return ae({queryKey:["marketplace-mcp-installed"],queryFn:()=>qe(),staleTime:1e4})}function Oe(){const e=te();return R({mutationFn:Fe,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceInstallSuccessMcp"))},onError:t=>{C.error(t.message||n("marketplaceInstallFailed"))}})}function Qe(){const e=te();return R({mutationFn:$e,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceMcpManageSuccess"))},onError:t=>{C.error(t.message||n("marketplaceOperationFailed"))}})}const Ue=12;function oe(e){return(e??"").trim().toLowerCase()}function Ke(e){const t=new Map;for(const c of e){const i=[c.catalogSlug,c.spec,c.id,c.label];for(const d of i){const o=oe(d);!o||t.has(o)||t.set(o,c)}}return t}function Be(e,t){const c=[e.slug,e.install.spec,e.id,e.name];for(const i of c){const d=oe(i);if(!d)continue;const o=t.get(d);if(o)return o}}function T(e,t,c,i,d){const o=k=>k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),y=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -37,4 +37,4 @@ import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-CNhxtHCf.js";im
37
37
  </section>
38
38
  </main>
39
39
  </body>
40
- </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(y)}`}function ee(e,t,c){const i=Te(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,e);return i||Pe(c,e)||n("marketplaceInstalledLocalSummary")}function Ve(e,t){if(t!=null&&t.transport)return t.transport.toUpperCase();const c=e==null?void 0:e.install;return((c==null?void 0:c.transportTypes)??[]).map(i=>i.toUpperCase()).join(" / ")||"MCP"}function Je(e){var b,j;const t=(b=e.item)==null?void 0:b.install,[c,i]=m.useState(""),[d,o]=m.useState(!0),[y,k]=m.useState({});return m.useEffect(()=>{i((t==null?void 0:t.defaultName)??""),o(!0),k(Object.fromEntries(((t==null?void 0:t.inputs)??[]).map(p=>[p.id,p.defaultValue??""])))},[t,e.open]),a.jsx(se,{open:e.open,onOpenChange:e.onOpenChange,children:a.jsxs(ne,{children:[a.jsxs(re,{children:[a.jsx(le,{children:n("marketplaceMcpInstallDialogTitle")}),a.jsx(ce,{children:((j=e.item)==null?void 0:j.name)??"-"})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-gray-800",children:n("marketplaceMcpServerName")}),a.jsx(P,{value:c,onChange:p=>i(p.target.value),placeholder:(t==null?void 0:t.defaultName)??"mcp-server"})]}),a.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium text-gray-900",children:n("marketplaceMcpAllAgents")}),a.jsx("div",{className:"text-xs text-gray-500",children:n("marketplaceMcpAllAgentsDescription")})]}),a.jsx(Ce,{checked:d,onCheckedChange:o})]}),((t==null?void 0:t.inputs)??[]).map(p=>a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-gray-800",children:p.label}),p.description&&a.jsx("div",{className:"text-xs text-gray-500",children:p.description}),a.jsx(P,{type:p.secret?"password":"text",value:y[p.id]??"",onChange:w=>k(N=>({...N,[p.id]:w.target.value})),placeholder:p.defaultValue??""})]},p.id))]}),a.jsxs(Se,{children:[a.jsx(Y,{variant:"outline",onClick:()=>e.onOpenChange(!1),disabled:e.pending,children:n("cancel")}),a.jsx(Y,{onClick:()=>void e.onSubmit({name:c,allAgents:d,inputs:y}),disabled:e.pending||!c.trim(),children:e.pending?n("marketplaceInstalling"):n("marketplaceInstall")})]})]})})}function _e(e){return a.jsx(se,{open:e.open,onOpenChange:e.onOpenChange,children:a.jsxs(ne,{children:[a.jsxs(re,{children:[a.jsx(le,{children:n("marketplaceMcpDoctorTitle")}),a.jsx(ce,{children:e.targetName??"-"})]}),e.pending&&a.jsx("div",{className:"text-sm text-gray-500",children:n("loading")}),!e.pending&&e.result&&a.jsxs("div",{className:"space-y-3 text-sm text-gray-700",children:[a.jsxs("div",{children:[n("marketplaceMcpDoctorAccessible"),": ",e.result.accessible?n("statusReady"):n("marketplaceOperationFailed")]}),a.jsxs("div",{children:[n("marketplaceMcpDoctorTransport"),": ",e.result.transport.toUpperCase()]}),a.jsxs("div",{children:[n("marketplaceMcpDoctorTools"),": ",e.result.toolCount]}),e.result.error&&a.jsx("div",{className:"rounded-lg bg-rose-50 px-3 py-2 text-rose-600",children:e.result.error})]})]})})}function ta(){var Q,K,U,B,V,J,_,H,Z,G;const[e,t]=m.useState("catalog"),[c,i]=m.useState(""),[d,o]=m.useState(""),[y,k]=m.useState("relevance"),[b,j]=m.useState(1),[p,w]=m.useState(null),[N,I]=m.useState(null),[ie,q]=m.useState(null),{language:E}=be(),D=ke(),{confirm:de,ConfirmDialog:pe}=Ie(),F=m.useMemo(()=>De(E),[E]);m.useEffect(()=>{const s=window.setTimeout(()=>{j(1),o(c.trim())},250);return()=>window.clearTimeout(s)},[c]);const u=ze({q:d||void 0,sort:y,page:b,pageSize:Ke}),f=Ae(),$=Oe(),me=Qe(),L=R({mutationFn:Le,onSuccess:(s,r)=>{I(r),q(s)}}),ue=m.useMemo(()=>{var s;return Ue(((s=f.data)==null?void 0:s.records)??[])},[(Q=f.data)==null?void 0:Q.records]),z=m.useMemo(()=>{var r;return(((r=f.data)==null?void 0:r.records)??[]).filter(l=>{const h=[l.id??"",l.label??"",l.catalogSlug??"",l.description??"",l.descriptionZh??""].join(" ").toLowerCase();return d?h.includes(d.toLowerCase()):!0})},[(K=f.data)==null?void 0:K.records,d]),xe=async(s,r)=>{const l=(s==null?void 0:s.name)??(r==null?void 0:r.label)??(r==null?void 0:r.id)??"MCP",h=ee(F,s,r);if(!s){const x=T(l,JSON.stringify(r??{},null,2),n("marketplaceInstalledLocalSummary"),r==null?void 0:r.docsUrl,h);D.open(x,{newTab:!0,title:l,kind:"content"});return}try{const x=await Ee(s.slug),M=T(l,x.metadataRaw||JSON.stringify(s,null,2),x.bodyRaw||x.raw,x.sourceUrl,h);D.open(M,{newTab:!0,title:l,kind:"content"})}catch(x){const M=T(l,JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),h,void 0,h);D.open(M,{newTab:!0,title:l,kind:"content"})}},ge=async s=>{p&&(await $.mutateAsync({spec:p.slug,name:s.name.trim(),allAgents:s.allAgents,inputs:s.inputs}),w(null))},A=async(s,r)=>{const l=r.id||r.spec;l&&(s==="remove"&&!await de({title:`${n("marketplaceMcpRemoveTitle")} ${l}?`,description:n("marketplaceMcpRemoveDescription"),confirmLabel:n("marketplaceMcpRemove"),variant:"destructive"})||await me.mutateAsync({action:s,id:l,spec:r.spec}))},O=(s,r)=>{const l=r??(s?Be(s,ue):void 0),h=(s==null?void 0:s.name)??(r==null?void 0:r.label)??(r==null?void 0:r.id)??"MCP",x=ee(F,s,r),M=Ve(s,r),W=l?l.enabled===!1?n("marketplaceDisable"):n("statusReady"):null;return a.jsx("article",{onClick:()=>void xe(s,r),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:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-semibold text-gray-900",children:h}),a.jsx("div",{className:"mt-1 text-xs text-gray-500",children:M}),a.jsx("div",{className:"mt-2 line-clamp-2 text-sm text-gray-600",children:x}),a.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[((s==null?void 0:s.tags)??[]).map(g=>a.jsx("span",{className:"rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-600",children:g},g)),W&&a.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] text-emerald-700",children:W})]})]}),a.jsxs("div",{className:"flex shrink-0 flex-col gap-2",children:[!l&&s&&a.jsx("button",{className:"rounded-xl bg-primary px-3 py-1.5 text-xs font-medium text-white",onClick:g=>{g.stopPropagation(),w(s)},children:n("marketplaceInstall")}),l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"rounded-xl border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700",onClick:g=>{g.stopPropagation(),A(l.enabled===!1?"enable":"disable",l)},children:l.enabled===!1?n("marketplaceEnable"):n("marketplaceDisable")}),a.jsx("button",{className:"rounded-xl border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700",onClick:g=>{g.stopPropagation(),I(l.id??null),q(null),L.mutateAsync(l.id??"")},children:n("marketplaceMcpDoctor")}),a.jsx("button",{className:"rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600",onClick:g=>{g.stopPropagation(),A("remove",l)},children:n("marketplaceMcpRemove")})]})]})]})},`${(s==null?void 0:s.id)??(r==null?void 0:r.id)??(r==null?void 0:r.spec)}`)};return a.jsxs(he,{className:"flex h-full min-h-0 flex-col pb-0",children:[a.jsx(fe,{title:n("marketplaceMcpPageTitle"),description:n("marketplaceMcpPageDescription")}),a.jsx(ye,{tabs:[{id:"catalog",label:n("marketplaceMcpTabCatalog")},{id:"installed",label:n("marketplaceMcpTabInstalled"),count:((U=f.data)==null?void 0:U.total)??0}],activeTab:e,onChange:s=>t(s),className:"mb-4"}),a.jsxs("div",{className:"mb-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[a.jsx(P,{value:c,onChange:s=>i(s.target.value),placeholder:n("marketplaceMcpSearchPlaceholder"),className:"md:max-w-sm"}),a.jsxs(je,{value:y,onValueChange:s=>k(s),children:[a.jsx(ve,{className:"h-9 w-[180px] rounded-lg",children:a.jsx(we,{})}),a.jsxs(Me,{children:[a.jsx(X,{value:"relevance",children:n("marketplaceSortRelevance")}),a.jsx(X,{value:"updated",children:n("marketplaceSortUpdated")})]})]})]}),a.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:e==="catalog"?n("marketplaceMcpSectionCatalog"):n("marketplaceMcpSectionInstalled")}),a.jsx("span",{className:"text-xs text-gray-500",children:e==="catalog"?((B=u.data)==null?void 0:B.total)??0:((V=f.data)==null?void 0:V.total)??0})]}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[a.jsxs("div",{className:Ne("grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3"),children:[e==="catalog"&&u.isLoading&&Array.from({length:6},(s,r)=>a.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm",children:[a.jsx(S,{className:"h-4 w-32"}),a.jsx(S,{className:"mt-2 h-3 w-20"}),a.jsx(S,{className:"mt-3 h-3 w-full"}),a.jsx(S,{className:"mt-2 h-3 w-2/3"})]},r)),e==="catalog"&&!u.isLoading&&(((J=u.data)==null?void 0:J.items)??[]).map(s=>O(s)),e==="installed"&&z.map(s=>O(void 0,s))]}),e==="catalog"&&u.isError&&a.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700",children:u.error.message}),e==="installed"&&f.isError&&a.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700",children:f.error.message}),e==="catalog"&&!u.isLoading&&(((H=(_=u.data)==null?void 0:_.items)==null?void 0:H.length)??0)===0&&a.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:n("marketplaceNoMcp")}),e==="installed"&&z.length===0&&a.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:n("marketplaceNoInstalledMcp")})]})]}),e==="catalog"&&a.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[a.jsx("button",{className:"h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40",onClick:()=>j(s=>Math.max(1,s-1)),disabled:b<=1||u.isFetching,children:n("prev")}),a.jsx("div",{className:"min-w-20 text-center text-sm text-gray-600",children:(Z=u.data)!=null&&Z.totalPages?`${b} / ${u.data.totalPages}`:"0 / 0"}),a.jsx("button",{className:"h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40",onClick:()=>j(s=>s+1),disabled:!((G=u.data)!=null&&G.totalPages)||b>=u.data.totalPages||u.isFetching,children:n("next")})]}),a.jsx(Je,{item:p,open:!!p,pending:$.isPending,onOpenChange:s=>!s&&w(null),onSubmit:ge}),a.jsx(_e,{open:!!N,targetName:N,result:ie,pending:L.isPending,onOpenChange:s=>!s&&I(null)}),a.jsx(pe,{})]})}export{ta as McpMarketplacePage};
40
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(y)}`}function ee(e,t,c){const i=Te(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,e);return i||Pe(c,e)||n("marketplaceInstalledLocalSummary")}function Ve(e,t){if(t!=null&&t.transport)return t.transport.toUpperCase();const c=e==null?void 0:e.install;return((c==null?void 0:c.transportTypes)??[]).map(i=>i.toUpperCase()).join(" / ")||"MCP"}function Je(e){var b,j;const t=(b=e.item)==null?void 0:b.install,[c,i]=m.useState(""),[d,o]=m.useState(!0),[y,k]=m.useState({});return m.useEffect(()=>{i((t==null?void 0:t.defaultName)??""),o(!0),k(Object.fromEntries(((t==null?void 0:t.inputs)??[]).map(p=>[p.id,p.defaultValue??""])))},[t,e.open]),a.jsx(se,{open:e.open,onOpenChange:e.onOpenChange,children:a.jsxs(ne,{children:[a.jsxs(re,{children:[a.jsx(le,{children:n("marketplaceMcpInstallDialogTitle")}),a.jsx(ce,{children:((j=e.item)==null?void 0:j.name)??"-"})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-gray-800",children:n("marketplaceMcpServerName")}),a.jsx(P,{value:c,onChange:p=>i(p.target.value),placeholder:(t==null?void 0:t.defaultName)??"mcp-server"})]}),a.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium text-gray-900",children:n("marketplaceMcpAllAgents")}),a.jsx("div",{className:"text-xs text-gray-500",children:n("marketplaceMcpAllAgentsDescription")})]}),a.jsx(Ce,{checked:d,onCheckedChange:o})]}),((t==null?void 0:t.inputs)??[]).map(p=>a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-gray-800",children:p.label}),p.description&&a.jsx("div",{className:"text-xs text-gray-500",children:p.description}),a.jsx(P,{type:p.secret?"password":"text",value:y[p.id]??"",onChange:w=>k(N=>({...N,[p.id]:w.target.value})),placeholder:p.defaultValue??""})]},p.id))]}),a.jsxs(Se,{children:[a.jsx(Y,{variant:"outline",onClick:()=>e.onOpenChange(!1),disabled:e.pending,children:n("cancel")}),a.jsx(Y,{onClick:()=>void e.onSubmit({name:c,allAgents:d,inputs:y}),disabled:e.pending||!c.trim(),children:e.pending?n("marketplaceInstalling"):n("marketplaceInstall")})]})]})})}function _e(e){return a.jsx(se,{open:e.open,onOpenChange:e.onOpenChange,children:a.jsxs(ne,{children:[a.jsxs(re,{children:[a.jsx(le,{children:n("marketplaceMcpDoctorTitle")}),a.jsx(ce,{children:e.targetName??"-"})]}),e.pending&&a.jsx("div",{className:"text-sm text-gray-500",children:n("loading")}),!e.pending&&e.result&&a.jsxs("div",{className:"space-y-3 text-sm text-gray-700",children:[a.jsxs("div",{children:[n("marketplaceMcpDoctorAccessible"),": ",e.result.accessible?n("statusReady"):n("marketplaceOperationFailed")]}),a.jsxs("div",{children:[n("marketplaceMcpDoctorTransport"),": ",e.result.transport.toUpperCase()]}),a.jsxs("div",{children:[n("marketplaceMcpDoctorTools"),": ",e.result.toolCount]}),e.result.error&&a.jsx("div",{className:"rounded-lg bg-rose-50 px-3 py-2 text-rose-600",children:e.result.error})]})]})})}function ta(){var Q,U,K,B,V,J,_,H,Z,G;const[e,t]=m.useState("catalog"),[c,i]=m.useState(""),[d,o]=m.useState(""),[y,k]=m.useState("relevance"),[b,j]=m.useState(1),[p,w]=m.useState(null),[N,I]=m.useState(null),[ie,q]=m.useState(null),{language:E}=be(),D=ke(),{confirm:de,ConfirmDialog:pe}=Ie(),F=m.useMemo(()=>De(E),[E]);m.useEffect(()=>{const s=window.setTimeout(()=>{j(1),o(c.trim())},250);return()=>window.clearTimeout(s)},[c]);const u=ze({q:d||void 0,sort:y,page:b,pageSize:Ue}),f=Ae(),$=Oe(),me=Qe(),L=R({mutationFn:Le,onSuccess:(s,r)=>{I(r),q(s)}}),ue=m.useMemo(()=>{var s;return Ke(((s=f.data)==null?void 0:s.records)??[])},[(Q=f.data)==null?void 0:Q.records]),z=m.useMemo(()=>{var r;return(((r=f.data)==null?void 0:r.records)??[]).filter(l=>{const h=[l.id??"",l.label??"",l.catalogSlug??"",l.description??"",l.descriptionZh??""].join(" ").toLowerCase();return d?h.includes(d.toLowerCase()):!0})},[(U=f.data)==null?void 0:U.records,d]),xe=async(s,r)=>{const l=(s==null?void 0:s.name)??(r==null?void 0:r.label)??(r==null?void 0:r.id)??"MCP",h=ee(F,s,r);if(!s){const x=T(l,JSON.stringify(r??{},null,2),n("marketplaceInstalledLocalSummary"),r==null?void 0:r.docsUrl,h);D.open(x,{newTab:!0,title:l,kind:"content"});return}try{const x=await Ee(s.slug),M=T(l,x.metadataRaw||JSON.stringify(s,null,2),x.bodyRaw||x.raw,x.sourceUrl,h);D.open(M,{newTab:!0,title:l,kind:"content"})}catch(x){const M=T(l,JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),h,void 0,h);D.open(M,{newTab:!0,title:l,kind:"content"})}},ge=async s=>{p&&(await $.mutateAsync({spec:p.slug,name:s.name.trim(),allAgents:s.allAgents,inputs:s.inputs}),w(null))},A=async(s,r)=>{const l=r.id||r.spec;l&&(s==="remove"&&!await de({title:`${n("marketplaceMcpRemoveTitle")} ${l}?`,description:n("marketplaceMcpRemoveDescription"),confirmLabel:n("marketplaceMcpRemove"),variant:"destructive"})||await me.mutateAsync({action:s,id:l,spec:r.spec}))},O=(s,r)=>{const l=r??(s?Be(s,ue):void 0),h=(s==null?void 0:s.name)??(r==null?void 0:r.label)??(r==null?void 0:r.id)??"MCP",x=ee(F,s,r),M=Ve(s,r),W=l?l.enabled===!1?n("marketplaceDisable"):n("statusReady"):null;return a.jsx("article",{onClick:()=>void xe(s,r),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:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-semibold text-gray-900",children:h}),a.jsx("div",{className:"mt-1 text-xs text-gray-500",children:M}),a.jsx("div",{className:"mt-2 line-clamp-2 text-sm text-gray-600",children:x}),a.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[((s==null?void 0:s.tags)??[]).map(g=>a.jsx("span",{className:"rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-600",children:g},g)),W&&a.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] text-emerald-700",children:W})]})]}),a.jsxs("div",{className:"flex shrink-0 flex-col gap-2",children:[!l&&s&&a.jsx("button",{className:"rounded-xl bg-primary px-3 py-1.5 text-xs font-medium text-white",onClick:g=>{g.stopPropagation(),w(s)},children:n("marketplaceInstall")}),l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"rounded-xl border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700",onClick:g=>{g.stopPropagation(),A(l.enabled===!1?"enable":"disable",l)},children:l.enabled===!1?n("marketplaceEnable"):n("marketplaceDisable")}),a.jsx("button",{className:"rounded-xl border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700",onClick:g=>{g.stopPropagation(),I(l.id??null),q(null),L.mutateAsync(l.id??"")},children:n("marketplaceMcpDoctor")}),a.jsx("button",{className:"rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600",onClick:g=>{g.stopPropagation(),A("remove",l)},children:n("marketplaceMcpRemove")})]})]})]})},`${(s==null?void 0:s.id)??(r==null?void 0:r.id)??(r==null?void 0:r.spec)}`)};return a.jsxs(he,{className:"flex h-full min-h-0 flex-col pb-0",children:[a.jsx(fe,{title:n("marketplaceMcpPageTitle"),description:n("marketplaceMcpPageDescription")}),a.jsx(ye,{tabs:[{id:"catalog",label:n("marketplaceMcpTabCatalog")},{id:"installed",label:n("marketplaceMcpTabInstalled"),count:((K=f.data)==null?void 0:K.total)??0}],activeTab:e,onChange:s=>t(s),className:"mb-4"}),a.jsxs("div",{className:"mb-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[a.jsx(P,{value:c,onChange:s=>i(s.target.value),placeholder:n("marketplaceMcpSearchPlaceholder"),className:"md:max-w-sm"}),a.jsxs(je,{value:y,onValueChange:s=>k(s),children:[a.jsx(ve,{className:"h-9 w-[180px] rounded-lg",children:a.jsx(we,{})}),a.jsxs(Me,{children:[a.jsx(X,{value:"relevance",children:n("marketplaceSortRelevance")}),a.jsx(X,{value:"updated",children:n("marketplaceSortUpdated")})]})]})]}),a.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:e==="catalog"?n("marketplaceMcpSectionCatalog"):n("marketplaceMcpSectionInstalled")}),a.jsx("span",{className:"text-xs text-gray-500",children:e==="catalog"?((B=u.data)==null?void 0:B.total)??0:((V=f.data)==null?void 0:V.total)??0})]}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[a.jsxs("div",{className:Ne("grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3"),children:[e==="catalog"&&u.isLoading&&Array.from({length:6},(s,r)=>a.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm",children:[a.jsx(S,{className:"h-4 w-32"}),a.jsx(S,{className:"mt-2 h-3 w-20"}),a.jsx(S,{className:"mt-3 h-3 w-full"}),a.jsx(S,{className:"mt-2 h-3 w-2/3"})]},r)),e==="catalog"&&!u.isLoading&&(((J=u.data)==null?void 0:J.items)??[]).map(s=>O(s)),e==="installed"&&z.map(s=>O(void 0,s))]}),e==="catalog"&&u.isError&&a.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700",children:u.error.message}),e==="installed"&&f.isError&&a.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700",children:f.error.message}),e==="catalog"&&!u.isLoading&&(((H=(_=u.data)==null?void 0:_.items)==null?void 0:H.length)??0)===0&&a.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:n("marketplaceNoMcp")}),e==="installed"&&z.length===0&&a.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:n("marketplaceNoInstalledMcp")})]})]}),e==="catalog"&&a.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[a.jsx("button",{className:"h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40",onClick:()=>j(s=>Math.max(1,s-1)),disabled:b<=1||u.isFetching,children:n("prev")}),a.jsx("div",{className:"min-w-20 text-center text-sm text-gray-600",children:(Z=u.data)!=null&&Z.totalPages?`${b} / ${u.data.totalPages}`:"0 / 0"}),a.jsx("button",{className:"h-8 rounded-xl border border-gray-200/80 px-3 text-sm text-gray-600 disabled:opacity-40",onClick:()=>j(s=>s+1),disabled:!((G=u.data)!=null&&G.totalPages)||b>=u.data.totalPages||u.isFetching,children:n("next")})]}),a.jsx(Je,{item:p,open:!!p,pending:$.isPending,onOpenChange:s=>!s&&w(null),onSubmit:ge}),a.jsx(_e,{open:!!N,targetName:N,result:ie,pending:L.isPending,onOpenChange:s=>!s&&I(null)}),a.jsx(pe,{})]})}export{ta as McpMarketplacePage};
@@ -1 +1 @@
1
- import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-CNhxtHCf.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-j6A_-1b6.js";import{L as R}from"./label-GACO2RzW.js";import{S as u}from"./skeleton-Dm2xOBSA.js";import{h as _}from"./config-hints-CApS3K_7.js";import{b as le,f as oe,t as F,c as ne}from"./provider-models-BOeNnjk9.js";import{P as ce,a as ie}from"./page-layout-DjXaK3A3.js";function de(c){const r=new Set;for(const p of c){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:c,value:r,onChange:p,options:x,disabled:i=!1,placeholder:T,className:k,inputClassName:v,emptyText:j,createText:b,maxItems:N=Number.POSITIVE_INFINITY,onEnter:M}){const[o,l]=n.useState(!1);n.useEffect(()=>{i&&o&&l(!1)},[i,o]);const h=n.useMemo(()=>de(x),[x]),d=r.trim().toLowerCase(),a=n.useMemo(()=>{const s=h.map((f,w)=>({option:f,index:w}));d.length>0&&s.sort((f,w)=>{const S=f.option.toLowerCase(),P=w.option.toLowerCase(),D=S===d?0:S.startsWith(d)?1:S.includes(d)?2:3,I=P===d?0:P.startsWith(d)?1:P.includes(d)?2:3;return D!==I?D-I:f.index-w.index});const g=s.map(f=>f.option);return Number.isFinite(N)?g.slice(0,Math.max(1,N)):g},[h,d,N]),C=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",k),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:c,value:r,disabled:i,onFocus:()=>{i||l(!0)},onChange:s=>{p(s.target.value),!o&&!i&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),l(!1))},placeholder:T,className:L("pr-10",v)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:i,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",i?"cursor-not-allowed text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"toggle model options",children:e.jsx(W,{className:"h-4 w-4"})}),o&&!i&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!C&&r.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{p(r.trim()),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",r.trim()):r.trim()})]}),a.map(s=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{p(s),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:L("h-4 w-4",s===r.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),a.length===0&&r.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:j??"No models available"})]})})]})}function Ne(){const{data:c,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),i=X(),[T,k]=n.useState(""),[v,j]=n.useState(""),[b,N]=n.useState(""),M=x==null?void 0:x.uiHints,o=_("agents.defaults.model",M),l=_("agents.defaults.workspace",M),h=n.useMemo(()=>le({meta:p,config:c,onlyConfigured:!0}),[c,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),C=(a==null?void 0:a.name)??"",s=n.useMemo(()=>(a==null?void 0:a.aliases)??[],[a]),g=n.useMemo(()=>(a==null?void 0:a.models)??[],[a]);n.useEffect(()=>{var E,B;if(!((E=c==null?void 0:c.agents)!=null&&E.defaults))return;const t=(c.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];k(y),j(y?F(t,V):""),N(c.agents.defaults.workspace||"")},[c,h,d]);const f=n.useMemo(()=>{const t=new Set;for(const O of g){const y=O.trim();y&&t.add(y)}return[...t]},[g]),w=n.useMemo(()=>{if(!a)return"";const t=F(v,s);return t?ne(a.prefix,t):""},[v,a,s]),S=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",P=t=>{k(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),i.mutate({model:w,workspace:b})};return r?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(ce,{children:[e.jsx(ie,{title:m("modelPageTitle"),description:m("modelPageDescription")}),e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(o==null?void 0:o.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(Z,{value:C,onValueChange:P,children:[e.jsx(H,{className:"h-10 w-full rounded-xl",children:e.jsx(ee,{placeholder:m("providersSelectPlaceholder")})}),e.jsx(se,{children:h.map(t=>e.jsx(te,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(me,{id:"model",value:v,onChange:D,options:f,disabled:!C,placeholder:(o==null?void 0:o.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:m("modelPickerNoOptions"),createText:m("modelPickerUseCustom")},C)]}),e.jsx("p",{className:"text-xs text-gray-400",children:S}),e.jsx("p",{className:"text-xs text-gray-500",children:m("modelInputCustomHint")}),e.jsxs("a",{href:`${ae}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),m("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(l==null?void 0:l.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:b,onChange:t=>N(t.target.value),placeholder:(l==null?void 0:l.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:i.isPending,size:"lg",children:i.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
1
+ import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-waGu-koL.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-COJomMe9.js";import{L as R}from"./label-BnSDpjhL.js";import{S as u}from"./skeleton-D4Eyop0R.js";import{h as _}from"./config-hints-CApS3K_7.js";import{b as le,f as oe,t as F,c as ne}from"./provider-models-BOeNnjk9.js";import{P as ce,a as ie}from"./page-layout-B1RIu5-r.js";function de(c){const r=new Set;for(const p of c){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:c,value:r,onChange:p,options:x,disabled:i=!1,placeholder:T,className:k,inputClassName:v,emptyText:j,createText:b,maxItems:N=Number.POSITIVE_INFINITY,onEnter:M}){const[o,l]=n.useState(!1);n.useEffect(()=>{i&&o&&l(!1)},[i,o]);const h=n.useMemo(()=>de(x),[x]),d=r.trim().toLowerCase(),a=n.useMemo(()=>{const s=h.map((f,w)=>({option:f,index:w}));d.length>0&&s.sort((f,w)=>{const S=f.option.toLowerCase(),P=w.option.toLowerCase(),D=S===d?0:S.startsWith(d)?1:S.includes(d)?2:3,I=P===d?0:P.startsWith(d)?1:P.includes(d)?2:3;return D!==I?D-I:f.index-w.index});const g=s.map(f=>f.option);return Number.isFinite(N)?g.slice(0,Math.max(1,N)):g},[h,d,N]),C=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",k),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:c,value:r,disabled:i,onFocus:()=>{i||l(!0)},onChange:s=>{p(s.target.value),!o&&!i&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),l(!1))},placeholder:T,className:L("pr-10",v)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:i,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",i?"cursor-not-allowed text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"toggle model options",children:e.jsx(W,{className:"h-4 w-4"})}),o&&!i&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!C&&r.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{p(r.trim()),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",r.trim()):r.trim()})]}),a.map(s=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{p(s),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:L("h-4 w-4",s===r.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),a.length===0&&r.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:j??"No models available"})]})})]})}function Ne(){const{data:c,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),i=X(),[T,k]=n.useState(""),[v,j]=n.useState(""),[b,N]=n.useState(""),M=x==null?void 0:x.uiHints,o=_("agents.defaults.model",M),l=_("agents.defaults.workspace",M),h=n.useMemo(()=>le({meta:p,config:c,onlyConfigured:!0}),[c,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),C=(a==null?void 0:a.name)??"",s=n.useMemo(()=>(a==null?void 0:a.aliases)??[],[a]),g=n.useMemo(()=>(a==null?void 0:a.models)??[],[a]);n.useEffect(()=>{var E,B;if(!((E=c==null?void 0:c.agents)!=null&&E.defaults))return;const t=(c.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];k(y),j(y?F(t,V):""),N(c.agents.defaults.workspace||"")},[c,h,d]);const f=n.useMemo(()=>{const t=new Set;for(const O of g){const y=O.trim();y&&t.add(y)}return[...t]},[g]),w=n.useMemo(()=>{if(!a)return"";const t=F(v,s);return t?ne(a.prefix,t):""},[v,a,s]),S=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",P=t=>{k(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),i.mutate({model:w,workspace:b})};return r?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(ce,{children:[e.jsx(ie,{title:m("modelPageTitle"),description:m("modelPageDescription")}),e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(o==null?void 0:o.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(Z,{value:C,onValueChange:P,children:[e.jsx(H,{className:"h-10 w-full rounded-xl",children:e.jsx(ee,{placeholder:m("providersSelectPlaceholder")})}),e.jsx(se,{children:h.map(t=>e.jsx(te,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(me,{id:"model",value:v,onChange:D,options:f,disabled:!C,placeholder:(o==null?void 0:o.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:m("modelPickerNoOptions"),createText:m("modelPickerUseCustom")},C)]}),e.jsx("p",{className:"text-xs text-gray-400",children:S}),e.jsx("p",{className:"text-xs text-gray-500",children:m("modelInputCustomHint")}),e.jsxs("a",{href:`${ae}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),m("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(l==null?void 0:l.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:b,onChange:t=>N(t.target.value),placeholder:(l==null?void 0:l.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:i.isPending,size:"lg",children:i.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
@@ -0,0 +1 @@
1
+ import{r as p,j as e,aF as St,aG as Tt,az as et,ax as ke,aH as tt,i as kt,X as Xe,f as Lt,e as R,aI as It,G as Dt,K as Et}from"./vendor-waGu-koL.js";import{c as ue,I as J,B as O,t as s,S as Le,e as Ie,f as De,g as Ee,h as fe,u as st,a as nt,b as rt,J as _t,K as Bt,M as $t,N as Kt,O as zt,P as Ft,Q as Ot,R as Ht}from"./index-COJomMe9.js";import{L as F}from"./label-BnSDpjhL.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Rt,b as Wt,C as qt,a as Ut}from"./config-layout-BHnOoweL.js";import{S as Gt}from"./switch-C3vVTpfU.js";import{a as Qt,b as Vt,c as Xt}from"./popover-ChzbCIfO.js";import{S as Se}from"./status-dot-CrCw5tkJ.js";import{T as Yt}from"./tabs-custom-Ilrgt6n1.js";import{L as Jt}from"./LogoBadge-33Qlv3Hg.js";import{P as Zt,a as es}from"./page-layout-B1RIu5-r.js";function ts({isSet:t,className:n,value:r,onChange:i,placeholder:l,...h}){const[d,c]=p.useState(!1),[g,v]=p.useState(!1),w=typeof r=="string"&&r.length>0,P=t&&!w&&!g;return e.jsxs("div",{className:"relative",children:[P?e.jsx("div",{onClick:()=>v(!0),className:ue("flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12",n),children:"••••••••••••"}):e.jsx(J,{type:d?"text":"password",className:ue("pr-12",n),value:r,onChange:i,onBlur:()=>{w||v(!1)},placeholder:l,autoFocus:g,...h}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!d),children:d?e.jsx(St,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function ss({value:t,onChange:n,className:r}){const i=t?Object.entries(t):[],l=(c,g,v)=>{const w=[...i];w[c]=[g,v],n(Object.fromEntries(w))},h=()=>{n({...t,"":""})},d=c=>{const g=i.filter((v,w)=>w!==c);n(Object.fromEntries(g))};return e.jsxs("div",{className:ue("space-y-2",r),children:[i.map(([c,g],v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(J,{type:"text",value:c,onChange:w=>l(v,w.target.value,g),placeholder:s("headerName"),className:"flex-1"}),e.jsx(J,{type:"text",value:g,onChange:w=>l(v,c,w.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(v),children:e.jsx(et,{className:"h-4 w-4 text-red-500"})})]},v)),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:h,children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function at(t){const{value:n,onChange:r,options:i}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(l=>{const h=l.value===n;return e.jsx("button",{type:"button",onClick:()=>r(l.value),"aria-pressed":h,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${h?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:l.label},l.value)})})}function ns(t){const{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:l,wireApi:h,onWireApiChange:d,shouldUseWireApiPills:c,wireApiSelectOptions:g,extraHeadersLabel:v,extraHeaders:w,onExtraHeadersChange:P}=t;return e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),s("providerAdvancedSettings")]}),e.jsx(kt,{className:`h-4 w-4 transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{className:"mt-4 space-y-5",children:[i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:l}),c?e.jsx(at,{value:h,onChange:C=>d(C),options:g}):e.jsxs(Le,{value:h,onValueChange:C=>d(C),children:[e.jsx(Ie,{className:"rounded-xl",children:e.jsx(De,{})}),e.jsx(Ee,{children:g.map(C=>e.jsx(fe,{value:C.value,children:C.label},C.value))})]})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:v}),e.jsx(ss,{value:w,onChange:P}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerExtraHeadersHelpShort")})]})]}):null]})}function rs(t){const{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:l,selectedAuthMethodHint:h,shouldUseAuthMethodPills:d,resolvedAuthMethodId:c,onAuthMethodChange:g,onStartProviderAuth:v,onImportProviderAuthFromCli:w,startPending:P,importPending:C,authSessionId:b,authStatusMessage:N}=t;return(n==null?void 0:n.kind)!=="device_code"?null:e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:n.displayName||s("providerAuthSectionTitle")}),r?e.jsx("p",{className:"text-xs text-gray-600",children:r}):null,l>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerAuthMethodLabel")}),d?e.jsx(at,{value:c,onChange:g,options:i}):e.jsxs(Le,{value:c,onValueChange:g,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white",children:e.jsx(De,{placeholder:s("providerAuthMethodPlaceholder")})}),e.jsx(Ee,{children:i.map(A=>e.jsx(fe,{value:A.value,children:A.label},A.value))})]}),h?e.jsx("p",{className:"text-xs text-gray-500",children:h}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:v,disabled:P||!!b,children:P?s("providerAuthStarting"):b?s("providerAuthAuthorizing"):s("providerAuthAuthorizeInBrowser")}),n.supportsCliImport?e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:C,children:C?s("providerAuthImporting"):s("providerAuthImportFromCli")}):null,b?e.jsxs("span",{className:"text-xs text-gray-500",children:[s("providerAuthSessionLabel"),": ",b.slice(0,8),"…"]}):null]}),N?e.jsx("p",{className:"text-xs text-gray-600",children:N}):null]})}function as(t){return e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("enabled")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500",children:t.enabled?s("enabled"):s("disabled")}),e.jsx(Gt,{checked:t.enabled,onCheckedChange:t.onChange})]})]})}const is={enabled:!0,displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Te=["off","minimal","low","medium","high","adaptive","xhigh"],os=new Set(Te);function ce(t){if(!t)return null;const n=Object.entries(t).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return n.length===0?null:Object.fromEntries(n)}function Ye(t,n){const r=ce(t),i=ce(n);if(r===null&&i===null)return!0;if(!r||!i)return!1;const l=Object.entries(r).sort(([d],[c])=>d.localeCompare(c)),h=Object.entries(i).sort(([d],[c])=>d.localeCompare(c));return l.length!==h.length?!1:l.every(([d,c],g)=>d===h[g][0]&&c===h[g][1])}function Me(t){if(!t||t.length===0)return[];const n=new Set;for(const r of t){const i=r.trim();i&&n.add(i)}return[...n]}function ls(t,n){const r=t.trim();if(!r||!n.trim())return r;const i=`${n.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function de(t,n){let r=t.trim();if(!r)return"";for(const i of n){const l=i.trim();l&&(r=ls(r,l))}return r.trim()}function ge(t,n){return t.length!==n.length?!1:t.every((r,i)=>r===n[i])}function ds(t,n){const r=[...t];for(const i of n)r.includes(i)||r.push(i);return r}function cs(t,n){return n.length===0?t:n.every(i=>!t.includes(i))?ds(t,n):n}function us(t,n){return ge(t,n)?[]:t}function hs(t,n,r){n!==r&&(t.enabled=n)}function _e(t){if(typeof t!="string")return null;const n=t.trim().toLowerCase();return n&&os.has(n)?n:null}function it(t){if(!Array.isArray(t))return[];const n=[];for(const r of t){const i=_e(r);!i||n.includes(i)||n.push(i)}return n}function ms(t,n){if(!t)return{};const r={};for(const[i,l]of Object.entries(t)){const h=de(i,n);if(!h)continue;const d=it(l==null?void 0:l.supported);if(d.length===0)continue;const c=_e(l==null?void 0:l.default);r[h]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return r}function Pe(t,n){const r=new Set(n.map(l=>l.trim()).filter(Boolean)),i={};for(const[l,h]of Object.entries(t)){if(!r.has(l))continue;const d=it(h.supported);if(d.length===0)continue;const c=_e(h.default);i[l]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return i}function Je(t,n){const r=Object.keys(t).sort(),i=Object.keys(n).sort();if(r.length!==i.length)return!1;for(let l=0;l<r.length;l+=1){const h=r[l];if(h!==i[l])return!1;const d=t[h],c=n[h];if(!d||!c)return!1;const g=[...d.supported].sort(),v=[...c.supported].sort();if(!ge(g,v)||(d.default??null)!==(c.default??null))return!1}return!0}function xs(t){return t==="off"?s("chatThinkingLevelOff"):t==="minimal"?s("chatThinkingLevelMinimal"):t==="low"?s("chatThinkingLevelLow"):t==="medium"?s("chatThinkingLevelMedium"):t==="high"?s("chatThinkingLevelHigh"):t==="adaptive"?s("chatThinkingLevelAdaptive"):s("chatThinkingLevelXhigh")}function ps(t){var g,v,w,P,C;const{providerName:n,methods:r,defaultMethodId:i,language:l}=t;if(r.length===0)return"";const h=new Map;for(const b of r){const N=b.id.trim();N&&h.set(N.toLowerCase(),N)}const d=(...b)=>{for(const N of b){const A=h.get(N.toLowerCase());if(A)return A}},c=i==null?void 0:i.trim();if(n==="minimax-portal"){if(l==="zh")return d("cn","china-mainland")??d(c??"")??((g=r[0])==null?void 0:g.id)??"";if(l==="en")return d("global","intl","international")??d(c??"")??((v=r[0])==null?void 0:v.id)??""}if(c){const b=d(c);if(b)return b}return l==="zh"?d("cn")??((w=r[0])==null?void 0:w.id)??"":l==="en"?d("global")??((P=r[0])==null?void 0:P.id)??"":((C=r[0])==null?void 0:C.id)??""}function Ze(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function fs(t){const{models:n,modelThinking:r,modelDraft:i,showModelInput:l,onModelDraftChange:h,onShowModelInputChange:d,onAddModel:c,onRemoveModel:g,onToggleModelThinkingLevel:v,onSetModelThinkingDefault:w,thinkingLevels:P,formatThinkingLevelLabel:C}=t;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("providerModelsTitle")}),l?null:e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80",children:[e.jsx(ke,{className:"h-3 w-3"}),s("providerAddModel")]})]}),l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{value:i,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c()),b.key==="Escape"&&(d(!1),h(""))},placeholder:s("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(O,{type:"button",size:"sm",onClick:c,disabled:i.trim().length===0,children:s("add")}),e.jsx(O,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(!1),h("")},children:e.jsx(Xe,{className:"h-4 w-4"})})]}):null,n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:s("providerModelsEmptyShort")}),l?null:e.jsx("button",{type:"button",onClick:()=>d(!0),className:"mt-2 text-sm font-medium text-primary hover:text-primary/80",children:s("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(b=>{const N=r[b],A=(N==null?void 0:N.supported)??[],K=(N==null?void 0:N.default)??null;return e.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:[e.jsx("span",{className:"max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]",children:b}),e.jsxs(Qt,{children:[e.jsx(Vt,{asChild:!0,children:e.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":s("providerModelThinkingTitle"),title:s("providerModelThinkingTitle"),children:e.jsx(tt,{className:"h-3 w-3"})})}),e.jsxs(Xt,{className:"w-80 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:s("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{const y=A.includes(S);return e.jsx("button",{type:"button",onClick:()=>v(b,S),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${y?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:C(S)},S)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerModelThinkingDefault")}),e.jsxs(Le,{value:K??"__none__",onValueChange:S=>w(b,S==="__none__"?null:S),disabled:A.length===0,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(De,{})}),e.jsxs(Ee,{children:[e.jsx(fe,{value:"__none__",children:s("providerModelThinkingDefaultNone")}),A.map(S=>e.jsx(fe,{value:S,children:C(S)},S))]})]}),A.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>g(b),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":s("remove"),children:e.jsx(Xe,{className:"h-3 w-3"})})]},b)})})]})}function gs(t){return t.enabled?e.jsx(Se,{status:t.apiKeySet?"ready":"setup",label:t.apiKeySet?s("statusReady"):s("statusSetup"),className:t.className}):e.jsx(Se,{status:"inactive",label:s("disabled"),className:t.className})}function ys({providerName:t,onProviderDeleted:n}){var Re,We,qe,Ue,Ge,Qe,Ve;const r=Lt(),{data:i}=st(),{data:l}=nt(),{data:h}=rt(),d=_t(),c=Bt(),g=$t(),v=Kt(),w=zt(),P=Ft(),[C,b]=p.useState(""),[N,A]=p.useState(!0),[K,S]=p.useState(""),[y,j]=p.useState(null),[T,k]=p.useState("auto"),[M,G]=p.useState([]),[D,B]=p.useState({}),[ye,Q]=p.useState(""),[W,be]=p.useState(""),[ot,lt]=p.useState(!1),[dt,ct]=p.useState(!1),[ut,q]=p.useState(null),[ht,$]=p.useState(""),[Be,je]=p.useState(""),he=p.useRef(null),o=l==null?void 0:l.providers.find(a=>a.name===t),L=(t?i==null?void 0:i.providers[t]:null)??is,me=h==null?void 0:h.uiHints,Z=!!(o!=null&&o.isCustom),ee=t?le(`providers.${t}.apiKey`,me):void 0,H=t?le(`providers.${t}.apiBase`,me):void 0,ve=t?le(`providers.${t}.extraHeaders`,me):void 0,we=t?le(`providers.${t}.wireApi`,me):void 0,$e=(o==null?void 0:o.displayName)||t||"",te=(L.displayName||"").trim()||$e,se=L.enabled!==!1,mt=W.trim()||te||t||s("providersSelectPlaceholder"),Ke=(o==null?void 0:o.modelPrefix)||t||"",U=p.useMemo(()=>Me([Ke,t||""]),[Ke,t]),Ce=(o==null?void 0:o.defaultApiBase)||"",re=L.apiBase||Ce,Ne=ce(L.extraHeaders||null),ae=L.wireApi||(o==null?void 0:o.defaultWireApi)||"auto",Ae=p.useMemo(()=>Me(((o==null?void 0:o.defaultModels)??[]).map(a=>de(a,U))),[o==null?void 0:o.defaultModels,U]),ze=p.useMemo(()=>Me((L.models??[]).map(a=>de(a,U))),[L.models,U]),V=p.useMemo(()=>cs(Ae,ze),[Ae,ze]),ie=p.useMemo(()=>Pe(ms(L.modelThinking,U),V),[V,U,L.modelThinking]),X=Ot(),xt=((Re=o==null?void 0:o.apiBaseHelp)==null?void 0:Re[X])||((We=o==null?void 0:o.apiBaseHelp)==null?void 0:We.en)||(H==null?void 0:H.help)||s("providerApiBaseHelp"),f=o==null?void 0:o.auth,E=p.useMemo(()=>(f==null?void 0:f.methods)??[],[f==null?void 0:f.methods]),pt=p.useMemo(()=>E.map(a=>{var u,m;return{value:a.id,label:((u=a.label)==null?void 0:u[X])||((m=a.label)==null?void 0:m.en)||a.id}}),[E,X]),xe=p.useMemo(()=>ps({providerName:t,methods:E,defaultMethodId:f==null?void 0:f.defaultMethodId,language:X}),[t,f==null?void 0:f.defaultMethodId,E,X]),oe=p.useMemo(()=>{var u;if(!E.length)return"";const a=Be.trim();return a&&E.some(m=>m.id===a)?a:xe||((u=E[0])==null?void 0:u.id)||""},[Be,xe,E]),ne=p.useMemo(()=>E.find(a=>a.id===oe),[E,oe]),ft=((qe=ne==null?void 0:ne.hint)==null?void 0:qe[X])||((Ue=ne==null?void 0:ne.hint)==null?void 0:Ue.en)||"",gt=Ze({required:(f==null?void 0:f.kind)==="device_code",hasDefault:!!((Ge=f==null?void 0:f.defaultMethodId)!=null&&Ge.trim()),optionCount:E.length}),yt=((Qe=f==null?void 0:f.note)==null?void 0:Qe[X])||((Ve=f==null?void 0:f.note)==null?void 0:Ve.en)||(f==null?void 0:f.displayName)||"",Fe=((o==null?void 0:o.wireApiOptions)||["auto","chat","responses"]).map(a=>({value:a,label:a==="chat"?s("wireApiChat"):a==="responses"?s("wireApiResponses"):s("wireApiAuto")})),bt=Ze({required:!!(o!=null&&o.supportsWireApi),hasDefault:typeof(o==null?void 0:o.defaultWireApi)=="string"&&o.defaultWireApi.length>0,optionCount:Fe.length}),_=p.useCallback(()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},[]),Oe=p.useCallback((a,u)=>{_(),he.current=window.setTimeout(()=>{(async()=>{if(t)try{const m=await w.mutateAsync({provider:t,data:{sessionId:a}});if(m.status==="pending"){$(s("providerAuthWaitingBrowser")),Oe(a,m.nextPollMs??u);return}if(m.status==="authorized"){q(null),_(),$(s("providerAuthCompleted")),R.success(s("providerAuthCompleted")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]});return}q(null),_(),$(m.message||`Authorization ${m.status}.`),R.error(m.message||`Authorization ${m.status}.`)}catch(m){q(null),_();const x=m instanceof Error?m.message:String(m);$(x),R.error(`Authorization failed: ${x}`)}})()},Math.max(1e3,u))},[_,w,t,r]);p.useEffect(()=>{if(!t){b(""),A(!0),S(""),j(null),k("auto"),G([]),B({}),Q(""),be(""),q(null),$(""),je(""),_();return}b(""),A(se),S(re),j(L.extraHeaders||null),k(ae),G(V),B(ie),Q(""),be(te),q(null),$(""),je(xe),_()},[t,re,se,L.extraHeaders,ae,V,ie,te,xe,_]),p.useEffect(()=>()=>_(),[_]),p.useEffect(()=>{B(a=>Pe(a,M))},[M]);const He=p.useMemo(()=>{if(!t)return!1;const a=C.trim().length>0,u=K.trim()!==re.trim(),m=!Ye(y,Ne),x=o!=null&&o.supportsWireApi?T!==ae:!1,I=!ge(M,V),z=!Je(D,ie),pe=Z?W.trim()!==te:!1;return a||N!==se||u||m||x||I||z||pe},[t,Z,W,te,C,N,se,K,re,y,Ne,o==null?void 0:o.supportsWireApi,T,ae,M,V,D,ie]),jt=()=>{const a=de(ye,U);if(a){if(M.includes(a)){Q("");return}G(u=>[...u,a]),Q("")}},vt=(a,u)=>{B(m=>{const x=m[a],I=(x==null?void 0:x.supported)??[],z=I.includes(u)?I.filter(Y=>Y!==u):Te.filter(Y=>Y===u||I.includes(Y));if(z.length===0){const Y={...m};return delete Y[a],Y}const pe=x!=null&&x.default&&z.includes(x.default)?x.default:void 0;return{...m,[a]:pe?{supported:z,default:pe}:{supported:z}}})},wt=(a,u)=>{B(m=>{const x=m[a];return!x||x.supported.length===0||u&&!x.supported.includes(u)?m:{...m,[a]:u?{supported:x.supported,default:u}:{supported:x.supported}}})},Ct=a=>{if(a.preventDefault(),!t)return;const u={},m=C.trim(),x=K.trim(),I=ce(y),z=W.trim();Z&&z!==te&&(u.displayName=z.length>0?z:null),m.length>0&&(u.apiKey=m),hs(u,N,se),x!==re.trim()&&(u.apiBase=x.length>0&&x!==Ce?x:null),Ye(I,Ne)||(u.extraHeaders=I),o!=null&&o.supportsWireApi&&T!==ae&&(u.wireApi=T),ge(M,V)||(u.models=us(M,Ae)),Je(D,ie)||(u.modelThinking=Pe(D,M)),d.mutate({provider:t,data:u})},Nt=async()=>{if(!t)return;const a=M.find(x=>x.trim().length>0)??"",u=de(a,U),m={apiBase:K.trim(),extraHeaders:ce(y),model:u||null};C.trim().length>0&&(m.apiKey=C.trim()),o!=null&&o.supportsWireApi&&(m.wireApi=T);try{const x=await g.mutateAsync({provider:t,data:m});if(x.success){R.success(`${s("providerTestConnectionSuccess")} (${x.latencyMs}ms)`);return}const I=[`provider=${x.provider}`,`latency=${x.latencyMs}ms`];x.model&&I.push(`model=${x.model}`),R.error(`${s("providerTestConnectionFailed")}: ${x.message} | ${I.join(" | ")}`)}catch(x){const I=x instanceof Error?x.message:String(x);R.error(`${s("providerTestConnectionFailed")}: ${I}`)}},At=async()=>{if(!(!t||!Z||!window.confirm(s("providerDeleteConfirm"))))try{await c.mutateAsync({provider:t}),n==null||n(t)}catch{}},Mt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{$("");const a=await v.mutateAsync({provider:t,data:oe?{methodId:oe}:{}});if(!a.sessionId||!a.verificationUri)throw new Error(s("providerAuthStartFailed"));q(a.sessionId),$(`${s("providerAuthOpenPrompt")}${a.userCode}${s("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Oe(a.sessionId,a.intervalMs)}catch(a){const u=a instanceof Error?a.message:String(a);q(null),_(),$(u),R.error(`${s("providerAuthStartFailed")}: ${u}`)}},Pt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{_(),q(null);const a=await P.mutateAsync({provider:t}),u=a.expiresAt?` (expires: ${a.expiresAt})`:"";$(`${s("providerAuthImportStatusPrefix")}${u}`),R.success(s("providerAuthImportSuccess")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]})}catch(a){const u=a instanceof Error?a.message:String(a);$(u),R.error(`${s("providerAuthImportFailed")}: ${u}`)}};return!t||!o?e.jsx("div",{className:Rt,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:s("providersSelectDescription")})]})}):e.jsxs("div",{className:Wt,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:mt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:At,disabled:c.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:s("providerDelete"),children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx(gs,{enabled:se,apiKeySet:L.apiKeySet})]})]})}),e.jsxs("form",{onSubmit:Ct,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[e.jsx(as,{enabled:N,onChange:A}),Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:s("providerDisplayName")}),e.jsx(J,{id:"providerDisplayName",type:"text",value:W,onChange:a=>be(a.target.value),placeholder:$e||s("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??s("apiKey")}),e.jsx(ts,{id:"apiKey",value:C,isSet:L.apiKeySet,onChange:a=>b(a.target.value),placeholder:(ee==null?void 0:ee.placeholder)??s("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("leaveBlankToKeepUnchanged")})]}),e.jsx(rs,{providerAuth:f,providerAuthNote:yt,providerAuthMethodOptions:pt,providerAuthMethodsCount:E.length,selectedAuthMethodHint:ft,shouldUseAuthMethodPills:gt,resolvedAuthMethodId:oe,onAuthMethodChange:je,onStartProviderAuth:Mt,onImportProviderAuthFromCli:Pt,startPending:v.isPending,importPending:P.isPending,authSessionId:ut,authStatusMessage:ht}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(H==null?void 0:H.label)??s("apiBase")}),e.jsx(J,{id:"apiBase",type:"text",value:K,onChange:a=>S(a.target.value),placeholder:Ce||(H==null?void 0:H.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:xt})]}),e.jsx(fs,{models:M,modelThinking:D,modelDraft:ye,showModelInput:dt,onModelDraftChange:Q,onShowModelInputChange:ct,onAddModel:jt,onRemoveModel:a=>{G(u=>u.filter(m=>m!==a)),B(u=>{const m={...u};return delete m[a],m})},onToggleModelThinkingLevel:vt,onSetModelThinkingDefault:wt,thinkingLevels:Te,formatThinkingLevelLabel:xs}),e.jsx(ns,{showAdvanced:ot,onShowAdvancedChange:lt,supportsWireApi:!!o.supportsWireApi,wireApiLabel:(we==null?void 0:we.label)??s("wireApi"),wireApi:T,onWireApiChange:k,shouldUseWireApiPills:bt,wireApiSelectOptions:Fe,extraHeadersLabel:(ve==null?void 0:ve.label)??s("extraHeaders"),extraHeaders:y,onExtraHeadersChange:j})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:Nt,disabled:g.isPending,children:[e.jsx(It,{className:"mr-1.5 h-4 w-4"}),g.isPending?s("providerTestingConnection"):s("providerTestConnection")]}),e.jsx(O,{type:"submit",disabled:d.isPending||!He,children:d.isPending?s("saving"):He?s("save"):s("unchanged")})]})]})]})}function bs(t){if(!t)return null;try{const n=new URL(t),r=n.pathname&&n.pathname!=="/"?n.pathname:"";return`${n.host}${r}`}catch{return t.replace(/^https?:\/\//,"")}}function Es(){const{data:t}=st(),{data:n}=nt(),{data:r}=rt(),i=Ht(),[l,h]=p.useState("installed"),[d,c]=p.useState(),[g,v]=p.useState(""),w=r==null?void 0:r.uiHints,P=(n==null?void 0:n.providers)??[],C=(t==null?void 0:t.providers)??{},b=P.filter(y=>{const j=C[y.name];return(j==null?void 0:j.enabled)!==!1&&(j==null?void 0:j.apiKeySet)}).length,N=[{id:"installed",label:s("providersTabConfigured"),count:b},{id:"all",label:s("providersTabAll"),count:P.length}],A=p.useMemo(()=>{const y=(n==null?void 0:n.providers)??[],j=(t==null?void 0:t.providers)??{},T=g.trim().toLowerCase();return y.filter(k=>{if(l==="installed"){const M=j[k.name];return!!((M==null?void 0:M.enabled)!==!1&&(M!=null&&M.apiKeySet))}return!0}).filter(k=>{var D,B;return T?(((B=(D=j[k.name])==null?void 0:D.displayName)==null?void 0:B.trim())||k.displayName||k.name).toLowerCase().includes(T)||k.name.toLowerCase().includes(T):!0})},[n,t,l,g]);p.useEffect(()=>{if(A.length===0){c(void 0);return}A.some(j=>j.name===d)||c(A[0].name)},[A,d]);const K=d,S=async()=>{try{const y=await i.mutateAsync({data:{}});h("all"),v(""),c(y.name)}catch{}};return!t||!n?e.jsx("div",{className:"p-8",children:s("providersLoading")}):e.jsxs(Zt,{children:[e.jsx(es,{title:s("providersPageTitle"),description:s("providersPageDescription")}),e.jsxs("div",{className:qt,children:[e.jsxs("section",{className:Ut,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Yt,{tabs:N,activeTab:l,onChange:h,className:"mb-0"}),e.jsxs(O,{type:"button",variant:"outline",className:"w-full justify-center",onClick:S,disabled:i.isPending,children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),i.isPending?s("saving"):s("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(J,{value:g,onChange:y=>v(y.target.value),placeholder:s("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[A.map(y=>{var W;const j=t.providers[y.name],T=(j==null?void 0:j.enabled)!==!1,k=!!(T&&(j!=null&&j.apiKeySet)),M=K===y.name,G=((W=j==null?void 0:j.displayName)==null?void 0:W.trim())||y.displayName||y.name,D=le(`providers.${y.name}`,w),B=(j==null?void 0:j.apiBase)||y.defaultApiBase||"",Q=bs(B)||(D==null?void 0:D.help)||s("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(y.name),className:ue("w-full rounded-xl border p-2.5 text-left transition-all",M?"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:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Jt,{name:y.name,src:y.logo?`/logos/${y.logo}`:null,className:ue("h-10 w-10 rounded-lg border",k?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:y.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:G}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:Q})]})]}),e.jsx(Se,{status:T?k?"ready":"setup":"inactive",label:T?k?s("statusReady"):s("statusSetup"):s("disabled"),className:"min-w-[56px] justify-center"})]})},y.name)}),A.length===0&&e.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:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Et,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:s("providersNoMatch")})]})]})]}),e.jsx(ys,{providerName:K,onProviderDeleted:y=>{y===d&&c(void 0)}})]})]})}export{Es as ProvidersList};
@@ -0,0 +1 @@
1
+ import{r as y,j as r,b8 as C,S as H,b9 as L}from"./vendor-waGu-koL.js";import{P as k,a as z}from"./page-layout-B1RIu5-r.js";import{t,a9 as T,aa as E,ab as q,ac as P,C as R,Y as j,Z as N,_ as w,y as A,i as I,B as b}from"./index-COJomMe9.js";import{S as d}from"./status-dot-CrCw5tkJ.js";const M=[/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 B(i){var n,e;return((e=(n=i==null?void 0:i.runtime)==null?void 0:n.lastError)==null?void 0:e.trim())||""}function O(i){if(!(i!=null&&i.settings.enabled))return!1;const n=B(i);return M.some(e=>e.test(n))}function V(i){var e,a;return O(i)?{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}:i!=null&&i.account.loggedIn?i.settings.enabled?i.service.running?((e=i.runtime)==null?void 0:e.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}:((a=i.runtime)==null?void 0:a.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:!!(i.settings.enabled&&i.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}}function s(i){const{label:n,muted:e,value:a}=i,o=a==null||a===""?"-":String(a);return r.jsxs("div",{className:"flex items-start justify-between gap-4 py-2 text-sm",children:[r.jsx("span",{className:"text-gray-500",children:n}),r.jsx("span",{className:e?"text-right text-gray-500":"text-right text-gray-900",children:o})]})}function G(){var h,p,x,S,v;const i=T(),n=E(),e=n.data,a=q(c=>c.actionLabel),o=y.useMemo(()=>V(e),[e]),m=!!a,g=((p=(h=e==null?void 0:e.runtime)==null?void 0:h.deviceName)==null?void 0:p.trim())||((x=e==null?void 0:e.settings.deviceName)==null?void 0:x.trim())||t("remoteDeviceNameAuto"),D=!!(e!=null&&e.account.loggedIn&&P(e)),{hero:l,issueHint:u}=o;return y.useEffect(()=>{i.remoteAccessManager.syncStatus(e)},[i,e]),n.isLoading&&!e?r.jsx("div",{className:"p-8 text-gray-400",children:t("remoteLoading")}):r.jsxs(k,{className:"space-y-6",children:[r.jsx(z,{title:t("remotePageTitle"),description:t("remotePageDescription")}),r.jsxs("div",{className:"grid gap-6 xl:grid-cols-[1.2fr_0.8fr]",children:[r.jsxs(R,{children:[r.jsxs(j,{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(N,{children:l.title}),r.jsx(d,{status:l.badgeStatus,label:l.badgeLabel})]}),r.jsx(w,{children:l.description})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteSignedInAccount"),value:e==null?void 0:e.account.email}),r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(S=e==null?void 0:e.runtime)!=null&&S.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsxs("div",{className:"flex flex-wrap gap-3",children:[o.primaryAction?r.jsxs(b,{onClick:()=>{var c,f;if(((c=o.primaryAction)==null?void 0:c.kind)==="reauthorize"){i.remoteAccessManager.reauthorizeRemoteAccess(e);return}if(((f=o.primaryAction)==null?void 0:f.kind)==="repair"){i.remoteAccessManager.repairRemoteAccess(e);return}i.remoteAccessManager.enableRemoteAccess(e)},disabled:m,children:[o.primaryAction.showRefreshIcon?r.jsx(C,{className:"mr-2 h-4 w-4"}):null,a||o.primaryAction.label]}):null,r.jsxs(b,{variant:"outline",onClick:()=>void i.accountManager.openNextClawWeb(),disabled:m||!D,children:[r.jsx(H,{className:"mr-2 h-4 w-4"}),t("remoteOpenDeviceList")]}),e!=null&&e.settings.enabled?r.jsx(b,{variant:"outline",onClick:()=>void i.remoteAccessManager.disableRemoteAccess(e),disabled:m,children:t("remoteDisable")}):null]}),o.shouldShowIssueHint&&u?r.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3",children:[r.jsx("p",{className:"text-sm font-medium text-amber-900",children:u.title}),r.jsx("p",{className:"mt-1 text-sm leading-6 text-amber-800",children:u.body})]}):null,r.jsx("p",{className:"text-xs text-gray-500",children:t("remoteOpenWebHint")})]})]}),r.jsxs(R,{children:[r.jsxs(j,{children:[r.jsxs(N,{className:"flex items-center gap-2",children:[r.jsx(L,{className:"h-4 w-4 text-primary"}),t("remoteDeviceSectionTitle")]}),r.jsx(w,{children:t("remoteDeviceSectionDescription")})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(d,{status:e!=null&&e.account.loggedIn?"ready":"inactive",label:e!=null&&e.account.loggedIn?t("remoteAccountConnected"):t("remoteAccountNotConnected")}),r.jsx(d,{status:e!=null&&e.settings.enabled?"active":"inactive",label:e!=null&&e.settings.enabled?t("remoteEnabled"):t("remoteStateDisabled")}),r.jsx(d,{status:e!=null&&e.service.running?"active":"inactive",label:e!=null&&e.service.running?t("remoteServiceRunning"):t("remoteServiceStopped")})]}),r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(v=e==null?void 0:e.runtime)!=null&&v.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:e!=null&&e.account.loggedIn?t("remoteOpenWebHint"):t("remoteStatusNeedsSignInDescription")})]})]})]})]})}export{G as RemoteAccessPage};
@@ -0,0 +1 @@
1
+ import{r as p,j as e,az as ee,ax as ae,b5 as de,e as se}from"./vendor-waGu-koL.js";import{u as me,b as he,X as ue,t,C as R,Y as $,Z as z,_ as D,y as L,I as i,S as te,e as re,f as ne,g as le,h as S,B as w}from"./index-COJomMe9.js";import{S as pe}from"./switch-C3vVTpfU.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-B1RIu5-r.js";const je=[{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 ve(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function fe(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function Ce(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[X,Y]=p.useState(2e5),[Z,G]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),Y(d.agents.defaults.contextTokens??2e5),G(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),v=x("session.agentToAgent.maxPingPongTurns",u),f=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var J,Q,W,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,P=((H=(W=s.match.peer)==null?void 0:W.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,X),engine:Z.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(xe,{className:"space-y-6",children:[e.jsx(ge,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:X,onChange:a=>Y(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:Z,onChange:a=>G(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(S,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(pe,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(S,{value:"__none__",children:t("peerKindOptional")}),e.jsx(S,{value:"direct",children:"direct"}),e.jsx(S,{value:"group",children:"group"}),e.jsx(S,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{Ce as RuntimeConfig};
@@ -1 +1 @@
1
- import{r as l,j as e,G as X,ai as Z,K as $}from"./vendor-CNhxtHCf.js";import{P as ee,a as se}from"./page-layout-DjXaK3A3.js";import{u as ae,a as re,V as le,t as a,c as k,B as j,S as b,e as y,f as g,g as N,h as m,I as h}from"./index-j6A_-1b6.js";import{L as c}from"./label-GACO2RzW.js";import{C as te,a as ce,b as ne}from"./config-layout-BHnOoweL.js";const ie=[{value:"noLimit",label:"searchFreshnessNoLimit"},{value:"oneDay",label:"searchFreshnessOneDay"},{value:"oneWeek",label:"searchFreshnessOneWeek"},{value:"oneMonth",label:"searchFreshnessOneMonth"},{value:"oneYear",label:"searchFreshnessOneYear"}];function ue(){var O;const{data:u}=ae(),{data:n}=re(),x=le(),i=(n==null?void 0:n.search)??[],r=u==null?void 0:u.search,[t,f]=l.useState("bocha"),[S,P]=l.useState("bocha"),[d,C]=l.useState(["bocha"]),[w,B]=l.useState("10"),[A,V]=l.useState(""),[D,K]=l.useState("https://api.bocha.cn/v1/web-search"),[L,U]=l.useState(!0),[E,F]=l.useState("noLimit"),[R,T]=l.useState(""),[I,_]=l.useState("https://api.search.brave.com/res/v1/web/search");l.useEffect(()=>{r&&(f(r.provider),P(r.provider),C(r.enabledProviders),B(String(r.defaults.maxResults)),K(r.providers.bocha.baseUrl),U(!!r.providers.bocha.summary),F(r.providers.bocha.freshness??"noLimit"),_(r.providers.brave.baseUrl))},[r]);const v=l.useMemo(()=>i.find(s=>s.name===t),[i,t]),G=r==null?void 0:r.providers[t],p=d.includes(t),H=(r==null?void 0:r.providers.bocha.docsUrl)??((O=n==null?void 0:n.search.find(s=>s.name==="bocha"))==null?void 0:O.docsUrl)??"https://open.bocha.cn",W=p?a("searchProviderDeactivate"):a("searchProviderActivate"),M=(s=d,o=S)=>({provider:o,enabledProviders:s,defaults:{maxResults:Number(w)||10},providers:{bocha:{apiKey:A||void 0,baseUrl:D,summary:L,freshness:E},brave:{apiKey:R||void 0,baseUrl:I}}}),Y=()=>{const s=p?d.filter(o=>o!==t):[...d,t];C(s),x.mutate({data:M(s)})},q=s=>{P(s)},z=s=>{s.preventDefault(),x.mutate({data:M()})};return!r||i.length===0?e.jsx("div",{className:"p-8",children:a("loading")}):e.jsxs(ee,{children:[e.jsx(se,{title:a("searchPageTitle"),description:a("searchPageDescription")}),e.jsxs("div",{className:te,children:[e.jsxs("section",{className:ce,children:[e.jsx("div",{className:"border-b border-gray-100 px-4 py-4",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-gray-500",children:a("searchChannels")})}),e.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:i.map(s=>{const o=r.providers[s.name],J=d.includes(s.name),Q=t===s.name;return e.jsx("button",{type:"button",onClick:()=>f(s.name),className:k("w-full rounded-xl border p-3 text-left transition-all",Q?"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:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:s.displayName}),e.jsx("p",{className:"line-clamp-2 text-[11px] text-gray-500",children:s.name==="bocha"?a("searchProviderBochaDescription"):a("searchProviderBraveDescription")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:o.apiKeySet?a("searchStatusConfigured"):a("searchStatusNeedsSetup")}),J?e.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",children:a("searchProviderActivated")}):null]})]})},s.name)})})]}),e.jsx("form",{onSubmit:z,className:k(ne,"p-6"),children:!v||!G?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-500",children:a("searchNoProviderSelected")}):e.jsxs("div",{className:"space-y-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:v.displayName}),e.jsx("p",{className:"text-sm text-gray-500",children:v.description})]})]}),e.jsx(j,{type:"button",variant:p?"secondary":"outline",className:"rounded-xl",onClick:Y,children:W})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchActiveProvider")}),e.jsxs(b,{value:S,onValueChange:q,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:i.map(s=>e.jsx(m,{value:s.name,children:s.displayName},s.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchDefaultMaxResults")}),e.jsx(h,{value:w,onChange:s=>B(s.target.value),inputMode:"numeric",className:"rounded-xl"})]})]}),t==="bocha"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:A,onChange:s=>V(s.target.value),placeholder:r.providers.bocha.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:D,onChange:s=>K(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderSummary")}),e.jsxs(b,{value:L?"true":"false",onValueChange:s=>U(s==="true"),children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsxs(N,{children:[e.jsx(m,{value:"true",children:a("enabled")}),e.jsx(m,{value:"false",children:a("disabled")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderFreshness")}),e.jsxs(b,{value:E,onValueChange:F,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:ie.map(s=>e.jsx(m,{value:s.value,children:a(s.label)},s.value))})]})]})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("a",{href:H,target:"_blank",rel:"noreferrer",children:e.jsxs(j,{type:"button",variant:"outline",className:"rounded-xl",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),a("searchProviderOpenDocs")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:R,onChange:s=>T(s.target.value),placeholder:r.providers.brave.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:I,onChange:s=>_(s.target.value),className:"rounded-xl"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(j,{type:"submit",disabled:x.isPending,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),x.isPending?a("saving"):a("saveChanges")]})})]})})]})]})}export{ue as SearchConfig};
1
+ import{r as l,j as e,G as X,ai as Z,K as $}from"./vendor-waGu-koL.js";import{P as ee,a as se}from"./page-layout-B1RIu5-r.js";import{u as ae,a as re,H as le,t as a,c as k,B as j,S as b,e as y,f as g,g as N,h as m,I as h}from"./index-COJomMe9.js";import{L as c}from"./label-BnSDpjhL.js";import{C as te,a as ce,b as ne}from"./config-layout-BHnOoweL.js";const ie=[{value:"noLimit",label:"searchFreshnessNoLimit"},{value:"oneDay",label:"searchFreshnessOneDay"},{value:"oneWeek",label:"searchFreshnessOneWeek"},{value:"oneMonth",label:"searchFreshnessOneMonth"},{value:"oneYear",label:"searchFreshnessOneYear"}];function ue(){var O;const{data:u}=ae(),{data:n}=re(),x=le(),i=(n==null?void 0:n.search)??[],r=u==null?void 0:u.search,[t,f]=l.useState("bocha"),[S,P]=l.useState("bocha"),[d,C]=l.useState(["bocha"]),[w,B]=l.useState("10"),[A,T]=l.useState(""),[D,K]=l.useState("https://api.bocha.cn/v1/web-search"),[L,U]=l.useState(!0),[E,F]=l.useState("noLimit"),[R,V]=l.useState(""),[I,_]=l.useState("https://api.search.brave.com/res/v1/web/search");l.useEffect(()=>{r&&(f(r.provider),P(r.provider),C(r.enabledProviders),B(String(r.defaults.maxResults)),K(r.providers.bocha.baseUrl),U(!!r.providers.bocha.summary),F(r.providers.bocha.freshness??"noLimit"),_(r.providers.brave.baseUrl))},[r]);const v=l.useMemo(()=>i.find(s=>s.name===t),[i,t]),G=r==null?void 0:r.providers[t],p=d.includes(t),H=(r==null?void 0:r.providers.bocha.docsUrl)??((O=n==null?void 0:n.search.find(s=>s.name==="bocha"))==null?void 0:O.docsUrl)??"https://open.bocha.cn",W=p?a("searchProviderDeactivate"):a("searchProviderActivate"),M=(s=d,o=S)=>({provider:o,enabledProviders:s,defaults:{maxResults:Number(w)||10},providers:{bocha:{apiKey:A||void 0,baseUrl:D,summary:L,freshness:E},brave:{apiKey:R||void 0,baseUrl:I}}}),Y=()=>{const s=p?d.filter(o=>o!==t):[...d,t];C(s),x.mutate({data:M(s)})},q=s=>{P(s)},z=s=>{s.preventDefault(),x.mutate({data:M()})};return!r||i.length===0?e.jsx("div",{className:"p-8",children:a("loading")}):e.jsxs(ee,{children:[e.jsx(se,{title:a("searchPageTitle"),description:a("searchPageDescription")}),e.jsxs("div",{className:te,children:[e.jsxs("section",{className:ce,children:[e.jsx("div",{className:"border-b border-gray-100 px-4 py-4",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-gray-500",children:a("searchChannels")})}),e.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:i.map(s=>{const o=r.providers[s.name],J=d.includes(s.name),Q=t===s.name;return e.jsx("button",{type:"button",onClick:()=>f(s.name),className:k("w-full rounded-xl border p-3 text-left transition-all",Q?"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:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:s.displayName}),e.jsx("p",{className:"line-clamp-2 text-[11px] text-gray-500",children:s.name==="bocha"?a("searchProviderBochaDescription"):a("searchProviderBraveDescription")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:o.apiKeySet?a("searchStatusConfigured"):a("searchStatusNeedsSetup")}),J?e.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",children:a("searchProviderActivated")}):null]})]})},s.name)})})]}),e.jsx("form",{onSubmit:z,className:k(ne,"p-6"),children:!v||!G?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-500",children:a("searchNoProviderSelected")}):e.jsxs("div",{className:"space-y-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:v.displayName}),e.jsx("p",{className:"text-sm text-gray-500",children:v.description})]})]}),e.jsx(j,{type:"button",variant:p?"secondary":"outline",className:"rounded-xl",onClick:Y,children:W})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchActiveProvider")}),e.jsxs(b,{value:S,onValueChange:q,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:i.map(s=>e.jsx(m,{value:s.name,children:s.displayName},s.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchDefaultMaxResults")}),e.jsx(h,{value:w,onChange:s=>B(s.target.value),inputMode:"numeric",className:"rounded-xl"})]})]}),t==="bocha"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:A,onChange:s=>T(s.target.value),placeholder:r.providers.bocha.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:D,onChange:s=>K(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderSummary")}),e.jsxs(b,{value:L?"true":"false",onValueChange:s=>U(s==="true"),children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsxs(N,{children:[e.jsx(m,{value:"true",children:a("enabled")}),e.jsx(m,{value:"false",children:a("disabled")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderFreshness")}),e.jsxs(b,{value:E,onValueChange:F,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:ie.map(s=>e.jsx(m,{value:s.value,children:a(s.label)},s.value))})]})]})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("a",{href:H,target:"_blank",rel:"noreferrer",children:e.jsxs(j,{type:"button",variant:"outline",className:"rounded-xl",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),a("searchProviderOpenDocs")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:R,onChange:s=>V(s.target.value),placeholder:r.providers.brave.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:I,onChange:s=>_(s.target.value),className:"rounded-xl"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(j,{type:"submit",disabled:x.isPending,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),x.isPending?a("saving"):a("saveChanges")]})})]})})]})]})}export{ue as SearchConfig};
@@ -1,3 +1,3 @@
1
- import{r as u,j as e,aA as H,au as L,b6 as z,e as G}from"./vendor-CNhxtHCf.js";import{u as K,ah as Q,t as a,C as R,a6 as T,a7 as M,a8 as O,J as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-j6A_-1b6.js";import{L as k}from"./label-GACO2RzW.js";import{S as W}from"./switch-DCHAJSrA.js";import{P as X,a as Y}from"./page-layout-DjXaK3A3.js";const U=["env","file","exec"];function N(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...N(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...N(n),source:"file",path:l.path}:{...N(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
1
+ import{r as u,j as e,az as H,ax as L,b5 as Y,e as Z}from"./vendor-waGu-koL.js";import{u as G,a8 as J,t as a,C as R,Y as T,Z as M,_ as O,y as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-COJomMe9.js";import{L as k}from"./label-BnSDpjhL.js";import{S as K}from"./switch-C3vVTpfU.js";import{P as Q,a as W}from"./page-layout-B1RIu5-r.js";const U=["env","file","exec"];function y(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function X(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...y(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...y(n),source:"file",path:l.path}:{...y(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
2
2
  `),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
3
- `).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function ie(){const{data:n,isLoading:l}=K(),P=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},b=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},J=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}P.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);G.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(X,{className:"space-y-6",children:[e.jsx(Y,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(W,{checked:D,onCheckedChange:y})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:F||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.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:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,N()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[q.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>b(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:J,disabled:P.isPending,children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),P.isPending?a("saving"):a("save")]})})]})}export{ie as SecretsConfig};
3
+ `).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function ie(){const{data:n,isLoading:l}=G(),N=J(),[D,P]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){P(!0),E(""),S(""),$(""),f([]),v([]);return}P(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},b=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},z=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}N.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);Z.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(Q,{className:"space-y-6",children:[e.jsx(W,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(K,{checked:D,onCheckedChange:P})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:F||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.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:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,y()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[q.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>b(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,X()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:z,disabled:N.isPending,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),N.isPending?a("saving"):a("save")]})})]})}export{ie as SecretsConfig};
@@ -0,0 +1,2 @@
1
+ import{r as l,j as e,aA as U,G as W,b6 as Q,b1 as Y,a0 as J,M as F,b7 as X,al as Z,am as ee}from"./vendor-waGu-koL.js";import{u as se}from"./useConfirmDialog-BeaFLDO8.js";import{E as te,a4 as ae,a5 as re,a6 as ne,t as r,B as y,c,S as le,e as ie,f as oe,g as ce,h as R,I as M,a7 as de,i as xe}from"./index-COJomMe9.js";import{a as me,s as L,S as K}from"./ncp-session-adapter-w8ZHprab.js";import{P as ue,a as he}from"./page-layout-B1RIu5-r.js";const p="__unknown_channel__";function ge(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?p:a.slice(0,n).trim()||p}function D(a){return a===p?r("sessionsUnknownChannel"):a}function fe(a){return a==="service"?"system":a==="tool"?"tool":a}function pe(a){var i;const n=[];for(const s of a.parts){if(s.type==="text"||s.type==="rich-text"||s.type==="reasoning"){n.push(s.text);continue}if(s.type==="tool-invocation"){const d=(i=s.toolName)!=null&&i.trim()?`[${s.toolName.trim()}]`:"[tool]";if(s.state==="result"&&typeof s.result=="string"&&s.result.trim()){n.push(`${d} ${s.result.trim()}`);continue}n.push(d)}}return n.join(`
2
+ `).trim()}function be({session:a,summary:n,channel:i,isSelected:s,onSelect:d}){const u=D(i),N=L(a);return e.jsxs("button",{onClick:d,className:c("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",s?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:c("font-semibold truncate pr-2 flex-1 text-sm",s?"text-brand-800":"text-gray-900"),children:N}),e.jsx("div",{className:c("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",s?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:u})]}),e.jsxs("div",{className:c("flex items-center text-xs justify-between mt-2 font-medium",s?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:n.status==="running"?e.jsx(K,{status:"running"}):null}),e.jsx(X,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:de(n.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:n.messageCount})]})]})]})}function ye({message:a}){const n=fe(a.role),i=n==="user",s=pe(a);return e.jsx("div",{className:c("flex w-full mb-6",i?"justify-end":"justify-start"),children:e.jsxs("div",{className:c("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",i?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:i?e.jsx(Z,{className:"w-4 h-4 text-primary-100"}):e.jsx(ee,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:c("font-semibold text-xs capitalize",i?"text-primary-50":"text-gray-900"),children:n}),e.jsx("span",{className:c("text-[10px]",i?"text-primary-200":"text-gray-400"),children:ge(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:s||"-"})]})]})})}function ke(){var A,B,T;const[a,n]=l.useState(""),[i]=l.useState(100),[s,d]=l.useState(null),[u,N]=l.useState("all"),[_,v]=l.useState(""),[z,w]=l.useState(""),[S,k]=l.useState(!1),g=te({limit:i}),h=ae(s,300),C=re(),E=ne(),{confirm:$,ConfirmDialog:O}=se(),b=l.useMemo(()=>{var t;return((t=g.data)==null?void 0:t.sessions)??[]},[(A=g.data)==null?void 0:A.sessions]),x=l.useMemo(()=>me(b),[b]),f=l.useMemo(()=>new Map(b.map(t=>[t.sessionId,t])),[b]),I=l.useMemo(()=>{const t=a.trim().toLowerCase();return x.filter(o=>u!=="all"&&j(o.key)!==u?!1:t?o.key.toLowerCase().includes(t)||L(o).toLowerCase().includes(t):!0)},[a,u,x]),m=l.useMemo(()=>x.find(t=>t.key===s)??null,[s,x]),P=l.useMemo(()=>s?f.get(s)??null:null,[s,f]),V=l.useMemo(()=>{const t=new Set;for(const o of x)t.add(j(o.key));return Array.from(t).sort((o,H)=>o===p?1:H===p?-1:o.localeCompare(H))},[x]);l.useEffect(()=>{s&&!f.has(s)&&d(null)},[s,f]),l.useEffect(()=>{m?(v(m.label||""),w(m.preferredModel||"")):(v(""),w("")),k(!1)},[m]);const q=()=>{s&&(C.mutate({sessionId:s,data:{label:_.trim()||null,preferredModel:z.trim()||null}}),k(!1))},G=async()=>{if(!s)return;await $({title:r("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:r("sessionsDeleteConfirm")})&&E.mutate({sessionId:s},{onSuccess:()=>d(null)})};return e.jsxs(ue,{fullHeight:!0,children:[e.jsx(he,{title:r("sessionsPageTitle"),description:r("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[x.length," ",r("sessionsListTitle")]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(U,{className:c("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(le,{value:u,onValueChange:N,children:[e.jsx(ie,{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:e.jsx(oe,{placeholder:r("sessionsAllChannels")})}),e.jsxs(ce,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(R,{value:"all",className:"rounded-lg text-xs",children:r("sessionsAllChannels")}),V.map(t=>e.jsx(R,{value:t,className:"rounded-lg text-xs truncate pr-6",children:D(t)},t))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(W,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(M,{value:a,onChange:t=>n(t.target.value),placeholder:r("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:r("sessionsLoading")}):I.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(Q,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),r("sessionsEmpty")]}):I.map(t=>{const o=f.get(t.key);return o?e.jsx(be,{session:t,summary:o,channel:j(t.key),isSelected:s===t.key,onSelect:()=>d(t.key)},t.key):null})})]}),e.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:[(C.isPending||E.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),s&&m&&P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.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:e.jsx(Y,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:L(m)}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:D(j(m.key))}),P.status==="running"?e.jsx(K,{status:"running",className:"h-4 w-4"}):null]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:s,children:s})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>k(!S),className:c("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",S?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),r("sessionsMetadata")]}),e.jsx(y,{variant:"outline",size:"sm",onClick:G,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:r("delete")})]})]}),S&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(M,{placeholder:r("sessionsLabelPlaceholder"),value:_,onChange:t=>v(t.target.value),className:"h-8 text-sm bg-white"}),e.jsx(M,{placeholder:r("sessionsModelPlaceholder"),value:z,onChange:t=>w(t.target.value),className:"h-8 text-sm bg-white"}),e.jsx(y,{size:"sm",onClick:q,className:"h-8 px-4 shrink-0 shadow-none",disabled:C.isPending,children:r("sessionsSaveMeta")})]})]}),e.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:[h.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(U,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:r("sessionsHistoryLoading")})]})}),h.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:h.error.message}),!h.isLoading&&((B=h.data)==null?void 0:B.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(F,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:r("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((T=h.data)==null?void 0:T.messages)??[]).map(t=>e.jsx(ye,{message:t},t.id))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.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:e.jsx(Q,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:r("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:r("sessionsNoSelectionDescription")})]})]})]}),e.jsx(O,{})]})}export{ke as SessionsConfig};