nextclaw 0.21.2 → 0.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/app/index.js +1 -1
- package/dist/cli/app/index.js.map +1 -1
- package/package.json +16 -16
- package/resources/USAGE.md +2 -2
- package/ui-dist/assets/{api-BCDb13Uv.js → api-CIJxdHmy.js} +5 -5
- package/ui-dist/assets/app-presenter-provider-CKZqZfv5.js +3 -0
- package/ui-dist/assets/arrow-left-DHcD-tbC.js +1 -0
- package/ui-dist/assets/channels-list-page-C_Xe0CNX.js +8 -0
- package/ui-dist/assets/chat-page-CXRtoQR2.js +105 -0
- package/ui-dist/assets/{config-split-page-BwhGqmUS.js → config-split-page-DBAcw9mJ.js} +1 -1
- package/ui-dist/assets/{confirm-dialog-DBkKcQ1q.js → confirm-dialog-DwPTxq8C.js} +1 -1
- package/ui-dist/assets/{desktop-update-config-BE9KjiXi.js → desktop-update-config-BqABa_1C.js} +1 -1
- package/ui-dist/assets/{dist-BI0bX8jv.js → dist-BfcibKyv.js} +1 -1
- package/ui-dist/assets/{dist-C8JRt-tf.js → dist-WjhKB-pc.js} +1 -1
- package/ui-dist/assets/{doc-browser-eqdNEerh.js → doc-browser-8EEDwGCJ.js} +1 -1
- package/ui-dist/assets/doc-browser-DlT90zQD.js +1 -0
- package/ui-dist/assets/{doc-browser-context-VHUOIUXL.js → doc-browser-context-DLJOy6Am.js} +1 -1
- package/ui-dist/assets/{ellipsis-C9VB2CxT.js → ellipsis-H-4aNwgt.js} +1 -1
- package/ui-dist/assets/{es2015-BCw3Q7nY.js → es2015-B5k1IpKX.js} +1 -1
- package/ui-dist/assets/{external-link-Bp7_4s9t.js → external-link-BN1wd-eI.js} +1 -1
- package/ui-dist/assets/{index-DTdPDqto.js → index-WJt0X9wC.js} +5 -5
- package/ui-dist/assets/{key-round-Ccy6oND3.js → key-round-D-7IaAQS.js} +1 -1
- package/ui-dist/assets/{loader-circle-OpH4EErP.js → loader-circle-CB38Q7Ws.js} +1 -1
- package/ui-dist/assets/mcp-marketplace-page-CmZwt64F.js +1 -0
- package/ui-dist/assets/{mcp-marketplace-page-B-GxKOqS.js → mcp-marketplace-page-ju1KH3TG.js} +2 -2
- package/ui-dist/assets/{model-config-BXPnV_7n.js → model-config-CgS6dp65.js} +1 -1
- package/ui-dist/assets/{notice-card-Dsbkl7u7.js → notice-card-DW9BLKpG.js} +1 -1
- package/ui-dist/assets/play-DGpH8jeI.js +1 -0
- package/ui-dist/assets/plus-CkcQjwuH.js +1 -0
- package/ui-dist/assets/{popover-BTLZE5Iz.js → popover-ofN845gZ.js} +1 -1
- package/ui-dist/assets/{provider-scoped-model-input-DKI9KN7N.js → provider-scoped-model-input-DaDqi8Zy.js} +1 -1
- package/ui-dist/assets/providers-list-CZNQXY4n.js +1 -0
- package/ui-dist/assets/{react-BqS8oMyM.js → react-Bq34NL59.js} +1 -1
- package/ui-dist/assets/{refresh-cw-BIaj7txb.js → refresh-cw-DJttSXS8.js} +1 -1
- package/ui-dist/assets/remote-CYmsM9DD.js +1 -0
- package/ui-dist/assets/rotate-cw-D_xslHna.js +1 -0
- package/ui-dist/assets/{runtime-config-page-DX_wSK1J.js → runtime-config-page-gUjM6Z_A.js} +1 -1
- package/ui-dist/assets/{save-BEoORten.js → save-DtAFbS7x.js} +1 -1
- package/ui-dist/assets/search-CNMRwAFx.js +1 -0
- package/ui-dist/assets/{search-config-DA5By-tE.js → search-config-C04PrmHj.js} +1 -1
- package/ui-dist/assets/{secrets-config-eDxG7iN4.js → secrets-config-DvxHdz9h.js} +2 -2
- package/ui-dist/assets/{status-dot-oWBjTovo.js → status-dot-D4jbKDLB.js} +1 -1
- package/ui-dist/assets/{tabs-CGaY0BVO.js → tabs-Ca2vw7YQ.js} +1 -1
- package/ui-dist/assets/{tabs-custom-D2fPYb4G.js → tabs-custom-DzGDjYxf.js} +1 -1
- package/ui-dist/assets/{tag-chip-TVkgofS1.js → tag-chip-CW-_pHjH.js} +1 -1
- package/ui-dist/assets/{tooltip-BwHPKBv9.js → tooltip-Cq2mERPk.js} +1 -1
- package/ui-dist/assets/{trash-2-D3psAGrz.js → trash-2-rumaEu9l.js} +1 -1
- package/ui-dist/assets/x-DGqjdMUt.js +1 -0
- package/ui-dist/index.html +24 -24
- package/ui-dist/assets/app-presenter-provider-C-QMjK7m.js +0 -3
- package/ui-dist/assets/arrow-left-rIXFA2Zy.js +0 -1
- package/ui-dist/assets/channels-list-page-DnqwsKGe.js +0 -8
- package/ui-dist/assets/chat-page-CsQx20xL.js +0 -105
- package/ui-dist/assets/doc-browser-lpF_pyx4.js +0 -1
- package/ui-dist/assets/mcp-marketplace-page-Dm-0-w51.js +0 -1
- package/ui-dist/assets/play-CvgYhNbo.js +0 -1
- package/ui-dist/assets/plus-DHcP-K1U.js +0 -1
- package/ui-dist/assets/providers-list-Bko6B7dE.js +0 -1
- package/ui-dist/assets/remote-DHn_b8QU.js +0 -1
- package/ui-dist/assets/rotate-cw-DMqSkRJQ.js +0 -1
- package/ui-dist/assets/search-COFh_SFI.js +0 -1
- package/ui-dist/assets/x-CHAxzyp2.js +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import{d as e,g as t,i as n,m as r,y as i}from"./react-BqS8oMyM.js";import{D as a,I as o,L as s,R as c,w as l}from"./app-presenter-provider-C-QMjK7m.js";import{A as u,Bt as d,D as f,Dt as p,E as m,Et as h,Ft as g,Gt as _,Jt as v,Kt as y,Mt as b,O as x,Pt as S,Qt as C,Ut as w,Vt as T,Wt as E,Xt as D,Yt as O,an as k,in as A,j as ee,jt as te,k as ne,nn as re,on as j,qt as M,rn as N,sn as ie,yt as P,zt as F}from"./api-BCDb13Uv.js";import{a as ae,c as oe,i as se,l as I,n as ce,o as le,r as ue,s as L}from"./mcp-marketplace-page-B-GxKOqS.js";import{c as R}from"./dist-C8JRt-tf.js";import{a as de,i as z,n as B,o as fe,r as V,s as pe}from"./confirm-dialog-DBkKcQ1q.js";import{t as me}from"./arrow-left-rIXFA2Zy.js";import{i as he,n as ge,r as _e,t as ve}from"./tooltip-BwHPKBv9.js";import{t as ye}from"./provider-scoped-model-input-DKI9KN7N.js";import{t as be}from"./ellipsis-C9VB2CxT.js";import{t as xe}from"./play-CvgYhNbo.js";import{t as Se}from"./plus-DHcP-K1U.js";import{t as Ce}from"./refresh-cw-BIaj7txb.js";import{t as we}from"./trash-2-D3psAGrz.js";import{t as Te}from"./notice-card-Dsbkl7u7.js";import{n as Ee,r as De,t as Oe}from"./popover-BTLZE5Iz.js";import{n as ke}from"./doc-browser-context-VHUOIUXL.js";import{A as Ae,At as je,B as Me,C as Ne,Ct as Pe,D as Fe,E as Ie,Et as Le,F as Re,Ft as ze,H as Be,I as H,J as U,K as Ve,L as He,M as Ue,N as We,O as Ge,Ot as Ke,P as qe,Pt as Je,R as Ye,Rt as Xe,S as Ze,T as Qe,V as $e,X as et,Y as tt,Z as nt,_ as rt,a as it,b as at,c as ot,d as st,dt as ct,f as lt,g as ut,h as dt,i as ft,j as pt,jt as mt,k as ht,l as gt,lt as _t,m as vt,mt as yt,n as bt,nt as xt,o as St,ot as Ct,p as wt,q as Tt,r as Et,s as Dt,st as Ot,t as kt,tt as At,u as W,ut as jt,v as Mt,w as Nt,wt as Pt,x as G,y as K,z as Ft,zt as It}from"./index-DTdPDqto.js";import{t as Lt}from"./tabs-custom-D2fPYb4G.js";import{t as Rt}from"./tag-chip-TVkgofS1.js";import{c as zt,n as Bt,r as Vt}from"./provider-models-C_yOh6DE.js";function Ht(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ut(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wt=class extends ie{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,N.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!j(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ht(e,n).forEach(e=>{e.destroy()}),Ht(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=k(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new re(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ut(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&N.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},q=i(t(),1);function Gt({queries:e,...t},n){let r=C(n),i=D(),a=O(),o=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{w(e),y(e,a,r.getQueryCache().get(e.queryHash))}),v(a);let[s]=q.useState(()=>new Wt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;q.useSyncExternalStore(q.useCallback(e=>d?s.subscribe(N.batchCalls(e)):A,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>_(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&_(n,e)?E(n,new re(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&M({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var Kt=R(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),qt=R(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Jt=R(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Yt=R(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Xt=R(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Zt=R(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),Qt=R(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),$t=R(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),J=r(),en=q.forwardRef(({className:t,...n},r)=>(0,J.jsx)(`textarea`,{className:e(`flex min-h-28 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t),ref:r,...n}));en.displayName=`Textarea`;function tn(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function nn(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=K(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:G(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function rn({value:e,disabled:t=!1,runtimeOptions:r,defaultRuntime:i,onChange:a}){let o=e.trim()?K(e):``,s=nn({runtimeOptions:r,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?n(`agentsRuntimeUnavailableHelp`):``);return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(Ve,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,J.jsx)(tt,{"aria-label":n(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,J.jsx)(et,{placeholder:n(`agentsRuntimeSelectPlaceholder`)})}),(0,J.jsx)(Tt,{className:`rounded-xl`,children:s.map(e=>(0,J.jsx)(U,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,J.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function an({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,J.jsx)(B,{open:e!==null,onOpenChange:a,children:e?(0,J.jsx)(on,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function on(e){let{agent:t,pending:r,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,u]=(0,q.useState)(tn(t));return(0,J.jsxs)(V,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,J.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,J.jsxs)(fe,{className:`text-left`,children:[(0,J.jsx)(pe,{children:n(`agentsEditDialogTitle`)}),(0,J.jsx)(z,{children:n(`agentsEditDialogDescription`)})]})}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(Te,{tone:`warning`,title:n(`agentsEditHomeReadonly`),description:n(`agentsEditHomeReadonlyHint`),children:(0,J.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(S,{value:l.displayName,onChange:e=>u(t=>({...t,displayName:e.target.value})),placeholder:n(`agentsFormNamePlaceholder`)}),(0,J.jsx)(en,{value:l.description,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:n(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,J.jsx)(S,{value:l.avatar,onChange:e=>u(t=>({...t,avatar:e.target.value})),placeholder:n(`agentsFormAvatarPlaceholder`)}),(0,J.jsx)(ye,{value:l.model,onChange:e=>u(t=>({...t,model:e})),providerCatalog:i,disabled:r,className:`md:col-span-2`}),(0,J.jsx)(rn,{value:l.runtime,onChange:e=>u(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:r})]})]})}),(0,J.jsxs)(de,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,J.jsx)(g,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:r,children:n(`cancel`)}),(0,J.jsxs)(g,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:r,children:[(0,J.jsx)(Ke,{className:`mr-2 h-4 w-4`}),n(`agentsEditSaveAction`)]})]})]})}var sn=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function cn(e){let{agentCount:t,onCreate:r}=e;return(0,J.jsxs)(`section`,{className:`flex flex-col gap-3 border-b border-gray-200 pb-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:n(`agentsHeroEyebrow`)}),(0,J.jsx)(`span`,{className:`rounded-full border border-gray-200 bg-white px-2 py-0.5 text-xs font-medium text-gray-500`,children:t})]}),(0,J.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:n(`agentsHeroDescription`)})]}),(0,J.jsxs)(g,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:r,children:[(0,J.jsx)(Se,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}function ln(t){let{icon:n,label:r,disabled:i=!1,destructive:a=!1,onClick:o}=t;return(0,J.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:o,disabled:i,children:[(0,J.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:r})]})}function un(e){let{agent:t,runtimeOptions:r,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:s,onEdit:c,onDelete:u}=e,d=t.runtime?.trim()||t.engine?.trim()||``,f=d?r.find(e=>e.value===K(d))?.label??G(d):i;return(0,J.jsx)(h,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,J.jsxs)(p,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,J.jsx)(Be,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,J.jsxs)(Rt,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,J.jsx)(l,{className:`h-3 w-3`}),n(`agentsCardBuiltInTag`)]}):null]}),(0,J.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,J.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,J.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":n(`agentsCardStartChat`),title:n(`agentsCardStartChat`),onClick:s,children:(0,J.jsx)(je,{className:`h-4 w-4`})}),(0,J.jsxs)(Oe,{children:[(0,J.jsx)(De,{asChild:!0,children:(0,J.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":n(`chatSessionMoreActions`),title:n(`chatSessionMoreActions`),children:(0,J.jsx)(be,{className:`h-4 w-4`})})}),(0,J.jsxs)(Ee,{align:`end`,className:`w-44 p-1.5`,children:[(0,J.jsx)(ln,{icon:Ke,label:n(`agentsEditAction`),onClick:c,disabled:a}),t.builtIn?null:(0,J.jsx)(ln,{icon:we,label:n(`agentsRemoveAction`),onClick:u,disabled:o,destructive:!0})]})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?n(`agentsCardBuiltInSummary`):n(`agentsCardCustomSummary`))}),(0,J.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,J.jsx)(`span`,{className:`truncate`,children:f})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(mt,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,J.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function dn(){let e=Ft(),t=Ne(),r=nt(),i=jt(),a=_t(),o=Dt(),s=Qe(),c=Nt(),[l,u]=(0,q.useState)(null),d=(0,q.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),f=(0,q.useMemo)(()=>[...d].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[d]),m=(0,q.useMemo)(()=>Bt({config:r.data,providersView:i.data,templatesView:a.data,onlyConfigured:!0}),[r.data,i.data,a.data]),_=(0,q.useMemo)(()=>Mt(o.data?.options??[]),[o.data?.options]),v=(0,q.useMemo)(()=>K(o.data?.defaultType??`native`),[o.data?.defaultType]),y=(0,q.useMemo)(()=>_.find(e=>e.value===v)?.label??G(v),[v,_]),x=e=>{u(e)},S=async(e,t)=>{await s.mutateAsync({agentId:e,data:{displayName:t.displayName,description:t.description,avatar:t.avatar,model:t.model,...t.runtime.trim()?{runtime:t.runtime.trim()}:{runtime:``}}}),u(null)},C=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,at(t,v))};return(0,J.jsxs)(b,{className:`space-y-5`,children:[(0,J.jsx)(cn,{agentCount:d.length,onCreate:()=>e.startAgentCreationDraft(sn)}),(0,J.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,J.jsx)(h,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,J.jsx)(p,{className:`py-14 text-center text-sm text-gray-500`,children:n(`agentsLoading`)})}):f.length===0?(0,J.jsx)(h,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,J.jsxs)(p,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,J.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,J.jsx)(Xe,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,J.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:n(`agentsEmpty`)}),(0,J.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:n(`agentsEmptyDescription`)}),(0,J.jsxs)(g,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>e.startAgentCreationDraft(sn),children:[(0,J.jsx)(Se,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}):f.map(e=>(0,J.jsx)(un,{agent:e,runtimeOptions:_,defaultRuntimeLabel:y,updatePending:s.isPending,deletePending:c.isPending,onStartChat:()=>C(e),onEdit:()=>x(e),onDelete:()=>c.mutate({agentId:e.id})},e.id))}),(0,J.jsx)(an,{agent:l,pending:s.isPending,providerCatalog:m,runtimeOptions:_,defaultRuntime:v,onOpenChange:e=>{!e&&!s.isPending&&u(null)},onSubmit:S})]})}function fn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.sessionId??``,e.payload.channel??``,e.payload.to??``].join(` `).toLowerCase().includes(n):!0}function pn(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function mn(t){let{job:r,onDelete:i,onRun:a,onToggle:o}=t;return(0,J.jsx)(h,{className:`border border-gray-200`,children:(0,J.jsx)(p,{className:`pt-5 pb-5`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:r.name||r.id}),(0,J.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-semibold text-gray-500`,children:r.id}),(0,J.jsx)(`span`,{className:e(`rounded-full px-2 py-0.5 text-[10px] font-semibold`,r.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:r.enabled?n(`enabled`):n(`disabled`)}),r.deleteAfterRun?(0,J.jsx)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-semibold text-amber-700`,children:n(`cronOneShot`)}):null]}),(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronScheduleLabel`),`: `,lt(r)]}),(0,J.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-gray-700`,children:r.payload.message}),(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronSessionLabel`),`: `,wt(r)]}),(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronDeliverTo`),`: `,st(r)]})]}),(0,J.jsxs)(`div`,{className:`min-w-[220px] space-y-2 text-xs text-gray-500`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronNextRun`),`:`]}),` `,vt(r.state.nextRunAt)]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronLastRun`),`:`]}),` `,vt(r.state.lastRunAt)]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronLastStatus`),`:`]}),` `,r.state.lastStatus??`-`]}),r.state.lastError?(0,J.jsx)(`div`,{className:`break-words text-[11px] text-red-500`,children:r.state.lastError}):null]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-end gap-2`,children:[(0,J.jsxs)(g,{variant:`subtle`,size:`sm`,onClick:()=>a(r),className:`gap-1`,children:[(0,J.jsx)(xe,{className:`h-3.5 w-3.5`}),n(`cronRunNow`)]}),(0,J.jsxs)(g,{variant:r.enabled?`outline`:`primary`,size:`sm`,onClick:()=>o(r),className:`gap-1`,children:[(0,J.jsx)(Qt,{className:`h-3.5 w-3.5`}),r.enabled?n(`cronDisable`):n(`cronEnable`)]}),(0,J.jsxs)(g,{variant:`destructive`,size:`sm`,onClick:()=>i(r),className:`gap-1`,children:[(0,J.jsx)(we,{className:`h-3.5 w-3.5`}),n(`delete`)]})]})]})})})}function hn(){let[t,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(`all`),o=At({all:!0}),s=xt(),c=yt(),l=ct(),{confirm:u,ConfirmDialog:d}=dt(),f=(0,q.useMemo)(()=>(o.data?.jobs??[]).filter(e=>fn(e,t)).filter(e=>pn(e,i)),[o.data,t,i]),p=async e=>{await u({title:`${n(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:n(`delete`)})&&s.mutate({id:e.id})},m=async e=>{let t=!e.enabled;await u({title:t?`${n(`cronEnableConfirm`)}?`:`${n(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:n(t?`cronEnable`:`cronDisable`)})&&c.mutate({id:e.id,enabled:t})},h=async e=>{let t=!e.enabled;await u({title:t?`${n(`cronRunForceConfirm`)}?`:`${n(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:n(`cronRunNow`)})&&l.mutate({id:e.id,force:t})};return(0,J.jsxs)(b,{fullHeight:!0,children:[(0,J.jsx)(te,{title:n(`cronPageTitle`),description:n(`cronPageDescription`),actions:(0,J.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>o.refetch(),children:(0,J.jsx)(Ce,{className:e(`h-4 w-4`,o.isFetching&&`animate-spin`)})})}),(0,J.jsx)(`div`,{className:`mb-6`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,J.jsx)(S,{value:t,onChange:e=>r(e.target.value),placeholder:n(`cronSearchPlaceholder`),className:`pl-9`}),(0,J.jsx)(It,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,J.jsx)(`div`,{className:`min-w-[180px]`,children:(0,J.jsxs)(Ve,{value:i,onValueChange:e=>a(e),children:[(0,J.jsx)(tt,{className:`w-full`,children:(0,J.jsx)(et,{placeholder:n(`cronStatusLabel`)})}),(0,J.jsxs)(Tt,{children:[(0,J.jsx)(U,{value:`all`,children:n(`cronStatusAll`)}),(0,J.jsx)(U,{value:`enabled`,children:n(`cronStatusEnabled`)}),(0,J.jsx)(U,{value:`disabled`,children:n(`cronStatusDisabled`)})]})]})}),(0,J.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[n(`cronTotalLabel`),`: `,o.data?.total??0,` / `,f.length]})]})}),(0,J.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:o.isLoading?(0,J.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:n(`cronLoading`)}):f.length===0?(0,J.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:n(`cronEmpty`)}):(0,J.jsx)(`div`,{className:`space-y-4`,children:f.map(e=>(0,J.jsx)(mn,{job:e,onDelete:p,onRun:h,onToggle:m},e.id))})}),(0,J.jsx)(d,{})]})}function gn(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function _n(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function vn(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function yn(e,t){return t??{type:e,total:0,specs:[],records:[]}}function bn(e){let t=yn(e.result.type,e.view),n=_n(e),r=t.records.findIndex(e=>vn(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:gn(i),total:i.length}}function xn(e){let t=yn(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!vn(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:gn(n),total:n.length}}let n=t.records.map(t=>vn(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:e.result.action===`update`?{...t,installedAt:new Date().toISOString(),origin:t.origin??`marketplace`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:gn(n),total:n.length}}function Sn(e){let t=I({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>f({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&Cn(r,e)?t:void 0},staleTime:15e3}),n=(0,q.useMemo)(()=>oe(t.data),[t.data]);return{...t,data:n}}function Cn(e,t){return e.q===t.q&&e.tag===t.tag&&e.scene===t.scene&&e.sort===t.sort&&e.pageSize===t.pageSize}function wn(e=!0){return T({queryKey:[`marketplace-skill-scenes`],queryFn:ne,enabled:e,staleTime:6e4})}function Tn(e,t=!0){let n=Gt({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>f({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,q.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function En(e){return T({queryKey:[`marketplace-installed`,e],queryFn:()=>m(e),staleTime:1e4})}function Dn(){let e=C();return d({mutationFn:e=>u(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>bn({view:e,request:r,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),F.success(t.message||n(`marketplaceInstallSuccessSkill`))},onError:e=>{F.error(e.message||n(`marketplaceInstallFailed`))}})}function On(){let e=C();return d({mutationFn:e=>ee(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>xn({view:e,request:r,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`});let i=t.action===`enable`?n(`marketplaceEnableSuccess`):t.action===`disable`?n(`marketplaceDisableSuccess`):t.action===`update`?n(`marketplaceUpdateSuccess`):n(`marketplaceUninstallSuccess`);F.success(t.message||i)},onError:e=>{F.error(e.message||n(`marketplaceOperationFailed`))}})}function kn(e){return(e??``).trim().toLowerCase()}function Y(e,t){let n=kn(t);return n.length>0?`${e}:${n}`:``}function An(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Y(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function jn(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Y(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function Mn(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Y(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function Nn(e,t){return t.get(Y(e.type,e.spec))||t.get(Y(e.type,e.id))||t.get(Y(e.type,e.label))}function Pn(e,t,n,r){let i=kn(n);if(!i)return!0;let a=se(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>kn(e)).filter(Boolean).some(e=>e.includes(i))}function X(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Fn(e){let t=e.replace(/\r\n/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`);if(t[0]?.trim()!==`---`)return e;let n=t.findIndex((e,t)=>t>0&&e.trim()===`---`);return n>0?t.slice(n+1).join(`
|
|
4
|
-
`).trim():e}function Z(e){return X(e).replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`)}function In(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function Ln(e,t,n){let r=[],i=t+1;for(;i<e.length&&!e[i]?.trim().startsWith("```");)r.push(e[i]??``),i+=1;return{html:`<div class="code-block">${n[1]?`<span class="code-language">${X(n[1])}</span>`:``}<pre><code>${X(r.join(`
|
|
5
|
-
`))}</code></pre></div>`,nextIndex:i+1}}function Rn(e,t){let n=Math.min(4,e[1]?.length??2);return{html:`<h${n}>${Z(e[2]??``)}</h${n}>`,nextIndex:t+1}}function zn(e,t,n){let r=[],i=t,a=n?/^\d+\.\s+/:/^[-*]\s+/;for(;i<e.length&&a.test(e[i]?.trim()??``);)r.push(`<li>${Z((e[i]??``).trim().replace(a,``))}</li>`),i+=1;return{html:n?`<ol>${r.join(``)}</ol>`:`<ul>${r.join(``)}</ul>`,nextIndex:i}}function Bn(e,t){let n=[],r=t;for(;r<e.length&&/^>\s?/.test(e[r]?.trim()??``);)n.push((e[r]??``).trim().replace(/^>\s?/,``)),r+=1;return{html:`<blockquote>${Z(n.join(` `))}</blockquote>`,nextIndex:r}}function Vn(e,t){let n=[],r=t;for(;r<e.length;){let t=e[r]?.trim()??``;if(!t||In(t))break;n.push(t),r+=1}return{html:`<p>${Z(n.join(` `))}</p>`,nextIndex:r}}function Hn(e,t){let n=e[t]?.trim()??``,r=n.match(/^```(\S*)/);if(r)return Ln(e,t,r);let i=n.match(/^(#{1,4})\s+(.+)$/);return i?Rn(i,t):/^[-*]\s+/.test(n)?zn(e,t,!1):/^\d+\.\s+/.test(n)?zn(e,t,!0):/^>\s?/.test(n)?Bn(e,t):Vn(e,t)}function Un(e){let t=Fn(e).replace(/\r\n/g,`
|
|
6
|
-
`).split(`
|
|
7
|
-
`),n=[],r=0;for(;r<t.length;){if(!(t[r]??``).trim()){r+=1;continue}let e=Hn(t,r);n.push(e.html),r=e.nextIndex}return n.join(``)}function Wn(e){return Array.isArray(e)?e.map(e=>Wn(e)).join(`, `):e&&typeof e==`object`?JSON.stringify(e):String(e??``)}function Gn(e){try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?[]:Object.entries(t).map(([e,t])=>({key:e,value:Wn(t)})).filter(e=>e.value.trim().length>0)}catch{return[]}}function Kn(e){return e.replace(/\r\n/g,`
|
|
8
|
-
`).split(`
|
|
9
|
-
`).map(e=>e.match(/^([A-Za-z0-9_.-]+):\s*(.+)$/)).filter(e=>!!e).map(e=>({key:e[1]??``,value:e[2]?.replace(/^["']|["']$/g,``)??``})).filter(e=>e.key&&e.value.trim().length>0)}function qn(e){let t=Gn(e),n=t.length>0?t:Kn(e);return n.length===0?`<pre class="code">${X(e)}</pre>`:`<dl class="metadata-list">${n.map(e=>`<div><dt>${X(e.key)}</dt><dd>${X(e.value)}</dd></div>`).join(``)}</dl>`}function Jn(e){let{title:t,typeLabel:n,spec:r,summary:i,description:a,metadataRaw:o,contentRaw:s,sourceUrl:c,sourceLabel:l,tags:u,author:d,loading:f}=e,p=o?.trim()||`-`,m=s?.trim()||`-`,h=i?.trim(),g=a?.trim(),_=!!g&&g!==h,v=qn(p),y=Un(m),b=`<!doctype html>
|
|
10
|
-
<html>
|
|
11
|
-
<head>
|
|
12
|
-
<meta charset="utf-8" />
|
|
13
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
14
|
-
<title>${X(t)}</title>
|
|
15
|
-
<style>
|
|
16
|
-
:root { color-scheme: light; }
|
|
17
|
-
body { margin: 0; background: #f9f8f5; color: #2f2212; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
|
|
18
|
-
.wrap { max-width: 940px; margin: 0 auto; padding: 24px 20px 36px; }
|
|
19
|
-
.hero { border: 1px solid #f0e2c8; border-radius: 14px; background: linear-gradient(180deg, #fff9f1 0%, #ffffff 28%); padding: 18px; box-shadow: 0 1px 3px rgba(30, 20, 10, 0.05); }
|
|
20
|
-
.hero h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
|
|
21
|
-
.meta { margin-top: 7px; color: #78644d; font-size: 12px; overflow-wrap: anywhere; word-break: break-word; }
|
|
22
|
-
.summary { margin: 12px 0 0; font-size: 13px; line-height: 1.65; color: #5f5142; }
|
|
23
|
-
.grid { display: grid; grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
|
|
24
|
-
.card { border: 1px solid #eee3d1; background: #fffdf9; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(30, 20, 10, 0.035); }
|
|
25
|
-
.card h2 { margin: 0; padding: 11px 13px; font-size: 12px; font-weight: 650; color: #3f472f; border-bottom: 1px solid #f1e7d4; background: #fffaf2; }
|
|
26
|
-
.card .body { padding: 12px 13px; font-size: 12px; color: #4e463d; line-height: 1.65; }
|
|
27
|
-
.code { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.55; margin: 0; }
|
|
28
|
-
.metadata-list { margin: 0; }
|
|
29
|
-
.metadata-list div { display: grid; grid-template-columns: minmax(72px, 0.36fr) minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid #f2eadc; }
|
|
30
|
-
.metadata-list div:last-child { border-bottom: 0; }
|
|
31
|
-
.metadata-list dt { color: #7a5a24; font-weight: 650; overflow-wrap: anywhere; }
|
|
32
|
-
.metadata-list dd { margin: 0; color: #4e463d; overflow-wrap: anywhere; }
|
|
33
|
-
.markdown { font-size: 13px; line-height: 1.68; }
|
|
34
|
-
.markdown > *:first-child { margin-top: 0; }
|
|
35
|
-
.markdown > *:last-child { margin-bottom: 0; }
|
|
36
|
-
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 18px 0 8px; color: #2f2212; line-height: 1.25; letter-spacing: 0; }
|
|
37
|
-
.markdown h1 { font-size: 20px; }
|
|
38
|
-
.markdown h2 { font-size: 17px; }
|
|
39
|
-
.markdown h3 { font-size: 15px; }
|
|
40
|
-
.markdown h4 { font-size: 13px; }
|
|
41
|
-
.markdown p { margin: 10px 0; }
|
|
42
|
-
.markdown ul, .markdown ol { margin: 10px 0; padding-left: 20px; }
|
|
43
|
-
.markdown li { margin: 5px 0; }
|
|
44
|
-
.markdown blockquote { margin: 12px 0; padding: 8px 12px; border-left: 3px solid #d9b56f; border-radius: 8px; background: #fff7ea; color: #6d5841; }
|
|
45
|
-
.markdown code { border: 1px solid #eadcc6; border-radius: 5px; background: #fff7ea; padding: 1px 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: #6b4b16; }
|
|
46
|
-
.markdown a { color: #5f6b45; text-decoration: none; font-weight: 600; }
|
|
47
|
-
.markdown a:hover { text-decoration: underline; }
|
|
48
|
-
.code-block { position: relative; margin: 12px 0; overflow: hidden; border: 1px solid #eadcc6; border-radius: 10px; background: #2f2a24; }
|
|
49
|
-
.code-block pre { margin: 0; overflow-x: auto; padding: 13px; }
|
|
50
|
-
.code-block code { border: 0; border-radius: 0; background: transparent; padding: 0; color: #f7efe3; }
|
|
51
|
-
.code-language { position: absolute; right: 10px; top: 8px; color: #d8c3a0; font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
52
|
-
.tags { margin-top: 10px; }
|
|
53
|
-
.tag { display: inline-block; margin: 0 6px 6px 0; padding: 4px 8px; border: 1px solid #ecd9b5; border-radius: 999px; background: #fff7ea; color: #7a5a24; font-size: 11px; }
|
|
54
|
-
.source { color: #5f6b45; text-decoration: none; overflow-wrap: anywhere; word-break: break-all; }
|
|
55
|
-
.source:hover { text-decoration: underline; }
|
|
56
|
-
.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, #f0e6d6 0%, #fffaf2 42%, #f0e6d6 78%); background-size: 220% 100%; animation: shimmer 1.35s ease-in-out infinite; }
|
|
57
|
-
.detail-skeleton .hero { padding: 18px; }
|
|
58
|
-
.sk-title { width: 52%; height: 24px; }
|
|
59
|
-
.sk-meta { width: 78%; height: 12px; margin-top: 12px; }
|
|
60
|
-
.sk-line { height: 12px; margin-top: 12px; }
|
|
61
|
-
.sk-line.short { width: 62%; }
|
|
62
|
-
.sk-line.mid { width: 82%; }
|
|
63
|
-
.sk-body { height: 220px; margin: 13px; }
|
|
64
|
-
@keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
|
|
65
|
-
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
|
|
66
|
-
</style>
|
|
67
|
-
</head>
|
|
68
|
-
<body>
|
|
69
|
-
<main class="wrap${f?` detail-skeleton`:``}"${f?` aria-busy="true"`:``}>
|
|
70
|
-
${f?`
|
|
71
|
-
<section class="hero">
|
|
72
|
-
<span class="skeleton sk-title"></span>
|
|
73
|
-
<span class="skeleton sk-meta"></span>
|
|
74
|
-
<span class="skeleton sk-line mid"></span>
|
|
75
|
-
<span class="skeleton sk-line"></span>
|
|
76
|
-
<span class="skeleton sk-line short"></span>
|
|
77
|
-
</section>
|
|
78
|
-
<section class="grid">
|
|
79
|
-
<article class="card"><span class="skeleton sk-body"></span></article>
|
|
80
|
-
<article class="card"><span class="skeleton sk-body"></span></article>
|
|
81
|
-
</section>
|
|
82
|
-
`:`
|
|
83
|
-
<section class="hero">
|
|
84
|
-
<h1>${X(t)}</h1>
|
|
85
|
-
<div class="meta">${X(n)} · ${X(r)}${d?` · ${X(d)}`:``}</div>
|
|
86
|
-
${h?`<p class="summary">${X(h)}</p>`:``}
|
|
87
|
-
${_?`<p class="summary">${X(g)}</p>`:``}
|
|
88
|
-
${u&&u.length>0?`<div class="tags">${u.map(e=>`<span class="tag">${X(e)}</span>`).join(``)}</div>`:``}
|
|
89
|
-
${c?`<p class="meta" style="margin-top:12px;">${X(l??`Source`)}: <a class="source" href="${X(c)}" target="_blank" rel="noopener noreferrer">${X(c)}</a></p>`:``}
|
|
90
|
-
</section>
|
|
91
|
-
|
|
92
|
-
<section class="grid">
|
|
93
|
-
<article class="card">
|
|
94
|
-
<h2>Metadata</h2>
|
|
95
|
-
<div class="body">${v}</div>
|
|
96
|
-
</article>
|
|
97
|
-
<article class="card">
|
|
98
|
-
<h2>Content</h2>
|
|
99
|
-
<div class="body markdown">${y}</div>
|
|
100
|
-
</article>
|
|
101
|
-
</section>
|
|
102
|
-
`}
|
|
103
|
-
</main>
|
|
104
|
-
</body>
|
|
105
|
-
</html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(b)}`}var Yn=[`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`];function Xn(t){let{name:n,fallback:r,className:i}=t,a=n||r,o=a.substring(0,2).toUpperCase();return(0,J.jsx)(`div`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,Zn(a),i),children:o})}function Zn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Yn[Math.abs(t)%Yn.length]}function Qn({title:e,spec:t,summary:n}){return(0,J.jsxs)(_e,{delayDuration:400,children:[(0,J.jsxs)(ve,{children:[(0,J.jsx)(he,{asChild:!0,children:(0,J.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-900`,children:e})}),(0,J.jsx)(ge,{className:`max-w-[300px] text-xs`,children:e})]}),(0,J.jsx)(`div`,{className:`mb-1.5 mt-0.5 flex min-w-0 items-center gap-1.5`,children:t?(0,J.jsxs)(ve,{children:[(0,J.jsx)(he,{asChild:!0,children:(0,J.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono text-gray-400`,children:t})}),(0,J.jsx)(ge,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null}),(0,J.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500/90`,children:n})]})}function $n(t){let{item:r,record:i,isInstalling:a,isDisabled:o,canUpdate:s,canUninstall:c,busyAction:l,busyForRecord:u,language:d,onInstall:f,onManage:p}=t,m=!!(r&&!i||i&&(s||c));return(0,J.jsxs)(`div`,{className:e(`relative flex h-8 shrink-0 items-center justify-end`,i?`md:w-5`:`md:w-0`),children:[(0,J.jsx)(`div`,{className:e(`hidden items-center justify-end transition-opacity duration-150 md:flex`,m&&`group-hover:opacity-0 group-focus-within:opacity-0`),children:i?(0,J.jsx)(er,{disabled:o,language:d}):null}),(0,J.jsxs)(`div`,{className:e(`flex w-max items-center justify-end gap-2 transition-opacity duration-150`,`opacity-100 md:pointer-events-none md:absolute md:right-0 md:opacity-0`,`md:group-hover:pointer-events-auto md:group-hover:opacity-100`,`md:group-focus-within:pointer-events-auto md:group-focus-within:opacity-100`),children:[r&&!i&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(r)},disabled:a,className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl bg-primary px-3 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,J.jsx)(Je,{className:`h-3.5 w-3.5`}),n(a?`marketplaceInstalling`:`marketplaceInstall`)]}),i&&s&&(0,J.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),p(`update`,i)},className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl border border-blue-200/80 bg-white px-3 text-xs font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,J.jsx)(Ce,{className:`h-3.5 w-3.5`}),n(l===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),i&&c&&(0,J.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),p(`uninstall`,i)},className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 text-xs font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,J.jsx)(we,{className:`h-3.5 w-3.5`}),n(l===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]})]})}function er(t){let{disabled:n,language:r}=t,i=nr(n?{zh:`已禁用`,en:`Disabled`}:{zh:`已安装`,en:`Installed`},r);return(0,J.jsx)(_e,{delayDuration:300,children:(0,J.jsxs)(ve,{children:[(0,J.jsx)(he,{asChild:!0,children:(0,J.jsx)(`span`,{"aria-label":i,className:e(`inline-flex h-5 w-5 items-center justify-center`,n?`text-gray-400`:`text-emerald-700`),children:n?(0,J.jsx)(a,{className:`h-4 w-4 opacity-40`}):(0,J.jsx)(a,{className:`h-4 w-4`})})}),(0,J.jsx)(ge,{className:`text-xs`,children:i})]})})}function tr(e){let{item:t,record:r,language:i,installState:a,manageState:o,onOpen:s,onInstall:c,onManage:l}=e,u=ue(i),d=t?.name??r?.label??r?.id??r?.spec??n(`marketplaceUnknownItem`),f=se(t?.summaryI18n,t?.summary,u)||(r?n(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??r?.spec??``,m=r?.id||r?.spec,h=m?o.actionsByTarget.get(m):void 0,g=!!h,_=r?.type===`skill`&&r.source===`workspace`,v=r?.type===`skill`&&r.origin===`marketplace`,y=r?r.enabled===!1||r.runtimeStatus===`disabled`:!1,b=t?.install.spec,x=typeof b==`string`&&a.installingSpecs.has(b);return(0,J.jsxs)(`article`,{onClick:s,className:`group flex cursor-pointer items-start justify-between gap-3.5 rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm transition-all hover:border-blue-300/80 hover:shadow-md`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,J.jsx)(Xn,{name:d,fallback:p||n(`marketplaceTypeSkill`)}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center`,children:(0,J.jsx)(Qn,{title:d,spec:p,summary:f})})]}),(0,J.jsx)($n,{item:t,record:r,isInstalling:x,isDisabled:y,canUpdate:v,canUninstall:_,busyAction:h,busyForRecord:g,language:i,onInstall:c,onManage:l})]})}function nr(e,t){return t.startsWith(`zh`)?e.zh:e.en}function rr(t){let{scope:n,title:r,summary:i,showTitle:a,showListSkeleton:o,skeletonCardCount:s,allItems:c,installedEntries:l,installedRecordLookup:u,language:d,installState:f,manageState:p,onOpen:m,onInstall:h,onManage:g}=t;return(0,J.jsxs)(`section`,{className:e(`flex min-h-full flex-col`,a&&`gap-3`),children:[a&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:r}),(0,J.jsx)(`span`,{className:`text-[12px] text-gray-500`,children:i})]}),(0,J.jsxs)(`div`,{"data-testid":o?`marketplace-list-skeleton`:void 0,className:e(`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`,o&&`min-h-0 flex-1 auto-rows-[104px] content-start`),children:[o&&(0,J.jsx)(L,{count:s}),!o&&n===`all`&&c.map(e=>(0,J.jsx)(tr,{item:e,record:Mn(e,u),language:d,installState:f,manageState:p,onOpen:()=>m(e,Mn(e,u)),onInstall:h,onManage:g},e.id)),!o&&n===`installed`&&l.map(e=>(0,J.jsx)(tr,{item:e.item,record:e.record,language:d,installState:f,manageState:p,onOpen:()=>m(e.item,e.record),onInstall:h,onManage:g},e.key))]})]})}function ir(t){let{entry:r,language:i,localeFallbacks:o,installState:s,layout:c=`rail`,onOpen:l,onInstall:u}=t,{item:d,record:f}=r,p=se(d.summaryI18n,d.summary,o),m=d.install.spec,h=s.installingSpecs.has(m),g=!!f;return(0,J.jsxs)(`article`,{onClick:()=>l(r),className:e(`group flex min-h-[166px] cursor-pointer flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,c===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,J.jsx)(Xn,{name:d.name,fallback:d.install.spec}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,J.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:d.name}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:ar(d)})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:p}),(0,J.jsx)(or,{tags:d.tags})]}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:sr(d.updatedAt)}),g?(0,J.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,J.jsx)(a,{className:`h-3.5 w-3.5`}),cr({zh:`已安装`,en:`Installed`},i)]}):(0,J.jsxs)(`button`,{type:`button`,disabled:h,onClick:e=>{e.stopPropagation(),u(d)},className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-gray-200 bg-white px-2 text-[11px] font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 disabled:opacity-50`,children:[(0,J.jsx)(Je,{className:`h-3.5 w-3.5`}),n(h?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function ar(e){return e.slug||e.install.spec}function or({tags:e}){let t=e.slice(0,2);return t.length===0?null:(0,J.jsx)(`div`,{className:`mt-2 truncate text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function sr(e){return e.slice(0,10)||e}function cr(e,t){return t.startsWith(`zh`)?e.zh:e.en}var lr=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:$t,tone:`dark`,span:`md:col-span-2`},{scene:`office-collaboration`,title:{zh:`办公协作`,en:`Office Work`},summary:{zh:`连接文档、日历、会议、邮件和团队通信。`,en:`Connect docs, calendars, meetings, mail, and teams.`},icon:Kt,tone:`green`,span:`md:col-span-2`},{scene:`writing-content`,title:{zh:`写作与内容`,en:`Writing`},summary:{zh:`把调研、写作、润色和发布组织成连续工作流。`,en:`Turn research, writing, polishing, and publishing into one flow.`},icon:Zt,tone:`amber`,span:`md:col-span-2`},{scene:`browser-automation`,title:{zh:`浏览器自动化`,en:`Browser`},summary:{zh:`操作网页、捕获动态内容并验证真实用户路径。`,en:`Operate pages, capture dynamic content, and verify user paths.`},icon:Yt,tone:`blue`,span:`md:col-span-2`},{scene:`local-environment`,title:{zh:`本地环境`,en:`Local`},summary:{zh:`管理终端、文件、运行时和本地服务。`,en:`Manage shells, files, runtimes, and local services.`},icon:ze,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:Xt,tone:`sky`,span:`md:col-span-1`},{scene:`nextclaw-official`,title:{zh:`NextClaw 官方`,en:`NextClaw Official`},summary:{zh:`优先查看由 NextClaw 维护的原生能力。`,en:`Browse native capabilities maintained by NextClaw.`},icon:Le,tone:`teal`,span:`md:col-span-2`}],ur={icon:Le,tone:`dark`,span:`md:col-span-2`},dr={dark:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-stone-600 bg-stone-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},blue:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-cyan-600 bg-cyan-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},green:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-emerald-600 bg-emerald-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},amber:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-amber-600 bg-amber-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},violet:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-violet-500 bg-violet-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},sky:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-sky-500 bg-sky-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},teal:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-teal-600 bg-teal-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`}},fr=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`,pr=24;function mr(e){let{entries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=ue(a),d=[...t].sort((e,t)=>xr(e.item,t.item)).slice(0,6);return(0,J.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,J.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,J.jsx)(br,{icon:Jt,title:Q({zh:`场景`,en:`Scenes`},a),description:Q({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,J.jsx)(hr,{}):(0,J.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:n.map(e=>(0,J.jsx)(gr,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||d.length>0)&&(0,J.jsx)(vr,{icon:qt,title:Q({zh:`最近更新`,en:`Recently updated`},a),description:Q({zh:`看看生态最近在补齐哪些能力。`,en:`See what the ecosystem has been improving lately.`},a),entries:d,language:a,localeFallbacks:u,isLoading:i,installState:o,onOpen:s,onInstall:c})]})}function hr(){return(0,J.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:lr.map(e=>(0,J.jsxs)(`div`,{className:`flex min-h-[74px] flex-col justify-center rounded-lg border border-gray-200/70 bg-white px-3 py-2.5 shadow-sm`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(W,{className:`h-7 w-7 shrink-0 rounded-md`}),(0,J.jsx)(W,{className:`h-3.5 min-w-0 flex-1`}),(0,J.jsx)(W,{className:`h-3 w-8 shrink-0`})]}),(0,J.jsx)(W,{className:`mt-2 h-3 w-4/5`})]},e.scene))})}function gr(t){let{scene:n,language:r,onSelect:i}=t,a=Sr(n.scene),o=a.icon,s=dr[a.tone];return(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(n.scene),className:e(`group flex min-h-[74px] flex-col justify-center rounded-lg border px-3 py-2.5 text-left shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/70`,s.card),children:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:e(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,s.icon),children:(0,J.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:Cr(n,a,r)}),typeof n.count==`number`&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:Tr(n.count,r)})]}),(0,J.jsx)(`p`,{className:e(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,s.text),children:wr(n,a,r)})]})})}function _r(t){let{scene:n,entries:r,isLoading:i,language:a,localeFallbacks:o,installState:s,onBack:c,onOpen:l,onInstall:u}=t,d=Sr(n.scene),f=d.icon,p=dr[d.tone];return(0,J.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,J.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":Q({zh:`返回`,en:`Back`},a),children:(0,J.jsx)(me,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:e(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,p.icon),children:(0,J.jsx)(f,{className:`h-4 w-4`})}),(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:Cr(n,d,a)}),(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:Q(i?{zh:`加载中`,en:`Loading`}:{zh:`${r.length} 个技能`,en:`${r.length} skills`},a)})]}),(0,J.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:wr(n,d,a)})})]})]}),i?(0,J.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:e(fr,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,J.jsx)(L,{count:pr})}):r.length>0?(0,J.jsx)(`div`,{className:fr,children:r.map(e=>(0,J.jsx)(ir,{entry:e,language:a,localeFallbacks:o,installState:s,layout:`grid`,onOpen:l,onInstall:u},e.item.id))}):(0,J.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 py-8 text-center text-[12px] text-gray-500`,children:Q({zh:`这个模块暂无技能。`,en:`No skills in this module yet.`},a)})]})}function vr(e){let{icon:t,title:n,description:r,entries:i,language:a,localeFallbacks:o,isLoading:s,installState:c,onOpen:l,onInstall:u}=e;return(0,J.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,J.jsx)(br,{icon:t,title:n,description:r}),s?(0,J.jsx)(yr,{}):(0,J.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,J.jsx)(ir,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function yr(){return(0,J.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 flex gap-2.5 overflow-hidden px-1 pb-1.5`,children:Array.from({length:4},(e,t)=>(0,J.jsxs)(`article`,{className:`flex min-h-[166px] w-[260px] shrink-0 flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,J.jsx)(W,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5 pt-0.5`,children:[(0,J.jsx)(W,{className:`h-3.5 w-32 max-w-full`}),(0,J.jsx)(W,{className:`h-3 w-24 max-w-full`})]})]}),(0,J.jsx)(W,{className:`h-3 w-full`}),(0,J.jsx)(W,{className:`mt-1.5 h-3 w-4/5`}),(0,J.jsx)(W,{className:`mt-2 h-3 w-24`})]}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,J.jsx)(W,{className:`h-3 w-20`}),(0,J.jsx)(W,{className:`h-7 w-16 rounded-md`})]})]},`marketplace-recent-skeleton-${t}`))})}function br({icon:e,title:t,description:n}){return(0,J.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,J.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,J.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function xr(e,t){let n=Date.parse(e.updatedAt),r=Date.parse(t.updatedAt);return Number.isNaN(n)||Number.isNaN(r)?t.updatedAt.localeCompare(e.updatedAt):r-n}function Q(e,t){return t.startsWith(`zh`)?e.zh:e.en}function Sr(e){return lr.find(t=>t.scene===e)??{scene:e,...ur}}function Cr(e,t,n){return t.title?Q(t.title,n):e.title}function wr(e,t,n){return t.summary?Q(t.summary,n):e.description??e.scene}function Tr(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}function Er(e){let{items:t,installedRecordLookup:n,scene:r,forcedType:i,typeFilter:a,scope:o,searchText:s,query:c,showListSkeleton:l,hasCatalogError:u}=e,d=wn(a===`skill`),f=(0,q.useMemo)(()=>d.data?.scenes??[],[d.data?.scenes]),p=Tn(f,a===`skill`),m=(0,q.useMemo)(()=>f.map(e=>({...e,count:typeof e.count==`number`?e.count:p.get(e.scene)})),[p,f]),h=(0,q.useMemo)(()=>t.map(e=>({item:e,record:Mn(e,n)})),[t,n]),g=(0,q.useMemo)(()=>{let e=r?.trim();if(e)return m.find(t=>t.scene===e)??{scene:e,title:e}},[r,m]),_=a===`skill`&&!!r?.trim(),v=a===`skill`&&o===`all`&&!s.trim()&&!c&&!_,y=l||t.length>=4,b=v&&!u&&y&&m.length===0&&d.isLoading;return{entries:h,scenes:m,selectedScene:g,sceneEntries:h,isSceneRoute:_,isScenesLoading:b,showShelves:v&&!u&&y&&(l||m.length>0||b),backPath:i?`/skills`:`/marketplace/skills`,pathPrefix:i?`/skills/scenes`:`/marketplace/skills/scenes`}}var Dr=20,Or=36;function kr(){return{pageTitle:`marketplaceSkillsPageTitle`,pageDescription:`marketplaceSkillsPageDescription`,tabMarketplace:`marketplaceTabMarketplaceSkills`,tabInstalled:`marketplaceTabInstalledSkills`,searchPlaceholder:`marketplaceSearchPlaceholderSkills`,sectionCatalog:`marketplaceSectionSkills`,sectionInstalled:`marketplaceSectionInstalledSkills`,errorLoadData:`marketplaceErrorLoadingSkillsData`,errorLoadInstalled:`marketplaceErrorLoadingInstalledSkills`,emptyData:`marketplaceNoSkills`,emptyInstalled:`marketplaceNoInstalledSkills`,installedCountSuffix:`marketplaceInstalledSkillsCountSuffix`}}function Ar(e={}){let{forcedType:t}=e,r=s(),i=c(),{language:a}=Pt(),o=ke(),l=`skill`,u=(0,q.useMemo)(()=>ue(a),[a]),d=kr(),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(`all`),[v,y]=(0,q.useState)(`relevance`),[S,C]=(0,q.useState)(new Set),[w,T]=(0,q.useState)(new Map),E=(0,q.useRef)({byKey:new Map,seq:0});(0,q.useEffect)(()=>{let e=setTimeout(()=>{h(f.trim())},250);return()=>clearTimeout(e)},[f]);let D=En(l),O=l===`skill`?i.scene?.trim():void 0,k=Sn({q:O?void 0:m||void 0,scene:O,type:l,sort:v,pageSize:Dr}),A=ce({disabled:g!==`all`||k.isError||!k.hasNextPage||k.isFetchingNextPage,onLoadMore:()=>k.fetchNextPage(),watchValue:`${l}:${g}:${m}:${O??``}:${v}:${k.data?.loadedItems??0}:${k.data?.loadedPages??0}`});(0,q.useEffect)(()=>{let e=A.containerRef.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[A.containerRef,m,O,g,v,l]);let ee=Dn(),te=On(),{confirm:ne,ConfirmDialog:re}=dt(),j=(0,q.useMemo)(()=>D.data?.records??[],[D.data?.records]),M=(0,q.useMemo)(()=>k.data?.items??[],[k.data?.items]),N=(0,q.useMemo)(()=>An(M),[M]),ie=(0,q.useMemo)(()=>jn(j),[j]),P=(0,q.useMemo)(()=>{let e=j.filter(e=>e.type===l).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:Nn(e,N)})).filter(e=>Pn(e.record,e.item,m,u));return e.sort((e,t)=>{let n=e.record.installedAt?Date.parse(e.record.installedAt):NaN,r=t.record.installedAt?Date.parse(t.record.installedAt):NaN;return!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r?r-n:e.record.spec.localeCompare(t.record.spec)}),e},[j,l,N,m,u]),F=g===`installed`?P.length:k.data?.total??0,oe={showCatalog:g===`all`&&k.isLoading&&!k.data,showInstalled:g===`installed`&&D.isLoading&&!D.data},I=oe.showCatalog||oe.showInstalled,L=(0,q.useMemo)(()=>g===`installed`?D.isLoading&&!D.data?n(`loading`):`${P.length} ${n(d.installedCountSuffix)}`:k.data?`${M.length} / ${F}`:n(`loading`),[g,D.data,D.isLoading,P.length,k.data,M.length,F,d.installedCountSuffix]),R={installingSpecs:S},de={actionsByTarget:w},z=Er({items:M,installedRecordLookup:ie,scene:O,forcedType:t,typeFilter:l,scope:g,searchText:f,query:m,showListSkeleton:I,hasCatalogError:k.isError}),B=async e=>{let t=e.install.spec;if(!S.has(t)){C(e=>{let n=new Set(e);return n.add(t),n});try{await ee.mutateAsync({type:e.type,spec:t,kind:e.install.kind,skill:e.slug,installPath:`skills/${e.slug}`})}catch{}finally{C(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n})}}},fe=async(e,t)=>{let r=e===`update`?t.catalogSlug||t.id||t.spec:t.id||t.spec;if(r&&!w.has(r)&&!(e===`uninstall`&&!await ne({title:`${n(`marketplaceUninstallTitle`)} ${r}?`,description:n(`marketplaceUninstallDescription`),confirmLabel:n(`marketplaceUninstall`),variant:`destructive`}))){T(t=>{let n=new Map(t);return n.set(r,e),n});try{await te.mutateAsync({type:t.type,action:e,id:r,spec:t.spec})}finally{T(e=>{if(!e.has(r))return e;let t=new Map(e);return t.delete(r),t})}}},V=async(e,t)=>{let r=e?.name??t?.label??t?.id??t?.spec??n(`marketplaceUnknownItem`),i=e?`marketplace:${e.type}:${e.slug}`:`marketplace:${t?.type??`unknown`}:${t?.id??t?.spec??r}`,a={title:r,kind:`content`,dedupeKey:i},s={...a,activate:!1};if(!e){let e=Jn({title:r,typeLabel:n(`marketplaceTypeSkill`),spec:t?.spec??`-`,summary:n(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(t??{},null,2),contentRaw:`-`});o.open(e,a);return}let c=E.current.seq+1;E.current.seq=c,E.current.byKey.set(i,c);let l=se(e.summaryI18n,e.summary,u),d={typeLabel:n(`marketplaceTypeSkill`),loadContent:()=>x(e.slug),fallbackContent:n(`marketplaceOperationFailed`),defaultContent:void 0};o.open(Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,loading:!0}),a);try{let t=await d.loadContent();if(E.current.byKey.get(i)!==c)return;let n=Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,summary:l,metadataRaw:t.metadataRaw,contentRaw:t.bodyRaw||t.raw||d.defaultContent,sourceUrl:t.sourceUrl,sourceLabel:`Source (${t.source})`,tags:e.tags,author:e.author});o.open(n,s)}catch(t){if(E.current.byKey.get(i)!==c)return;let n=Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,summary:l,metadataRaw:JSON.stringify({error:t instanceof Error?t.message:String(t)},null,2),contentRaw:d.fallbackContent});o.open(n,s)}};return(0,J.jsxs)(b,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!z.isSceneRoute&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Lt,{tabs:[{id:`all`,label:n(d.tabMarketplace)},{id:`installed`,label:n(d.tabInstalled),count:D.data?.total??0}],activeTab:g,onChange:e=>_(e),className:`mb-3`}),(0,J.jsx)(ae,{scope:g,searchText:f,searchPlaceholder:n(d.searchPlaceholder),sort:v,onSearchTextChange:p,onSortChange:y})]}),(0,J.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[!z.isSceneRoute&&!z.showShelves&&!I&&(0,J.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,J.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-900`,children:g===`installed`?n(d.sectionInstalled):a.startsWith(`zh`)?`全部技能`:`All Skills`}),(0,J.jsx)(`span`,{className:`text-[12px] text-gray-500`,children:L})]}),g===`all`&&k.isError&&(0,J.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[n(d.errorLoadData),`: `,k.error.message]}),g===`installed`&&D.isError&&(0,J.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[n(d.errorLoadInstalled),`: `,D.error.message]}),(0,J.jsxs)(`div`,{ref:A.containerRef,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":I||k.isFetchingNextPage,children:[z.isSceneRoute&&z.selectedScene&&(0,J.jsx)(_r,{scene:z.selectedScene,entries:z.sceneEntries,isLoading:I,language:a,localeFallbacks:u,installState:R,onBack:()=>r(z.backPath),onOpen:e=>void V(e.item,e.record),onInstall:B}),z.showShelves&&(0,J.jsx)(mr,{entries:z.entries,scenes:z.scenes,isScenesLoading:z.isScenesLoading,isItemsLoading:I,language:a,installState:R,onOpen:e=>void V(e.item,e.record),onInstall:B,onOpenScene:e=>r(`${z.pathPrefix}/${e}`)}),!z.isSceneRoute&&(0,J.jsx)(rr,{scope:g,title:g===`installed`?n(d.sectionInstalled):a.startsWith(`zh`)?`全部技能`:`All Skills`,summary:L,showTitle:z.showShelves,showListSkeleton:I,skeletonCardCount:Or,allItems:M,installedEntries:P,installedRecordLookup:ie,language:a,installState:R,manageState:de,onOpen:(e,t)=>void V(e,t),onInstall:B,onManage:fe}),g===`all`&&!z.isSceneRoute&&!I&&!k.isError&&M.length===0&&(0,J.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:n(d.emptyData)}),g===`installed`&&!z.isSceneRoute&&!I&&!D.isError&&P.length===0&&(0,J.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:n(d.emptyInstalled)}),g===`all`&&!I&&!k.isError&&(0,J.jsx)(le,{hasMore:!!k.hasNextPage,loading:k.isFetchingNextPage,sentinelRef:A.sentinelRef})]})]}),(0,J.jsx)(re,{})]})}function jr(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,q.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,q.useEffect)(()=>{a.current=r},[r,a])}function Mr({view:e,confirmDialog:t}){let{isMobile:n}=Pe();return(0,J.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,J.jsx)(ot,{}),e===`chat`?n?(0,J.jsx)(kt,{}):(0,J.jsx)(gt,{}):(0,J.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,J.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,J.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,J.jsx)(hn,{})})}):e===`agents`?(0,J.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,J.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,J.jsx)(dn,{})})}):(0,J.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,J.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,J.jsx)(Ar,{forcedType:`skills`})})})}),t]})}function Nr(e,t){return e.filter(e=>$e(e,t))}function Pr(e){let{config:t,providersView:n,templatesView:r}=e;return(0,q.useMemo)(()=>{let e=Bt({providersView:n,templatesView:r,config:t,onlyConfigured:!0}),i=new Set,a=[];for(let t of e)for(let e of t.models){let n=Vt(t.prefix,e);!n||i.has(n)||(i.add(n),a.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:zt(t.modelThinking,e,t.aliases)}))}return a.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[t,n,r])}function Fr(e){let{sessions:t,sessionKey:n,sessionType:r}=e;return{recentSessionPreferredModel:(0,q.useMemo)(()=>bt({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredModel?.trim()||void 0}),[n,r,t]),recentSessionPreferredThinking:(0,q.useMemo)(()=>bt({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredThinking??void 0}),[n,r,t])}}function Ir(e){let{currentSelectedModel:t,modelOptions:n}=e,r=(0,q.useMemo)(()=>n.find(e=>e.value===t),[t,n]);return{supportedThinkingLevels:(0,q.useMemo)(()=>r?.thinkingCapability?.supported??[],[r?.thinkingCapability?.supported]),defaultThinkingLevel:(0,q.useMemo)(()=>r?.thinkingCapability?.default??null,[r?.thinkingCapability?.default])}}function Lr(e){let{modelOptions:t,supportedModels:n}=e;if(!n||n.length===0)return t;let r=new Set(n),i=t.filter(e=>r.has(e.value));return i.length>0?i:t}function Rr(e){let{currentSelectedModel:t,pendingSessionType:n,projectRootOverride:r,query:i,sessionKey:a,setPendingSessionType:o,setSelectedModel:s,setSelectedThinkingLevel:c}=e,l=nt(),u=jt(),d=_t(),f=Ot({limit:200}),p=Dt(),m=Ct({sessionId:a?.trim()||`draft-session`,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:r??null}:{}}),h=(l.isFetched||l.isSuccess)&&(u.isFetched||u.isSuccess)&&(d.isFetched||d.isSuccess),g=Pr({config:l.data,providersView:u.data,templatesView:d.data}),_=(0,q.useMemo)(()=>f.data?.sessions??[],[f.data?.sessions]),v=(0,q.useMemo)(()=>Fe(_),[_]),y=(0,q.useMemo)(()=>Nr(v,i),[v,i]),b=(0,q.useMemo)(()=>v.find(e=>e.key===a)??null,[v,a]),x=(0,q.useMemo)(()=>m.data?.records??[],[m.data?.records]),S=Ze({selectedSession:b,pendingSessionType:n,setPendingSessionType:o,sessionTypesData:p.data}),C=(0,q.useMemo)(()=>Lr({modelOptions:g,supportedModels:S.selectedSessionTypeOption?.supportedModels}),[g,S.selectedSessionTypeOption?.supportedModels]),{recentSessionPreferredModel:w,recentSessionPreferredThinking:T}=Fr({sessions:v,sessionKey:a,sessionType:S.selectedSessionType}),{supportedThinkingLevels:E,defaultThinkingLevel:D}=Ir({currentSelectedModel:t,modelOptions:C});return Et({modelOptions:C,selectedSessionKey:a??``,selectedSessionExists:!!b,selectedSessionPreferredModel:b?.preferredModel,fallbackPreferredModel:S.selectedSessionTypeOption?.recommendedModel??w,defaultModel:S.selectedSessionTypeOption?.recommendedModel??l.data?.agents.defaults.model,setSelectedModel:s}),ft({supportedThinkingLevels:E,selectedSessionKey:a??``,selectedSessionExists:!!b,selectedSessionPreferredThinking:b?.preferredThinking??null,fallbackPreferredThinking:T??null,defaultThinkingLevel:D,setSelectedThinkingLevel:c}),{configQuery:l,providersQuery:u,templatesQuery:d,sessionsQuery:f,sessionTypesQuery:p,sessionSkillsQuery:m,isProviderStateResolved:h,modelOptions:C,sessionSummaries:_,sessions:y,skillRecords:x,selectedSession:b,...S}}function zr(e){return e.parentSessionKey?e.sessionSummaries.map(Ge).filter(t=>t.parentSessionId===e.parentSessionKey).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>({sessionKey:e.key,parentSessionKey:e.parentSessionId??null,label:e.label??null,agentId:e.agentId??null})):[]}function Br(e){let{availableAgents:t,parentSessionId:n,selectedAgentId:r,selectedSession:i,selectedSessionType:a,sessionKey:o,sessionSummaries:s,sessionTypeOptions:c}=e,l=i?Me(i):void 0,u=i?.agentId??r,d=t.find(e=>e.id===u)??null,f=(0,q.useMemo)(()=>{if(!n)return null;let e=s.find(e=>e.sessionId===n)??null;return e?Ge(e):null},[n,s]),p=c.find(e=>e.value===a)??null;return{currentSessionDisplayName:l,currentAgentId:u,currentAgent:d,parentSession:f,currentSessionTypeLabel:p?.label??G(a),currentSessionTypeIcon:p?.icon??null,currentChildSessionTabs:(0,q.useMemo)(()=>zr({parentSessionKey:o,sessionSummaries:s}),[o,s])}}function Vr(e){(0,q.useEffect)(()=>{e.presenter.chatInputManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,defaultSessionType:e.defaultSessionType,canStopGeneration:e.canStopCurrentRun,stopDisabledReason:e.stopDisabledReason,stopSupported:!0,stopReason:void 0,sendError:e.lastSendError,isSending:e.isSending,modelOptions:e.modelOptions,sessionTypeOptions:e.sessionTypeOptions,selectedSessionType:e.selectedSessionType,canEditSessionType:e.canEditSessionType,sessionTypeUnavailable:e.sessionTypeUnavailable,skillRecords:e.skillRecords,isSkillsLoading:e.isSkillsLoading}),e.presenter.chatThreadManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeUnavailable,sessionTypeUnavailableMessage:e.sessionTypeUnavailableMessage,sessionTypeLabel:e.currentSessionTypeLabel,sessionTypeIcon:e.currentSessionTypeIcon,sessionKey:e.sessionKey??null,agentId:e.currentAgentId,agentDisplayName:e.currentAgent?.displayName??null,agentAvatarUrl:e.currentAgent?.avatarUrl??null,availableAgents:e.availableAgents,sessionDisplayName:e.currentSessionDisplayName,sessionProjectRoot:e.effectiveSessionProjectRoot,sessionProjectName:e.effectiveSessionProjectName,canDeleteSession:!!e.selectedSession,threadRef:e.threadRef,isHistoryLoading:e.agent.isHydrating,messages:e.agent.visibleMessages,isSending:e.isSending,isAwaitingAssistantOutput:e.isAwaitingAssistantOutput,contextWindow:Ie(e.agent.snapshot.contextWindow),parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?Me(e.parentSession):null,childSessionTabs:e.childSessionTabs})},[e])}function Hr(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function $(e,t){return e?Object.fromEntries(t.map(t=>[t,e])):{}}function Ur(e){let t=Ae(e.projectRoot),n={...$(e.model?.trim(),[`model`,`preferred_model`]),...$(e.thinkingLevel?.trim(),[`thinkingEffort`,`thinking`,`preferred_thinking`]),...$(e.sessionType?.trim(),[`agentRuntimeId`,`session_type`,`runtime`]),...$(e.agentId?.trim(),[`agentId`,`agent_id`]),...$(t??void 0,[`projectRoot`,`project_root`])},r=Hr(e.requestedSkills);r.length>0&&(n.requested_skill_refs=r);let i=e.composerNodes?Ue(e.composerNodes):[];return i.length>0&&(n[pt]=i),n}function Wr(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r,selectedSessionProjectRoot:i}=e;return t!==null&&n!==null&&r===n&&(i??null)===t}function Gr(e){let t=Re(e=>e.snapshot.query),n=Re(e=>e.snapshot.selectedSessionKey),r=Re(e=>e.snapshot.selectedAgentId),i=H(e=>e.snapshot.pendingSessionType),a=H(e=>e.snapshot.pendingProjectRoot),l=H(e=>e.snapshot.pendingProjectRootSessionKey),u=H(e=>e.snapshot.selectedModel),d=P(),f=We(d),p=Ne(),{confirm:m,ConfirmDialog:h}=dt(),g=o(),_=s(),{sessionId:v}=c(),y=(0,q.useRef)(null),b=(0,q.useRef)(n),x=(0,q.useMemo)(()=>St(v),[v]),S=x??void 0,C=a!==null&&(!S||l===S),w=Rr({query:t,sessionKey:S??null,projectRootOverride:C?a:void 0,currentSelectedModel:u,pendingSessionType:i,setPendingSessionType:e.chatInputManager.setPendingSessionType,setSelectedModel:e.chatInputManager.setSelectedModel,setSelectedThinkingLevel:e.chatInputManager.setSelectedThinkingLevel});return{presenter:e,selectedSessionKey:n,selectedAgentId:r,pendingProjectRoot:a,pendingProjectRootSessionKey:l,systemStatus:d,isRuntimeBlocked:f,agentsQuery:p,confirm:m,ConfirmDialog:h,location:g,navigate:_,threadRef:y,selectedSessionKeyRef:b,routeSessionKey:x,sessionKey:S,hasSessionProjectRootOverride:C,agent:rt(S),...w}}function Kr(e){let t=Gr(e),{agent:n,agentsQuery:r,hasSessionProjectRootOverride:i,pendingProjectRoot:a,isRuntimeBlocked:o,systemStatus:s,selectedAgentId:c,selectedSession:l,selectedSessionType:u,sessionKey:d,sessionSummaries:f,sessionTypeOptions:p}=t,m=i?a:l?.projectRoot??null,h=i?ht(m):l?.projectName??ht(m),g=n.hydrateError?.message??n.snapshot.error?.message??null,_=s.phase===`ready`&&ut(g)?null:g,v=(r.data?.agents?.length??0)>0?r.data?.agents??[]:[{id:l?.agentId??c}],y=Br({sessionKey:d??null,selectedSession:l,selectedAgentId:c,availableAgents:v,parentSessionId:l?.parentSessionId??null,sessionSummaries:f,selectedSessionType:u,sessionTypeOptions:p}),b=n.isRunning||l?.status===`running`;return{...t,availableAgents:v,effectiveSessionProjectRoot:m,effectiveSessionProjectName:h,isSending:n.isSending||b,isAwaitingAssistantOutput:b,canStopCurrentRun:b,stopDisabledReason:b?null:`__preparing__`,lastSendError:o?null:s.phase===`ready`?_:qe({message:_,status:s}),...y}}function qr(e){let{agent:t,pendingProjectRoot:n,pendingProjectRootSessionKey:r,presenter:i,selectedSession:a,selectedSessionKeyRef:o,sessionKey:s}=e;(0,q.useEffect)(()=>{i.chatStreamActionsManager.bind({sendMessage:async e=>{if((e.sessionKey??null)!==(s??null))return;let o=Ur({agentId:e.agentId,model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:!e.sessionKey||e.sessionKey===r?n:a?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),c=He({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:o});if(c)try{let n=await t.send(c);!e.sessionKey&&n?.sessionId&&i.chatSessionListManager.materializeRootSessionRoute(n.sessionId)}catch(t){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?i.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):i.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),t}},stopCurrentRun:async()=>{await t.abort()},resumeRun:async e=>{e.sessionKey===s&&await t.streamRun()},resetStreamState:()=>{o.current=null},applyHistoryMessages:()=>{}})},[t,n,r,i,a?.projectRoot,o,s])}function Jr(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,selectedSession:r}=e;(0,q.useEffect)(()=>{!r||!Wr({pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r.key,selectedSessionProjectRoot:r.projectRoot??null})||H.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[t,n,r])}function Yr(e){let{confirm:t,location:n,navigate:r,presenter:i}=e;(0,q.useEffect)(()=>{i.chatUiManager.syncState({pathname:n.pathname}),i.chatUiManager.bindActions({navigate:r,confirm:t})},[t,n.pathname,r,i])}function Xr(e){let{presenter:t,selectedAgentId:n,selectedSession:r}=e;(0,q.useEffect)(()=>{!r?.agentId||n===r.agentId||t.chatSessionListManager.setSelectedAgentId(r.agentId)},[t,n,r?.agentId])}function Zr(e){let{agent:t,presenter:n,routeSessionKey:r}=e,i=t.snapshot.activeRun?.sessionId??t.visibleMessages.find(e=>e.sessionId.trim())?.sessionId??null;(0,q.useEffect)(()=>{r||!i||n.chatSessionListManager.materializeRootSessionRoute(i)},[i,n,r])}function Qr({view:e}){let[t]=(0,q.useState)(()=>new it),n=Kr(t);return qr(n),Jr(n),Yr(n),Xr(n),Zr(n),jr({view:e,routeSessionKey:n.routeSessionKey,selectedSessionKey:n.selectedSessionKey,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:n.selectedSessionKeyRef,resetStreamState:t.chatStreamActionsManager.resetStreamState}),Vr({presenter:t,isProviderStateResolved:n.isProviderStateResolved,defaultSessionType:n.defaultSessionType,canStopCurrentRun:n.canStopCurrentRun,stopDisabledReason:n.stopDisabledReason,lastSendError:n.lastSendError,isSending:n.isSending,modelOptions:n.modelOptions,sessionTypeOptions:n.sessionTypeOptions,selectedSessionType:n.selectedSessionType,canEditSessionType:n.canEditSessionType,sessionTypeUnavailable:n.sessionTypeUnavailable,skillRecords:n.skillRecords,isSkillsLoading:n.sessionSkillsQuery.isLoading,sessionTypeUnavailableMessage:n.sessionTypeUnavailableMessage,currentSessionTypeLabel:n.currentSessionTypeLabel,currentSessionTypeIcon:n.currentSessionTypeIcon,sessionKey:n.sessionKey,currentAgentId:n.currentAgentId,currentAgent:n.currentAgent,availableAgents:n.availableAgents,currentSessionDisplayName:n.currentSessionDisplayName,effectiveSessionProjectRoot:n.effectiveSessionProjectRoot,effectiveSessionProjectName:n.effectiveSessionProjectName,selectedSession:n.selectedSession,threadRef:n.threadRef,agent:n.agent,isAwaitingAssistantOutput:n.isAwaitingAssistantOutput,parentSession:n.parentSession,childSessionTabs:n.currentChildSessionTabs}),(0,J.jsx)(Ye,{presenter:t,children:(0,J.jsx)(Mr,{view:e,confirmDialog:(0,J.jsx)(n.ConfirmDialog,{})})})}function $r({view:e}){return(0,J.jsx)(Qr,{view:e})}export{$r as ChatPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./doc-browser-eqdNEerh.js";export{e as DocBrowser};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./mcp-marketplace-page-B-GxKOqS.js";export{e as McpMarketplacePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./dist-C8JRt-tf.js";var t=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./dist-C8JRt-tf.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e,g as t,i as n,m as r,o as i,y as a}from"./react-BqS8oMyM.js";import{Ft as o,Mt as s,Nt as c,Pt as l,Qt as u,jt as d,mt as f,zt as p}from"./api-BCDb13Uv.js";import{c as m}from"./dist-C8JRt-tf.js";import{t as h}from"./confirm-dialog-DBkKcQ1q.js";import{t as g}from"./ellipsis-C9VB2CxT.js";import{t as _}from"./key-round-Ccy6oND3.js";import{t as ee}from"./plus-DHcP-K1U.js";import{t as v}from"./search-COFh_SFI.js";import{t as te}from"./trash-2-D3psAGrz.js";import{t as y}from"./x-CHAxzyp2.js";import{t as b}from"./status-dot-oWBjTovo.js";import{n as x,r as S,t as C}from"./popover-BTLZE5Iz.js";import{$ as w,Ct as T,It as ne,J as E,K as D,U as O,X as k,Y as A,_t as re,at as ie,ct as ae,et as j,ft as oe,lt as se,pt as ce,q as M,rt as le,ut as ue}from"./index-DTdPDqto.js";import{t as N}from"./config-hints-Ceiol9x4.js";import{a as de,c as fe,i as pe,n as P,o as me,r as he,s as ge}from"./config-split-page-BwhGqmUS.js";import{a as _e,o as ve,s as ye,t as be}from"./provider-models-C_yOh6DE.js";var xe=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Se=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),F=m(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ce=m(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),I=a(t(),1),L=r();function we({isSet:t,className:n,value:r,onChange:i,placeholder:a,...s}){let[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,L.jsxs)(`div`,{className:`relative`,children:[t&&!p&&!d?(0,L.jsx)(`div`,{onClick:()=>f(!0),className:e(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,n),children:`••••••••••••`}):(0,L.jsx)(l,{type:c?`text`:`password`,className:e(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...s}),(0,L.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(t||p)&&(0,L.jsx)(o,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!c),children:c?(0,L.jsx)(Se,{className:`h-4 w-4`}):(0,L.jsx)(F,{className:`h-4 w-4`})})})]})}function R({value:t,onChange:r,className:i}){let a=t?Object.entries(t):[],s=(e,t,n)=>{let i=[...a];i[e]=[t,n],r(Object.fromEntries(i))},c=()=>{r({...t,"":``})},u=e=>{let t=a.filter((t,n)=>n!==e);r(Object.fromEntries(t))};return(0,L.jsxs)(`div`,{className:e(`space-y-2`,i),children:[a.map(([e,t],r)=>(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(l,{type:`text`,value:e,onChange:e=>s(r,e.target.value,t),placeholder:n(`headerName`),className:`flex-1`}),(0,L.jsx)(l,{type:`text`,value:t,onChange:t=>s(r,e,t.target.value),placeholder:n(`headerValue`),className:`flex-1`}),(0,L.jsx)(o,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>u(r),children:(0,L.jsx)(te,{className:`h-4 w-4 text-red-500`})})]},r)),(0,L.jsxs)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,L.jsx)(ee,{className:`h-4 w-4 mr-2`}),n(`add`)]})]})}function Te(e){let{value:t,onChange:n,options:r}=e;return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,L.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function Ee(e){let{showAdvanced:t,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:l,wireApiSelectOptions:u,extraHeadersLabel:d,extraHeaders:f,onExtraHeadersChange:p}=e;return(0,L.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(!t),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(Ce,{className:`h-3.5 w-3.5`}),n(`providerAdvancedSettings`)]}),(0,L.jsx)(ne,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,L.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),l?(0,L.jsx)(Te,{value:o,onChange:e=>s(e),options:u}):(0,L.jsxs)(D,{value:o,onValueChange:e=>s(e),children:[(0,L.jsx)(A,{className:`rounded-xl`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(M,{children:u.map(e=>(0,L.jsx)(E,{value:e.value,children:e.label},e.value))})]})]}):null,(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:d}),(0,L.jsx)(R,{value:f,onChange:p}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerExtraHeadersHelpShort`)})]})]}):null]})}function De(e){let{providerAuth:t,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:s,shouldUseAuthMethodPills:l,resolvedAuthMethodId:u,onAuthMethodChange:d,onStartProviderAuth:f,onImportProviderAuthFromCli:p,startPending:m,importPending:h,authSessionId:g,authStatusMessage:_}=e;return t?.kind===`device_code`?(0,L.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:t.displayName||n(`providerAuthSectionTitle`)}),r?(0,L.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{className:`text-xs font-medium text-gray-700`,children:n(`providerAuthMethodLabel`)}),l?(0,L.jsx)(Te,{value:u,onChange:d,options:i}):(0,L.jsxs)(D,{value:u,onValueChange:d,children:[(0,L.jsx)(A,{className:`h-8 rounded-lg bg-white`,children:(0,L.jsx)(k,{placeholder:n(`providerAuthMethodPlaceholder`)})}),(0,L.jsx)(M,{children:i.map(e=>(0,L.jsx)(E,{value:e.value,children:e.label},e.value))})]}),s?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:s}):null]}):null,(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:f,disabled:m||!!g,children:n(m?`providerAuthStarting`:g?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,L.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:h,children:n(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,g?(0,L.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[n(`providerAuthSessionLabel`),`: `,g.slice(0,8),`…`]}):null]}),_?(0,L.jsx)(`p`,{className:`text-xs text-gray-600`,children:_}):null]}):null}var Oe={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function z(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function ke(e,t){let n=z(e),r=z(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function B(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Ae(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function je(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ae(n,t))}return n.trim()}function Me(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ne(e,t){return B(t)}function Pe(e,t){return B(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Fe(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=ve(i.thinking?.supported);if(a.length>0){let t=ye(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function Ie(e,t,n){return{..._e(e,n),..._e(t,n)}}function Le(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Me([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Re(e){return n(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function ze(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Be(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Ve(e){let{models:t,modelConfig:r,modelDraft:i,showModelInput:a,onModelDraftChange:s,onShowModelInputChange:u,onAddModel:d,onRemoveModel:p,onToggleModelThinkingLevel:m,onSetModelThinkingDefault:h,onSetModelVision:g,thinkingLevels:_,formatThinkingLevelLabel:v}=e;return(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(c,{className:`text-sm font-medium text-gray-900`,children:n(`providerModelsTitle`)}),a?null:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,L.jsx)(ee,{className:`h-3 w-3`}),n(`providerAddModel`)]})]}),a?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(l,{value:i,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(u(!1),s(``))},placeholder:n(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,L.jsx)(o,{type:`button`,size:`sm`,onClick:d,disabled:i.trim().length===0,children:n(`add`)}),(0,L.jsx)(o,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{u(!1),s(``)},children:(0,L.jsx)(y,{className:`h-4 w-4`})})]}):null,t.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm text-gray-500`,children:n(`providerModelsEmptyShort`)}),a?null:(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:n(`providerAddFirstModel`)})]}):(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=r[e],i=t?.thinking,a=i?.supported??[],o=i?.default??null,s=t?.vision===!0;return(0,L.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,L.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,L.jsxs)(C,{children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`providerModelThinkingTitle`),title:n(`providerModelThinkingTitle`),children:(0,L.jsx)(Ce,{className:`h-3 w-3`})})}),(0,L.jsxs)(x,{className:`w-80 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-100 bg-gray-50 px-3 py-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:n(`providerModelVisionTitle`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelVisionHint`)})]}),(0,L.jsx)(f,{checked:s,onCheckedChange:t=>g(e,t)})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:n(`providerModelThinkingTitle`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingHint`)})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(t=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>m(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${a.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:v(t)},t))}),(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(c,{className:`text-xs font-medium text-gray-700`,children:n(`providerModelThinkingDefault`)}),(0,L.jsxs)(D,{value:o??`__none__`,onValueChange:t=>h(e,t===`__none__`?null:t),disabled:a.length===0,children:[(0,L.jsx)(A,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,L.jsx)(k,{})}),(0,L.jsxs)(M,{children:[(0,L.jsx)(E,{value:`__none__`,children:n(`providerModelThinkingDefaultNone`)}),a.map(e=>(0,L.jsx)(E,{value:e,children:v(e)},e))]})]}),a.length===0?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":n(`remove`),children:(0,L.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function He(e){return e.enabled?(0,L.jsx)(b,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?n(`statusReady`):n(`statusSetup`),className:e.className}):(0,L.jsx)(b,{status:`inactive`,label:n(`disabled`),className:e.className})}function V({providerName:e,onProviderDeleted:t}){let r=u(),{data:a}=ue(),{data:s}=se(),{data:d}=w(),f=re(),m=le(),h=ce(),g=oe(),_=ae(),ee=ie(),[v,y]=(0,I.useState)(``),[b,x]=(0,I.useState)(``),[S,C]=(0,I.useState)(null),[T,ne]=(0,I.useState)(`auto`),[E,D]=(0,I.useState)([]),[O,k]=(0,I.useState)({}),[A,j]=(0,I.useState)(``),[M,pe]=(0,I.useState)(``),[he,_e]=(0,I.useState)(!1),[ve,ye]=(0,I.useState)(!1),[Se,F]=(0,I.useState)(null),[Ce,R]=(0,I.useState)(``),[Te,Ae]=(0,I.useState)(``),V=(0,I.useRef)(null),H=e?a?.providers[e]:null,U=s?.providerTemplates.find(e=>e.providerType===H?.providerType),W=H??Oe,Ue=d?.uiHints,We=!!H?.isCustom,Ge=e?N(`providers.${e}.apiKey`,Ue):void 0,Ke=e?N(`providers.${e}.apiBase`,Ue):void 0,qe=e?N(`providers.${e}.extraHeaders`,Ue):void 0,Je=e?N(`providers.${e}.wireApi`,Ue):void 0,Ye=U?.displayName||H?.displayName||e||``,G=(W.displayName||``).trim()||Ye,Xe=W.enabled!==!1,Ze=M.trim()||G||e||n(`providersSelectPlaceholder`),K=(0,I.useMemo)(()=>B([U?.modelPrefix||U?.providerType||``,e||``]),[e,U?.modelPrefix,U?.providerType]),Qe=U?.defaultApiBase||``,q=W.apiBase||Qe,$e=z(W.extraHeaders||null),et=W.wireApi||U?.defaultWireApi||`auto`,tt=(0,I.useMemo)(()=>B((U?.defaultModels??[]).map(e=>je(e,K))),[U?.defaultModels,K]),nt=(0,I.useMemo)(()=>B((W.models??[]).map(e=>je(e,K))),[W.models,K]),J=(0,I.useMemo)(()=>Ne(tt,nt),[tt,nt]),rt=(0,I.useMemo)(()=>Fe(Ie(U?.modelConfig,W.modelConfig,K),J),[J,K,U?.modelConfig,W.modelConfig]),Y=i(),it=U?.apiBaseHelp?.[Y]||U?.apiBaseHelp?.en||Ke?.help||n(`providerApiBaseHelp`),X=U?.auth,Z=(0,I.useMemo)(()=>X?.methods??[],[X?.methods]),Q=!!U?.supportsWireApi||We,at=(0,I.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),ot=(0,I.useMemo)(()=>ze({providerName:U?.providerType??e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y,U?.providerType]),st=(0,I.useMemo)(()=>{if(!Z.length)return``;let e=Te.trim();return e&&Z.some(t=>t.id===e)?e:ot||Z[0]?.id||``},[Te,ot,Z]),ct=(0,I.useMemo)(()=>Z.find(e=>e.id===st),[Z,st]),lt=Be({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),ut=(U?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:n(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),dt=Be({required:Q,hasDefault:typeof U?.defaultWireApi==`string`&&U.defaultWireApi.length>0,optionCount:ut.length}),$=(0,I.useCallback)(()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},[]),ft=(0,I.useCallback)((t,i)=>{$(),V.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await _.mutateAsync({provider:e,data:{sessionId:t}});if(a.status===`pending`){R(n(`providerAuthWaitingBrowser`)),ft(t,a.nextPollMs??i);return}if(a.status===`authorized`){F(null),$(),R(n(`providerAuthCompleted`)),p.success(n(`providerAuthCompleted`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`providers`]});return}F(null),$(),R(a.message||`Authorization ${a.status}.`),p.error(a.message||`Authorization ${a.status}.`)}catch(e){F(null),$();let t=e instanceof Error?e.message:String(e);R(t),p.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,i))},[$,_,e,r]);(0,I.useEffect)(()=>{if(!e){y(``),x(``),C(null),ne(`auto`),D([]),k({}),j(``),pe(``),F(null),R(``),Ae(``),$();return}y(``),x(q),C(W.extraHeaders||null),ne(et),D(J),k(rt),j(``),pe(G),F(null),R(``),Ae(ot),$()},[e,q,W.extraHeaders,et,J,rt,G,ot,$]),(0,I.useEffect)(()=>()=>$(),[$]),(0,I.useEffect)(()=>k(e=>Fe(e,E)),[E]);let pt=(0,I.useMemo)(()=>e?v.trim().length>0||b.trim()!==q.trim()||!ke(S,$e)||Q&&T!==et||!Me(E,J)||!Le(O,rt)||M.trim()!==G:!1,[e,v,b,q,S,$e,Q,T,et,E,J,O,rt,M,G]);return!e||!H?(0,L.jsx)(P,{children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:n(`providersSelectTitle`)}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:n(`providersSelectDescription`)})]})}):(0,L.jsxs)(de,{children:[(0,L.jsx)(fe,{className:`px-6 py-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Ze}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:async()=>{if(e&&window.confirm(n(`providerDeleteConfirm`)))try{await m.mutateAsync({provider:e}),t?.(e)}catch{}},disabled:m.isPending,className:`text-gray-400 transition-colors hover:text-red-500`,title:n(`providerDelete`),children:(0,L.jsx)(te,{className:`h-4 w-4`})}),(0,L.jsx)(He,{enabled:Xe,apiKeySet:W.apiKeySet})]})]})}),(0,L.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=v.trim(),i=b.trim(),a=z(S),o=M.trim();o!==G&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),i!==q.trim()&&(n.apiBase=i.length>0&&i!==Qe?i:null),ke(a,$e)||(n.extraHeaders=a),Q&&T!==et&&(n.wireApi=T),Me(E,J)||(n.models=Pe(E,e)),Le(O,rt)||(n.modelConfig=Fe(O,E)),f.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(me,{className:`space-y-5 px-6 py-5`,children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:n(`providerDisplayName`)}),(0,L.jsx)(l,{id:`providerDisplayName`,type:`text`,value:M,onChange:e=>pe(e.target.value),placeholder:Ye||n(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`providerDisplayNameHelpShort`)})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:Ge?.label??n(`apiKey`)}),(0,L.jsx)(we,{id:`apiKey`,value:v,isSet:W.apiKeySet,onChange:e=>y(e.target.value),placeholder:Ge?.placeholder??n(`enterApiKey`),className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`leaveBlankToKeepUnchanged`)})]}),(0,L.jsx)(De,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:at,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:ct?.hint?.[Y]||ct?.hint?.en||``,shouldUseAuthMethodPills:lt,resolvedAuthMethodId:st,onAuthMethodChange:Ae,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{R(``);let t=await g.mutateAsync({provider:e,data:st?{methodId:st}:{}});if(!t.sessionId||!t.verificationUri)throw Error(n(`providerAuthStartFailed`));F(t.sessionId),R(`${n(`providerAuthOpenPrompt`)}${t.userCode}${n(`providerAuthOpenPromptSuffix`)}`),window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),ft(t.sessionId,t.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);F(null),$(),R(t),p.error(`${n(`providerAuthStartFailed`)}: ${t}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),F(null);let t=await ee.mutateAsync({provider:e});R(`${n(`providerAuthImportStatusPrefix`)}${t.expiresAt?` (expires: ${t.expiresAt})`:``}`),p.success(n(`providerAuthImportSuccess`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);R(t),p.error(`${n(`providerAuthImportFailed`)}: ${t}`)}},startPending:g.isPending,importPending:ee.isPending,authSessionId:Se,authStatusMessage:Ce}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(c,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Ke?.label??n(`apiBase`)}),(0,L.jsx)(l,{id:`apiBase`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:Qe||Ke?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:it})]}),(0,L.jsx)(Ve,{models:E,modelConfig:O,modelDraft:A,showModelInput:ve,onModelDraftChange:j,onShowModelInputChange:ye,onAddModel:()=>{let e=je(A,K);if(e){if(e.includes(`/`)){p.error(n(`providerModelInvalidProviderPrefix`));return}if(E.includes(e)){j(``);return}D(t=>[...t,e]),j(``)}},onRemoveModel:e=>{D(t=>t.filter(t=>t!==e)),k(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{k(n=>{let r=n[e],i=r?.thinking?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):be.filter(e=>e===t||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...n};return s.thinking||s.vision===!0?c[e]=s:delete c[e],c})},onSetModelThinkingDefault:(e,t)=>{k(n=>{let r=n[e],i=r?.thinking;return!i||i.supported.length===0||t&&!i.supported.includes(t)?n:{...n,[e]:{...r,thinking:t?{supported:i.supported,default:t}:{supported:i.supported}}}})},onSetModelVision:(e,t)=>{k(n=>{let r={...n[e],vision:t?!0:void 0},i={...n};return r.thinking||r.vision===!0?i[e]=r:delete i[e],i})},thinkingLevels:be,formatThinkingLevelLabel:Re}),(0,L.jsx)(Ee,{showAdvanced:he,onShowAdvancedChange:_e,supportsWireApi:Q,wireApiLabel:Je?.label??n(`wireApi`),wireApi:T,onWireApiChange:ne,shouldUseWireApiPills:dt,wireApiSelectOptions:ut,extraHeadersLabel:qe?.label??n(`extraHeaders`),extraHeaders:S,onExtraHeadersChange:C})]}),(0,L.jsxs)(ge,{className:`flex items-center justify-between px-6 py-4`,children:[(0,L.jsxs)(o,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let t=je(E.find(e=>e.trim().length>0)??``,K),r={apiBase:b.trim(),extraHeaders:z(S),model:t||null};v.trim().length>0&&(r.apiKey=v.trim()),Q&&(r.wireApi=T);try{let t=await h.mutateAsync({provider:e,data:r});if(t.success){p.success(`${n(`providerTestConnectionSuccess`)} (${t.latencyMs}ms)`);return}let i=[`provider=${t.provider}`,`latency=${t.latencyMs}ms`];t.model&&i.push(`model=${t.model}`),p.error(`${n(`providerTestConnectionFailed`)}: ${t.message} | ${i.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);p.error(`${n(`providerTestConnectionFailed`)}: ${t}`)}},disabled:h.isPending,children:[(0,L.jsx)(xe,{className:`mr-1.5 h-4 w-4`}),h.isPending?n(`providerTestingConnection`):n(`providerTestConnection`)]}),(0,L.jsx)(o,{type:`submit`,disabled:f.isPending||!pt,children:f.isPending?n(`saving`):n(pt?`save`:`unchanged`)})]})]})]})}function H(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function U(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function W(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function Ue(){let{isMobile:t}=T(),{data:r}=ue(),{data:i}=se(),a=j(),c=le(),u=re(),[p,m]=(0,I.useState)(null),[y,w]=(0,I.useState)(null),[ne,E]=(0,I.useState)(!1),[D,k]=(0,I.useState)([]),[A,ie]=(0,I.useState)(``),ae=(0,I.useMemo)(()=>U(Object.values(r?.providers??{}),D),[r?.providers,D]),oe=(0,I.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),ce=(0,I.useMemo)(()=>W(oe),[oe]),M=(0,I.useMemo)(()=>new Map(oe.map(e=>[e.providerType,e])),[oe]),N=(0,I.useMemo)(()=>{let e=A.trim().toLowerCase();return ae.filter(t=>{if(!e)return!0;let n=t.providerType?M.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[ae,A,M]),P=(0,I.useMemo)(()=>p&&N.some(e=>e.providerId===p)?p:t?null:N[0]?.providerId??null,[N,t,p]);return!r||!i?(0,L.jsx)(`div`,{className:`p-8`,children:n(`providersLoading`)}):(0,L.jsxs)(s,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,L.jsx)(d,{title:n(`providersPageTitle`),description:n(`providersPageDescription`)}),(0,L.jsxs)(pe,{className:`xl:min-h-0`,mobileView:t?P?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:n(`providersPageTitle`),children:[(0,L.jsxs)(de,{children:[(0,L.jsx)(fe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,L.jsxs)(C,{open:ne,onOpenChange:E,children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsxs)(o,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,L.jsx)(ee,{className:`mr-2 h-4 w-4`}),a.isPending?n(`saving`):n(`providerAdd`)]})}),(0,L.jsxs)(x,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,L.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-gray-500`,children:n(`providerTemplatePickerTitle`)}),(0,L.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-gray-300 bg-white px-3 py-2 text-left hover:border-primary/40 hover:bg-gray-50`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});ie(``),m(e.providerId),k(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),E(!1)}catch{}},children:[(0,L.jsx)(O,{name:`custom`,className:`h-8 w-8 rounded-lg border border-gray-200 bg-white`}),(0,L.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-gray-800`,children:n(`providerAddCustom`)})]}),ce.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-left hover:border-primary/40 hover:bg-gray-50`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});ie(``),m(t.providerId),k(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),E(!1)}catch{}},children:[(0,L.jsx)(O,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-gray-200 bg-white`,imgClassName:`h-4 w-4 object-contain`}),(0,L.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-gray-800`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,L.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,L.jsx)(l,{value:A,onChange:e=>ie(e.target.value),placeholder:n(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,L.jsxs)(me,{className:`space-y-2 p-3`,children:[N.map(t=>{let r=t.providerType?M.get(t.providerType):null,i=t.enabled!==!1,a=!!(i&&t.apiKeySet),o=t.displayName?.trim()||r?.displayName||t.providerId,s=H(t.apiBase||r?.defaultApiBase||``)||n(`providersDefaultDescription`);return(0,L.jsx)(`div`,{onClick:()=>m(t.providerId),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m(t.providerId))},role:`button`,tabIndex:0,className:e(`w-full rounded-xl border p-2.5 text-left transition-all`,P===t.providerId?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,L.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,L.jsx)(O,{name:t.providerType??t.providerId,src:r?.logo?`/logos/${r.logo}`:null,className:e(`h-10 w-10 rounded-lg border`,a?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,L.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:t.providerId[0]})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:o}),(0,L.jsx)(`p`,{className:`truncate font-mono text-[10px] text-gray-400`,children:t.providerId}),(0,L.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:[s,` · `,t.models?.length??0]})]})]}),(0,L.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,L.jsx)(f,{checked:i,disabled:u.isPending,title:n(i?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:e=>{u.mutateAsync({provider:t.providerId,data:{enabled:e},silentSuccess:!0})}})}),(0,L.jsxs)(C,{children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 hover:bg-gray-100 hover:text-gray-700`,onClick:e=>e.stopPropagation(),title:n(`more`),children:(0,L.jsx)(g,{className:`h-4 w-4`})})}),(0,L.jsx)(x,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-sm text-red-600 hover:bg-red-50`,onClick:()=>w(t.providerId),children:[(0,L.jsx)(te,{className:`h-4 w-4`}),n(`providerDelete`)]})})]})]}),(0,L.jsx)(b,{status:i?a?`ready`:`setup`:`inactive`,label:n(i?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},t.providerId)}),N.length===0?(0,L.jsx)(he,{icon:_,title:n(`providersNoMatch`)}):null]})]}),(0,L.jsx)(V,{providerName:P??void 0,onProviderDeleted:e=>{k(t=>t.filter(t=>t!==e)),e===P&&m(null)}})]}),(0,L.jsx)(h,{open:!!y,onOpenChange:e=>{e||w(null)},title:n(`providerDelete`),description:y??void 0,confirmLabel:n(`delete`),variant:`destructive`,onCancel:()=>w(null),onConfirm:()=>{y&&c.mutateAsync({provider:y}).then(()=>{k(e=>e.filter(e=>e!==y)),y===P&&m(null),w(null)})}})]})}export{Ue as ProvidersList};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./app-presenter-provider-C-QMjK7m.js";export{e as RemoteAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./dist-C8JRt-tf.js";var t=e(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./dist-C8JRt-tf.js";var t=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./dist-C8JRt-tf.js";var t=e(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
|