@nextclaw/ui 0.6.15 → 0.8.0

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 (103) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -0
  3. package/dist/assets/ChannelsList-DBcoVJRW.js +1 -0
  4. package/dist/assets/ChatPage-CD3cxyyM.js +37 -0
  5. package/dist/assets/DocBrowser-DDX2HMXW.js +1 -0
  6. package/dist/assets/{LogoBadge-Cer0jX6t.js → LogoBadge-J53F_3JA.js} +1 -1
  7. package/dist/assets/MarketplacePage-0BZ4bza0.js +49 -0
  8. package/dist/assets/ModelConfig-Wzq9wGHV.js +1 -0
  9. package/dist/assets/ProvidersList-kwzRS8_M.js +1 -0
  10. package/dist/assets/RuntimeConfig-N771_AM6.js +1 -0
  11. package/dist/assets/SearchConfig-DVt5QVa_.js +1 -0
  12. package/dist/assets/{SecretsConfig-BnGVZiv4.js → SecretsConfig-CkwauPa8.js} +2 -2
  13. package/dist/assets/SessionsConfig-C3mnHzkZ.js +2 -0
  14. package/dist/assets/{session-run-status-tZ4ISNj-.js → chat-message-pxr79GDs.js} +3 -3
  15. package/dist/assets/index-BIvFMkN4.js +1 -0
  16. package/dist/assets/index-CzkY1reu.js +8 -0
  17. package/dist/assets/{index-CkqvHQAt.js → index-GdpEEKnz.js} +1 -1
  18. package/dist/assets/index-RZ0kHHRI.css +1 -0
  19. package/dist/assets/{label-DkL14Jvl.js → label-CmksBHgc.js} +1 -1
  20. package/dist/assets/page-layout-Db0GbnhS.js +1 -0
  21. package/dist/assets/security-config-CjLFME5Q.js +1 -0
  22. package/dist/assets/skeleton-CkpQeVWN.js +1 -0
  23. package/dist/assets/{switch-CgbPbIX3.js → switch-C24d-UJU.js} +1 -1
  24. package/dist/assets/tabs-custom-D89bh-fc.js +1 -0
  25. package/dist/assets/useConfirmDialog-BeP35LcG.js +5 -0
  26. package/dist/assets/vendor-psXJBy9u.js +407 -0
  27. package/dist/index.html +3 -3
  28. package/package.json +12 -5
  29. package/src/App.tsx +49 -27
  30. package/src/api/client.ts +1 -0
  31. package/src/api/config.ts +98 -0
  32. package/src/api/types.ts +45 -0
  33. package/src/components/auth/login-page.tsx +69 -0
  34. package/src/components/chat/ChatConversationPanel.tsx +12 -54
  35. package/src/components/chat/ChatPage.tsx +10 -324
  36. package/src/components/chat/adapters/chat-input-bar.adapter.test.ts +80 -0
  37. package/src/components/chat/adapters/chat-input-bar.adapter.ts +329 -0
  38. package/src/components/chat/adapters/chat-message.adapter.test.ts +138 -0
  39. package/src/components/chat/adapters/chat-message.adapter.ts +200 -0
  40. package/src/components/chat/chat-chain.test.ts +22 -0
  41. package/src/components/chat/chat-chain.ts +23 -0
  42. package/src/components/chat/chat-input/chat-input-bar.controller.test.tsx +128 -0
  43. package/src/components/chat/chat-input/chat-input-bar.controller.ts +105 -0
  44. package/src/components/chat/chat-page-shell.tsx +103 -0
  45. package/src/components/chat/containers/chat-input-bar.container.tsx +270 -0
  46. package/src/components/chat/containers/chat-message-list.container.tsx +71 -0
  47. package/src/components/chat/index.ts +1 -0
  48. package/src/components/chat/legacy/LegacyChatPage.tsx +228 -0
  49. package/src/components/chat/managers/chat-thread.manager.ts +3 -1
  50. package/src/components/chat/ncp/NcpChatPage.tsx +349 -0
  51. package/src/components/chat/ncp/ncp-chat-input.manager.ts +173 -0
  52. package/src/components/chat/ncp/ncp-chat-page-data.ts +134 -0
  53. package/src/components/chat/ncp/ncp-chat-thread.manager.ts +89 -0
  54. package/src/components/chat/ncp/ncp-chat.presenter.ts +33 -0
  55. package/src/components/chat/ncp/ncp-session-adapter.test.ts +49 -0
  56. package/src/components/chat/ncp/ncp-session-adapter.ts +194 -0
  57. package/src/components/chat/nextclaw/index.ts +23 -0
  58. package/src/components/chat/presenter/chat-presenter-context.tsx +43 -4
  59. package/src/components/config/runtime-security-card.tsx +276 -0
  60. package/src/components/config/security-config.tsx +12 -0
  61. package/src/components/layout/Sidebar.tsx +6 -1
  62. package/src/components/marketplace/MarketplacePage.test.tsx +170 -0
  63. package/src/components/marketplace/MarketplacePage.tsx +77 -28
  64. package/src/hooks/use-auth.ts +111 -0
  65. package/src/hooks/useConfig.ts +42 -0
  66. package/src/hooks/useMarketplace.ts +9 -0
  67. package/src/lib/i18n.ts +73 -1
  68. package/src/test/setup.ts +16 -0
  69. package/tailwind.config.js +8 -3
  70. package/tsconfig.json +6 -2
  71. package/vite.config.ts +2 -1
  72. package/vitest.config.ts +16 -0
  73. package/dist/assets/ChannelsList-DzeVn-JC.js +0 -1
  74. package/dist/assets/ChatPage-BiFhIm1-.js +0 -36
  75. package/dist/assets/DocBrowser-By3lF9yN.js +0 -1
  76. package/dist/assets/MarketplacePage-EZxALdIz.js +0 -49
  77. package/dist/assets/ModelConfig-AchYxLft.js +0 -1
  78. package/dist/assets/ProvidersList-BsD-4kKX.js +0 -1
  79. package/dist/assets/RuntimeConfig-sKOERbFD.js +0 -1
  80. package/dist/assets/SearchConfig-DAfvDwX6.js +0 -1
  81. package/dist/assets/SessionsConfig-CzvrKDRs.js +0 -2
  82. package/dist/assets/card-BAM7vbMg.js +0 -1
  83. package/dist/assets/index-D9rRqOi8.css +0 -1
  84. package/dist/assets/index-DJZ5y7t1.js +0 -8
  85. package/dist/assets/input-BoelTiYL.js +0 -1
  86. package/dist/assets/page-layout-CERNdqzB.js +0 -1
  87. package/dist/assets/popover-uwYz3Chm.js +0 -1
  88. package/dist/assets/tabs-custom-pDyl95el.js +0 -1
  89. package/dist/assets/useConfirmDialog-DyP6Ac75.js +0 -5
  90. package/dist/assets/vendor-BKtTvQYU.js +0 -407
  91. package/src/components/chat/ChatThread.tsx +0 -402
  92. package/src/components/chat/SkillsPicker.tsx +0 -137
  93. package/src/components/chat/chat-input/ChatInputBarView.tsx +0 -82
  94. package/src/components/chat/chat-input/ChatInputBottomToolbar.tsx +0 -83
  95. package/src/components/chat/chat-input/components/ChatInputModelStateHint.tsx +0 -39
  96. package/src/components/chat/chat-input/components/ChatInputSelectedSkillsSection.tsx +0 -31
  97. package/src/components/chat/chat-input/components/ChatInputSlashPanelSection.tsx +0 -112
  98. package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputAttachButton.tsx +0 -24
  99. package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputModelSelector.tsx +0 -58
  100. package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputSendControls.tsx +0 -56
  101. package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputSessionTypeSelector.tsx +0 -40
  102. package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputThinkingSelector.tsx +0 -74
  103. package/src/components/chat/chat-input/useChatInputBarController.ts +0 -322
@@ -0,0 +1 @@
1
+ import{r as s,j as t,F as oe,b0 as ae,b1 as ne,a5 as W,a3 as ie,y as le,b2 as ce,s as de,a8 as ue,b3 as me}from"./vendor-psXJBy9u.js";import{n as we,D as Y,t as i,c as X,af as xe}from"./index-CzkY1reu.js";function pe(){const{isOpen:F,mode:g,tabs:T,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:A,toggleMode:I,goBack:$,goForward:O,canGoBack:_,canGoForward:G,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(!F)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:I,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:A,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:[T.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:$,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(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,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(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 +1 @@
1
- import{j as e,r as d}from"./vendor-BKtTvQYU.js";import{c as a}from"./index-DJZ5y7t1.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function b({status:s,label:r,className:n}){const t=c[s];return e.jsxs("div",{className:a("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:a("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:a("text-[11px] font-medium",t.text),children:r})]})}function p({name:s,src:r,className:n,imgClassName:t,fallback:o}){const[l,g]=d.useState(!1),i=!!r&&!l;return e.jsx("div",{className:a("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:i?e.jsx("img",{src:r,alt:`${s} logo`,className:a("block h-6 w-6 object-contain",t),onError:()=>g(!0),draggable:!1}):o??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{p as L,b as S};
1
+ import{j as e,r as d}from"./vendor-psXJBy9u.js";import{c as a}from"./index-CzkY1reu.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function b({status:s,label:r,className:n}){const t=c[s];return e.jsxs("div",{className:a("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:a("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:a("text-[11px] font-medium",t.text),children:r})]})}function p({name:s,src:r,className:n,imgClassName:t,fallback:o}){const[l,g]=d.useState(!1),i=!!r&&!l;return e.jsx("div",{className:a("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:i?e.jsx("img",{src:r,alt:`${s} logo`,className:a("block h-6 w-6 object-contain",t),onError:()=>g(!0),draggable:!1}):o??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{p as L,b as S};
@@ -0,0 +1,49 @@
1
+ import{u as Re,b as Me,d as Le,e as Y,r as i,j as n,aB as et,az as tt,aA as at,aC as De,aF as nt,aD as st,aE as A,aG as $e,aH as rt,aI as ot,aO as lt,aP as it,aX as ct,aY as dt,aQ as ut,at as pt,au as mt,aZ as gt}from"./vendor-psXJBy9u.js";import{ad as q,t as u,c as oe,p as ft,n as xt,S as ht,e as yt,f as bt,g as kt,h as Ne}from"./index-CzkY1reu.js";import{S as F}from"./skeleton-CkpQeVWN.js";import{T as vt}from"./tabs-custom-D89bh-fc.js";import{P as _e}from"./index-GdpEEKnz.js";import{u as wt}from"./useConfirmDialog-BeP35LcG.js";import{P as Tt,a as St}from"./page-layout-Db0GbnhS.js";function J(e){return e==="plugin"?"plugins":"skills"}async function Ct(e){var o,c;const t=new URLSearchParams,a=J(e.type);(o=e.q)!=null&&o.trim()&&t.set("q",e.q.trim()),(c=e.tag)!=null&&c.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 s=t.toString(),r=await q.get(s?`/api/marketplace/${a}/items?${s}`:`/api/marketplace/${a}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Pt(e){const t=await q.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 q.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Nt(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function It(e){const t=J(e),a=await q.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Rt(e){return Re({queryKey:["marketplace-items",e],queryFn:()=>Ct(e),placeholderData:(t,a)=>{var o;const s=(o=a==null?void 0:a.queryKey)==null?void 0:o[1];return!s||typeof s!="object"||s===null?void 0:("type"in s?s.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Mt(e){return Re({queryKey:["marketplace-installed",e],queryFn:()=>It(e),staleTime:1e4})}function Lt(){const e=Me();return Le({mutationFn:t=>Nt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.type==="plugin"?u("marketplaceInstallSuccessPlugin"):u("marketplaceInstallSuccessSkill");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceInstallFailed"))}})}function Dt(){const e=Me();return Le({mutationFn:t=>Et(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.action==="enable"?u("marketplaceEnableSuccess"):t.action==="disable"?u("marketplaceDisableSuccess"):u("marketplaceUninstallSuccess");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceOperationFailed"))}})}var[X]=ot("Tooltip",[$e]),W=$e(),Oe="TooltipProvider",$t=700,ne="tooltip.open",[_t,le]=X(Oe),Ae=e=>{const{__scopeTooltip:t,delayDuration:a=$t,skipDelayDuration:s=300,disableHoverableContent:r=!1,children:o}=e,c=i.useRef(!0),g=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),n.jsx(_t,{scope:t,isOpenDelayedRef:c,delayDuration:a,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:g,onPointerInTransitChange:i.useCallback(h=>{g.current=h},[]),disableHoverableContent:r,children:o})};Ae.displayName=Oe;var B="Tooltip",[Ot,G]=X(B),Fe=e=>{const{__scopeTooltip:t,children:a,open:s,defaultOpen:r,onOpenChange:o,disableHoverableContent:c,delayDuration:g}=e,d=le(B,e.__scopeTooltip),h=W(t),[p,y]=i.useState(null),v=et(),x=i.useRef(0),T=c??d.disableHoverableContent,f=g??d.delayDuration,C=i.useRef(!1),[I,N]=tt({prop:s,defaultProp:r??!1,onChange:S=>{S?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),o==null||o(S)},caller:B}),M=i.useMemo(()=>I?C.current?"delayed-open":"instant-open":"closed",[I]),P=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,C.current=!1,N(!0)},[N]),R=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,N(!1)},[N]),D=i.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{C.current=!0,N(!0),x.current=0},f)},[f,N]);return i.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),n.jsx(at,{...h,children:n.jsx(Ot,{scope:t,contentId:v,open:I,stateAttribute:M,trigger:p,onTriggerChange:y,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?D():P()},[d.isOpenDelayedRef,D,P]),onTriggerLeave:i.useCallback(()=>{T?R():(window.clearTimeout(x.current),x.current=0)},[R,T]),onOpen:P,onClose:R,disableHoverableContent:T,children:a})})};Fe.displayName=B;var se="TooltipTrigger",Ue=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,r=G(se,a),o=le(se,a),c=W(a),g=i.useRef(null),d=De(t,g,r.onTriggerChange),h=i.useRef(!1),p=i.useRef(!1),y=i.useCallback(()=>h.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),n.jsx(nt,{asChild:!0,...c,children:n.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...s,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(r.onTriggerEnter(),p.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),p.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),h.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:A(e.onFocus,()=>{h.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ue.displayName=se;var ie="TooltipPortal",[At,Ft]=X(ie,{forceMount:void 0}),ze=e=>{const{__scopeTooltip:t,forceMount:a,children:s,container:r}=e,o=G(ie,t);return n.jsx(At,{scope:t,forceMount:a,children:n.jsx(_e,{present:a||o.open,children:n.jsx(rt,{asChild:!0,container:r,children:s})})})};ze.displayName=ie;var z="TooltipContent",qe=i.forwardRef((e,t)=>{const a=Ft(z,e.__scopeTooltip),{forceMount:s=a.forceMount,side:r="top",...o}=e,c=G(z,e.__scopeTooltip);return n.jsx(_e,{present:s||c.open,children:c.disableHoverableContent?n.jsx(He,{side:r,...o,ref:t}):n.jsx(Ut,{side:r,...o,ref:t})})}),Ut=i.forwardRef((e,t)=>{const a=G(z,e.__scopeTooltip),s=le(z,e.__scopeTooltip),r=i.useRef(null),o=De(t,r),[c,g]=i.useState(null),{trigger:d,onClose:h}=a,p=r.current,{onPointerInTransitChange:y}=s,v=i.useCallback(()=>{g(null),y(!1)},[y]),x=i.useCallback((T,f)=>{const C=T.currentTarget,I={x:T.clientX,y:T.clientY},N=Bt(I,C.getBoundingClientRect()),M=Gt(I,N),P=Qt(f.getBoundingClientRect()),R=Yt([...M,...P]);g(R),y(!0)},[y]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&p){const T=C=>x(C,p),f=C=>x(C,d);return d.addEventListener("pointerleave",T),p.addEventListener("pointerleave",f),()=>{d.removeEventListener("pointerleave",T),p.removeEventListener("pointerleave",f)}}},[d,p,x,v]),i.useEffect(()=>{if(c){const T=f=>{const C=f.target,I={x:f.clientX,y:f.clientY},N=(d==null?void 0:d.contains(C))||(p==null?void 0:p.contains(C)),M=!Vt(I,c);N?v():M&&(v(),h())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,p,c,h,v]),n.jsx(He,{...e,ref:o})}),[zt,qt]=X(B,{isInside:!1}),Ht=dt("TooltipContent"),He=i.forwardRef((e,t)=>{const{__scopeTooltip:a,children:s,"aria-label":r,onEscapeKeyDown:o,onPointerDownOutside:c,...g}=e,d=G(z,a),h=W(a),{onClose:p}=d;return i.useEffect(()=>(document.addEventListener(ne,p),()=>document.removeEventListener(ne,p)),[p]),i.useEffect(()=>{if(d.trigger){const y=v=>{const x=v.target;x!=null&&x.contains(d.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,p]),n.jsx(lt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:n.jsxs(it,{"data-state":d.stateAttribute,...h,...g,ref:t,style:{...g.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:[n.jsx(Ht,{children:s}),n.jsx(zt,{scope:a,isInside:!0,children:n.jsx(ct,{id:d.contentId,role:"tooltip",children:r||s})})]})})});qe.displayName=z;var Ke="TooltipArrow",Kt=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,r=W(a);return qt(Ke,a).isInside?null:n.jsx(ut,{...r,...s,ref:t})});Kt.displayName=Ke;function Bt(e,t){const a=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(a,s,r,o)){case o:return"left";case r:return"right";case a:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function Gt(e,t,a=5){const s=[];switch(t){case"top":s.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":s.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":s.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":s.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return s}function Qt(e){const{top:t,right:a,bottom:s,left:r}=e;return[{x:r,y:t},{x:a,y:t},{x:a,y:s},{x:r,y:s}]}function Vt(e,t){const{x:a,y:s}=e;let r=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const g=t[o],d=t[c],h=g.x,p=g.y,y=d.x,v=d.y;p>s!=v>s&&a<(y-h)*(s-p)/(v-p)+h&&(r=!r)}return r}function Yt(e){const t=e.slice();return t.sort((a,s)=>a.x<s.x?-1:a.x>s.x?1:a.y<s.y?-1:a.y>s.y?1:0),Jt(t)}function Jt(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(;t.length>=2;){const o=t[t.length-1],c=t[t.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.x))t.pop();else break}t.push(r)}t.pop();const a=[];for(let s=e.length-1;s>=0;s--){const r=e[s];for(;a.length>=2;){const o=a[a.length-1],c=a[a.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.x))a.pop();else break}a.push(r)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Xt=Ae,Wt=Fe,Zt=Ue,ea=ze,Be=qe;const ta=Xt,ee=Wt,te=Zt,V=i.forwardRef(({className:e,sideOffset:t=4,...a},s)=>n.jsx(ea,{children:n.jsx(Be,{ref:s,sideOffset:t,className:oe("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),...a})}));V.displayName=Be.displayName;const Ge=12,aa=Ge;function re(e){return(e??"").trim().toLowerCase()}function U(e,t){const a=re(t);return a.length>0?`${e}:${a}`:""}function na(e){const t=new Map;for(const a of e){const s=[a.install.spec,a.slug,a.id];for(const r of s){const o=U(a.type,r);!o||t.has(o)||t.set(o,a)}}return t}function sa(e){const t=new Map;for(const a of e){const s=[a.spec,a.id,a.label];for(const r of s){const o=U(a.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Ie(e,t){const a=[e.install.spec,e.slug,e.id];for(const s of a){const r=U(e.type,s);if(!r)continue;const o=t.get(r);if(o)return o}}function ra(e,t){const a=t.get(U(e.type,e.spec));if(a)return a;const s=t.get(U(e.type,e.id));return s||t.get(U(e.type,e.label))}function oa(e){const t=e.trim().toLowerCase().replace(/_/g,"-"),a=t.split("-")[0],s=[t,a,"en"];return Array.from(new Set(s.filter(Boolean)))}function ae(e){return e.trim().toLowerCase().replace(/_/g,"-")}function ce(e,t,a){var s;if(e){const r=Object.entries(e).map(([o,c])=>({locale:ae(o),text:typeof c=="string"?c.trim():""})).filter(o=>o.text.length>0);if(r.length>0){const o=new Map(r.map(c=>[c.locale,c.text]));for(const c of a){const g=ae(c),d=o.get(g);if(d)return d}for(const c of a){const g=ae(c).split("-")[0];if(!g)continue;const d=r.find(h=>h.locale===g||h.locale.startsWith(`${g}-`));if(d)return d.text}return((s=r[0])==null?void 0:s.text)??""}}return(t==null?void 0:t.trim())??""}function la(e,t,a,s){const r=re(a);if(!r)return!0;const o=ce(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,s);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,o,...(t==null?void 0:t.tags)??[]].map(g=>re(g)).filter(Boolean).some(g=>g.includes(r))}function ia(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 a=0;for(let s=0;s<e.length;s++)a=e.charCodeAt(s)+((a<<5)-a);return t[Math.abs(a)%t.length]}function ca({name:e,fallback:t}){const a=e||t,s=a.substring(0,2).toUpperCase(),r=ia(a);return n.jsx("div",{className:oe("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:s})}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function K(e){var g,d,h,p;const t=((g=e.metadataRaw)==null?void 0:g.trim())||"-",a=((d=e.contentRaw)==null?void 0:d.trim())||"-",s=(h=e.summary)==null?void 0:h.trim(),r=(p=e.description)==null?void 0:p.trim(),o=!!r&&r!==s,c=`<!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>${E(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>${E(e.title)}</h1>
30
+ <div class="meta">${E(e.typeLabel)} · ${E(e.spec)}${e.author?` · ${E(e.author)}`:""}</div>
31
+ ${s?`<p class="summary">${E(s)}</p>`:""}
32
+ ${o?`<p class="summary">${E(r)}</p>`:""}
33
+ ${e.tags&&e.tags.length>0?`<div class="tags">${e.tags.map(y=>`<span class="tag">${E(y)}</span>`).join("")}</div>`:""}
34
+ ${e.sourceUrl?`<p class="meta" style="margin-top:12px;">${E(e.sourceLabel??"Source")}: <a class="source" href="${E(e.sourceUrl)}" target="_blank" rel="noopener noreferrer">${E(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">${E(t)}</pre></div>
41
+ </article>
42
+ <article class="card">
43
+ <h2>Content</h2>
44
+ <div class="body"><pre class="code">${E(a)}</pre></div>
45
+ </article>
46
+ </section>
47
+ </main>
48
+ </body>
49
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(c)}`}function da(e){return n.jsx("div",{className:"mb-4",children:n.jsxs("div",{className:"flex gap-3 items-center",children:[n.jsxs("div",{className:"flex-1 min-w-0 relative",children:[n.jsx(gt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),n.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&n.jsxs(ht,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[n.jsx(yt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:n.jsx(bt,{})}),n.jsxs(kt,{children:[n.jsx(Ne,{value:"relevance",children:u("marketplaceSortRelevance")}),n.jsx(Ne,{value:"updated",children:u("marketplaceSortUpdated")})]})]})]})})}function Ee(e){const{item:t,record:a,localeFallbacks:s,installState:r,manageState:o,onOpen:c,onInstall:g,onManage:d}=e,h=(a==null?void 0:a.type)==="plugin"?a:void 0,p=(t==null?void 0:t.type)??(a==null?void 0:a.type),y=(t==null?void 0:t.name)??(a==null?void 0:a.label)??(a==null?void 0:a.id)??(a==null?void 0:a.spec)??u("marketplaceUnknownItem"),v=ce(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,s)||(a?u("marketplaceInstalledLocalSummary"):""),x=(t==null?void 0:t.install.spec)??(a==null?void 0:a.spec)??"",T=(a==null?void 0:a.id)||(a==null?void 0:a.spec),f=!!T&&o.isPending&&o.targetId===T,C=!!h,I=(a==null?void 0:a.type)==="plugin"&&a.origin!=="bundled",N=(a==null?void 0:a.type)==="skill"&&a.source==="workspace",M=!!(I||N),P=a?a.enabled===!1||a.runtimeStatus==="disabled":!1,R=t==null?void 0:t.install.spec,D=typeof R=="string"&&r.installingSpecs.has(R),S=p==="plugin"?u("marketplaceTypePlugin"):p==="skill"?u("marketplaceTypeSkill"):u("marketplaceTypeExtension");return n.jsxs("article",{onClick:c,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:[n.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[n.jsx(ca,{name:y,fallback:x||u("marketplaceTypeExtension")}),n.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:n.jsxs(ta,{delayDuration:400,children:[n.jsxs(ee,{children:[n.jsx(te,{asChild:!0,children:n.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:y})}),n.jsx(V,{className:"max-w-[300px] text-xs",children:y})]}),n.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[n.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:S}),x&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),n.jsxs(ee,{children:[n.jsx(te,{asChild:!0,children:n.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:x})}),n.jsx(V,{className:"max-w-[300px] text-xs font-mono break-all",children:x})]})]})]}),n.jsxs(ee,{children:[n.jsx(te,{asChild:!0,children:n.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:v})}),v&&n.jsx(V,{className:"max-w-[400px] text-xs leading-relaxed",children:v})]})]})})]}),n.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[t&&!a&&n.jsx("button",{onClick:w=>{w.stopPropagation(),g(t)},disabled:D,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:D?u("marketplaceInstalling"):u("marketplaceInstall")}),h&&C&&n.jsx("button",{disabled:o.isPending,onClick:w=>{w.stopPropagation(),d(P?"enable":"disable",h)},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:f&&o.action!=="uninstall"?o.action==="enable"?u("marketplaceEnabling"):u("marketplaceDisabling"):P?u("marketplaceEnable"):u("marketplaceDisable")}),a&&M&&n.jsx("button",{disabled:o.isPending,onClick:w=>{w.stopPropagation(),d("uninstall",a)},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:f&&o.action==="uninstall"?u("marketplaceRemoving"):u("marketplaceUninstall")})]})]})}function ua(e){const t=e.count??aa;return n.jsx(n.Fragment,{children:Array.from({length:t},(a,s)=>n.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:n.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[n.jsx(F,{className:"h-10 w-10 shrink-0 rounded-xl"}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[n.jsx(F,{className:"h-4 w-32 max-w-[70%]"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(F,{className:"h-3 w-12"}),n.jsx(F,{className:"h-3 w-24"})]}),n.jsx(F,{className:"h-3 w-full"})]})]}),n.jsx(F,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${s}`))})}function pa(e){return n.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[n.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:u("prev")}),n.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),n.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:u("next")})]})}function ma(e={}){var ke,ve,we,Te,Se,Ce,Pe,je;const{forcedType:t}=e,a=pt(),s=mt(),{language:r}=ft(),o=xt(),c=i.useMemo(()=>t==="plugins"||t==="skills"?t:s.type==="plugins"||s.type==="skills"?s.type:null,[t,s.type]);i.useEffect(()=>{t||c||a("/marketplace/plugins",{replace:!0})},[t,c,a]);const g=c==="skills"?"skill":"plugin",d=i.useMemo(()=>oa(r),[r]),p=g==="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"},[y,v]=i.useState(""),[x,T]=i.useState(""),[f,C]=i.useState("all"),[I,N]=i.useState("relevance"),[M,P]=i.useState(1),[R,D]=i.useState(new Set);i.useEffect(()=>{const l=setTimeout(()=>{P(1),T(y.trim())},250);return()=>clearTimeout(l)},[y]),i.useEffect(()=>{P(1)},[g]);const S=Mt(g),w=Rt({q:x||void 0,type:g,sort:I,page:M,pageSize:Ge}),Qe=Lt(),_=Dt(),{confirm:Ve,ConfirmDialog:Ye}=wt(),Q=i.useMemo(()=>{var l;return((l=S.data)==null?void 0:l.records)??[]},[(ke=S.data)==null?void 0:ke.records]),O=i.useMemo(()=>{var l;return((l=w.data)==null?void 0:l.items)??[]},[(ve=w.data)==null?void 0:ve.items]),de=i.useMemo(()=>na(O),[O]),ue=i.useMemo(()=>sa(Q),[Q]),H=i.useMemo(()=>{const l=Q.filter(m=>m.type===g).map(m=>({key:`${m.type}:${m.spec}:${m.id??""}`,record:m,item:ra(m,de)})).filter(m=>la(m.record,m.item,x,d));return l.sort((m,k)=>{const j=m.record.installedAt?Date.parse(m.record.installedAt):Number.NaN,b=k.record.installedAt?Date.parse(k.record.installedAt):Number.NaN,L=!Number.isNaN(j),Ze=!Number.isNaN(b);return L&&Ze&&j!==b?b-j:m.record.spec.localeCompare(k.record.spec)}),l},[Q,g,de,x,d]),pe=f==="installed"?H.length:((we=w.data)==null?void 0:we.total)??0,Z=f==="installed"?1:((Te=w.data)==null?void 0:Te.totalPages)??0,me=f==="all"&&w.isLoading&&!w.data,Je=f==="installed"&&S.isLoading&&!S.data,$=me||Je,ge=!$&&(f==="all"&&w.isFetching||f==="installed"&&S.isFetching),Xe=i.useMemo(()=>f==="installed"?S.isLoading&&!S.data?u("loading"):`${H.length} ${u(p.installedCountSuffix)}`:w.data?`${O.length} / ${pe}`:u("loading"),[f,S.data,S.isLoading,H.length,w.data,O.length,pe,p.installedCountSuffix]),fe={installingSpecs:R},xe={isPending:_.isPending,targetId:((Se=_.variables)==null?void 0:Se.id)||((Ce=_.variables)==null?void 0:Ce.spec),action:(Pe=_.variables)==null?void 0:Pe.action},We=[{id:"all",label:u(p.tabMarketplace)},{id:"installed",label:u(p.tabInstalled),count:((je=S.data)==null?void 0:je.total)??0}],he=async l=>{const m=l.install.spec;if(!R.has(m)){D(k=>{const j=new Set(k);return j.add(m),j});try{await Qe.mutateAsync({type:l.type,spec:m,kind:l.install.kind,...l.type==="skill"?{skill:l.slug,installPath:`skills/${l.slug}`}:{}})}catch{}finally{D(k=>{if(!k.has(m))return k;const j=new Set(k);return j.delete(m),j})}}},ye=async(l,m)=>{if(_.isPending)return;const k=m.id||m.spec;k&&(l==="uninstall"&&!await Ve({title:`${u("marketplaceUninstallTitle")} ${k}?`,description:u("marketplaceUninstallDescription"),confirmLabel:u("marketplaceUninstall"),variant:"destructive"})||_.mutate({type:m.type,action:l,id:k,spec:m.spec}))},be=async(l,m)=>{const k=(l==null?void 0:l.name)??(m==null?void 0:m.label)??(m==null?void 0:m.id)??(m==null?void 0:m.spec)??u("marketplaceUnknownItem");if(!l){const b=K({title:k,typeLabel:(m==null?void 0:m.type)==="plugin"?u("marketplaceTypePlugin"):u("marketplaceTypeSkill"),spec:(m==null?void 0:m.spec)??"-",summary:u("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(m??{},null,2),contentRaw:"-"});o.open(b,{newTab:!0,title:k,kind:"content"});return}const j=ce(l.summaryI18n,l.summary,d);if(l.type==="skill"){try{const b=await Pt(l.slug),L=K({title:k,typeLabel:u("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});o.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=K({title:k,typeLabel:u("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:u("marketplaceOperationFailed")});o.open(L,{newTab:!0,title:k,kind:"content"})}return}try{const b=await jt(l.slug),L=K({title:k,typeLabel:u("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw||l.summary,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});o.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=K({title:k,typeLabel:u("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:"-"});o.open(L,{newTab:!0,title:k,kind:"content"})}};return n.jsxs(Tt,{className:"flex h-full min-h-0 flex-col pb-0",children:[n.jsx(St,{title:u(p.pageTitle),description:u(p.pageDescription)}),n.jsx(vt,{tabs:We,activeTab:f,onChange:l=>{C(l),P(1)},className:"mb-4"}),n.jsx(da,{scope:f,searchText:y,searchPlaceholder:u(p.searchPlaceholder),sort:I,onSearchTextChange:v,onSortChange:l=>{P(1),N(l)}}),n.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:f==="installed"?u(p.sectionInstalled):u(p.sectionCatalog)}),n.jsx("span",{className:"text-[12px] text-gray-500",children:Xe})]}),f==="all"&&w.isError&&n.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[u(p.errorLoadData),": ",w.error.message]}),f==="installed"&&S.isError&&n.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[u(p.errorLoadInstalled),": ",S.error.message]}),n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1","aria-busy":$||ge,children:[n.jsxs("div",{"data-testid":$?"marketplace-list-skeleton":void 0,className:oe("grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3 transition-opacity",ge?"opacity-70":"opacity-100"),children:[$&&n.jsx(ua,{}),!$&&f==="all"&&O.map(l=>n.jsx(Ee,{item:l,record:Ie(l,ue),localeFallbacks:d,installState:fe,manageState:xe,onOpen:()=>void be(l,Ie(l,ue)),onInstall:he,onManage:ye},l.id)),!$&&f==="installed"&&H.map(l=>n.jsx(Ee,{item:l.item,record:l.record,localeFallbacks:d,installState:fe,manageState:xe,onOpen:()=>void be(l.item,l.record),onInstall:he,onManage:ye},l.key))]}),f==="all"&&!$&&!w.isError&&O.length===0&&n.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:u(p.emptyData)}),f==="installed"&&!$&&!S.isError&&H.length===0&&n.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:u(p.emptyInstalled)})]})]}),f==="all"&&!me&&n.jsx("div",{className:"shrink-0",children:n.jsx(pa,{page:M,totalPages:Z,busy:w.isFetching,onPrev:()=>P(l=>Math.max(1,l-1)),onNext:()=>P(l=>Z>0?Math.min(Z,l+1):l+1)})}),n.jsx(Ye,{})]})}const va=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:ma},Symbol.toStringTag,{value:"Module"}));export{Be as C,ma as M,Xt as P,Wt as R,ta as T,ee as a,te as b,V as c,Zt as d,ea as e,va as f,Mt as u};
@@ -0,0 +1 @@
1
+ import{r as n,j as e,a0 as W,l as z,q,F as G,a1 as K,a2 as Y}from"./vendor-psXJBy9u.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-CzkY1reu.js";import{L as R}from"./label-CmksBHgc.js";import{S as u}from"./skeleton-CkpQeVWN.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-D3B_xWXx.js";import{P as ie,a as ce}from"./page-layout-Db0GbnhS.js";function de(i){const r=new Set;for(const p of i){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:i,value:r,onChange:p,options:x,disabled:c=!1,placeholder:T,className:P,inputClassName:b,emptyText:j,createText:k,maxItems:N=Number.POSITIVE_INFINITY,onEnter:v}){const[o,l]=n.useState(!1);n.useEffect(()=>{c&&o&&l(!1)},[c,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 C=f.option.toLowerCase(),S=w.option.toLowerCase(),D=C===d?0:C.startsWith(d)?1:C.includes(d)?2:3,I=S===d?0:S.startsWith(d)?1:S.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]),M=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",P),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:i,value:r,disabled:c,onFocus:()=>{c||l(!0)},onChange:s=>{p(s.target.value),!o&&!c&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(v&&(s.preventDefault(),v()),l(!1))},placeholder:T,className:L("pr-10",b)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:c,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",c?"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&&!c&&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:[!M&&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:k?k.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:i,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),c=X(),[T,P]=n.useState(""),[b,j]=n.useState(""),[k,N]=n.useState(""),v=x==null?void 0:x.uiHints,o=_("agents.defaults.model",v),l=_("agents.defaults.workspace",v),h=n.useMemo(()=>le({meta:p,config:i,onlyConfigured:!0}),[i,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),M=(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=i==null?void 0:i.agents)!=null&&E.defaults))return;const t=(i.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];P(y),j(y?F(t,V):""),N(i.agents.defaults.workspace||"")},[i,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(b,s);return t?ne(a.prefix,t):""},[b,a,s]),C=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",S=t=>{P(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),c.mutate({model:w})};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(ie,{children:[e.jsx(ce,{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:M,onValueChange:S,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:b,onChange:D,options:f,disabled:!M,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")},M)]}),e.jsx("p",{className:"text-xs text-gray-400",children:C}),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:k,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:c.isPending,size:"lg",children:c.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
@@ -0,0 +1 @@
1
+ import{r as f,j as e,av as kt,aw as St,ap as lt,a3 as _e,b as Lt,e as F,a5 as tt,ax as st,C as It,ay as Dt,s as Et,K as _t}from"./vendor-psXJBy9u.js";import{c as ne,I as X,B,t as n,u as ct,a as dt,b as ut,Q as $t,R as zt,U as Bt,V as Kt,W as Ft,X as Ot,Y as Rt,S as Te,e as ke,f as Se,g as Le,h as ye,Z as Ht}from"./index-CzkY1reu.js";import{L as O}from"./label-CmksBHgc.js";import{R as Wt,T as qt,P as Ut,C as mt}from"./index-BIvFMkN4.js";import{S as ht,L as Gt}from"./LogoBadge-J53F_3JA.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Qt,b as Vt,C as Xt,a as Yt}from"./config-layout-BHnOoweL.js";import{T as Zt}from"./tabs-custom-D89bh-fc.js";import{P as Jt,a as es}from"./page-layout-Db0GbnhS.js";import"./index-GdpEEKnz.js";const ts=Wt,ss=qt,pt=f.forwardRef(({className:t,sideOffset:r=8,align:a="start",...i},l)=>e.jsx(Ut,{children:e.jsx(mt,{ref:l,sideOffset:r,align:a,className:ne("z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})}));pt.displayName=mt.displayName;function ns({isSet:t,className:r,value:a,onChange:i,placeholder:l,...g}){const[d,u]=f.useState(!1),[j,b]=f.useState(!1),w=typeof a=="string"&&a.length>0,I=t&&!w&&!j;return e.jsxs("div",{className:"relative",children:[I?e.jsx("div",{onClick:()=>b(!0),className:ne("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",r),children:"••••••••••••"}):e.jsx(X,{type:d?"text":"password",className:ne("pr-12",r),value:a,onChange:i,onBlur:()=>{w||b(!1)},placeholder:l,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(B,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!d),children:d?e.jsx(kt,{className:"h-4 w-4"}):e.jsx(St,{className:"h-4 w-4"})})})]})}function rs({value:t,onChange:r,className:a}){const i=t?Object.entries(t):[],l=(u,j,b)=>{const w=[...i];w[u]=[j,b],r(Object.fromEntries(w))},g=()=>{r({...t,"":""})},d=u=>{const j=i.filter((b,w)=>w!==u);r(Object.fromEntries(j))};return e.jsxs("div",{className:ne("space-y-2",a),children:[i.map(([u,j],b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(X,{type:"text",value:u,onChange:w=>l(b,w.target.value,j),placeholder:n("headerName"),className:"flex-1"}),e.jsx(X,{type:"text",value:j,onChange:w=>l(b,u,w.target.value),placeholder:n("headerValue"),className:"flex-1"}),e.jsx(B,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(b),children:e.jsx(lt,{className:"h-4 w-4 text-red-500"})})]},b)),e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),n("add")]})]})}const as={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Ee=["off","minimal","low","medium","high","adaptive","xhigh"],is=new Set(Ee);function de(t){if(!t)return null;const r=Object.entries(t).map(([a,i])=>[a.trim(),i]).filter(([a])=>a.length>0);return r.length===0?null:Object.fromEntries(r)}function nt(t,r){const a=de(t),i=de(r);if(a===null&&i===null)return!0;if(!a||!i)return!1;const l=Object.entries(a).sort(([d],[u])=>d.localeCompare(u)),g=Object.entries(i).sort(([d],[u])=>d.localeCompare(u));return l.length!==g.length?!1:l.every(([d,u],j)=>d===g[j][0]&&u===g[j][1])}function Ie(t){if(!t||t.length===0)return[];const r=new Set;for(const a of t){const i=a.trim();i&&r.add(i)}return[...r]}function os(t,r){const a=t.trim();if(!a||!r.trim())return a;const i=`${r.trim()}/`;return a.startsWith(i)?a.slice(i.length):a}function ce(t,r){let a=t.trim();if(!a)return"";for(const i of r){const l=i.trim();l&&(a=os(a,l))}return a.trim()}function je(t,r){return t.length!==r.length?!1:t.every((a,i)=>a===r[i])}function ls(t,r){const a=[...t];for(const i of r)a.includes(i)||a.push(i);return a}function cs(t,r){return r.length===0?t:r.every(i=>!t.includes(i))?ls(t,r):r}function ds(t,r){return je(t,r)?[]:t}function $e(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r&&is.has(r)?r:null}function ft(t){if(!Array.isArray(t))return[];const r=[];for(const a of t){const i=$e(a);!i||r.includes(i)||r.push(i)}return r}function us(t,r){if(!t)return{};const a={};for(const[i,l]of Object.entries(t)){const g=ce(i,r);if(!g)continue;const d=ft(l==null?void 0:l.supported);if(d.length===0)continue;const u=$e(l==null?void 0:l.default);a[g]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return a}function De(t,r){const a=new Set(r.map(l=>l.trim()).filter(Boolean)),i={};for(const[l,g]of Object.entries(t)){if(!a.has(l))continue;const d=ft(g.supported);if(d.length===0)continue;const u=$e(g.default);i[l]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return i}function rt(t,r){const a=Object.keys(t).sort(),i=Object.keys(r).sort();if(a.length!==i.length)return!1;for(let l=0;l<a.length;l+=1){const g=a[l];if(g!==i[l])return!1;const d=t[g],u=r[g];if(!d||!u)return!1;const j=[...d.supported].sort(),b=[...u.supported].sort();if(!je(j,b)||(d.default??null)!==(u.default??null))return!1}return!0}function at(t){return t==="off"?n("chatThinkingLevelOff"):t==="minimal"?n("chatThinkingLevelMinimal"):t==="low"?n("chatThinkingLevelLow"):t==="medium"?n("chatThinkingLevelMedium"):t==="high"?n("chatThinkingLevelHigh"):t==="adaptive"?n("chatThinkingLevelAdaptive"):n("chatThinkingLevelXhigh")}function ms(t){var j,b,w,I,D;const{providerName:r,methods:a,defaultMethodId:i,language:l}=t;if(a.length===0)return"";const g=new Map;for(const k of a){const A=k.id.trim();A&&g.set(A.toLowerCase(),A)}const d=(...k)=>{for(const A of k){const P=g.get(A.toLowerCase());if(P)return P}},u=i==null?void 0:i.trim();if(r==="minimax-portal"){if(l==="zh")return d("cn","china-mainland")??d(u??"")??((j=a[0])==null?void 0:j.id)??"";if(l==="en")return d("global","intl","international")??d(u??"")??((b=a[0])==null?void 0:b.id)??""}if(u){const k=d(u);if(k)return k}return l==="zh"?d("cn")??((w=a[0])==null?void 0:w.id)??"":l==="en"?d("global")??((I=a[0])==null?void 0:I.id)??"":((D=a[0])==null?void 0:D.id)??""}function it(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function ot(t){const{value:r,onChange:a,options:i}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(l=>{const g=l.value===r;return e.jsx("button",{type:"button",onClick:()=>a(l.value),"aria-pressed":g,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${g?"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 hs({providerName:t,onProviderDeleted:r}){var Qe,Ve,Xe,Ye,Ze,Je,et;const a=Lt(),{data:i}=ct(),{data:l}=dt(),{data:g}=ut(),d=$t(),u=zt(),j=Bt(),b=Kt(),w=Ft(),I=Ot(),[D,k]=f.useState(""),[A,P]=f.useState(""),[R,re]=f.useState(null),[x,v]=f.useState("auto"),[N,M]=f.useState([]),[E,_]=f.useState({}),[H,$]=f.useState(""),[U,Y]=f.useState(""),[be,xt]=f.useState(!1),[ve,ue]=f.useState(!1),[me,W]=f.useState(null),[ze,z]=f.useState(""),[Be,he]=f.useState(""),pe=f.useRef(null),o=l==null?void 0:l.providers.find(s=>s.name===t),T=(t?i==null?void 0:i.providers[t]:null)??as,fe=g==null?void 0:g.uiHints,Z=!!(o!=null&&o.isCustom),J=t?le(`providers.${t}.apiKey`,fe):void 0,K=t?le(`providers.${t}.apiBase`,fe):void 0,we=t?le(`providers.${t}.extraHeaders`,fe):void 0,Ne=t?le(`providers.${t}.wireApi`,fe):void 0,Ke=(o==null?void 0:o.displayName)||t||"",ee=(T.displayName||"").trim()||Ke,gt=U.trim()||ee||t||n("providersSelectPlaceholder"),Fe=(o==null?void 0:o.modelPrefix)||t||"",q=f.useMemo(()=>Ie([Fe,t||""]),[Fe,t]),Ce=(o==null?void 0:o.defaultApiBase)||"",ae=T.apiBase||Ce,Ae=de(T.extraHeaders||null),ie=T.wireApi||(o==null?void 0:o.defaultWireApi)||"auto",Pe=f.useMemo(()=>Ie(((o==null?void 0:o.defaultModels)??[]).map(s=>ce(s,q))),[o==null?void 0:o.defaultModels,q]),Oe=f.useMemo(()=>Ie((T.models??[]).map(s=>ce(s,q))),[T.models,q]),G=f.useMemo(()=>cs(Pe,Oe),[Pe,Oe]),oe=f.useMemo(()=>De(us(T.modelThinking,q),G),[G,q,T.modelThinking]),Q=Rt(),yt=((Qe=o==null?void 0:o.apiBaseHelp)==null?void 0:Qe[Q])||((Ve=o==null?void 0:o.apiBaseHelp)==null?void 0:Ve.en)||(K==null?void 0:K.help)||n("providerApiBaseHelp"),p=o==null?void 0:o.auth,S=f.useMemo(()=>(p==null?void 0:p.methods)??[],[p==null?void 0:p.methods]),Re=f.useMemo(()=>S.map(s=>{var c,h;return{value:s.id,label:((c=s.label)==null?void 0:c[Q])||((h=s.label)==null?void 0:h.en)||s.id}}),[S,Q]),xe=f.useMemo(()=>ms({providerName:t,methods:S,defaultMethodId:p==null?void 0:p.defaultMethodId,language:Q}),[t,p==null?void 0:p.defaultMethodId,S,Q]),te=f.useMemo(()=>{var c;if(!S.length)return"";const s=Be.trim();return s&&S.some(h=>h.id===s)?s:xe||((c=S[0])==null?void 0:c.id)||""},[Be,xe,S]),se=f.useMemo(()=>S.find(s=>s.id===te),[S,te]),He=((Xe=se==null?void 0:se.hint)==null?void 0:Xe[Q])||((Ye=se==null?void 0:se.hint)==null?void 0:Ye.en)||"",jt=it({required:(p==null?void 0:p.kind)==="device_code",hasDefault:!!((Ze=p==null?void 0:p.defaultMethodId)!=null&&Ze.trim()),optionCount:S.length}),We=((Je=p==null?void 0:p.note)==null?void 0:Je[Q])||((et=p==null?void 0:p.note)==null?void 0:et.en)||(p==null?void 0:p.displayName)||"",Me=((o==null?void 0:o.wireApiOptions)||["auto","chat","responses"]).map(s=>({value:s,label:s==="chat"?n("wireApiChat"):s==="responses"?n("wireApiResponses"):n("wireApiAuto")})),bt=it({required:!!(o!=null&&o.supportsWireApi),hasDefault:typeof(o==null?void 0:o.defaultWireApi)=="string"&&o.defaultWireApi.length>0,optionCount:Me.length}),L=f.useCallback(()=>{pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null)},[]),qe=f.useCallback((s,c)=>{L(),pe.current=window.setTimeout(()=>{(async()=>{if(t)try{const h=await w.mutateAsync({provider:t,data:{sessionId:s}});if(h.status==="pending"){z(n("providerAuthWaitingBrowser")),qe(s,h.nextPollMs??c);return}if(h.status==="authorized"){W(null),L(),z(n("providerAuthCompleted")),F.success(n("providerAuthCompleted")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]});return}W(null),L(),z(h.message||`Authorization ${h.status}.`),F.error(h.message||`Authorization ${h.status}.`)}catch(h){W(null),L();const m=h instanceof Error?h.message:String(h);z(m),F.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,c))},[L,w,t,a]);f.useEffect(()=>{if(!t){k(""),P(""),re(null),v("auto"),M([]),_({}),$(""),Y(""),W(null),z(""),he(""),L();return}k(""),P(ae),re(T.extraHeaders||null),v(ie),M(G),_(oe),$(""),Y(ee),W(null),z(""),he(xe),L()},[t,ae,T.extraHeaders,ie,G,oe,ee,xe,L]),f.useEffect(()=>()=>L(),[L]),f.useEffect(()=>{_(s=>De(s,N))},[N]);const Ue=f.useMemo(()=>{if(!t)return!1;const s=D.trim().length>0,c=A.trim()!==ae.trim(),h=!nt(R,Ae),m=o!=null&&o.supportsWireApi?x!==ie:!1,y=!je(N,G),C=!rt(E,oe),ge=Z?U.trim()!==ee:!1;return s||c||h||m||y||C||ge},[t,Z,U,ee,D,A,ae,R,Ae,o==null?void 0:o.supportsWireApi,x,ie,N,G,E,oe]),Ge=()=>{const s=ce(H,q);if(s){if(N.includes(s)){$("");return}M(c=>[...c,s]),$("")}},vt=(s,c)=>{_(h=>{const m=h[s],y=(m==null?void 0:m.supported)??[],C=y.includes(c)?y.filter(V=>V!==c):Ee.filter(V=>V===c||y.includes(V));if(C.length===0){const V={...h};return delete V[s],V}const ge=m!=null&&m.default&&C.includes(m.default)?m.default:void 0;return{...h,[s]:ge?{supported:C,default:ge}:{supported:C}}})},wt=(s,c)=>{_(h=>{const m=h[s];return!m||m.supported.length===0||c&&!m.supported.includes(c)?h:{...h,[s]:c?{supported:m.supported,default:c}:{supported:m.supported}}})},Nt=s=>{if(s.preventDefault(),!t)return;const c={},h=D.trim(),m=A.trim(),y=de(R),C=U.trim();Z&&C!==ee&&(c.displayName=C.length>0?C:null),h.length>0&&(c.apiKey=h),m!==ae.trim()&&(c.apiBase=m.length>0&&m!==Ce?m:null),nt(y,Ae)||(c.extraHeaders=y),o!=null&&o.supportsWireApi&&x!==ie&&(c.wireApi=x),je(N,G)||(c.models=ds(N,Pe)),rt(E,oe)||(c.modelThinking=De(E,N)),d.mutate({provider:t,data:c})},Ct=async()=>{if(!t)return;const s=N.find(m=>m.trim().length>0)??"",c=ce(s,q),h={apiBase:A.trim(),extraHeaders:de(R),model:c||null};D.trim().length>0&&(h.apiKey=D.trim()),o!=null&&o.supportsWireApi&&(h.wireApi=x);try{const m=await j.mutateAsync({provider:t,data:h});if(m.success){F.success(`${n("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const y=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&y.push(`model=${m.model}`),F.error(`${n("providerTestConnectionFailed")}: ${m.message} | ${y.join(" | ")}`)}catch(m){const y=m instanceof Error?m.message:String(m);F.error(`${n("providerTestConnectionFailed")}: ${y}`)}},At=async()=>{if(!(!t||!Z||!window.confirm(n("providerDeleteConfirm"))))try{await u.mutateAsync({provider:t}),r==null||r(t)}catch{}},Pt=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{z("");const s=await b.mutateAsync({provider:t,data:te?{methodId:te}:{}});if(!s.sessionId||!s.verificationUri)throw new Error(n("providerAuthStartFailed"));W(s.sessionId),z(`${n("providerAuthOpenPrompt")}${s.userCode}${n("providerAuthOpenPromptSuffix")}`),window.open(s.verificationUri,"_blank","noopener,noreferrer"),qe(s.sessionId,s.intervalMs)}catch(s){const c=s instanceof Error?s.message:String(s);W(null),L(),z(c),F.error(`${n("providerAuthStartFailed")}: ${c}`)}},Mt=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{L(),W(null);const s=await I.mutateAsync({provider:t}),c=s.expiresAt?` (expires: ${s.expiresAt})`:"";z(`${n("providerAuthImportStatusPrefix")}${c}`),F.success(n("providerAuthImportSuccess")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]})}catch(s){const c=s instanceof Error?s.message:String(s);z(c),F.error(`${n("providerAuthImportFailed")}: ${c}`)}};if(!t||!o)return e.jsx("div",{className:Qt,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:n("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:n("providersSelectDescription")})]})});const Tt=T.apiKeySet?n("statusReady"):n("statusSetup");return e.jsxs("div",{className:Vt,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:gt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:At,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:n("providerDelete"),children:e.jsx(lt,{className:"h-4 w-4"})}),e.jsx(ht,{status:T.apiKeySet?"ready":"setup",label:Tt})]})]})}),e.jsxs("form",{onSubmit:Nt,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:[Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:n("providerDisplayName")}),e.jsx(X,{id:"providerDisplayName",type:"text",value:U,onChange:s=>Y(s.target.value),placeholder:Ke||n("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(J==null?void 0:J.label)??n("apiKey")}),e.jsx(ns,{id:"apiKey",value:D,isSet:T.apiKeySet,onChange:s=>k(s.target.value),placeholder:(J==null?void 0:J.placeholder)??n("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||n("providerAuthSectionTitle")}),We?e.jsx("p",{className:"text-xs text-gray-600",children:We}):null,S.length>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerAuthMethodLabel")}),jt?e.jsx(ot,{value:te,onChange:he,options:Re}):e.jsxs(Te,{value:te,onValueChange:he,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white",children:e.jsx(Se,{placeholder:n("providerAuthMethodPlaceholder")})}),e.jsx(Le,{children:Re.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]}),He?e.jsx("p",{className:"text-xs text-gray-500",children:He}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:Pt,disabled:b.isPending||!!me,children:b.isPending?n("providerAuthStarting"):me?n("providerAuthAuthorizing"):n("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:Mt,disabled:I.isPending,children:I.isPending?n("providerAuthImporting"):n("providerAuthImportFromCli")}):null,me?e.jsxs("span",{className:"text-xs text-gray-500",children:[n("providerAuthSessionLabel"),": ",me.slice(0,8),"…"]}):null]}),ze?e.jsx("p",{className:"text-xs text-gray-600",children:ze}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(K==null?void 0:K.label)??n("apiBase")}),e.jsx(X,{id:"apiBase",type:"text",value:A,onChange:s=>P(s.target.value),placeholder:Ce||(K==null?void 0:K.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:yt})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:n("providerModelsTitle")}),!ve&&e.jsxs("button",{type:"button",onClick:()=>ue(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(_e,{className:"h-3 w-3"}),n("providerAddModel")]})]}),ve&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:H,onChange:s=>$(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Ge()),s.key==="Escape"&&(ue(!1),$(""))},placeholder:n("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(B,{type:"button",size:"sm",onClick:Ge,disabled:H.trim().length===0,children:n("add")}),e.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ue(!1),$("")},children:e.jsx(tt,{className:"h-4 w-4"})})]}),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:n("providerModelsEmptyShort")}),!ve&&e.jsx("button",{type:"button",onClick:()=>ue(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:n("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(s=>{const c=E[s],h=(c==null?void 0:c.supported)??[],m=(c==null?void 0:c.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:s}),e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("providerModelThinkingTitle"),title:n("providerModelThinkingTitle"),children:e.jsx(st,{className:"h-3 w-3"})})}),e.jsxs(pt,{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:n("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ee.map(y=>{const C=h.includes(y);return e.jsx("button",{type:"button",onClick:()=>vt(s,y),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${C?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:at(y)},y)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerModelThinkingDefault")}),e.jsxs(Te,{value:m??"__none__",onValueChange:y=>wt(s,y==="__none__"?null:y),disabled:h.length===0,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(Se,{})}),e.jsxs(Le,{children:[e.jsx(ye,{value:"__none__",children:n("providerModelThinkingDefaultNone")}),h.map(y=>e.jsx(ye,{value:y,children:at(y)},y))]})]}),h.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>{M(y=>y.filter(C=>C!==s)),_(y=>{const C={...y};return delete C[s],C})},className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("remove"),children:e.jsx(tt,{className:"h-3 w-3"})})]},s)})})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>xt(!be),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),n("providerAdvancedSettings")]}),e.jsx(It,{className:`h-4 w-4 transition-transform ${be?"rotate-180":""}`})]}),be&&e.jsxs("div",{className:"mt-4 space-y-5",children:[o.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(Ne==null?void 0:Ne.label)??n("wireApi")}),bt?e.jsx(ot,{value:x,onChange:s=>v(s),options:Me}):e.jsxs(Te,{value:x,onValueChange:s=>v(s),children:[e.jsx(ke,{className:"rounded-xl",children:e.jsx(Se,{})}),e.jsx(Le,{children:Me.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(we==null?void 0:we.label)??n("extraHeaders")}),e.jsx(rs,{value:R,onChange:re}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:Ct,disabled:j.isPending,children:[e.jsx(Dt,{className:"mr-1.5 h-4 w-4"}),j.isPending?n("providerTestingConnection"):n("providerTestConnection")]}),e.jsx(B,{type:"submit",disabled:d.isPending||!Ue,children:d.isPending?n("saving"):Ue?n("save"):n("unchanged")})]})]})]})}function ps(t){if(!t)return null;try{const r=new URL(t),a=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${a}`}catch{return t.replace(/^https?:\/\//,"")}}function Ts(){const{data:t}=ct(),{data:r}=dt(),{data:a}=ut(),i=Ht(),[l,g]=f.useState("installed"),[d,u]=f.useState(),[j,b]=f.useState(""),w=a==null?void 0:a.uiHints,I=(r==null?void 0:r.providers)??[],D=(t==null?void 0:t.providers)??{},k=I.filter(x=>{var v;return(v=D[x.name])==null?void 0:v.apiKeySet}).length,A=[{id:"installed",label:n("providersTabConfigured"),count:k},{id:"all",label:n("providersTabAll"),count:I.length}],P=f.useMemo(()=>{const x=(r==null?void 0:r.providers)??[],v=(t==null?void 0:t.providers)??{},N=j.trim().toLowerCase();return x.filter(M=>{var E;return l==="installed"?!!((E=v[M.name])!=null&&E.apiKeySet):!0}).filter(M=>{var H,$;return N?((($=(H=v[M.name])==null?void 0:H.displayName)==null?void 0:$.trim())||M.displayName||M.name).toLowerCase().includes(N)||M.name.toLowerCase().includes(N):!0})},[r,t,l,j]);f.useEffect(()=>{if(P.length===0){u(void 0);return}P.some(v=>v.name===d)||u(P[0].name)},[P,d]);const R=d,re=async()=>{try{const x=await i.mutateAsync({data:{}});g("all"),b(""),u(x.name)}catch{}};return!t||!r?e.jsx("div",{className:"p-8",children:n("providersLoading")}):e.jsxs(Jt,{children:[e.jsx(es,{title:n("providersPageTitle"),description:n("providersPageDescription")}),e.jsxs("div",{className:Xt,children:[e.jsxs("section",{className:Yt,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Zt,{tabs:A,activeTab:l,onChange:g,className:"mb-0"}),e.jsxs(B,{type:"button",variant:"outline",className:"w-full justify-center",onClick:re,disabled:i.isPending,children:[e.jsx(_e,{className:"mr-2 h-4 w-4"}),i.isPending?n("saving"):n("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Et,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(X,{value:j,onChange:x=>b(x.target.value),placeholder:n("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:[P.map(x=>{var Y;const v=t.providers[x.name],N=!!(v!=null&&v.apiKeySet),M=R===x.name,E=((Y=v==null?void 0:v.displayName)==null?void 0:Y.trim())||x.displayName||x.name,_=le(`providers.${x.name}`,w),H=(v==null?void 0:v.apiBase)||x.defaultApiBase||"",U=ps(H)||(_==null?void 0:_.help)||n("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(x.name),className:ne("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(Gt,{name:x.name,src:x.logo?`/logos/${x.logo}`:null,className:ne("h-10 w-10 rounded-lg border",N?"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:x.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:E}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:U})]})]}),e.jsx(ht,{status:N?"ready":"setup",label:N?n("statusReady"):n("statusSetup"),className:"min-w-[56px] justify-center"})]})},x.name)}),P.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(_t,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:n("providersNoMatch")})]})]})]}),e.jsx(hs,{providerName:R,onProviderDeleted:x=>{x===d&&u(void 0)}})]})]})}export{Ts as ProvidersList};
@@ -0,0 +1 @@
1
+ import{r as p,j as e,ap as ee,a3 as ae,aU as de,e as se}from"./vendor-psXJBy9u.js";import{u as me,b as he,a0 as ue,t,C as R,a1 as $,a2 as z,a3 as D,z 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-CzkY1reu.js";import{S as pe}from"./switch-C24d-UJU.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-Db0GbnhS.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),[G,J]=p.useState(2e5),[Q,W]=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),J(d.agents.defaults.contextTokens??2e5),W(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 X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.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,G),engine:Q.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:G,onChange:a=>J(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:Q,onChange:a=>W(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};
@@ -0,0 +1 @@
1
+ import{r as l,j as e,s as X,a8 as Z,K as $}from"./vendor-psXJBy9u.js";import{P as ee,a as se}from"./page-layout-Db0GbnhS.js";import{u as ae,a as re,P 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-CzkY1reu.js";import{L as c}from"./label-CmksBHgc.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,ao as H,a1 as L,aT as z,d as G}from"./vendor-BKtTvQYU.js";import{u as J,Y as K,t as a,S as x,e as m,f as p,g as j,h as o}from"./index-DJZ5y7t1.js";import{P as Q,a as W,B as _}from"./page-layout-CERNdqzB.js";import{C as R,b as T,c as M,d as O,a as A}from"./card-BAM7vbMg.js";import{I as h}from"./input-BoelTiYL.js";import{L as k}from"./label-DkL14Jvl.js";import{S as X}from"./switch-CgbPbIX3.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,ap as H,a3 as L,aU as G,e as J}from"./vendor-psXJBy9u.js";import{u as K,ac as Q,t as a,C as R,a1 as T,a2 as M,a3 as O,z as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-CzkY1reu.js";import{L as k}from"./label-CmksBHgc.js";import{S as W}from"./switch-C24d-UJU.js";import{P as X,a as Y}from"./page-layout-Db0GbnhS.js";const U=["env","file","exec"];function P(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"?{...P(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...P(n),source:"file",path:l.path}:{...P(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 oe(){const{data:n,isLoading:l}=J(),P=K(),[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))},Y=()=>{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(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(X,{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:Y,disabled:P.isPending,children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),P.isPending?a("saving"):a("save")]})})]})}export{oe 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}=K(),b=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))},N=(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}}b.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);J.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,P()]),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=>N(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>N(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>N(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=>N(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:z,disabled:b.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),b.isPending?a("saving"):a("save")]})})]})}export{ie as SecretsConfig};
@@ -0,0 +1,2 @@
1
+ import{r,j as e,aq as I,s as J,aV as T,aS as X,z as Z,M as q,aW as ee,ab as se,ad as te}from"./vendor-psXJBy9u.js";import{u as ae}from"./useConfirmDialog-BeP35LcG.js";import{j as re,i as ne,l as le,a9 as ie,aa as oe,t,B as f,c as i,S as de,e as ce,f as xe,g as me,h as U,I as k,ab as ue,s as he}from"./index-CzkY1reu.js";import{b as ge,a as fe,S as ye,e as be}from"./chat-message-pxr79GDs.js";import{P as pe,a as je}from"./page-layout-Db0GbnhS.js";import"./index-GdpEEKnz.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const b=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"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:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:b})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"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:d?e.jsx(ye,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(q,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function we({message:a}){const l=a.role.toLowerCase()==="user",d=be(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"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:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{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:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function _e(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,b]=r.useState(null),[m,Q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),p=ie(),_=oe(),{confirm:z,ConfirmDialog:V}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),P=r.useMemo(()=>{var s;return ge(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),O=r.useMemo(()=>fe(P),[P]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),W=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const $=()=>{n&&(p.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},Y=async()=>{if(!n)return;await z({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&p.mutate({key:n,data:{clearHistory:!0}})},G=async()=>{if(!n)return;await z({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>b(null)})};return e.jsxs(pe,{fullHeight:!0,children:[e.jsx(je,{title:t("sessionsPageTitle"),description:t("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:[c.length," ",t("sessionsListTitle")]}),e.jsx(f,{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(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:Q,children:[e.jsx(ce,{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(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(U,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),W.map(s=>e.jsx(U,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),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:t("sessionsLoading")}):H.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(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:O.get(s.key),isSelected:n===s.key,onSelect:()=>b(s.key)},s.key))})]}),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:[(p.isPending||_.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"})}),n&&o?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(X,{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:o.label||o.key.split(":").pop()||o.key}),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:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(f,{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:t("delete")})]})]}),w&&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(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:$,className:"h-8 px-4 shrink-0 shadow-none",disabled:p.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
2
+ [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[u.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(I,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),u.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:u.error.message}),!u.isLoading&&((K=u.data)==null?void 0:K.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(q,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((R=u.data)==null?void 0:R.messages)??[]).map((s,h)=>e.jsx(we,{message:s},`${s.timestamp}-${h}`))})]})]}):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(T,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(V,{})]})}export{_e as SessionsConfig};
@@ -1,3 +1,3 @@
1
- import{j as u,a0 as m}from"./vendor-BKtTvQYU.js";import{t as p,c as g}from"./index-DJZ5y7t1.js";function R({status:t,className:n}){const e=t==="running"?p("sessionsRunStatusRunning"):p("sessionsRunStatusQueued");return u.jsxs("span",{className:g("inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400",n),title:e,"aria-label":e,children:[u.jsx(m,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:"sr-only",children:e})]})}const d=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
2
- …`}function a(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t==null)return"";try{return f(JSON.stringify(t,null,2))}catch{return String(t)}}function h(t){if(c(t))return t;if(typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const e=JSON.parse(n);return c(e)?e:null}catch{return null}}function A(t){const n=h(t);if(!n){const r=a(t).trim();return r?f(r,120):void 0}const e=[];for(const r of d){const s=n[r];if(typeof s=="string"&&s.trim()?e.push(`${r}: ${s.trim()}`):(typeof s=="number"||typeof s=="boolean")&&e.push(`${r}: ${String(s)}`),e.length>=2)break}return e.length>0?e.join(" · "):f(a(n),140)}function j(t){if(typeof t=="string")return t;if(Array.isArray(t)){const n=[];for(const e of t){if(typeof e=="string"){n.push(e);continue}if(c(e)){if(typeof e.text=="string"){n.push(e.text);continue}typeof e.content=="string"&&n.push(e.content)}}if(n.length>0)return n.join(`
3
- `)}return a(t)}const l={queued:1,running:2};function o(t){return t==="queued"||t==="running"?t:null}function y(t){const n=Date.parse(t??"");return Number.isFinite(n)?n:0}function S(t,n){const e=o(t.state),r=o(n.state);if(!e||!r)return!1;const s=l[e],i=l[r];return i!==s?i>s:y(n.requestedAt)>=y(t.requestedAt)}function T(t){var e;const n=new Map;for(const r of t){const s=(e=r.sessionKey)==null?void 0:e.trim();if(!s||!o(r.state))continue;const i=n.get(s);(!i||S(i,r))&&n.set(s,r)}return n}function N(t){const n=new Map;for(const[e,r]of t.entries()){const s=o(r.state);s&&n.set(e,s)}return n}export{R as S,a,T as b,N as c,j as e,A as s};
1
+ import{j as u,a2 as m}from"./vendor-psXJBy9u.js";import{t as p,c as g}from"./index-CzkY1reu.js";const l={queued:1,running:2};function o(t){return t==="queued"||t==="running"?t:null}function y(t){const n=Date.parse(t??"");return Number.isFinite(n)?n:0}function d(t,n){const e=o(t.state),r=o(n.state);if(!e||!r)return!1;const s=l[e],i=l[r];return i!==s?i>s:y(n.requestedAt)>=y(t.requestedAt)}function R(t){var e;const n=new Map;for(const r of t){const s=(e=r.sessionKey)==null?void 0:e.trim();if(!s||!o(r.state))continue;const i=n.get(s);(!i||d(i,r))&&n.set(s,r)}return n}function A(t){const n=new Map;for(const[e,r]of t.entries()){const s=o(r.state);s&&n.set(e,s)}return n}function j({status:t,className:n}){const e=t==="running"?p("sessionsRunStatusRunning"):p("sessionsRunStatusQueued");return u.jsxs("span",{className:g("inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400",n),title:e,"aria-label":e,children:[u.jsx(m,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:"sr-only",children:e})]})}const h=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
2
+ …`}function a(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t==null)return"";try{return f(JSON.stringify(t,null,2))}catch{return String(t)}}function S(t){if(c(t))return t;if(typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const e=JSON.parse(n);return c(e)?e:null}catch{return null}}function T(t){const n=S(t);if(!n){const r=a(t).trim();return r?f(r,120):void 0}const e=[];for(const r of h){const s=n[r];if(typeof s=="string"&&s.trim()?e.push(`${r}: ${s.trim()}`):(typeof s=="number"||typeof s=="boolean")&&e.push(`${r}: ${String(s)}`),e.length>=2)break}return e.length>0?e.join(" · "):f(a(n),140)}function N(t){if(typeof t=="string")return t;if(Array.isArray(t)){const n=[];for(const e of t){if(typeof e=="string"){n.push(e);continue}if(c(e)){if(typeof e.text=="string"){n.push(e.text);continue}typeof e.content=="string"&&n.push(e.content)}}if(n.length>0)return n.join(`
3
+ `)}return a(t)}export{j as S,A as a,R as b,a as c,N as e,T as s};
@@ -0,0 +1 @@
1
+ import{r as i,az as L,j as u,aA as G,aB as H,aC as A,aD as O,aE as P,aF as _,aG as E,aH as K,aI as $,aJ as z,aK as B,aL as J,aM as Q,aN as U,aO as V,aP as W,aQ as Z}from"./vendor-psXJBy9u.js";import{P as w}from"./index-GdpEEKnz.js";var x="Popover",[j]=$(x,[E]),g=E(),[q,d]=j(x),F=e=>{const{__scopePopover:n,children:t,open:a,defaultOpen:o,onOpenChange:r,modal:s=!1}=e,c=g(n),p=i.useRef(null),[l,h]=i.useState(!1),[C,f]=L({prop:a,defaultProp:o??!1,onChange:r,caller:x});return u.jsx(G,{...c,children:u.jsx(q,{scope:n,contentId:H(),triggerRef:p,open:C,onOpenChange:f,onOpenToggle:i.useCallback(()=>f(R=>!R),[f]),hasCustomAnchor:l,onCustomAnchorAdd:i.useCallback(()=>h(!0),[]),onCustomAnchorRemove:i.useCallback(()=>h(!1),[]),modal:s,children:t})})};F.displayName=x;var N="PopoverAnchor",b=i.forwardRef((e,n)=>{const{__scopePopover:t,...a}=e,o=d(N,t),r=g(t),{onCustomAnchorAdd:s,onCustomAnchorRemove:c}=o;return i.useEffect(()=>(s(),()=>c()),[s,c]),u.jsx(_,{...r,...a,ref:n})});b.displayName=N;var S="PopoverTrigger",y=i.forwardRef((e,n)=>{const{__scopePopover:t,...a}=e,o=d(S,t),r=g(t),s=A(n,o.triggerRef),c=u.jsx(O.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":k(o.open),...a,ref:s,onClick:P(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:u.jsx(_,{asChild:!0,...r,children:c})});y.displayName=S;var m="PopoverPortal",[X,Y]=j(m,{forceMount:void 0}),D=e=>{const{__scopePopover:n,forceMount:t,children:a,container:o}=e,r=d(m,n);return u.jsx(X,{scope:n,forceMount:t,children:u.jsx(w,{present:t||r.open,children:u.jsx(K,{asChild:!0,container:o,children:a})})})};D.displayName=m;var v="PopoverContent",M=i.forwardRef((e,n)=>{const t=Y(v,e.__scopePopover),{forceMount:a=t.forceMount,...o}=e,r=d(v,e.__scopePopover);return u.jsx(w,{present:a||r.open,children:r.modal?u.jsx(oe,{...o,ref:n}):u.jsx(re,{...o,ref:n})})});M.displayName=v;var ee=J("PopoverContent.RemoveScroll"),oe=i.forwardRef((e,n)=>{const t=d(v,e.__scopePopover),a=i.useRef(null),o=A(n,a),r=i.useRef(!1);return i.useEffect(()=>{const s=a.current;if(s)return z(s)},[]),u.jsx(B,{as:ee,allowPinchZoom:!0,children:u.jsx(I,{...e,ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:P(e.onCloseAutoFocus,s=>{var c;s.preventDefault(),r.current||(c=t.triggerRef.current)==null||c.focus()}),onPointerDownOutside:P(e.onPointerDownOutside,s=>{const c=s.detail.originalEvent,p=c.button===0&&c.ctrlKey===!0,l=c.button===2||p;r.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:P(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),re=i.forwardRef((e,n)=>{const t=d(v,e.__scopePopover),a=i.useRef(!1),o=i.useRef(!1);return u.jsx(I,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var s,c;(s=e.onCloseAutoFocus)==null||s.call(e,r),r.defaultPrevented||(a.current||(c=t.triggerRef.current)==null||c.focus(),r.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:r=>{var p,l;(p=e.onInteractOutside)==null||p.call(e,r),r.defaultPrevented||(a.current=!0,r.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=r.target;((l=t.triggerRef.current)==null?void 0:l.contains(s))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&o.current&&r.preventDefault()}})}),I=i.forwardRef((e,n)=>{const{__scopePopover:t,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:r,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:p,onFocusOutside:l,onInteractOutside:h,...C}=e,f=d(v,t),R=g(t);return Q(),u.jsx(U,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:r,children:u.jsx(V,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:p,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:u.jsx(W,{"data-state":k(f.open),role:"dialog",id:f.contentId,...R,...C,ref:n,style:{...C.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),T="PopoverClose",te=i.forwardRef((e,n)=>{const{__scopePopover:t,...a}=e,o=d(T,t);return u.jsx(O.button,{type:"button",...a,ref:n,onClick:P(e.onClick,()=>o.onOpenChange(!1))})});te.displayName=T;var ne="PopoverArrow",ae=i.forwardRef((e,n)=>{const{__scopePopover:t,...a}=e,o=g(t);return u.jsx(Z,{...o,...a,ref:n})});ae.displayName=ne;function k(e){return e?"open":"closed"}var ie=F,ue=b,pe=y,le=D,de=M;export{ue as A,de as C,le as P,ie as R,pe as T};