@nextclaw/ui 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/assets/{api-DPcvCLfa.js → api-a14tR_z1.js} +7 -7
- package/dist/assets/channels-list-page-CFGkm4DT.js +8 -0
- package/dist/assets/chat-page-CEdavJXc.js +105 -0
- package/dist/assets/{config-split-page-BCJhqdK9.js → config-split-page-B5b9B0uE.js} +1 -1
- package/dist/assets/{confirm-dialog-CWh5FfK2.js → confirm-dialog-ClH_Ec7n.js} +1 -1
- package/dist/assets/{desktop-update-config-DsRhBizi.js → desktop-update-config-DPNDnVpk.js} +1 -1
- package/dist/assets/{dist-DPrgcEC0.js → dist-BtCS2Ucq.js} +1 -1
- package/dist/assets/{dist-DsE4OsSS.js → dist-CLGGLm8b.js} +1 -1
- package/dist/assets/doc-browser-5nMWYKBD.js +1 -0
- package/dist/assets/doc-browser-BJRLhztv.js +1 -0
- package/dist/assets/doc-browser-context-D4JwMMxK.js +1 -0
- package/dist/assets/{ellipsis-B81FStLm.js → ellipsis-CtJXjIol.js} +1 -1
- package/dist/assets/{external-link-C_dmG-WJ.js → external-link-CdJiG13p.js} +1 -1
- package/dist/assets/index-BDN1zzMQ.js +105 -0
- package/dist/assets/index-g3uSZXoc.css +1 -0
- package/dist/assets/mcp-marketplace-page-BU0kIjhR.js +40 -0
- package/dist/assets/mcp-marketplace-page-sMNFSq_T.js +1 -0
- package/dist/assets/middleware-CkFT3R4v.js +1 -0
- package/dist/assets/model-config-page-D6hYXROd.js +1 -0
- package/dist/assets/plus-DPjb0piO.js +1 -0
- package/dist/assets/provider-scoped-model-input-DAX2HgmR.js +1 -0
- package/dist/assets/providers-config-page-BzAeaACA.js +1 -0
- package/dist/assets/{react-sZz5HSCm.js → react-C6cZgP44.js} +1 -1
- package/dist/assets/remote-B0G80uPr.js +1 -0
- package/dist/assets/rotate-cw-DnEB1Rju.js +1 -0
- package/dist/assets/runtime-config-page-C5xKaV3i.js +1 -0
- package/dist/assets/{save-MzjoiHri.js → save-DKA0x4zk.js} +1 -1
- package/dist/assets/{search-B29dE4GN.js → search-BNlcoj5c.js} +1 -1
- package/dist/assets/{search-config-page-Dl5sZzob.js → search-config-page-Cq9uJ-N8.js} +1 -1
- package/dist/assets/{secrets-config-page-C_l-IFCK.js → secrets-config-page-CxSbZLBo.js} +2 -2
- package/dist/assets/{select-BKmh05hd.js → select-CvTlDZTQ.js} +1 -1
- package/dist/assets/{tag-chip-BS_7Ueom.js → tag-chip-8ffF2y2C.js} +1 -1
- package/dist/assets/use-config-DmT0o1gv.js +1 -0
- package/dist/assets/x-BiSSpgqB.js +1 -0
- package/dist/index.html +15 -14
- package/package.json +9 -9
- package/src/app/components/app-presenter-provider.tsx +11 -2
- package/src/app/components/layout/__tests__/app-layout.test.tsx +11 -2
- package/src/app/components/layout/__tests__/sidebar.layout.test.tsx +110 -79
- package/src/app/components/layout/app-layout.tsx +18 -4
- package/src/app/components/layout/sidebar-items.tsx +194 -71
- package/src/app/components/layout/sidebar-rail.styles.ts +15 -0
- package/src/app/components/layout/sidebar.tsx +340 -83
- package/src/app/managers/viewport-layout.manager.ts +10 -0
- package/src/app/stores/viewport-layout.store.ts +39 -3
- package/src/features/agents/components/__tests__/agents-page.test.tsx +62 -39
- package/src/features/agents/components/agents-page.tsx +10 -6
- package/src/features/chat/components/conversation/__tests__/chat-conversation-header-section.test.tsx +145 -0
- package/src/features/chat/components/conversation/__tests__/chat-conversation-panel.test.tsx +69 -762
- package/src/features/chat/components/conversation/__tests__/chat-conversation-workspace-section.test.tsx +132 -0
- package/src/features/chat/components/conversation/chat-conversation-content.tsx +22 -15
- package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +14 -15
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +18 -18
- package/src/features/chat/components/conversation/chat-conversation-workspace-section.tsx +10 -4
- package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +52 -11
- package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +16 -14
- package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +247 -0
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +80 -7
- package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +82 -25
- package/src/features/chat/components/layout/chat-sidebar.tsx +59 -92
- package/src/features/chat/components/providers/chat-presenter.provider.tsx +0 -6
- package/src/features/chat/features/conversation/components/session-conversation-area.tsx +289 -0
- package/src/features/chat/features/conversation/components/session-conversation-input.tsx +427 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +204 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-attachments.ts +66 -0
- package/src/features/chat/features/{input/hooks/use-chat-input-bar-query-state.ts → conversation/hooks/use-session-conversation-input-query.ts} +32 -17
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-state.ts +281 -0
- package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +158 -0
- package/src/features/chat/features/input/hooks/__tests__/use-chat-input-surface-state.test.tsx +56 -0
- package/src/features/chat/features/input/hooks/use-chat-input-surface-state.ts +117 -0
- package/src/features/chat/features/input/input-surface-plugins/__tests__/panel-app-reference-plugin.test.ts +77 -0
- package/src/features/chat/features/input/input-surface-plugins/__tests__/slash-command-plugin.test.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/chat-input-product-plugin-adapters.types.ts +10 -0
- package/src/features/chat/features/input/input-surface-plugins/input-surface-search.utils.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/panel-app-reference-plugin.utils.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/slash-command-plugin.utils.ts +161 -0
- package/src/features/chat/features/input/utils/__tests__/chat-composer-state.utils.test.ts +22 -1
- package/src/features/chat/features/input/utils/__tests__/chat-inline-token.utils.test.ts +26 -13
- package/src/features/chat/features/input/utils/__tests__/ncp-chat-input-availability.utils.test.ts +7 -28
- package/src/features/chat/features/input/utils/chat-composer-state.utils.ts +6 -0
- package/src/features/chat/features/input/utils/chat-inline-token.utils.ts +26 -51
- package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +2 -0
- package/src/features/chat/features/input/utils/ncp-chat-input-availability.utils.ts +5 -6
- package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +47 -12
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +93 -12
- package/src/features/chat/features/message/utils/__tests__/chat-message.utils.test.ts +31 -12
- package/src/features/chat/features/message/utils/chat-message-markdown-part.utils.ts +38 -0
- package/src/features/chat/features/message/utils/chat-message-part.utils.ts +1 -1
- package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +2 -2
- package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +2 -2
- package/src/features/chat/features/session/hooks/__tests__/use-chat-session-project.test.tsx +3 -30
- package/src/features/chat/features/session/hooks/use-chat-session-project.ts +0 -5
- package/src/features/chat/features/session/utils/chat-run-metadata.utils.ts +8 -0
- package/src/features/chat/features/session-type/components/__tests__/chat-session-type-menu.test.tsx +2 -2
- package/src/features/chat/features/session-type/components/__tests__/chat-session-type-option-item.test.tsx +2 -0
- package/src/features/chat/features/session-type/components/chat-session-type-menu.tsx +2 -2
- package/src/features/chat/features/session-type/components/chat-session-type-option-item.tsx +2 -2
- package/src/features/chat/features/welcome/components/__tests__/chat-conversation-welcome.test.tsx +49 -31
- package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +2 -2
- package/src/features/chat/features/welcome/components/chat-conversation-welcome.tsx +21 -10
- package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +2 -2
- package/src/features/chat/features/welcome/components/chat-welcome.tsx +2 -2
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +54 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +44 -76
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-nav.tsx +5 -1
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +7 -1
- package/src/features/chat/features/workspace/hooks/use-chat-conversation-workspace-state.ts +40 -31
- package/src/features/chat/features/workspace/utils/__tests__/chat-workspace-panel-view-model.utils.test.ts +59 -1
- package/src/features/chat/features/workspace/utils/chat-thread-workspace-session.utils.ts +109 -0
- package/src/features/chat/features/workspace/utils/chat-workspace-panel-view-model.utils.ts +44 -4
- package/src/features/chat/index.ts +0 -1
- package/src/features/chat/managers/__tests__/chat-session-list.manager.test.ts +51 -99
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +135 -21
- package/src/features/chat/managers/chat-session-list.manager.ts +12 -43
- package/src/features/chat/managers/chat-thread.manager.ts +108 -34
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.ts +48 -1
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.tsx +72 -0
- package/src/features/chat/pages/ncp-chat-page.tsx +0 -122
- package/src/features/chat/presenters/chat.presenter.ts +2 -19
- package/src/features/chat/stores/__tests__/chat-thread.store.test.ts +31 -0
- package/src/features/chat/stores/chat-thread.store.ts +42 -26
- package/src/features/panel-apps/hooks/use-panel-apps.ts +2 -1
- package/src/platforms/desktop/components/__tests__/desktop-app-shell.test.tsx +50 -10
- package/src/platforms/desktop/components/desktop-app-shell.tsx +34 -10
- package/src/platforms/desktop/components/desktop-window-chrome.tsx +41 -16
- package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +24 -1
- package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +8 -4
- package/src/shared/lib/i18n/locales/en-US/chat.json +20 -2
- package/src/shared/lib/i18n/locales/en-US/core.json +2 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +20 -2
- package/src/shared/lib/i18n/locales/zh-CN/core.json +2 -0
- package/src/shared/lib/ui-document-title/__tests__/ui-document-title.test.ts +49 -0
- package/src/shared/lib/ui-document-title/index.ts +50 -21
- package/dist/assets/channels-list-page-D6jtziu4.js +0 -8
- package/dist/assets/chat-page-BBnNJoKG.js +0 -105
- package/dist/assets/doc-browser-C8xOF_9F.js +0 -1
- package/dist/assets/doc-browser-DgQedeAn.js +0 -1
- package/dist/assets/doc-browser-context-B46tQGmO.js +0 -1
- package/dist/assets/index-7o1WdUbU.js +0 -103
- package/dist/assets/index-DQWmEWzk.css +0 -1
- package/dist/assets/mcp-marketplace-page-CWZN7ohK.js +0 -1
- package/dist/assets/mcp-marketplace-page-Dzull_4-.js +0 -40
- package/dist/assets/model-config-page-Cv0O3BIj.js +0 -1
- package/dist/assets/plus-Bnt56oqG.js +0 -1
- package/dist/assets/provider-scoped-model-input-Duuh7i3h.js +0 -1
- package/dist/assets/providers-config-page-CPDz0Lxc.js +0 -1
- package/dist/assets/remote-B0LMs8u7.js +0 -1
- package/dist/assets/rotate-cw-BfyG_KEF.js +0 -1
- package/dist/assets/runtime-config-page-q0fvv8ME.js +0 -1
- package/dist/assets/use-config-DZkBWIdL.js +0 -1
- package/dist/assets/x-CW2KO-Hz.js +0 -1
- package/src/features/chat/components/conversation/chat-conversation-alerts.tsx +0 -37
- package/src/features/chat/features/input/components/__tests__/chat-attachment-upload-limit.test.ts +0 -38
- package/src/features/chat/features/input/components/chat-input-bar.container.tsx +0 -496
- package/src/features/chat/features/message/utils/chat-message-inline-content.utils.ts +0 -95
- package/src/features/chat/managers/__tests__/chat-input.manager.test.ts +0 -448
- package/src/features/chat/managers/__tests__/chat-run-snapshot.manager.test.ts +0 -129
- package/src/features/chat/managers/__tests__/chat-run.manager.test.ts +0 -236
- package/src/features/chat/managers/__tests__/chat-session-preference-sync.manager.test.ts +0 -219
- package/src/features/chat/managers/chat-input.manager.ts +0 -430
- package/src/features/chat/managers/chat-run.manager.ts +0 -110
- package/src/features/chat/managers/chat-session-preference-sync.manager.ts +0 -142
- package/src/features/chat/stores/chat-input.store.ts +0 -104
- /package/dist/assets/{config-hints-CTqBnCDp.js → config-hints-BkYBc7z0.js} +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import{h as e,p as t,r as n,u as r,v as i}from"./react-sZz5HSCm.js";import{$t as a,A as o,At as s,Bt as c,Gt as l,Jt as u,Kt as d,Lt as f,M as p,Mt as m,N as h,P as g,Qt as _,St as v,Wt as y,Xt as b,Yt as x,Zt as S,cn as C,dn as w,dt as T,en as E,fn as D,j as O,jt as k,k as ee,ln as te,rn as A,sn as ne,tn as re,un as ie,zt as ae}from"./api-DPcvCLfa.js";import{a as oe,c as se,i as j,l as ce,n as le,o as ue,r as M,s as N}from"./mcp-marketplace-page-Dzull_4-.js";import{c as P}from"./dist-DsE4OsSS.js";import{a as de,i as fe,n as pe,r as me,t as he}from"./select-BKmh05hd.js";import{a as ge,i as _e,n as ve,o as ye,r as be,s as xe}from"./confirm-dialog-CWh5FfK2.js";import{n as Se}from"./search-B29dE4GN.js";import{a as F,c as I,o as L,s as Ce}from"./doc-browser-DgQedeAn.js";import{t as we}from"./provider-scoped-model-input-Duuh7i3h.js";import{t as Te}from"./ellipsis-B81FStLm.js";import{t as Ee}from"./external-link-C_dmG-WJ.js";import{t as De}from"./plus-Bnt56oqG.js";import{n as Oe}from"./doc-browser-context-B46tQGmO.js";import{$ as ke,A as Ae,At as je,B as Me,C as Ne,D as Pe,E as Fe,F as Ie,Ft as Le,H as Re,I as ze,It as Be,L as R,M as Ve,Mt as He,N as Ue,P as We,Pt as Ge,Q as z,R as Ke,S as qe,St as Je,Tt as Ye,X as Xe,Y as Ze,Z as Qe,_ as $e,a as et,b as tt,bt as nt,d as rt,f as it,ft as at,g as ot,gt as st,ht as B,i as ct,j as lt,jt as V,k as ut,kt as dt,m as ft,n as pt,o as mt,p as ht,pt as gt,r as _t,t as vt,u as yt,vt as bt,w as xt,z as H}from"./index-7o1WdUbU.js";import{l as St,t as Ct,u as wt}from"./use-config-DZkBWIdL.js";import{t as Tt}from"./tag-chip-BS_7Ueom.js";function Et(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Dt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ot=class extends D{#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,C.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||!w(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Et(e,n).forEach(e=>{e.destroy()}),Et(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=ie(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 ne(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Dt(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)&&C.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},U=i(e(),1);function kt({queries:e,...t},n){let r=A(n),i=re(),o=E(),s=U.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);s.forEach(e=>{u(e),S(e,o,r.getQueryCache().get(e.queryHash))}),a(o);let[c]=U.useState(()=>new Ot(r,s,t)),[l,d,f]=c.getOptimisticResult(s,t.combine),p=!i&&t.subscribed!==!1;U.useSyncExternalStore(U.useCallback(e=>p?c.subscribe(C.batchCalls(e)):te,[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),U.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let m=l.some((e,t)=>b(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&b(n,e)?x(n,new ne(r,n),o):[]}):[];if(m.length>0)throw Promise.all(m);let h=l.find((e,t)=>{let n=s[t];return n&&_({result:e,errorResetBoundary:o,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(h?.error)throw h.error;return d(f())}var At=P(`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`}]]),jt=P(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),Mt=P(`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`}]]),Nt=P(`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`}]]),Pt=P(`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`}]]),Ft=P(`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`}]]),It=P(`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`}]]),W=t(),Lt=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`textarea`,{className:r(`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`,e),ref:n,...t}));Lt.displayName=`Textarea`;function Rt(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function zt(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=R(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:H(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 Bt({value:e,disabled:t=!1,runtimeOptions:r,defaultRuntime:i,onChange:a}){let o=e.trim()?R(e):``,s=zt({runtimeOptions:r,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?n(`agentsRuntimeUnavailableHelp`):``);return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(he,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,W.jsx)(fe,{"aria-label":n(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,W.jsx)(de,{placeholder:n(`agentsRuntimeSelectPlaceholder`)})}),(0,W.jsx)(pe,{className:`rounded-xl`,children:s.map(e=>(0,W.jsx)(me,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function Vt({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,W.jsx)(ve,{open:e!==null,onOpenChange:a,children:e?(0,W.jsx)(Ht,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ht(e){let{agent:t,pending:r,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:l}=e,[u,d]=(0,U.useState)(Rt(t));return(0,W.jsxs)(be,{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,W.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,W.jsxs)(ye,{className:`text-left`,children:[(0,W.jsx)(xe,{children:n(`agentsEditDialogTitle`)}),(0,W.jsx)(_e,{children:n(`agentsEditDialogDescription`)})]})}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(at,{tone:`warning`,title:n(`agentsEditHomeReadonly`),description:n(`agentsEditHomeReadonlyHint`),children:(0,W.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,W.jsx)(ae,{value:u.displayName,onChange:e=>d(t=>({...t,displayName:e.target.value})),placeholder:n(`agentsFormNamePlaceholder`)}),(0,W.jsx)(Lt,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:n(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,W.jsx)(ae,{value:u.avatar,onChange:e=>d(t=>({...t,avatar:e.target.value})),placeholder:n(`agentsFormAvatarPlaceholder`)}),(0,W.jsx)(we,{value:u.model,onChange:e=>d(t=>({...t,model:e})),providerCatalog:i,disabled:r,className:`md:col-span-2`}),(0,W.jsx)(Bt,{value:u.runtime,onChange:e=>d(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:r})]})]})}),(0,W.jsxs)(ge,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,W.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:r,children:n(`cancel`)}),(0,W.jsxs)(c,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>l(t.id,u),disabled:r,children:[(0,W.jsx)(nt,{className:`mr-2 h-4 w-4`}),n(`agentsEditSaveAction`)]})]})]})}var Ut=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function Wt(e){let{agentCount:t,onCreate:r}=e;return(0,W.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,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:n(`agentsHeroEyebrow`)}),(0,W.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,W.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:n(`agentsHeroDescription`)})]}),(0,W.jsxs)(c,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:r,children:[(0,W.jsx)(De,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}function Gt(e){let{icon:t,label:n,disabled:i=!1,destructive:a=!1,onClick:o}=e;return(0,W.jsxs)(`button`,{type:`button`,className:r(`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,W.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:n})]})}function Kt(e){let{agent:t,runtimeOptions:r,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:s,onEdit:l,onDelete:u}=e,d=t.runtime?.trim()||t.engine?.trim()||``,f=d?r.find(e=>e.value===R(d))?.label??H(d):i;return(0,W.jsx)(k,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,W.jsxs)(m,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,W.jsx)(Ve,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,W.jsxs)(Tt,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,W.jsx)(st,{className:`h-3 w-3`}),n(`agentsCardBuiltInTag`)]}):null]}),(0,W.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,W.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,W.jsx)(c,{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,W.jsx)(Je,{className:`h-4 w-4`})}),(0,W.jsxs)(xt,{children:[(0,W.jsx)(Pe,{asChild:!0,children:(0,W.jsx)(c,{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,W.jsx)(Te,{className:`h-4 w-4`})})}),(0,W.jsxs)(Fe,{align:`end`,className:`w-44 p-1.5`,children:[(0,W.jsx)(Gt,{icon:nt,label:n(`agentsEditAction`),onClick:l,disabled:a}),t.builtIn?null:(0,W.jsx)(Gt,{icon:gt,label:n(`agentsRemoveAction`),onClick:u,disabled:o,destructive:!0})]})]})]}),(0,W.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,W.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(B,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,W.jsx)(`span`,{className:`truncate`,children:f})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(Ye,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function qt(){let e=z(),t=ut(),r=Ct(),i=wt(),a=St(),o=pt(),s=lt(),l=Ae(),[u,d]=(0,U.useState)(null),p=(0,U.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),h=(0,U.useMemo)(()=>[...p].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[p]),g=(0,U.useMemo)(()=>Re({config:r.data,providersView:i.data,templatesView:a.data,onlyConfigured:!0}),[r.data,i.data,a.data]),_=(0,U.useMemo)(()=>ze(o.data?.options??[]),[o.data?.options]),v=(0,U.useMemo)(()=>R(o.data?.defaultType??`native`),[o.data?.defaultType]),y=(0,U.useMemo)(()=>_.find(e=>e.value===v)?.label??H(v),[v,_]),b=e=>{d(e)},x=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:``}}}),d(null)},S=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,Ke(t,v))};return(0,W.jsxs)(f,{className:`space-y-5`,children:[(0,W.jsx)(Wt,{agentCount:p.length,onCreate:()=>e.startAgentCreationDraft(Ut)}),(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,W.jsx)(k,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,W.jsx)(m,{className:`py-14 text-center text-sm text-gray-500`,children:n(`agentsLoading`)})}):h.length===0?(0,W.jsx)(k,{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,W.jsxs)(m,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,W.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,W.jsx)(He,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,W.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:n(`agentsEmpty`)}),(0,W.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:n(`agentsEmptyDescription`)}),(0,W.jsxs)(c,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>e.startAgentCreationDraft(Ut),children:[(0,W.jsx)(De,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}):h.map(e=>(0,W.jsx)(Kt,{agent:e,runtimeOptions:_,defaultRuntimeLabel:y,updatePending:s.isPending,deletePending:l.isPending,onStartChat:()=>S(e),onEdit:()=>b(e),onDelete:()=>l.mutate({agentId:e.id})},e.id))}),(0,W.jsx)(Vt,{agent:u,pending:s.isPending,providerCatalog:g,runtimeOptions:_,defaultRuntime:v,onOpenChange:e=>{!e&&!s.isPending&&d(null)},onSubmit:x})]})}function G(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function Jt(e){let{request:t,result:n}=e,r=new Date().toISOString();return n.type===`skill`?{type:`skill`,spec:n.spec,id:t.skill??n.spec,label:t.skill??n.name??n.spec,source:`workspace`,installPath:t.installPath,installedAt:r}:{type:n.type,spec:n.spec,id:n.name??n.spec,label:n.name??n.spec,source:`marketplace`,origin:`marketplace`,enabled:t.enabled??!0,runtimeStatus:t.enabled===!1?`disabled`:`ready`,installedAt:r}}function K(e,t){let{id:n,spec:r}=t;return!!(r&&e.spec===r||n&&e.id===n)}function Yt(e,t){return t??{type:e,total:0,specs:[],records:[]}}function Xt(e){let{result:t,view:n}=e,r=Yt(t.type,n),i=Jt(e),a=r.records.findIndex(e=>K(e,{id:i.id,spec:i.spec})),o=[...r.records];return a>=0?o[a]={...o[a],...i}:o.unshift(i),{...r,type:t.type,records:o,specs:G(o),total:o.length}}function Zt(e){let{request:t,result:n,view:r}=e,i=Yt(n.type,r);if(n.action===`uninstall`||n.action===`remove`){let e=i.records.filter(e=>!K(e,{id:n.id,spec:t.spec}));return{...i,records:e,specs:G(e),total:e.length}}let a=i.records.map(e=>K(e,{id:n.id,spec:t.spec})?n.action===`disable`?{...e,enabled:!1,runtimeStatus:`disabled`}:n.action===`update`?{...e,installedAt:new Date().toISOString(),origin:e.origin??`marketplace`}:{...e,enabled:!0,runtimeStatus:`ready`}:e);return{...i,records:a,specs:G(a),total:a.length}}function Qt(e){let t=ce({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>o({...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&&$t(r,e)?t:void 0},staleTime:15e3}),n=(0,U.useMemo)(()=>se(t.data),[t.data]);return{...t,data:n}}function $t(e,t){return e.tag===t.tag&&e.scene===t.scene&&e.pageSize===t.pageSize}function en(e=!0){return d({queryKey:[`marketplace-skill-scenes`],queryFn:p,enabled:e,staleTime:6e4})}function tn(e,t=!0){let n=kt({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>o({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,U.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 nn(e){return d({queryKey:[`marketplace-installed`,e],queryFn:()=>ee(e),staleTime:1e4})}function rn(){let e=A();return l({mutationFn:e=>h(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>Xt({view:e,request:r,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),y.success(t.message||n(`marketplaceInstallSuccessSkill`))},onError:e=>{y.error(e.message||n(`marketplaceInstallFailed`))}})}function an(){let e=A();return l({mutationFn:e=>g(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>Zt({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`);y.success(t.message||i)},onError:e=>{y.error(e.message||n(`marketplaceOperationFailed`))}})}var on=[`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 sn(e){let{name:t,fallback:n,className:i}=e,a=t||n,o=a.substring(0,2).toUpperCase();return(0,W.jsx)(`div`,{className:r(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,cn(a),i),children:o})}function cn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return on[Math.abs(t)%on.length]}function ln({title:e,spec:t}){return(0,W.jsxs)(Ce,{delayDuration:400,children:[(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-950`,children:e})}),(0,W.jsx)(L,{className:`max-w-[300px] text-xs`,children:e})]}),(0,W.jsx)(`div`,{className:`mb-2 mt-1 flex min-w-0 items-center gap-1.5`,children:t?(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono leading-tight text-gray-400`,children:t})}),(0,W.jsx)(L,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null})]})}function un(e){let{item:t,record:i,state:a,onInstall:o,onManage:s}=e,{isInstalling:c,canUpdate:l,canUninstall:u,busyAction:d}=a,f=!!d;return t&&!i||i&&(l||u)?(0,W.jsxs)(`div`,{className:r(`flex shrink-0 items-center justify-end gap-1.5 opacity-100 transition-opacity duration-150`,`md:pointer-events-none 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:[t&&!i&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),o(t)},disabled:c,className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md bg-primary px-2 text-[11px] font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,W.jsx)(dt,{className:`h-3 w-3`}),n(c?`marketplaceInstalling`:`marketplaceInstall`)]}),i&&l&&(0,W.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`update`,i)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-blue-200/80 bg-white px-2 text-[11px] font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,W.jsx)(bt,{className:`h-3 w-3`}),n(d===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),i&&u&&(0,W.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`uninstall`,i)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-gray-200/80 bg-white px-2 text-[11px] font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,W.jsx)(gt,{className:`h-3 w-3`}),n(d===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]}):null}function dn(e){let{record:t,disabled:n}=e;return t?(0,W.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-end`,children:(0,W.jsx)(fn,{disabled:n})}):null}function fn(e){let{disabled:t}=e,i=n(t?`marketplaceDisabledStatus`:`marketplaceInstalledStatus`);return(0,W.jsx)(Ce,{delayDuration:300,children:(0,W.jsxs)(F,{children:[(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(`span`,{"aria-label":i,className:r(`inline-flex h-5 w-5 items-center justify-center`,t?`text-gray-400`:`text-emerald-700`),children:t?(0,W.jsx)(V,{className:`h-4 w-4 opacity-40`}):(0,W.jsx)(V,{className:`h-4 w-4`})})}),(0,W.jsx)(L,{className:`text-xs`,children:i})]})})}function pn(e){let{item:t,record:r,installState:i,manageState:a,onOpen:o,onInstall:s,onManage:c}=e,{language:l}=Xe(),u=M(l),d=t?.name??r?.label??r?.id??r?.spec??n(`marketplaceUnknownItem`),f=j(t?.summaryI18n,t?.summary,u)||(r?n(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??r?.spec??``,m=t?.tags??[],h=r?.id||r?.spec,g=h?a.actionsByTarget.get(h):void 0,_=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`&&i.installingSpecs.has(b);return(0,W.jsxs)(`article`,{onClick:o,className:`group flex h-full min-h-[156px] cursor-pointer flex-col rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,W.jsx)(sn,{name:d,fallback:p||n(`marketplaceTypeSkill`),className:`h-9 w-9 rounded-lg text-xs`}),(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,W.jsx)(ln,{title:d,spec:p})}),(0,W.jsx)(dn,{record:r,disabled:y})]}),(0,W.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-1 flex-col`,children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500`,children:f}),(0,W.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-end justify-between gap-2 pt-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(mn,{tags:m})}),(0,W.jsx)(un,{item:t,record:r,state:{isInstalling:x,canUpdate:v,canUninstall:_,busyAction:g},onInstall:s,onManage:c})]})]})]})}function mn({tags:e}){let t=e.filter(hn).slice(0,3);return t.length===0?null:(0,W.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5 overflow-hidden`,children:t.map(e=>(0,W.jsx)(`span`,{className:`max-w-[104px] truncate rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-medium leading-5 text-gray-500`,children:e},e))})}function hn(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function gn({model:e,showTitle:t,operationState:n,scroll:i,actions:a}){let{scope:o,entries:s,header:c,status:l,emptyLabel:u,errorLabel:d}=e,{showSkeleton:f,isRefreshing:p,error:m}=l,{hasMore:h,loadingMore:g,sentinelRef:_}=i,{installState:v,manageState:y}=n,{onOpen:b,onInstall:x,onManage:S}=a;return(0,W.jsxs)(`section`,{className:r(`flex min-h-full flex-col`,t&&`gap-3`),children:[t&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:c.title}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-gray-500`,children:[p&&(0,W.jsx)(`span`,{className:`font-medium text-primary`,children:c.refreshingLabel}),(0,W.jsx)(`span`,{children:c.summary})]})]}),m&&(0,W.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[d,`: `,m.message]}),p&&(0,W.jsx)(`div`,{"data-testid":`marketplace-list-refreshing`,className:`h-0.5 overflow-hidden rounded-full bg-primary/10`,children:(0,W.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-primary`})}),(0,W.jsxs)(`div`,{"data-testid":f?`marketplace-list-skeleton`:void 0,className:r(`grid grid-cols-1 gap-2.5 md:grid-cols-2 xl:grid-cols-3`,f&&`min-h-0 flex-1 auto-rows-[156px] content-start`),children:[f&&(0,W.jsx)(N,{count:36}),!f&&!m&&s.map(e=>(0,W.jsx)(pn,{item:e.item,record:e.record,installState:v,manageState:y,onOpen:()=>b(e.item,e.record),onInstall:x,onManage:S},e.key))]}),!f&&!m&&s.length===0&&(0,W.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:u}),o===`all`&&!f&&!m&&(0,W.jsx)(ue,{hasMore:h,loading:g,sentinelRef:_})]})}function _n(e){let{entry:t,language:i,localeFallbacks:a,installState:o,layout:s=`rail`,onOpen:c,onInstall:l}=e,{item:u,record:d}=t,f=j(u.summaryI18n,u.summary,a),p=u.install.spec,m=o.installingSpecs.has(p),h=!!d;return(0,W.jsxs)(`article`,{onClick:()=>c(t),className:r(`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`,s===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,W.jsx)(sn,{name:u.name,fallback:u.install.spec}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,W.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:u.name}),(0,W.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:vn(u)})]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:f}),(0,W.jsx)(yn,{tags:u.tags})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:xn(u.updatedAt)}),h?(0,W.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,W.jsx)(V,{className:`h-3.5 w-3.5`}),Sn({zh:`已安装`,en:`Installed`},i)]}):(0,W.jsxs)(`button`,{type:`button`,disabled:m,onClick:e=>{e.stopPropagation(),l(u)},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,W.jsx)(dt,{className:`h-3.5 w-3.5`}),n(m?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function vn(e){return e.slug||e.install.spec}function yn({tags:e}){let t=e.filter(bn).slice(0,2);return t.length===0?null:(0,W.jsx)(`div`,{className:`mt-auto truncate pt-2 text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function bn(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function xn(e){return e.slice(0,10)||e}function Sn(e,t){return t.startsWith(`zh`)?e.zh:e.en}var Cn=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:It,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:At,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:Ft,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:Nt,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:je,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:Pt,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:B,tone:`teal`,span:`md:col-span-2`}],wn={icon:B,tone:`dark`,span:`md:col-span-2`},Tn={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`}},En=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`;function Dn(e){let{entries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=M(a),d=[...t].sort((e,t)=>Mn(e.item,t.item)).slice(0,6);return(0,W.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,W.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,W.jsx)(jn,{icon:Mt,title:q({zh:`场景`,en:`Scenes`},a),description:q({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,W.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid auto-rows-[104px] grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:(0,W.jsx)(N,{count:Cn.length})}):(0,W.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,W.jsx)(On,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||d.length>0)&&(0,W.jsx)(An,{icon:jt,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 On(e){let{scene:t,language:n,onSelect:i}=e,a=J(t.scene),o=a.icon,s=Tn[a.tone];return(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(t.scene),className:r(`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,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:r(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,s.icon),children:(0,W.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:Nn(t,a,n)}),typeof t.count==`number`&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:Fn(t.count,n)})]}),(0,W.jsx)(`p`,{className:r(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,s.text),children:Pn(t,a,n)})]})})}function kn(e){let{scene:t,entries:n,isLoading:i,language:a,localeFallbacks:o,installState:s,onBack:c,onOpen:l,onInstall:u}=e,d=J(t.scene),f=d.icon,p=Tn[d.tone];return(0,W.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,W.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,W.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,W.jsx)(Se,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:r(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,p.icon),children:(0,W.jsx)(f,{className:`h-4 w-4`})}),(0,W.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:Nn(t,d,a)}),(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:q(i?{zh:`加载中`,en:`Loading`}:{zh:`${n.length} 个技能`,en:`${n.length} skills`},a)})]}),(0,W.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,W.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:Pn(t,d,a)})})]})]}),i?(0,W.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:r(En,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,W.jsx)(N,{count:24})}):n.length>0?(0,W.jsx)(`div`,{className:En,children:n.map(e=>(0,W.jsx)(_n,{entry:e,language:a,localeFallbacks:o,installState:s,layout:`grid`,onOpen:l,onInstall:u},e.item.id))}):(0,W.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 An(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,W.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,W.jsx)(jn,{icon:t,title:n,description:r}),s?(0,W.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 grid auto-rows-[166px] grid-cols-[repeat(4,260px)] gap-2.5 overflow-hidden px-1 pb-1.5`,children:(0,W.jsx)(N,{count:4})}):(0,W.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,W.jsx)(_n,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function jn({icon:e,title:t,description:n}){return(0,W.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,W.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function Mn(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 J(e){return Cn.find(t=>t.scene===e)??{scene:e,...wn}}function Nn(e,t,n){return t.title?q(t.title,n):e.title}function Pn(e,t,n){return t.summary?q(t.summary,n):e.description??e.scene}function Fn(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}function In({label:e,className:t,onClick:n}){return(0,W.jsxs)(`button`,{type:`button`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-1.5 text-[13px] font-medium text-primary transition-colors hover:text-primary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,t),onClick:n,children:[(0,W.jsx)(Ee,{className:`h-3.5 w-3.5`}),e]})}var Ln=`https://skillhub.cn/`;function Rn(){return(0,W.jsx)(In,{label:n(`marketplaceExternalSkillSourceTitle`),onClick:()=>void ke.openExternalUrl(Ln)})}function Y(e){return(e??``).trim().toLowerCase()}function X(e,t){let n=Y(t);return n.length>0?`${e}:${n}`:``}function zn(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=X(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function Bn(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=X(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function Vn(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=X(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function Hn(e,t){return t.get(X(e.type,e.spec))||t.get(X(e.type,e.id))||t.get(X(e.type,e.label))}function Un(e,t,n,r){let i=Y(n);if(!i)return!0;let a=j(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>Y(e)).filter(Boolean).some(e=>e.includes(i))}function Wn(e){let{items:t,installedRecordLookup:n,scene:r,forcedType:i,typeFilter:a,scope:o,searchText:s,query:c,showListSkeleton:l,hasCatalogError:u}=e,d=en(a===`skill`),f=(0,U.useMemo)(()=>d.data?.scenes??[],[d.data?.scenes]),p=tn(f,a===`skill`),m=(0,U.useMemo)(()=>f.map(e=>({...e,count:typeof e.count==`number`?e.count:p.get(e.scene)})),[p,f]),h=(0,U.useMemo)(()=>t.map(e=>({item:e,record:Vn(e,n)})),[t,n]),g=(0,U.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`}}function Gn(){let e=rn(),t=an(),{confirm:r,ConfirmDialog:i}=$e(),[a,o]=(0,U.useState)(new Set),[s,c]=(0,U.useState)(new Map);return{installState:{installingSpecs:a},manageState:{actionsByTarget:s},handleInstall:async t=>{let n=t.install.spec;if(!a.has(n)){o(e=>new Set(e).add(n));try{await e.mutateAsync({type:t.type,spec:n,kind:t.install.kind,skill:t.slug,installPath:`skills/${t.slug}`})}catch{}finally{o(e=>{let t=new Set(e);return t.delete(n),t})}}},handleManage:async(e,i)=>{let a=e===`update`?i.catalogSlug||i.id||i.spec:i.id||i.spec;if(!(!a||s.has(a))&&!(e===`uninstall`&&!await r({title:`${n(`marketplaceUninstallTitle`)} ${a}?`,description:n(`marketplaceUninstallDescription`),confirmLabel:n(`marketplaceUninstall`),variant:`destructive`}))){c(t=>new Map(t).set(a,e));try{await t.mutateAsync({type:i.type,action:e,id:a,spec:i.spec})}finally{c(e=>{let t=new Map(e);return t.delete(a),t})}}},ConfirmDialog:i}}function Z(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Kn(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 Q(e){return Z(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 qn(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function Jn(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">${Z(n[1])}</span>`:``}<pre><code>${Z(r.join(`
|
|
5
|
-
`))}</code></pre></div>`,nextIndex:i+1}}function Yn(e,t){let n=Math.min(4,e[1]?.length??2);return{html:`<h${n}>${Q(e[2]??``)}</h${n}>`,nextIndex:t+1}}function Xn(e,t,n){let r=[],i=t,a=n?/^\d+\.\s+/:/^[-*]\s+/;for(;i<e.length&&a.test(e[i]?.trim()??``);)r.push(`<li>${Q((e[i]??``).trim().replace(a,``))}</li>`),i+=1;return{html:n?`<ol>${r.join(``)}</ol>`:`<ul>${r.join(``)}</ul>`,nextIndex:i}}function Zn(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>${Q(n.join(` `))}</blockquote>`,nextIndex:r}}function Qn(e,t){let n=[],r=t;for(;r<e.length;){let t=e[r]?.trim()??``;if(!t||qn(t))break;n.push(t),r+=1}return{html:`<p>${Q(n.join(` `))}</p>`,nextIndex:r}}function $n(e,t){let n=e[t]?.trim()??``,r=n.match(/^```(\S*)/);if(r)return Jn(e,t,r);let i=n.match(/^(#{1,4})\s+(.+)$/);return i?Yn(i,t):/^[-*]\s+/.test(n)?Xn(e,t,!1):/^\d+\.\s+/.test(n)?Xn(e,t,!0):/^>\s?/.test(n)?Zn(e,t):Qn(e,t)}function er(e){let t=Kn(e).replace(/\r\n/g,`
|
|
6
|
-
`).split(`
|
|
7
|
-
`),n=[],r=0;for(;r<t.length;){if(!(t[r]??``).trim()){r+=1;continue}let e=$n(t,r);n.push(e.html),r=e.nextIndex}return n.join(``)}function tr(e){return Array.isArray(e)?e.map(e=>tr(e)).join(`, `):e&&typeof e==`object`?JSON.stringify(e):String(e??``)}function nr(e){try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?[]:Object.entries(t).map(([e,t])=>({key:e,value:tr(t)})).filter(e=>e.value.trim().length>0)}catch{return[]}}function rr(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 ir(e){let t=nr(e),n=t.length>0?t:rr(e);return n.length===0?`<pre class="code">${Z(e)}</pre>`:`<dl class="metadata-list">${n.map(e=>`<div><dt>${Z(e.key)}</dt><dd>${Z(e.value)}</dd></div>`).join(``)}</dl>`}function $(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=ir(p),y=er(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>${Z(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>${Z(t)}</h1>
|
|
85
|
-
<div class="meta">${Z(n)} · ${Z(r)}${d?` · ${Z(d)}`:``}</div>
|
|
86
|
-
${h?`<p class="summary">${Z(h)}</p>`:``}
|
|
87
|
-
${_?`<p class="summary">${Z(g)}</p>`:``}
|
|
88
|
-
${u&&u.length>0?`<div class="tags">${u.map(e=>`<span class="tag">${Z(e)}</span>`).join(``)}</div>`:``}
|
|
89
|
-
${c?`<p class="meta" style="margin-top:12px;">${Z(l??`Source`)}: <a class="source" href="${Z(c)}" target="_blank" rel="noopener noreferrer">${Z(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)}`}function ar(e){let t=Oe(),r=(0,U.useRef)({byKey:new Map,seq:0});return{openItemDetail:async(i,a)=>{let o=i?.name??a?.label??a?.id??a?.spec??n(`marketplaceUnknownItem`),s=i?`marketplace:${i.type}:${i.slug}`:`marketplace:${a?.type??`unknown`}:${a?.id??a?.spec??o}`,c={title:o,kind:`content`,dedupeKey:s},l={...c,activate:!1},u=n(`marketplaceTypeSkill`);if(!i){t.open($({title:o,typeLabel:u,spec:a?.spec??`-`,summary:n(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(a??{},null,2),contentRaw:`-`}),c);return}let d=r.current.seq+1;r.current.seq=d,r.current.byKey.set(s,d);let f=j(i.summaryI18n,i.summary,e);t.open($({title:o,typeLabel:u,spec:i.install.spec,loading:!0}),c);try{let e=await O(i.slug);if(r.current.byKey.get(s)!==d)return;t.open($({title:o,typeLabel:u,spec:i.install.spec,summary:f,metadataRaw:e.metadataRaw,contentRaw:e.bodyRaw||e.raw,sourceUrl:e.sourceUrl,sourceLabel:`Source (${e.source})`,tags:i.tags,author:i.author}),l)}catch(e){if(r.current.byKey.get(s)!==d)return;t.open($({title:o,typeLabel:u,spec:i.install.spec,summary:f,metadataRaw:JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),contentRaw:n(`marketplaceOperationFailed`)}),l)}}}}function or(e){let{scope:t,typeFilter:r,query:i,localeFallbacks:a,catalogView:o,installedView:s,isCatalogLoading:c,isCatalogFetching:l,isCatalogFetchingNextPage:u,catalogError:d,isInstalledLoading:f,installedError:p}=e,m=(0,U.useMemo)(()=>s?.records??[],[s?.records]),h=(0,U.useMemo)(()=>o?.items??[],[o?.items]),g=(0,U.useMemo)(()=>zn(h),[h]),_=(0,U.useMemo)(()=>Bn(m),[m]),v=(0,U.useMemo)(()=>m.filter(e=>e.type===r).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:Hn(e,g)})).filter(e=>Un(e.record,e.item,i,a)).sort((e,t)=>sr(e.record,t.record)),[m,r,g,i,a]),y=(0,U.useMemo)(()=>t===`installed`?v:h.map(e=>({key:e.id,item:e,record:Vn(e,_)})),[h,v,_,t]),b=t===`all`&&c&&!o||t===`installed`&&f&&!s,x=t===`all`&&!b&&!!o&&l&&!u,S=t===`installed`?f&&!s?n(`loading`):`${v.length} ${n(`marketplaceInstalledSkillsCountSuffix`)}`:o?`${h.length} / ${o.total}`:n(`loading`),C=t===`all`&&d?d:t===`installed`&&p?p:void 0,w={scope:t,entries:y,header:{title:n(t===`installed`?`marketplaceSectionInstalledSkills`:`marketplaceAllSkills`),summary:S,refreshingLabel:n(`marketplaceRefreshingResults`)},status:{showSkeleton:b,isRefreshing:x,error:C},emptyLabel:n(t===`installed`?`marketplaceNoInstalledSkills`:`marketplaceNoSkills`),errorLabel:n(t===`installed`?`marketplaceErrorLoadingInstalledSkills`:`marketplaceErrorLoadingSkillsData`)};return{allItems:h,installedRecordLookup:_,installedTotal:s?.total??0,itemListView:w,showListSkeleton:b,isRefreshingList:x}}function sr(e,t){let n=Date.parse(e.installedAt??``),r=Date.parse(t.installedAt??``);return Number.isNaN(n)||Number.isNaN(r)||n===r?e.spec.localeCompare(t.spec):r-n}var cr=20;function lr({forcedType:e}={}){let t=Le(),r=Be(),{language:i}=Xe(),a=`skill`,o=(0,U.useMemo)(()=>M(i),[i]),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[d,p]=(0,U.useState)(`all`),[m,h]=(0,U.useState)(`relevance`),{installState:g,manageState:_,handleInstall:v,handleManage:y,ConfirmDialog:b}=Gn(),{openItemDetail:x}=ar(o);(0,U.useEffect)(()=>{let e=setTimeout(()=>{u(s.trim())},250);return()=>clearTimeout(e)},[s]);let S=nn(a),C=a===`skill`?r.scene?.trim():void 0,w=Qt({q:C?void 0:l||void 0,scene:C,type:a,sort:m,pageSize:cr}),{containerRef:T,sentinelRef:E}=le({disabled:d!==`all`||w.isError||!w.hasNextPage||w.isFetchingNextPage,onLoadMore:()=>w.fetchNextPage(),watchValue:`${a}:${d}:${l}:${C??``}:${m}:${w.data?.loadedItems??0}:${w.data?.loadedPages??0}`});(0,U.useEffect)(()=>{let e=T.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[T,l,C,d,m,a]);let D=or({scope:d,typeFilter:a,query:l,localeFallbacks:o,catalogView:w.data,installedView:S.data,isCatalogLoading:w.isLoading,isCatalogFetching:w.isFetching,isCatalogFetchingNextPage:w.isFetchingNextPage,catalogError:w.isError?w.error:void 0,isInstalledLoading:S.isLoading,installedError:S.isError?S.error:void 0}),O=Wn({items:D.allItems,installedRecordLookup:D.installedRecordLookup,scene:C,forcedType:e,typeFilter:a,scope:d,searchText:s,query:l,showListSkeleton:D.showListSkeleton,hasCatalogError:w.isError});return(0,W.jsxs)(f,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!O.isSceneRoute&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3 border-b border-gray-200/60`,children:[(0,W.jsx)(tt,{value:d,onValueChange:e=>p(e),children:(0,W.jsxs)(qe,{className:`mb-0 h-auto flex-1 justify-start gap-6 rounded-none border-b-0 bg-transparent p-0 text-gray-500`,children:[(0,W.jsx)(Ne,{value:`all`,className:`rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:n(`marketplaceTabMarketplaceSkills`)}),(0,W.jsxs)(Ne,{value:`installed`,className:`gap-1.5 rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:[n(`marketplaceTabInstalledSkills`),(0,W.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:D.installedTotal})]})]})}),(0,W.jsx)(Rn,{})]}),(0,W.jsx)(oe,{scope:d,searchText:s,isRefreshing:D.isRefreshingList,searchPlaceholder:n(`marketplaceSearchPlaceholderSkills`),sort:m,onSearchTextChange:c,onSortChange:h})]}),(0,W.jsx)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsxs)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":D.showListSkeleton||w.isFetchingNextPage,children:[O.isSceneRoute&&O.selectedScene&&(0,W.jsx)(kn,{scene:O.selectedScene,entries:O.sceneEntries,isLoading:D.showListSkeleton,language:i,localeFallbacks:o,installState:g,onBack:()=>t(O.backPath),onOpen:e=>void x(e.item,e.record),onInstall:v}),O.isSceneRoute&&!D.showListSkeleton&&(0,W.jsx)(ue,{hasMore:!!w.hasNextPage,loading:w.isFetchingNextPage,sentinelRef:E}),O.showShelves&&(0,W.jsx)(Dn,{entries:O.entries,scenes:O.scenes,isScenesLoading:O.isScenesLoading,isItemsLoading:D.showListSkeleton,language:i,installState:g,onOpen:e=>void x(e.item,e.record),onInstall:v,onOpenScene:e=>t(`${O.pathPrefix}/${e}`)}),!O.isSceneRoute&&(0,W.jsx)(gn,{model:D.itemListView,showTitle:O.showShelves||!D.showListSkeleton,operationState:{installState:g,manageState:_},scroll:{hasMore:!!w.hasNextPage,loadingMore:w.isFetchingNextPage,sentinelRef:E},actions:{onOpen:(e,t)=>void x(e,t),onInstall:v,onManage:y}})]})}),(0,W.jsx)(b,{})]})}function ur(e){let{view:t,routeSessionKey:n,syncRouteSessionSelection:r}=e;(0,U.useEffect)(()=>{r({isChatView:t===`chat`,routeSessionKey:n})},[n,r,t])}function dr({view:e,confirmDialog:t}){let{isMobile:n}=Ze();return(0,W.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,W.jsx)(et,{}),e===`chat`?n?(0,W.jsx)(mt,{}):(0,W.jsx)(yt,{}):(0,W.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,W.jsx)(ot,{})})}):e===`agents`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,W.jsx)(qt,{})})}):(0,W.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,W.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,W.jsx)(lr,{forcedType:`skills`})})})}),t]})}function fr(e){let t=z(),n=Ct(),r=wt(),i=St(),a=ft({limit:200}),o=pt(),s=e.sessionKey?.trim()||`draft-session`,c=ht({sessionId:s});(0,U.useEffect)(()=>{t.chatQueryManager.syncSnapshot({configQuery:n,providersQuery:r,providerTemplatesQuery:i,sessionsQuery:a,sessionTypesQuery:o,sessionSkillsSessionId:s,sessionSkillsQuery:c})},[n,t.chatQueryManager,r,s,c,a,o,i])}function pr(){let e=z();(0,U.useEffect)(()=>T.eventBus.on(s.uiShowContent,t=>{e.chatThreadManager.handleUiShowContentEvent(t)}),[e])}function mr(){let e=vt(),t=z();(0,U.useEffect)(()=>{let n=n=>{t.startAgentCreationDraft(n.prompt),e.chatDraftIntentManager.markConsumed(n.id)},r=e.chatDraftIntentManager.subscribe(n),i=e.chatDraftIntentManager.consumePending();return i&&n(i),r},[e,t])}function hr(){let{sessionId:e}=Be(),t=(0,U.useMemo)(()=>ct(e),[e]);return{routeSessionKey:t,sessionKey:t??void 0}}function gr(e){let t=z(),{agent:n,sessionKey:r}=e;(0,U.useEffect)(()=>(t.chatRunManager.setActiveRuntime({sessionKey:r??null,sendEnvelope:e=>n.send(e),abortCurrentRun:()=>n.abort(),resumeCurrentSessionRun:()=>n.streamRun()}),()=>{t.chatRunManager.setActiveRuntime(null)}),[n,t,r])}function _r(){let e=z(),{confirm:t,ConfirmDialog:n}=$e(),r=Ge(),i=Le();return(0,U.useEffect)(()=>{e.chatUiManager.syncState({pathname:r.pathname}),e.chatUiManager.bindActions({navigate:i,confirm:t})},[t,r.pathname,i,e]),(0,W.jsx)(n,{})}function vr(e){let t=z(),{agent:n,isRunning:r,isSending:i,lastSendError:a,routeSessionKey:o}=e;(0,U.useEffect)(()=>{t.chatRunManager.applyRunSnapshot({routeSessionKey:o,isHydrating:n.isHydrating,isSending:i,isRunning:r,visibleMessages:n.visibleMessages,contextWindow:Ue(n.snapshot.contextWindow),sendErrorMessage:a,materializedSessionKey:n.snapshot.activeRun?.sessionId??n.visibleMessages.find(e=>e.sessionId.trim())?.sessionId??null})},[n.isHydrating,n.snapshot.activeRun?.sessionId,n.snapshot.contextWindow,n.visibleMessages,r,i,a,t,o])}function yr({view:e}){let t=vt(),[n]=(0,U.useState)(()=>new _t(t));return(0,W.jsx)(Qe,{presenter:n,children:(0,W.jsx)(br,{view:e})})}function br({view:e}){let t=z(),n=v(),r=We(n),i=_r(),{routeSessionKey:a,sessionKey:o}=hr();fr({sessionKey:o??null});let s=Me(o??null),c=it(o),l=c.hydrateError?.message??c.snapshot.error?.message??null,u=n.phase===`ready`&&rt(l)?null:l,d=c.isRunning||s?.status===`running`,f=c.isSending||d,p=r?null:n.phase===`ready`?u:Ie({message:u,status:n});return gr({agent:c,sessionKey:o}),ur({view:e,routeSessionKey:a,syncRouteSessionSelection:t.chatSessionListManager.syncRouteSessionSelection}),mr(),pr(),vr({agent:c,isRunning:d,routeSessionKey:a,lastSendError:p,isSending:f}),(0,W.jsx)(dr,{view:e,confirmDialog:i})}function xr({view:e}){return(0,W.jsx)(yr,{view:e})}export{xr as ChatPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./doc-browser-DgQedeAn.js";export{e as DocBrowser};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,p as t,r as n,u as r,v as i}from"./react-sZz5HSCm.js";import{a,b as o,c as s,f as c,g as l,h as u,i as d,l as f,m as p,o as m,r as h,s as g,t as _,u as v,x as y,y as b}from"./dist-DsE4OsSS.js";import{t as x}from"./dist-DPrgcEC0.js";import{n as S,t as C}from"./search-B29dE4GN.js";import{t as w}from"./external-link-C_dmG-WJ.js";import{t as T}from"./plus-Bnt56oqG.js";import{t as E}from"./x-CW2KO-Hz.js";import{c as ee,f as D,n as te,p as ne,s as re}from"./doc-browser-context-B46tQGmO.js";var O=s(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),k=s(`Boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),ie=s(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),A=s(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),j=s(`PanelRightOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),M=s(`PinOff`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),N=s(`Pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),P=i(e(),1),F=t(),[I,ae]=b(`Tooltip`,[g]),L=g(),R=`TooltipProvider`,oe=700,z=`tooltip.open`,[B,V]=I(R),H=e=>{let{__scopeTooltip:t,delayDuration:n=oe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=P.useRef(!0),s=P.useRef(!1),c=P.useRef(0);return P.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,F.jsx)(B,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:P.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:P.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:P.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};H.displayName=R;var U=`Tooltip`,[se,W]=I(U),G=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=V(U,e.__scopeTooltip),d=L(t),[f,p]=P.useState(null),h=l(),g=P.useRef(0),_=o??c.disableHoverableContent,v=s??c.delayDuration,y=P.useRef(!1),[b,x]=u({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(z))):c.onClose(),a?.(e)},caller:U}),S=P.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=P.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=P.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=P.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);return P.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]),(0,F.jsx)(m,{...d,children:(0,F.jsx)(se,{scope:t,contentId:h,open:b,stateAttribute:S,trigger:f,onTriggerChange:p,onTriggerEnter:P.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:P.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:n})})};G.displayName=U;var K=`TooltipTrigger`,q=P.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=W(K,n),a=V(K,n),s=L(n),l=o(t,P.useRef(null),i.onTriggerChange),u=P.useRef(!1),d=P.useRef(!1),f=P.useCallback(()=>u.current=!1,[]);return P.useEffect(()=>()=>document.removeEventListener(`pointerup`,f),[f]),(0,F.jsx)(h,{asChild:!0,...s,children:(0,F.jsx)(c.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:y(e.onPointerMove,e=>{e.pointerType!==`touch`&&!d.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),d.current=!0)}),onPointerLeave:y(e.onPointerLeave,()=>{i.onTriggerLeave(),d.current=!1}),onPointerDown:y(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener(`pointerup`,f,{once:!0})}),onFocus:y(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:y(e.onBlur,i.onClose),onClick:y(e.onClick,i.onClose)})})});q.displayName=K;var J=`TooltipPortal`,[ce,le]=I(J,{forceMount:void 0}),ue=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=W(J,t);return(0,F.jsx)(ce,{scope:t,forceMount:n,children:(0,F.jsx)(x,{present:n||a.open,children:(0,F.jsx)(f,{asChild:!0,container:i,children:r})})})};ue.displayName=J;var Y=`TooltipContent`,de=P.forwardRef((e,t)=>{let n=le(Y,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=W(Y,e.__scopeTooltip);return(0,F.jsx)(x,{present:r||o.open,children:o.disableHoverableContent?(0,F.jsx)(ge,{side:i,...a,ref:t}):(0,F.jsx)(fe,{side:i,...a,ref:t})})}),fe=P.forwardRef((e,t)=>{let n=W(Y,e.__scopeTooltip),r=V(Y,e.__scopeTooltip),i=P.useRef(null),a=o(t,i),[s,c]=P.useState(null),{trigger:l,onClose:u}=n,d=i.current,{onPointerInTransitChange:f}=r,p=P.useCallback(()=>{c(null),f(!1)},[f]),m=P.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=be(r,ye(r,n.getBoundingClientRect())),a=xe(t.getBoundingClientRect());c(Ce([...i,...a])),f(!0)},[f]);return P.useEffect(()=>()=>p(),[p]),P.useEffect(()=>{if(l&&d){let e=e=>m(e,d),t=e=>m(e,l);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),P.useEffect(()=>{if(s){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!Se(n,s);r?p():i&&(p(),u())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,s,u,p]),(0,F.jsx)(ge,{...e,ref:a})}),[pe,me]=I(U,{isInside:!1}),he=p(`TooltipContent`),ge=P.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=W(Y,n),u=L(n),{onClose:d}=l;return P.useEffect(()=>(document.addEventListener(z,d),()=>document.removeEventListener(z,d)),[d]),P.useEffect(()=>{if(l.trigger){let e=e=>{e.target?.contains(l.trigger)&&d()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]),(0,F.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,F.jsxs)(a,{"data-state":l.stateAttribute,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,F.jsx)(he,{children:r}),(0,F.jsx)(pe,{scope:n,isInside:!0,children:(0,F.jsx)(_,{id:l.contentId,role:`tooltip`,children:i||r})})]})})});de.displayName=Y;var _e=`TooltipArrow`,ve=P.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=L(n);return me(_e,n).isInside?null:(0,F.jsx)(d,{...i,...r,ref:t})});ve.displayName=_e;function ye(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function be(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function xe(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Se(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ce(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),we(t)}function we(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Te=H,Ee=G,De=q,Oe=ue,ke=de,Ae=Te,je=Ee,Me=De,X=P.forwardRef(({className:e,sideOffset:t=4,...n},i)=>(0,F.jsx)(Oe,{children:(0,F.jsx)(ke,{ref:i,sideOffset:t,className:r(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));X.displayName=ke.displayName;function Ne(){return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-5 py-6`,children:(0,F.jsxs)(`div`,{className:`flex max-w-[260px] flex-col items-center gap-3 text-center`,children:[(0,F.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-lg border border-gray-100 bg-gray-50 text-gray-600 shadow-[0_1px_2px_rgba(30,20,10,0.04)]`,children:(0,F.jsx)(k,{className:`h-5 w-5`})}),(0,F.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:n(`docBrowserHomeTitle`)})]})})}function Pe({isDocsTab:e,onSubmit:t,onUrlInputChange:r,urlInput:i}){return e?(0,F.jsx)(`div`,{className:`flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:(0,F.jsxs)(`form`,{onSubmit:t,className:`flex-1 relative`,children:[(0,F.jsx)(C,{className:`w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(`input`,{type:`text`,value:i,onChange:e=>r(e.target.value),placeholder:n(`docBrowserSearchPlaceholder`),className:`w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400`})]})}):null}function Fe({currentTab:e,currentUrl:t,customContent:n,iframeRef:r,iframeInstanceId:i,iframeSandbox:a,isDragging:o,isResizing:s}){return(0,F.jsxs)(`div`,{className:`flex-1 relative overflow-hidden`,children:[n||(0,F.jsx)(`iframe`,{ref:r,src:t,className:`absolute inset-0 w-full h-full border-0`,title:e?.title||`NextClaw Docs`,sandbox:a,allow:`clipboard-read; clipboard-write`},i),(s||o)&&(0,F.jsx)(`div`,{className:`absolute inset-0 z-10`})]})}function Ie({currentUrl:e,isDocsTab:t}){return!t||!D(e)?null:(0,F.jsx)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0`,children:(0,F.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,"data-doc-external":!0,className:`flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors`,children:[n(`docBrowserOpenExternal`),(0,F.jsx)(w,{className:`w-3 h-3`})]})})}var Z=P.forwardRef(({className:e,disabled:t=!1,icon:n,label:i,tooltip:a,...o},s)=>{let c=(0,F.jsx)(`button`,{...o,ref:s,type:`button`,disabled:t,"aria-label":i,className:r(`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 disabled:cursor-not-allowed`,`text-gray-500 hover:bg-gray-100 hover:text-gray-900 disabled:text-gray-300 disabled:hover:bg-transparent disabled:hover:text-gray-300`,e),children:n}),l=a===!1?null:a??i;return l?(0,F.jsx)(Ae,{delayDuration:250,children:(0,F.jsxs)(je,{children:[(0,F.jsx)(Me,{asChild:!0,children:t?(0,F.jsx)(`span`,{className:`inline-flex`,children:c}):c}),(0,F.jsx)(X,{side:`bottom`,className:`text-xs`,children:l})]})}):c});Z.displayName=`IconActionButton`;function Le(e,t){e.stopPropagation(),t()}function Re({labelClassName:e,tab:t}){let n=(0,F.jsxs)(`button`,{type:`button`,onClick:t.onSelect,"aria-label":t.label,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,F.jsx)(`span`,{className:r(`min-w-0 truncate text-[12px] font-medium`,e),children:t.label}),t.badge,t.unreadIndicator]}),i=t.tooltip??t.label;return i?(0,F.jsx)(Ae,{delayDuration:250,children:(0,F.jsxs)(je,{children:[(0,F.jsx)(Me,{asChild:!0,children:n}),(0,F.jsx)(X,{side:`bottom`,className:`text-xs`,children:i})]})}):n}function ze({activeTabClassName:e,inactiveTabClassName:t,itemRef:n,labelClassName:i,tab:a,tabBaseClassName:o}){let s=a.onClose&&a.closePlacement===`leading-hover`;return(0,F.jsxs)(`div`,{ref:n,className:r(o??`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,a.active?e??`border-b-primary bg-white text-gray-900`:t??`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[s?(0,F.jsxs)(`button`,{type:`button`,onClick:e=>Le(e,a.onClose),className:`relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,"aria-label":a.closeLabel,children:[(0,F.jsx)(`span`,{className:`flex items-center justify-center group-hover:hidden`,children:a.leadingIcon}),(0,F.jsx)(E,{className:`hidden h-3.5 w-3.5 group-hover:block`})]}):a.leadingIcon?(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center`,children:a.leadingIcon}):null,(0,F.jsx)(Re,{tab:a,labelClassName:i}),a.onClose&&a.closePlacement!==`leading-hover`?(0,F.jsx)(Z,{icon:(0,F.jsx)(E,{className:`h-3 w-3`}),label:a.closeLabel??``,tooltip:a.closeLabel??null,onClick:e=>Le(e,a.onClose),className:`h-5 w-5 rounded p-0.5 hover:bg-black/10`}):null]})}function Be({actionButtonClassName:e,actions:t,actionsClassName:n,actionsTestId:i,className:a,onPointerDown:o,onScrollPointerDown:s,scrollClassName:c,scrollTestId:l,tabs:u,tabsClassName:d,testId:f,...p}){let m=P.useCallback(e=>{e?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[]);return(0,F.jsxs)(`div`,{"data-testid":f,className:r(`flex min-w-0 items-stretch border-b border-gray-200/70 bg-gray-50/85`,a),onPointerDown:o,children:[(0,F.jsx)(`div`,{className:r(`min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,c),onPointerDown:s,children:(0,F.jsx)(`div`,{"data-testid":l,className:r(`flex min-w-max items-stretch`,d),children:u.map(e=>(0,F.jsx)(ze,{itemRef:e.active?m:void 0,tab:e,...p},e.key))})}),(0,F.jsx)(`div`,{className:r(`flex shrink-0 items-center gap-1`,n),"data-testid":i,onPointerDown:e=>e.stopPropagation(),children:t.map(t=>(0,F.jsx)(Z,{icon:t.icon,label:t.label,disabled:t.disabled,onClick:t.onClick,className:e},t.key))})]})}function Ve({tabs:e,activeTabId:t,canGoBack:i,canGoForward:a,isDocked:o,isFullscreen:s,dockState:c,onGoBack:l,onGoForward:u,onOpenNewTab:d,onToggleDock:f,onSetActiveTab:p,onCloseTab:m,onClose:h,onDragStart:g,onToggleMode:_}){let v=n(`docBrowserBack`),y=n(`docBrowserClose`),b=n(`docBrowserCloseTab`),x=c?.isDocked?c.removable?n(`sideDockUnpinCurrent`):n(`sideDockBuiltInDocked`):n(`sideDockPinCurrent`),C=n(`docBrowserForward`),w=n(o?`docBrowserFloatMode`:`docBrowserDockMode`),ee=n(`docBrowserNewTab`);return(0,F.jsx)(Be,{testId:`doc-browser-tab-strip`,actionsTestId:`doc-browser-tab-actions`,tabs:e.map(e=>({key:e.id,label:e.title||n(`docBrowserTabUntitled`),active:e.id===t,tooltip:e.title,closeLabel:b,closePlacement:`trailing`,onSelect:()=>p(e.id),onClose:()=>m(e.id)})),actions:[{key:`back`,disabled:!i,icon:(0,F.jsx)(S,{className:`h-3.5 w-3.5`}),label:v,onClick:l},{key:`forward`,disabled:!a,icon:(0,F.jsx)(O,{className:`h-3.5 w-3.5`}),label:C,onClick:u},{key:`new-tab`,icon:(0,F.jsx)(T,{className:`h-3.5 w-3.5`}),label:ee,onClick:d},...c?.canDock?[{key:`dock`,disabled:c.isDocked&&!c.removable,icon:c.isDocked&&c.removable?(0,F.jsx)(M,{className:`h-3.5 w-3.5`}):(0,F.jsx)(N,{className:`h-3.5 w-3.5`}),label:x,onClick:()=>f?.()}]:[],...s?[]:[{key:`mode`,icon:o?(0,F.jsx)(A,{className:`h-3.5 w-3.5`}):(0,F.jsx)(j,{className:`h-3.5 w-3.5`}),label:w,onClick:_}],{key:`close`,icon:(0,F.jsx)(E,{className:`h-3.5 w-3.5`}),label:y,onClick:h}],className:r(`h-11 gap-2 px-2.5 bg-background border-[#f1e7d4] shrink-0 select-none`,s&&`h-[calc(env(safe-area-inset-top,0px)+2.75rem)] pt-[env(safe-area-inset-top,0px)]`),scrollClassName:`doc-browser-tab-scrollbar flex h-full items-center gap-1.5`,tabsClassName:`items-center gap-1.5`,actionsClassName:`h-full items-center gap-1`,actionButtonClassName:`rounded-md p-1.5 hover:text-gray-700 disabled:opacity-60`,tabBaseClassName:`group inline-flex min-w-0 items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors`,activeTabClassName:`bg-amber-50/80 border-amber-200 text-amber-900 shadow-[0_1px_2px_rgba(30,20,10,0.04)]`,inactiveTabClassName:`bg-[#f9f8f5] border-[#eee3d1] text-[#78644d] hover:bg-[#fff7ea] hover:text-[#2f2212]`,labelClassName:`px-1 text-xs font-normal`,onPointerDown:!o&&!s?g:void 0,onScrollPointerDown:e=>e.stopPropagation()})}function He({children:e,className:t,style:n,defaultWidth:i=420,minWidth:a=320,maxWidth:o=860,overlay:s=!1,...c}){let l=(0,P.useRef)(null),[u,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(i),m=e=>{if(s)return;e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),d(!0),l.current={startX:e.clientX,startWidth:f};let t=e=>{let t=l.current;if(!t)return;let n=t.startWidth+t.startX-e.clientX;p(Math.max(a,Math.min(o,n)))},n=()=>{d(!1),l.current=null,window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,n)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,n)};return(0,F.jsxs)(`aside`,{...c,className:r(`relative flex h-full min-h-0 shrink-0 overflow-hidden bg-white`,s?`fixed inset-0 z-40`:`border-l border-gray-200`,t),style:s?n:{...n,width:f},children:[s?null:(0,F.jsx)(`div`,{className:`absolute left-0 top-0 z-20 h-full w-3 cursor-ew-resize transition-colors hover:bg-primary/10`,"data-testid":`resizable-right-panel-handle`,onPointerDown:m}),(0,F.jsx)(`div`,{className:`flex h-full min-h-0 w-full flex-col overflow-hidden`,children:e}),u?(0,F.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-ew-resize`,"data-testid":`resizable-right-panel-resize-shield`}):null]})}var Q=40,Ue=360,We=400,Ge=`allow-same-origin allow-scripts allow-popups allow-forms`;function Ke(e,t){return t?e?.getIframeSandbox?.(t)??Ge:Ge}function qe(e,t,n){return(0,P.useCallback)(()=>{if(n?.canDock){if(n.isDocked){n.removable&&e?.unpinTab(t);return}e?.pinTab(t)}},[t,e,n])}function $(e,t,n){return Math.min(n,Math.max(t,e))}function Je(){return{x:Math.max(Q,window.innerWidth-520),y:80,w:480,h:600}}function Ye({customTabRenderers:e={},displayMode:t=`desktop`,dockControls:n}){let{isOpen:i,mode:a,tabs:o,activeTabId:s,activeHistory:c,activeHistoryIndex:l,currentTab:u,open:d,openTarget:f,openNewTab:p,close:m,toggleMode:h,goBack:g,goForward:_,navigate:v,syncUrl:y,setActiveTab:b,closeTab:x}=te(),[S,C]=(0,P.useState)(``),[w,T]=(0,P.useState)(0),[E,D]=(0,P.useState)(Je),[O,k]=(0,P.useState)(null),A=(0,P.useRef)(null),j=u?.currentUrl??re,M=u?.navVersion??0,N=`${s}:${M}:${w}`,I=(0,P.useRef)(null),ae=(0,P.useRef)(M),L=u?.kind===`docs`,R=u?.kind===ee,oe=l>0,z=l<c.length-1,B=u?e[u.kind]:void 0,V=n?.getDockState(u);(0,P.useEffect)(()=>{if(!L){C(``);return}try{C(new URL(j).pathname)}catch{C(j)}},[j,s,L]),(0,P.useEffect)(()=>{if(!L){I.current=null;return}if(M!==ae.current){ae.current=M,I.current=ne(j);return}if(A.current?.contentWindow)try{let e=new URL(j).pathname;I.current=ne(j),A.current.contentWindow.postMessage({type:`docs-navigate`,path:e},`*`)}catch{}},[j,M,L]),(0,P.useEffect)(()=>{let e=e=>{if(L&&e.data?.type===`docs-route-change`&&typeof e.data.url==`string`){let t=ne(e.data.url);if(I.current&&t!==I.current)return;I.current=null,y(e.data.url)}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[j,y,L]),(0,P.useEffect)(()=>{if(!u||!B?.onIframeMessage)return;let e=e=>{B.onIframeMessage?.({event:e,iframe:A.current,iframeInstanceId:N,tab:u})};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[u,B,N]);let H=(0,P.useCallback)(e=>{e.preventDefault(),k({kind:`drag`,startX:e.clientX,startY:e.clientY,startRect:E})},[E]),U=(0,P.useCallback)(e=>t=>{t.preventDefault(),t.stopPropagation(),k({kind:`resize`,edge:e,startX:t.clientX,startY:t.clientY,startRect:E})},[E]);(0,P.useEffect)(()=>{if(!O)return;let e=e=>{let{startRect:t,startX:n,startY:r}=O,i=e.clientX-n,a=e.clientY-r;if(O.kind===`drag`){D({...t,x:$(t.x+i,Q,window.innerWidth-Q-t.w),y:$(t.y+a,Q,window.innerHeight-Q-t.h)});return}if(O.edge===`left`||O.edge===`top`){let e=O.edge===`left`,n=e?t.x+t.w:t.y+t.h,r=$(e?t.x+i:t.y+a,Q,n-(e?Ue:We));D(e?{...t,x:r,w:n-r}:{...t,y:r,h:n-r});return}let o=$(t.x+t.w+i,t.x+Ue,window.innerWidth-Q),s=$(t.y+t.h+a,t.y+We,window.innerHeight-Q);D({...t,w:O.edge===`bottom`?t.w:o-t.x,h:O.edge===`right`?t.h:s-t.y})},t=()=>k(null);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[O]);let se=(0,P.useCallback)(e=>{if(e.preventDefault(),!L)return;let t=S.trim();t&&(t.startsWith(`/`)?v(`${re}${t}`):t.startsWith(`http`)?v(t):v(`${re}/${t}`))},[S,v,L]),W=(0,P.useCallback)(()=>{T(e=>e+1)},[]),G=qe(n,u,V);if(!i)return null;let K=a===`docked`,q=t===`fullscreen`,J=u?{currentUrl:j,open:d,openTarget:f,refreshIframe:W,tab:u}:void 0,ce=J?B?.renderToolbar?.(J):null,le=J?B?.renderContent?.(J)??(R?(0,F.jsx)(Ne,{}):null):null,ue=Ke(B,u),Y=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Ve,{tabs:o,activeTabId:s,canGoBack:oe,canGoForward:z,dockState:V,isDocked:K,isFullscreen:q,onGoBack:g,onGoForward:_,onOpenNewTab:p,onToggleDock:G,onSetActiveTab:b,onCloseTab:x,onClose:m,onDragStart:H,onToggleMode:h}),(0,F.jsx)(Pe,{isDocsTab:L,onSubmit:se,onUrlInputChange:C,urlInput:S}),ce,(0,F.jsx)(Fe,{currentTab:u,currentUrl:j,customContent:le,iframeRef:A,iframeInstanceId:N,iframeSandbox:ue,isDragging:O?.kind===`drag`,isResizing:O?.kind===`resize`}),(0,F.jsx)(Ie,{currentUrl:j,isDocsTab:L})]});return K&&!q?(0,F.jsx)(He,{"data-testid":`doc-browser-panel`,defaultWidth:420,minWidth:320,maxWidth:860,children:Y}):(0,F.jsxs)(`div`,{"data-testid":`doc-browser-panel`,className:r(`flex flex-col bg-white overflow-hidden relative`,q?`fixed inset-0 z-[9999] h-[100dvh] w-screen rounded-none border-0 shadow-2xl`:`rounded-2xl shadow-2xl border border-gray-200`),style:q?void 0:{position:`fixed`,left:E.x,top:E.y,width:E.w,height:E.h,zIndex:9999},children:[Y,!K&&!q&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`absolute top-0 left-0 h-3 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors`,"data-testid":`doc-browser-resize-top`,onPointerDown:U(`top`)}),(0,F.jsx)(`div`,{className:`absolute top-0 left-0 w-3 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,"data-testid":`doc-browser-resize-left`,onPointerDown:U(`left`)}),(0,F.jsx)(`div`,{className:`absolute top-0 right-0 w-3 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,"data-testid":`doc-browser-resize-right`,onPointerDown:U(`right`)}),(0,F.jsx)(`div`,{className:`absolute bottom-0 left-0 h-3 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors`,"data-testid":`doc-browser-resize-bottom`,onPointerDown:U(`bottom`)}),(0,F.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors`,"data-testid":`doc-browser-resize-bottom-right`,onPointerDown:U(`bottom-right`),children:(0,F.jsx)(ie,{className:`w-3 h-3 rotate-[-45deg]`})})]})]})}export{je as a,Me as c,Te as d,Ee as f,O as g,k as h,Z as i,ke as l,A as m,He as n,X as o,De as p,Be as r,Ae as s,Ye as t,Oe as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,h as t,p as n,r,t as i,v as a}from"./react-sZz5HSCm.js";function o(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var s=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return s(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return s(t)(e)}}}},c=(e,t)=>(n,r,i)=>{let a={storage:o(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},c=!1,l=0,u=new Set,d=new Set,f=a.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let p=()=>{let e=a.partialize({...r()});return f.setItem(a.name,{state:e,version:a.version})},m=i.setState;i.setState=(e,t)=>(m(e,t),p());let h=e((...e)=>(n(...e),p()),r,i);i.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++l;c=!1,u.forEach(e=>e(r()??h));let t=a.onRehydrateStorage?.call(a,r()??h)||void 0;return s(f.getItem.bind(f))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==l)return;let[i,o]=t;if(g=a.merge(o,r()??h),n(g,!0),i)return p()}).then(()=>{e===l&&(t?.(g,void 0),g=r(),c=!0,d.forEach(e=>e(g)))}).catch(n=>{e===l&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},a.skipHydration||_(),g||h},l=`docs.nextclaw.io`,u=`nextclaw-docs.pages.dev`,d=new Set([l,`www.${l}`,u,`www.${u}`]),f=`https://${l}`,p=`home`,m=`nextclaw://new-tab`,h=`/guide/getting-started`;function g(e){return e===`zh`?`zh`:`en`}function _(e,t){let n=e.startsWith(`/`)?e:`/${e}`;return n===`/`||n===``?`/${t}/`:/^\/(en|zh)(\/|$)/.test(n)?n:`/${t}${n}`}function v(t){let n=g(e());try{let e=new URL(t,f);return d.has(e.hostname)&&(e.pathname=_(e.pathname,n)),e.toString()}catch{return new URL(`/${n}${h}`,f).toString()}}function y(){return v(h)}function b(e){try{return new URL(e).pathname.replace(/\.html$/,``).replace(/\/$/,``)}catch{return e}}function x(e,t,n=`Docs`){try{let r=new URL(e,f);if(r.protocol===`data:`)return t===`docs`?n:`Detail`;let i=r.pathname.split(`/`).filter(Boolean),a=i[i.length-1]??n;return decodeURIComponent(a).replace(/[-_]/g,` `).slice(0,40)||n}catch{return n}}function S(e){try{let t=new URL(e,window.location.origin);return d.has(t.hostname)}catch{return!1}}function C(e,t){return t===`docs`?v(e):e}var w=0;function T(){return w+=1,`doc-tab-${Date.now()}-${w}`}function E(e,t,n,i,a,o){let s=n?.trim()||x(e,t,t===`docs`?r(`docBrowserHelp`):`Detail`),c=a?.trim();return{id:T(),kind:t,title:s,currentUrl:e,resourceUri:c||void 0,dockIcon:o,dedupeKey:i,history:[e],historyIndex:0,navVersion:0}}function D(e){return{kind:e.kind,resourceUri:e.resourceUri,tabId:e.id,url:e.currentUrl}}function O(){let e=E(m,p,r(`docBrowserHomeTitle`));return{isOpen:!1,mode:`docked`,tabs:[e],activeTabId:e.id,activeHistory:[D(e)],activeHistoryIndex:0}}var k=`nextclaw.doc-browser.state`,A=1,j=8;function M(e){return!!e&&typeof e==`object`}function N(e){return e===`floating`||e===`docked`}function P(e,t){if(!Array.isArray(e))return[t];let n=e.filter(e=>typeof e==`string`&&e.trim().length>0);return n.length>0?n:[t]}function F(e,t,n,r){return typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r}function I(e){if(!(!M(e)||typeof e.type!=`string`)){if(e.type===`builtin`&&typeof e.name==`string`&&e.name.trim().length>0)return{type:`builtin`,name:e.name.trim()};if(e.type===`url`&&typeof e.url==`string`&&e.url.trim().length>0)return{type:`url`,url:e.url.trim()};if(e.type===`text`&&typeof e.value==`string`&&e.value.trim().length>0)return{type:`text`,value:e.value.trim()}}}function L(e){if(!M(e)||typeof e.id!=`string`||typeof e.kind!=`string`||typeof e.title!=`string`||typeof e.currentUrl!=`string`||e.currentUrl.trim().length===0)return null;let t=P(e.history,e.currentUrl),n=F(e.historyIndex,0,t.length-1,t.length-1),r=F(e.navVersion,0,2**53-1,0),i=typeof e.dedupeKey==`string`&&e.dedupeKey.trim().length>0?e.dedupeKey:void 0,a=typeof e.resourceUri==`string`&&e.resourceUri.trim().length>0?e.resourceUri.trim():void 0,o=I(e.dockIcon);return{id:e.id,kind:e.kind,title:e.title,currentUrl:t[n]??e.currentUrl,resourceUri:a,dockIcon:o,dedupeKey:i,history:t,historyIndex:n,navVersion:r}}function R(e){return{kind:e.kind,resourceUri:e.resourceUri,tabId:e.id,url:e.currentUrl}}function z(e,t){if(!M(e)||typeof e.tabId!=`string`||typeof e.kind!=`string`||typeof e.url!=`string`||e.url.trim().length===0||!t.has(e.tabId))return null;let n=typeof e.resourceUri==`string`&&e.resourceUri.trim().length>0?e.resourceUri.trim():void 0;return{kind:e.kind,resourceUri:n,tabId:e.tabId,url:e.url}}function B(e){if(!M(e))return null;let t=Array.isArray(e.tabs)?e.tabs.map(L).filter(e=>e!==null).slice(-j):[];if(t.length===0)return null;let n=typeof e.activeTabId==`string`?e.activeTabId:null,r=t.some(e=>e.id===n)?n??t[0].id:t[0].id,i=new Map(t.map(e=>[e.id,e])),a=Array.isArray(e.activeHistory)?e.activeHistory.map(e=>z(e,i)).filter(e=>e!==null):[],o=[R(i.get(r)??t[0])],s=a.length>0?a:o,c=F(e.activeHistoryIndex,0,s.length-1,s.length-1),l=s[c],u=i.has(l.tabId)?l.tabId:r;return{isOpen:e.isOpen===!0,mode:N(e.mode)?e.mode:`docked`,tabs:t,activeTabId:u,activeHistory:s,activeHistoryIndex:c}}function V(e,t){return typeof t==`function`?t(e):t}var H=i()(c(e=>({snapshot:O(),setSnapshot:t=>e(e=>({snapshot:V(e.snapshot,t)}))}),{name:k,version:A,storage:o(()=>window.localStorage),partialize:e=>({snapshot:{isOpen:e.snapshot.isOpen,mode:e.snapshot.mode,tabs:e.snapshot.tabs.slice(-j),activeTabId:e.snapshot.activeTabId,activeHistory:e.snapshot.activeHistory,activeHistoryIndex:e.snapshot.activeHistoryIndex}}),merge:(e,t)=>{let n=B(M(e)?e.snapshot:null);return n?{...t,snapshot:n}:t}})),U=a(t(),1),W=n(),G=(0,U.createContext)(null);function K(){let e=(0,U.useContext)(G);if(!e)throw Error(`useDocBrowser must be used within DocBrowserProvider`);return e}function q({children:e,manager:t}){let n=H(e=>e.snapshot),r=(0,U.useMemo)(()=>n.tabs.find(e=>e.id===n.activeTabId)??n.tabs[0],[n.activeTabId,n.tabs]),i=(0,U.useMemo)(()=>({...n,currentTab:r,open:t.open,openTarget:t.openTarget,openNewTab:t.openNewTab,close:t.close,toggleMode:t.toggleMode,navigate:t.navigate,syncUrl:t.syncUrl,goBack:t.goBack,goForward:t.goForward,closeTab:t.closeTab,setActiveTab:t.setActiveTab}),[r,t,n]);return(0,W.jsx)(G.Provider,{value:i,children:e})}export{D as a,p as c,x as d,S as f,c as g,o as h,O as i,m as l,C as m,K as n,E as o,b as p,H as r,f as s,q as t,y as u};
|