@wrongstack/webui 0.298.2 → 0.299.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentRosterView-RvxaV08Y.js → AgentRosterView-BqojERFR.js} +4 -4
- package/dist/assets/{AnalyticsDashboard-irejsLMt.js → AnalyticsDashboard-D58kSekC.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DDW_WPjf.js → AudienceMemoryPanel-Cc1UkbDl.js} +1 -1
- package/dist/assets/ChangesView-BKU80ANq.js +1 -0
- package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +1 -0
- package/dist/assets/CodeEditor-BHZQhx_8.js +1 -0
- package/dist/assets/CodeMap-qllGEFLB.js +1 -0
- package/dist/assets/{CronJobsPanel-BXujnpGC.js → CronJobsPanel-DD5mhZ4Q.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-HTbGUTMl.js → DeadCodeScanPanel-PB-c8et_.js} +1 -1
- package/dist/assets/{DebugDashboard-B5kJBUv0.js → DebugDashboard-Q8QiVflQ.js} +1 -1
- package/dist/assets/{DesignGalleryView-BQ0CZpQm.js → DesignGalleryView-CGOtWO7s.js} +1 -1
- package/dist/assets/{GoalView-DvaSR6CO.js → GoalView-Dlk42vW7.js} +1 -1
- package/dist/assets/KanbanView-DIP6kKmU.js +3 -0
- package/dist/assets/{MailboxDetailView-Dh8ekyMw.js → MailboxDetailView-ZcKcOEAe.js} +1 -1
- package/dist/assets/MemoryManager-B7620q_K.js +1 -0
- package/dist/assets/{ModelPicker-BxYMTEEN.js → ModelPicker-DvNLZzkm.js} +1 -1
- package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +4 -0
- package/dist/assets/{ProcessMonitor-DVUCtVHZ.js → ProcessMonitor-2nSk6sXA.js} +1 -1
- package/dist/assets/{QueuePanel-n9lScdWu.js → QueuePanel-4KBBWFxj.js} +1 -1
- package/dist/assets/{RefreshDebugView-eZQ3wdxU.js → RefreshDebugView-D3XnE53y.js} +1 -1
- package/dist/assets/RequirementIntakeView-BMxlf8bt.js +1 -0
- package/dist/assets/{SageTabs-B-eQ--Sb.js → SageTabs-g1hO2hJ0.js} +2 -2
- package/dist/assets/SddHub-Kv_TbTgT.js +2 -0
- package/dist/assets/SessionInspectView-PnKTvyvP.js +1 -0
- package/dist/assets/SessionList-BeinIC-h.js +1 -0
- package/dist/assets/SessionsDashboard-DEG_BylE.js +1 -0
- package/dist/assets/SetupScreen-DxJwZ1OZ.js +1 -0
- package/dist/assets/SkillDetailView-D7EQ2XtV.js +3 -0
- package/dist/assets/{SpecsView-BYiJr__T.js → SpecsView-Fm7pYYcj.js} +1 -1
- package/dist/assets/TechStackView-Bo_UenRF.js +1 -0
- package/dist/assets/{TerminalPanel-BgMsGfGa.js → TerminalPanel-BL9ZPGJt.js} +1 -1
- package/dist/assets/{Toaster-EXqX2jqp.js → Toaster-CJI70aa-.js} +1 -1
- package/dist/assets/{activity-DReNmuta.js → activity-BCgOEWgR.js} +2 -2
- package/dist/assets/{activity-Dyh19u3P.js → activity-BQ0zqkw2.js} +2 -2
- package/dist/assets/{activity-BJijwuIr.js → activity-CAovbq3e.js} +2 -2
- package/dist/assets/{activity-BBPMHCAJ.js → activity-CFQyCvgu.js} +2 -2
- package/dist/assets/{activity-GR8KiHvf.js → activity-CdQf7zRK.js} +2 -2
- package/dist/assets/{activity-iuGHFz2B.js → activity-DACvyn2-.js} +2 -2
- package/dist/assets/{activity-DeEOo2zu.js → activity-DOwYydU-.js} +2 -2
- package/dist/assets/{button-DwmC7ENW.js → button-Dcy288Mc.js} +1 -1
- package/dist/assets/{chat-store-LHzJqRCp.js → chat-store-CtOyUCdF.js} +2 -2
- package/dist/assets/{codemap-activity-store-B6n7KiS8.js → codemap-activity-store-DQfjo7-j.js} +1 -1
- package/dist/assets/codemap-index-store-COStDU-8.js +1 -0
- package/dist/assets/{dialog-DsCmc6eL.js → dialog-ftgTihmF.js} +1 -1
- package/dist/assets/{empty-state-02bIS4x7.js → empty-state-RRSqQaCk.js} +1 -1
- package/dist/assets/{i18n-DxnYsmc-.js → i18n-B0hsnanh.js} +2 -2
- package/dist/assets/index-DHdO0CRE.js +132 -0
- package/dist/assets/index-DKrFQ76m.css +1 -0
- package/dist/assets/{input-UhWgodVi.js → input-fo9-BPBC.js} +1 -1
- package/dist/assets/{mailbox-store-xh2Ux-Xs.js → mailbox-store-D8TvJsuk.js} +1 -1
- package/dist/assets/{progress-ring-C0O73ZjR.js → progress-ring-61A-xUEl.js} +1 -1
- package/dist/assets/{roster-ws-DlQQL7Eh.js → roster-ws-Dfg_187V.js} +1 -1
- package/dist/assets/{session-store-BE_S1f5v.js → session-store-b2KGFwkX.js} +1 -1
- package/dist/assets/{shared-bBntASiy.js → shared-KAzksK0C.js} +1 -1
- package/dist/assets/stores-BptlyD_v.js +7 -0
- package/dist/assets/ui-store-BsBnjO3w.js +1 -0
- package/dist/assets/useWebSocket-Bc4S0N4r.js +29 -0
- package/dist/assets/{utils-_s0GyctV.js → utils-B-9lSDIn.js} +1 -1
- package/dist/assets/{vendor-CxV3l5PQ.js → vendor-BuarzSSb.js} +30 -30
- package/dist/assets/{view-navigation-DLdE7qHU.js → view-navigation-DxfiZrXS.js} +1 -1
- package/dist/assets/ws-client-DqFoX4jJ.js +1 -0
- package/dist/components/CouncilLogTimeline.d.ts +2 -0
- package/dist/components/QuickModelSwitcher.filter.d.ts +9 -4
- package/dist/components/RequirementIntakeView.d.ts +2 -0
- package/dist/components/SessionInspectView.d.ts +2 -0
- package/dist/components/SettingsPanel/ModelCatalogPicker.d.ts +1 -2
- package/dist/components/SettingsPanel/brain-section-options.d.ts +16 -0
- package/dist/components/ViewRouter.d.ts +1 -1
- package/dist/hooks/useWebSocket.d.ts +1 -0
- package/dist/index.html +21 -21
- package/dist/index.js +10761 -9484
- package/dist/lib/view-navigation.d.ts +2 -2
- package/dist/lib/ws-client-actions.d.ts +1 -0
- package/dist/stores/council-log-store.d.ts +67 -0
- package/dist/stores/index.d.ts +3 -1
- package/dist/stores/session-inspect-store.d.ts +51 -0
- package/dist/stores/ui-store.d.ts +19 -7
- package/dist/stores/viz-store.d.ts +1 -1
- package/dist/types/brain.d.ts +15 -0
- package/dist/types/client-message.d.ts +5 -0
- package/dist/types/server-message.d.ts +2 -2
- package/dist/types/system.d.ts +35 -0
- package/package.json +8 -8
- package/dist/assets/ChangesView-Bnd167hf.js +0 -1
- package/dist/assets/ChronicleDashboard-DC62FDEt.js +0 -1
- package/dist/assets/CodeEditor-DCWcCQPO.js +0 -1
- package/dist/assets/CodeMap-DSqqgBuD.js +0 -1
- package/dist/assets/KanbanView-DpWs_i8T.js +0 -3
- package/dist/assets/MemoryManager-CUAbNwsz.js +0 -1
- package/dist/assets/OfficeMapPanel-HgERknuN.js +0 -4
- package/dist/assets/SddHub-D81poT6w.js +0 -2
- package/dist/assets/SessionsDashboard-CR3NZeHw.js +0 -1
- package/dist/assets/SetupScreen-t6wrhv6l.js +0 -1
- package/dist/assets/SkillDetailView-D6TOvMQU.js +0 -3
- package/dist/assets/TechStackView-HEMM3PkG.js +0 -1
- package/dist/assets/codemap-index-store-oapPwtvI.js +0 -1
- package/dist/assets/index-Bf75VrDE.js +0 -132
- package/dist/assets/index-NFp5CXyK.css +0 -1
- package/dist/assets/stores-BS-Bdi-5.js +0 -7
- package/dist/assets/ui-store-C4Ybfoon.js +0 -1
- package/dist/assets/useWebSocket-x8PMoTq8.js +0 -28
- package/dist/assets/ws-client-Cy3oRAmZ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Fi as n,Ia as r,Oa as i,Oi as a,Ot as o,Pa as s,Ri as c,Sn as l,Ta as u,Tn as d,Ui as f,Ur as p,Vi as m,_i as h,_n as g,an as _,dt as ee,ft as te,gn as ne,ja as v,jt as y,lt as b,mt as x,nr as S,pt as C,ri as re,wr as w,zt as T}from"./vendor-CxV3l5PQ.js";import"./i18n-DxnYsmc-.js";import{n as E}from"./ui-store-C4Ybfoon.js";import{t as D}from"./useWebSocket-x8PMoTq8.js";import{t as O}from"./utils-_s0GyctV.js";import{t as k}from"./session-store-BE_S1f5v.js";import{M as A,d as j}from"./stores-BS-Bdi-5.js";import{D as M,E as N,O as P,S as ie,T as F,c as I,v as L}from"./index-Bf75VrDE.js";var R=e(r(),1),z=b(),ae=10,oe=20,B=e=>{if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t},V=e=>(e.iterationCount??0)+(e.toolCallCount??0)+(e.fileChangeCount??0),se=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);if(n<6e4)return s.t(`common:time.justNow`);if(n<36e5)return s.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return s.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?s.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()},H=e=>e.lastActivityAt??e.endedAt??e.startedAt;function ce(e){let t=B(e.startedAt);if(!t)return``;let n=e.isCurrent?Date.now():B(e.endedAt)||t,r=Math.max(0,Math.floor((n-t)/6e4));if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function U(e){return new Intl.NumberFormat(void 0,{notation:e>=1e3?`compact`:`standard`,maximumFractionDigits:1}).format(e)}function le(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function ue(e,t){let n=t.query.trim().toLocaleLowerCase(),r=new Set(t.favoriteIds);return[...e.filter(e=>{if(!(!n||[e.name,e.title,e.lastUserMessage,e.model,e.provider,e.id,...Object.keys(e.toolBreakdown??{})].some(e=>e?.toLocaleLowerCase().includes(n))))return!1;switch(t.filter){case`favorites`:return r.has(e.id);case`active`:return e.isCurrent;case`completed`:return!e.isCurrent&&(e.outcome===`completed`||e.outcome===void 0&&!!e.endedAt);case`issues`:return e.outcome===`error`||e.outcome===`timeout`||e.outcome===`aborted`||(e.toolErrorCount??0)>0;default:return!0}})].sort((e,n)=>{if(t.sort===`tokens`&&n.tokenTotal!==e.tokenTotal)return n.tokenTotal-e.tokenTotal;if(t.sort===`activity`){let t=V(n)-V(e);if(t!==0)return t}return B(H(n))-B(H(e))})}function de(e,t,n=Date.now()){let r=new Date(n);r.setHours(0,0,0,0);let i=r.getTime(),a=i-864e5,o=i-6*864e5,s=new Set(t),c=e.filter(e=>s.has(e.id)),l={today:[],yesterday:[],thisWeek:[],earlier:[]};for(let t of e){if(s.has(t.id))continue;let e=B(H(t));e>=i?l.today.push(t):e>=a?l.yesterday.push(t):e>=o?l.thisWeek.push(t):l.earlier.push(t)}let u=[];c.length>0&&u.push({label:`favorites`,rows:c,favorite:!0});for(let e of[`today`,`yesterday`,`thisWeek`,`earlier`])l[e].length>0&&u.push({label:e,rows:l[e]});return u}function fe(e){return e.reduce((e,t)=>({sessions:e.sessions+1,active:e.active+ +!!t.isCurrent,tokens:e.tokens+t.tokenTotal,tools:e.tools+(t.toolCallCount??0),files:e.files+(t.fileChangeCount??0),errors:e.errors+(t.toolErrorCount??0)+ +(t.outcome===`error`)}),{sessions:0,active:0,tokens:0,tools:0,files:0,errors:0})}function pe(e){if(e.isCurrent)return{icon:u,label:`active`,defaultLabel:`Active`,className:`text-primary`};switch(e.outcome){case`completed`:return{icon:m,label:`completed`,defaultLabel:`Completed`,className:`text-success`};case`error`:return{icon:o,label:`error`,defaultLabel:`Error`,className:`text-destructive`};case`timeout`:return{icon:a,label:`timeout`,defaultLabel:`Timed out`,className:`text-warning`};case`aborted`:return{icon:n,label:`aborted`,defaultLabel:`Aborted`,className:`text-muted-foreground`};default:return e.endedAt?{icon:m,label:`completed`,defaultLabel:`Completed`,className:`text-success`}:{icon:w,label:`saved`,defaultLabel:`Saved session`,className:`text-muted-foreground`}}}function me({stats:e}){let{t}=v();return(0,z.jsx)(`div`,{className:`grid grid-cols-2 border-b border-border/75 bg-card md:grid-cols-5`,children:[{label:t(`activity:sessions.stats.sessions`,{defaultValue:`Sessions`}),value:e.sessions,icon:w},{label:t(`activity:sessions.stats.tokens`,{defaultValue:`Tokens`}),value:e.tokens,icon:u},{label:t(`activity:sessions.stats.tools`,{defaultValue:`Tool calls`}),value:e.tools,icon:te},{label:t(`activity:sessions.stats.files`,{defaultValue:`Files changed`}),value:e.files,icon:re},{label:t(`activity:sessions.stats.errors`,{defaultValue:`Errors`}),value:e.errors,icon:o}].map(e=>{let t=e.icon;return(0,z.jsxs)(`div`,{className:`border-b border-r border-border/75 px-4 py-3 md:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,z.jsx)(t,{className:`h-3 w-3`}),e.label]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-xl font-semibold tabular-nums`,children:U(e.value)})]},e.label)})})}function W({historyQuery:e,setHistoryQuery:t,historyEntries:n,historyLoading:r,historyError:i,wsConnected:a,listSessions:s,resumeSession:c,deleteSession:u,renameSession:f,variant:p=`sidebar`}){let{t:m}=v(),h=E(e=>e.favoriteSessionIds),g=E(e=>e.toggleFavoriteSession),b=E(e=>e.sessionNicknames),x=E(e=>e.setSessionNickname),[C,D]=(0,R.useState)(`all`),[k,A]=(0,R.useState)(`recent`),[j,M]=(0,R.useState)(null),[N,P]=(0,R.useState)(``),[F,I]=(0,R.useState)(null),[B,V]=(0,R.useState)(1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=p===`workspace`,q=(0,R.useCallback)(e=>e.name||b[e.id]||e.title||m(`activity:sessions.empty`),[b,m]),J=(0,R.useCallback)(e=>{M(e.id),P(e.name??b[e.id]??e.title??``)},[b]),Y=(0,R.useCallback)(e=>{M(null),x(e,N),f(e,N)},[N,f,x]);(0,R.useEffect)(()=>{F&&n.some(e=>e.id===F&&e.isCurrent)&&(I(null),W.current&&clearTimeout(W.current))},[n,F]),(0,R.useEffect)(()=>{j&&(G.current?.focus(),G.current?.select())},[j]),(0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current)},[]);let X=(0,R.useCallback)(e=>{I(e),c(e),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>I(null),1e4)},[c]),Z=(0,R.useMemo)(()=>le(n),[n]),Q=(0,R.useMemo)(()=>ue(n,{query:e,filter:C,sort:k,favoriteIds:h}),[h,C,n,e,k]),$=K?oe:ae,he=(0,R.useMemo)(()=>Q.slice((B-1)*$,B*$),[B,$,Q]),ge=(0,R.useMemo)(()=>de(he,h),[h,he]),_e=(0,R.useMemo)(()=>fe(n),[n]);(0,R.useEffect)(()=>{V(1)},[C,e,k]),(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(Q.length/$));B>e&&V(e)},[B,$,Q.length]);let ve=(0,R.useCallback)(async()=>{if(Z.length!==0&&await L({title:m(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),message:m(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:m(`common:action.delete`),danger:!0}))for(let e of Z)u(e)},[u,Z,m]),ye=[{id:`all`,label:m(`activity:sessions.filters.all`,{defaultValue:`All`})},{id:`favorites`,label:m(`activity:sessions.filters.favorites`,{defaultValue:`Pinned`})},{id:`active`,label:m(`activity:sessions.filters.active`,{defaultValue:`Active`})},{id:`completed`,label:m(`activity:sessions.filters.completed`,{defaultValue:`Completed`})},{id:`issues`,label:m(`activity:sessions.filters.issues`,{defaultValue:`Issues`})}];return(0,z.jsxs)(`div`,{className:O(`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,K&&`h-full`),"data-history-variant":p,children:[K?(0,z.jsx)(me,{stats:_e}):null,(0,z.jsxs)(`div`,{className:O(`border-b border-border/75 bg-card`,K?`px-4 py-3`:`px-3 py-2`),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:m(`activity:sessions.recentSessions`)}),K?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:m(`activity:sessions.workspaceHint`,{defaultValue:`Search, inspect, pin and resume every project conversation.`})}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center border border-border/75`,children:[Z.length>0?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center justify-center gap-1 border-r border-border/75 px-2 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40`,onClick:ve,disabled:!a,title:m(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),K?(0,z.jsx)(`span`,{className:`text-[10px]`,children:Z.length}):null]}):null,(0,z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:()=>s(200),disabled:!a,title:m(`common:action.refresh`),children:r?(0,z.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]}),(0,z.jsxs)(`div`,{className:O(`grid gap-2`,K?`mt-3 lg:grid-cols-[minmax(18rem,1fr)_auto_auto]`:`mt-2`),children:[(0,z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,z.jsx)(_,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:m(`activity:sessions.filterPlaceholder`),"aria-label":m(`activity:sessions.filterPlaceholder`),className:`h-9 w-full border border-border/75 bg-background pl-8 pr-8 text-xs outline-none transition-colors placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary`}),e?(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-0 top-0 inline-flex h-9 w-8 items-center justify-center text-muted-foreground hover:text-foreground`,title:m(`activity:sessions.clearFilter`),children:(0,z.jsx)(ee,{className:`h-3.5 w-3.5`})}):null]}),(0,z.jsxs)(`fieldset`,{className:`flex min-w-0 overflow-x-auto border border-border/75`,children:[(0,z.jsx)(`legend`,{className:`sr-only`,children:`History filters`}),ye.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>D(e.id),"aria-pressed":C===e.id,className:O(`h-9 shrink-0 border-r border-border/75 px-2.5 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors last:border-r-0`,C===e.id?`bg-foreground text-background`:`bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))]}),(0,z.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),"aria-label":m(`activity:sessions.sort.label`,{defaultValue:`Sort sessions`}),className:`h-9 border border-border/75 bg-background px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground outline-none focus:border-primary`,children:[(0,z.jsx)(`option`,{value:`recent`,children:m(`activity:sessions.sort.recent`,{defaultValue:`Recent`})}),(0,z.jsx)(`option`,{value:`tokens`,children:m(`activity:sessions.sort.tokens`,{defaultValue:`Most tokens`})}),(0,z.jsx)(`option`,{value:`activity`,children:m(`activity:sessions.sort.activity`,{defaultValue:`Most activity`})})]})]})]}),i?(0,z.jsx)(`div`,{className:`border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i}):null,(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain overflow-x-hidden [scrollbar-gutter:stable]`,children:n.length===0&&!r?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(w,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:m(`activity:sessions.noHistory`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:m(`activity:sessions.noHistoryHint`)})]}):ge.length===0?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(_,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:m(`activity:sessions.noMatches`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:m(`activity:sessions.noMatchesHint`)})]}):(0,z.jsxs)(`div`,{className:O(K?`mx-auto w-full max-w-7xl p-4 lg:p-6`:`p-2`),children:[(0,z.jsx)(`div`,{className:O(`space-y-5`,K&&`grid gap-x-5 space-y-0 xl:grid-cols-2`),children:ge.map(e=>(0,z.jsxs)(`section`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:O(`sticky top-0 z-[1] flex items-center gap-1 border-b border-border/75 bg-background/95 px-1 py-2 text-[10px] font-semibold uppercase tracking-[0.14em] backdrop-blur-sm`,e.favorite?`text-warning`:`text-muted-foreground`),children:[e.favorite?(0,z.jsx)(T,{className:`h-3 w-3 fill-current`}):null,m(`activity:sessions.group.${e.label}`),(0,z.jsx)(`span`,{className:`ml-1 font-mono font-normal text-muted-foreground`,children:e.rows.length})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border/75 border-x border-b border-border/75`,children:e.rows.map(e=>{let t=h.includes(e.id),n=pe(e),r=n.icon,i=j===e.id,a=F===e.id;return(0,z.jsxs)(`article`,{className:O(`group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] bg-card transition-colors`,e.isCurrent?`border-l-2 border-l-primary bg-primary/5`:`border-l-2 border-l-transparent hover:bg-muted/45`),"data-session-id":e.id,children:[i?(0,z.jsxs)(`div`,{className:`min-w-0 px-3 py-3`,children:[(0,z.jsx)(`label`,{className:`block text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,htmlFor:`session-name-${e.id}`,children:m(`activity:sessions.rename`,{defaultValue:`Session name`})}),(0,z.jsx)(`input`,{ref:G,id:`session-name-${e.id}`,value:N,onChange:e=>P(e.target.value),onBlur:()=>Y(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Y(e.id)):t.key===`Escape`&&(t.preventDefault(),M(null))},placeholder:e.title||m(`activity:sessions.nicknamePlaceholder`),className:`mt-1 h-8 w-full border border-primary bg-background px-2 text-sm outline-none ring-1 ring-primary`})]}):(0,z.jsx)(`button`,{type:`button`,disabled:e.isCurrent||F!==null,onClick:()=>X(e.id),onDoubleClick:()=>J(e),"aria-current":e.isCurrent?`page`:void 0,className:`min-w-0 px-3 py-3 text-left outline-none focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:cursor-default`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,z.jsx)(`span`,{className:O(`mt-0.5 shrink-0`,n.className),title:m(`activity:sessions.status.${n.label}`,{defaultValue:n.defaultLabel}),children:(0,z.jsx)(r,{className:O(`h-3.5 w-3.5`,e.isCurrent&&`animate-pulse`)})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,title:q(e),children:q(e)}),(0,z.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider,`/`,e.model]}),e.lastUserMessage?(0,z.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground`,title:e.lastUserMessage,children:e.lastUserMessage}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] text-muted-foreground`,children:[a?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-sans font-semibold text-primary`,children:[(0,z.jsx)(S,{className:`h-3 w-3 animate-spin`}),m(`activity:sessions.resuming`)]}):(0,z.jsx)(`span`,{title:new Date(H(e)).toLocaleString(),children:se(H(e))}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`span`,{children:ce(e)}),e.tokenTotal>0?(0,z.jsxs)(`span`,{children:[U(e.tokenTotal),` tok`]}):null,(e.messageCount??0)>0?(0,z.jsxs)(`span`,{children:[U(e.messageCount??0),` msg`]}):null,(e.toolCallCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(te,{className:`h-3 w-3`}),e.toolCallCount]}):null,(e.fileChangeCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(re,{className:`h-3 w-3`}),e.fileChangeCount]}):null,(e.toolErrorCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,z.jsx)(o,{className:`h-3 w-3`}),e.toolErrorCount]}):null]})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-start gap-0.5 p-2`,children:[!e.isCurrent&&K&&!i?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>X(e.id),disabled:F!==null,className:`inline-flex h-7 items-center gap-1 border border-border/75 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:border-primary hover:text-primary disabled:opacity-40`,title:m(`activity:sessions.resume`,{defaultValue:`Resume session`}),children:[(0,z.jsx)(l,{className:`h-3 w-3`}),m(`activity:sessions.resumeShort`,{defaultValue:`Resume`})]}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>g(e.id),"aria-pressed":t,className:O(`inline-flex h-7 w-7 items-center justify-center transition-colors hover:bg-warning/10 hover:text-warning`,t?`text-warning`:`text-muted-foreground`),title:m(t?`activity:sessions.unfavorite`:`activity:sessions.markFavorite`),children:(0,z.jsx)(T,{className:O(`h-3.5 w-3.5`,t&&`fill-current`)})}),i?null:(0,z.jsx)(`button`,{type:`button`,onClick:()=>J(e),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,title:m(`activity:sessions.renameAction`,{defaultValue:`Rename`}),children:(0,z.jsx)(d,{className:`h-3.5 w-3.5`})}),e.isCurrent?null:(0,z.jsx)(`button`,{type:`button`,onClick:async()=>{await L({title:m(`activity:sessions.deleteSessionConfirmTitle`),message:m(`activity:sessions.deleteSessionConfirmBody`,{name:q(e)}),confirmLabel:m(`common:action.delete`),danger:!0})&&u(e.id)},className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:m(`activity:sessions.deleteSessionTitle`),children:(0,z.jsx)(y,{className:`h-3.5 w-3.5`})})]})]},e.id)})})]},e.label))}),(0,z.jsx)(ie,{page:B,pageSize:$,totalItems:Q.length,onPageChange:V,compact:!K,itemLabel:`sessions`})]})})]})}var G=12;async function K(e){try{let t=await e.clone().json(),n=typeof t.error==`string`?t.error:t.message;if(typeof n==`string`&&n.trim())return n}catch{try{let t=await e.text();if(t.trim())return t.trim()}catch{}}return e.statusText||`HTTP ${e.status}`}function q(e){switch(e){case`running`:return{icon:(0,z.jsx)(u,{className:`h-3.5 w-3.5`}),cls:`text-success`};case`streaming`:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-primary`};case`waiting_user`:return{icon:(0,z.jsx)(t,{className:`h-3.5 w-3.5`}),cls:`text-warning`};case`error`:return{icon:(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),cls:`text-destructive`};case`idle`:return{icon:(0,z.jsx)(c,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`};default:return{icon:(0,z.jsx)(m,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`}}}function J(e){switch(e){case`active`:return{icon:(0,z.jsx)(C,{className:`h-3.5 w-3.5`}),cls:`text-success`,badge:`border-success/25 bg-success/8 text-success`};case`idle`:return{icon:(0,z.jsx)(x,{className:`h-3.5 w-3.5`}),cls:`text-primary`,badge:`border-primary/25 bg-primary/10 text-primary`};case`closing`:return{icon:(0,z.jsx)(t,{className:`h-3.5 w-3.5`}),cls:`text-warning`,badge:`border-warning/25 bg-warning/10 text-warning`};case`lost`:return{icon:(0,z.jsx)(x,{className:`h-3.5 w-3.5`}),cls:`text-destructive/60`,badge:`border-destructive/15 bg-destructive/5 text-destructive/70`};default:return{icon:(0,z.jsx)(x,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`,badge:`border-border bg-muted text-muted-foreground`}}}function Y(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`<1m`;if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function X(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<10)return s.t(`common:time.justNow`);if(n<60)return s.t(`common:time.secondsAgo`,{count:n});let r=Math.floor(n/60);return r<60?s.t(`common:time.minutesAgo`,{count:r}):s.t(`common:time.hoursAgo`,{count:Math.floor(r/60)})}function Z(){let e=A(e=>e.wsConnected),t=k(e=>e.session?.id),{entries:n,loading:r,error:a}=j(i(e=>({entries:e.entries,loading:e.loading,error:e.error}))),{listSessions:o,resumeSession:s,deleteSession:c,renameSession:l}=D(),[u,d]=(0,R.useState)(``);return(0,R.useEffect)(()=>{e&&o(200)},[t,o,e]),(0,z.jsx)(W,{historyQuery:u,setHistoryQuery:d,historyEntries:n,historyLoading:r,historyError:a,wsConnected:e,listSessions:o,resumeSession:s,deleteSession:c,renameSession:l,variant:`workspace`})}function Q(){let{t:e}=v();return(0,z.jsxs)(F,{defaultValue:`history`,className:`flex h-full min-h-0 flex-col bg-background`,"data-testid":`sessions-workspace`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border/75 bg-card px-4 py-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-primary`,children:e(`activity:sessions.workspaceEyebrow`,{defaultValue:`Conversation control`})}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-lg font-semibold tracking-tight`,children:e(`activity:sessions.workspaceTitle`,{defaultValue:`Sessions`})})]}),(0,z.jsxs)(M,{className:`h-9 min-h-9 justify-start border-border/75 bg-background p-0 shadow-none`,children:[(0,z.jsxs)(P,{value:`history`,className:`h-9 gap-1.5 border-r border-border/75 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(w,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.history`,{defaultValue:`History`})]}),(0,z.jsxs)(P,{value:`live`,className:`h-9 gap-1.5 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.live`,{defaultValue:`Live sessions`})]})]})]}),(0,z.jsx)(N,{value:`history`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)(Z,{})}),(0,z.jsx)(N,{value:`live`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)($,{})})]})}function $(){let{t:e}=v(),[n,r]=(0,R.useState)([]),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(1),u=I(`sessions`,!i&&!o&&n.length>0),d=(0,R.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(!e.ok){if(e.status===404){s(null),r([]);return}throw Error(`HTTP ${e.status}: ${await K(e)}`)}if(!(e.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`)){s(null),r([]);return}let t=await e.json();if(!Array.isArray(t)){s(null),r([]);return}r(e=>{let n=t;if(e.length===n.length){let t=!0;for(let r=0;r<n.length;r++){let i=n[r],a=e[r];if(i.sessionId!==a.sessionId||i.status!==a.status||i.agentCount!==a.agentCount||i.startedAt!==a.startedAt){t=!1;break}}if(t)return e}return n}),s(null)}catch(e){if(e instanceof SyntaxError){s(null),r([]);return}s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,R.useEffect)(()=>{d();let e=setInterval(d,5e3);return()=>clearInterval(e)},[d]);let m=n.filter(e=>e.status===`active`).length,g=n.reduce((e,t)=>e+t.agentCount,0),_=n.slice((c-1)*G,c*G);return(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(n.length/G));c>e&&l(e)},[c,n.length]),i?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,z.jsx)(S,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:liveSessions.loading`)]})}):o?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-lg p-5 text-center`,children:[(0,z.jsx)(f,{className:`mx-auto h-8 w-8 text-warning`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium`,children:e(`activity:liveSessions.apiUnavailable`)}),(0,z.jsx)(`p`,{className:`mt-1 break-words text-xs text-muted-foreground`,children:o})]})}):n.length===0?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-md p-6 text-center text-muted-foreground`,children:[(0,z.jsx)(x,{className:`mx-auto h-9 w-9 opacity-50`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:e(`activity:liveSessions.empty`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:e(`activity:liveSessions.autoRefresh`)})]})}):(0,z.jsx)(`div`,{ref:u,className:`h-full min-h-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4`,children:[(0,z.jsx)(`header`,{className:`border border-border/70 bg-card/75 p-4`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(C,{className:`h-4 w-4 text-primary`}),(0,z.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`activity:liveSessions.heading`,{count:n.length})})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:liveSessions.autoRefresh`)})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center sm:min-w-[22rem]`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:n.length}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Sessions`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-success`,children:m}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Active`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:g}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Agents`})]})]})]})}),(0,z.jsx)(`div`,{className:`grid gap-3`,children:_.map(n=>{let r=J(n.status);return(0,z.jsxs)(`article`,{className:`border border-border/70 bg-card/75 p-3 sm:p-4`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:r.cls,children:r.icon}),(0,z.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold`,title:n.projectName,children:n.projectName}),(0,z.jsx)(`span`,{className:`bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:n.projectSlug}),(0,z.jsx)(`span`,{className:`inline-flex items-center border px-1.5 py-0.5 text-[10px] font-semibold uppercase ${r.badge}`,children:n.status})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-1.5 text-xs text-muted-foreground md:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:n.workingDir,children:n.workingDir})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.gitBranch?(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 text-primary`,children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,children:n.gitBranch})]}):null,(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(t,{className:`h-3.5 w-3.5`}),Y(n.startedAt)]}),(0,z.jsx)(`span`,{className:`font-mono`,children:e(`activity:liveSessions.pidLabel`,{pid:n.pid})})]})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs sm:grid-cols-3 lg:w-64`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Agents`}),(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:n.agentCount})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Status`}),(0,z.jsx)(`div`,{className:`truncate font-mono font-semibold`,children:n.status})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Runtime`}),(0,z.jsx)(`div`,{className:`font-mono font-semibold`,children:Y(n.startedAt)})]})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 overflow-hidden border border-border/70 bg-background/45`,children:[n.agents.length===0?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e(`activity:liveSessions.noAgents`)}):(0,z.jsx)(`div`,{className:`divide-y divide-border/60`,children:n.agents.slice(0,5).map(t=>{let n=q(t.status);return(0,z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 px-3 py-2 text-xs sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,14rem)_auto]`,children:[(0,z.jsx)(`span`,{className:O(`mt-0.5 shrink-0`,n.cls),children:n.icon}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,title:t.name,children:t.name}),(0,z.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground`,children:e(`activity:liveSessions.agentMeta`,{iter:t.iterations,tools:t.toolCalls,ago:X(t.lastActivityAt)})})]}),(0,z.jsx)(`div`,{className:`min-w-0 font-mono text-[10px] text-muted-foreground sm:text-xs`,children:t.currentTool?(0,z.jsx)(`span`,{className:`block truncate`,title:t.currentTool,children:t.currentTool}):(0,z.jsx)(`span`,{className:`text-muted-foreground/75`,children:t.status})}),(0,z.jsx)(`span`,{className:`hidden font-mono text-[10px] text-muted-foreground sm:block`,children:X(t.lastActivityAt)})]},t.id)})}),n.agents.length>5?(0,z.jsx)(`div`,{className:`border-t border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:e(`activity:liveSessions.andMore`,{count:n.agents.length-5})}):null]})]},n.sessionId)})}),(0,z.jsx)(ie,{page:c,pageSize:G,totalItems:n.length,onPageChange:l,itemLabel:`sessions`})]})})}export{Q as SessionsDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ia as t,Jt as n,Mr as r,Oa as i,Or as a,Pa as o,Wt as s,Xi as c,Yi as l,_r as u,ci as d,en as f,ga as p,gn as m,ja as ee,lt as h,nr as g,oa as _,qi as v,t as y,xn as b,yi as x}from"./vendor-CxV3l5PQ.js";import"./i18n-DxnYsmc-.js";import{t as te}from"./useWebSocket-x8PMoTq8.js";import{t as S}from"./ws-client-Cy3oRAmZ.js";import{t as C}from"./utils-_s0GyctV.js";import{M as w}from"./stores-BS-Bdi-5.js";import{o as T}from"./view-navigation-DLdE7qHU.js";import{n as E}from"./Toaster-EXqX2jqp.js";import{a as D,n as ne,o as re,r as O,t as k}from"./dialog-DsCmc6eL.js";import{t as A}from"./button-DwmC7ENW.js";import{t as j}from"./input-UhWgodVi.js";import{C as M,S as N,a as P,i as F,k as I,r as L,t as R}from"./index-Bf75VrDE.js";var z=e(t(),1);function B(e,t=8e3){return new Promise((n,r)=>{let i=setTimeout(()=>{a(),r(Error(`timeout`))},t),a=e.on(`key.operation_result`,e=>{clearTimeout(i),a(),n(e.payload)})})}var V=h();function ie({onKeySaved:e}){let{t}=ee(),[n,r]=(0,z.useState)(!1),[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(`openai-compatible`),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)([]),{setFieldRef:_,handleKeyDown:y}=P(),x=async()=>{if(i.trim()){p(!0);try{let n=S(w.getState().wsUrl),s=B(n);n.send({type:`provider.add`,payload:{id:i.trim(),family:o,baseUrl:c.trim()||void 0,apiKey:u.trim()||void 0,models:m.length>0?m.map(e=>e.id):void 0,customModels:m.length>0?Object.fromEntries(m.filter(e=>e.name||e.maxOutput||e.capabilities).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.values(e.capabilities).some(Boolean)?{capabilities:e.capabilities}:{}}])):void 0}});let f=await s;if(!f.success)throw Error(f.message);E.success(t(`setup:screen.toasts.providerAdded`,{id:i.trim()})),e(i.trim()),n.listSavedProviders(),n.probeProvider(i.trim()),a(``),l(``),d(``),h([]),r(!1)}catch(e){let n=e instanceof Error&&e.message&&e.message!==`timeout`?e.message:null;E.error(n??t(`setup:screen.toasts.providerAddFailed`))}finally{p(!1)}}};return(0,V.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,V.jsx)(b,{className:`h-5 w-5 text-muted-foreground`})}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`setup:screen.custom.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`setup:screen.custom.description`)})]}),(0,V.jsx)(v,{className:C(`h-4 w-4 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,V.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,V.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:t(`setup:screen.custom.localServers`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:L.map(e=>(0,V.jsx)(A,{type:`button`,size:`sm`,variant:i===e.id?`default`:`outline`,onClick:()=>{a(e.id),s(`openai-compatible`),l(e.defaultBaseUrl),e.noAuth&&d(``),h([])},title:e.hint,children:e.label},e.id))})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.providerId`)}),(0,V.jsx)(j,{placeholder:`e.g. my-llm`,value:i,onChange:e=>a(e.target.value),className:`text-sm`,ref:_(0),onKeyDown:e=>y(e,0)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.family`)}),(0,V.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,ref:_(1),onKeyDown:e=>y(e,1),children:[(0,V.jsx)(`option`,{value:`openai-compatible`,children:t(`setup:screen.custom.familyOpenAiCompatible`)}),(0,V.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,V.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,V.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.baseUrl`)}),(0,V.jsx)(j,{placeholder:`e.g. http://localhost:11434/v1`,value:c,onChange:e=>l(e.target.value),className:`text-sm font-mono`,ref:_(2),onKeyDown:e=>y(e,2)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.apiKey`)}),(0,V.jsx)(j,{type:`password`,placeholder:t(`setup:screen.custom.apiKeyPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`text-sm font-mono`,ref:_(3),onKeyDown:e=>y(e,3)})]}),(0,V.jsx)(R,{models:m,onChange:h}),(0,V.jsxs)(A,{onClick:x,disabled:!i.trim()||f,size:`sm`,ref:_(4),onKeyDown:e=>y(e,4,x),children:[f?(0,V.jsx)(g,{className:`h-4 w-4 animate-spin mr-2`}):null,t(`setup:screen.custom.add`)]})]})]})}var H=F();async function ae(e,t){try{let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(!Array.isArray(r))throw Error(`Expected JSON array`);let i=r.filter(e=>typeof e.id==`string`&&typeof e.name==`string`&&typeof e.family==`string`);return i.length>0?i:H}catch{return H}}function oe(e,t){let n=new Date().getTime()-e.getTime(),r=Math.floor(n/1e3);if(r<10)return t(`setup:screen.time.justNow`);if(r<60)return t(`setup:screen.time.secondsAgo`,{count:r});let i=Math.floor(r/60);if(i<60)return t(`setup:screen.time.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`setup:screen.time.hoursAgo`,{count:a}):t(`setup:screen.time.daysAgo`,{count:Math.floor(a/24)})}var se=e(y(),1);function ce({popular:e,catalogProvider:t,savedProvider:n,onKeySaved:i,probeResult:a}){let{t:o}=ee(),[s,u]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1),[h,_]=(0,z.useState)(!!n?.apiKeys.some(e=>e.isActive)),[y,b]=(0,z.useState)(!1),[te,T]=(0,z.useState)(!1),[M,N]=(0,z.useState)(!1),[P,F]=(0,z.useState)(null);(0,z.useEffect)(()=>{M&&e.referral&&se.toDataURL(e.referral.url,{width:200,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).then(e=>F(e)).catch(()=>F(null))},[M,e.referral]);let I=async()=>{if(s.trim()){m(!0);try{let n=S(w.getState().wsUrl),r=B(n);t?n.addKey(e.id,`default`,s.trim()):n.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:s.trim()}});let a=await r;if(!a.success)throw Error(a.message);_(!0),u(``),E.success(o(`setup:screen.toasts.keySaved`,{name:e.name})),i(e.id),n.listSavedProviders(),n.probeProvider(e.id)}catch(t){let n=t instanceof Error&&t.message&&t.message!==`timeout`?t.message:null;E.error(n??o(`setup:screen.toasts.keySaveFailed`,{name:e.name}))}finally{m(!1)}}},L=e=>{e.key===`Enter`&&s.trim()&&I()},R=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),T(!0),E.success(o(`setup:screen.toasts.referralCopied`)),setTimeout(()=>T(!1),2e3)}catch{E.error(o(`setup:screen.toasts.referralCopyFailed`))}},ie=t&&t.modelCount>0;return(0,V.jsxs)(`div`,{className:C(`rounded-xl border p-4 transition-all`,h?`border-success/30 bg-success/5`:`bg-gradient-to-br ${e.color}`),children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),h&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-success/10 text-success border border-success/20`,children:[(0,V.jsx)(c,{className:`h-2.5 w-2.5`}),o(`setup:screen.card.keySaved`)]}),e.referral&&!h&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning border border-warning/20`,children:[(0,V.jsx)(r,{className:`h-2.5 w-2.5`}),o(`setup:screen.card.referral`)]})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!h&&(0,V.jsxs)(`p`,{className:`text-[11px] text-warning/80 mt-1`,children:[`🎁 `,e.referral.reward]}),h?h?(0,V.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[n?.baseUrl&&(0,V.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 font-mono truncate`,title:n.baseUrl,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground/50`,children:`URL: `}),n.baseUrl]}),n?.models&&n.models.length>0&&(0,V.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground/50`,children:`Models: `}),n.pickedModelId??n.models[0],(0,V.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[` (+`,n.models.length-1,` more)`]})]}),a===`probing`?(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mt-1`,children:[(0,V.jsx)(g,{className:`h-3 w-3 animate-spin`}),o(`setup:screen.probe.checking`,`Checking connection…`)]}):a?.ok?(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success mt-1`,children:[(0,V.jsx)(c,{className:`h-3 w-3`}),(0,V.jsxs)(`span`,{children:[o(`setup:screen.probe.connected`,`Connected`),a.modelCount!=null&&` · ${a.modelCount} ${o(`setup:screen.probe.models`,`models`)}`,a.elapsedMs!=null&&` · ${a.elapsedMs}ms`]})]}):a&&!a.ok?(0,V.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-destructive mt-1`,children:[(0,V.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:`✕`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:o(`setup:screen.probe.failed`,`Probe failed`)}),a.status===`no_base_url`&&(0,V.jsx)(`span`,{className:`block text-destructive/70`,children:o(`setup:screen.probe.noBaseUrl`,`No base URL configured`)}),a.status===`unreachable`&&(0,V.jsxs)(`span`,{className:`block text-destructive/70`,children:[o(`setup:screen.probe.unreachable`,`Could not connect`),a.detail?`: ${a.detail}`:``]}),a.status!==`no_base_url`&&a.status!==`unreachable`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`block text-destructive/70`,children:a.httpStatus==null?a.status:`${o(`setup:screen.probe.httpStatus`,`Status`)} ${a.httpStatus}`}),a.detail&&(0,V.jsx)(`span`,{className:`block text-destructive/70 truncate max-w-[250px]`,title:a.detail,children:a.detail})]})]})]}):null,ie&&(0,V.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[o(`setup:screen.providers.modelsAvailable`,{count:t?.modelCount??0}),y?(0,V.jsx)(l,{className:`h-3 w-3`}):(0,V.jsx)(v,{className:`h-3 w-3`})]})]}):null:(0,V.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(j,{type:`password`,placeholder:e.keyPlaceholder,value:s,onChange:e=>u(e.target.value),onKeyDown:L,className:`font-mono text-sm`}),(0,V.jsx)(A,{onClick:I,disabled:!s.trim()||p,size:`sm`,className:`shrink-0`,children:p?(0,V.jsx)(g,{className:`h-4 w-4 animate-spin`}):o(`setup:screen.card.save`)})]}),e.docsUrl&&(0,V.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,children:[o(`setup:screen.card.getKey`),` `,(0,V.jsx)(d,{className:`h-3 w-3`})]}),e.referral&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:R,className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:te?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(c,{className:`h-3 w-3`}),` `,o(`setup:screen.card.copied`)]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(x,{className:`h-3 w-3`}),` `,o(`setup:screen.card.copyReferral`)]})}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:[(0,V.jsx)(f,{className:`h-3 w-3`}),` `,o(`setup:screen.card.share`)]})]})]})]})]}),(0,V.jsx)(k,{open:M,onOpenChange:N,children:(0,V.jsxs)(ne,{className:`sm:max-w-md`,children:[(0,V.jsxs)(D,{children:[(0,V.jsxs)(re,{className:`flex items-center gap-2`,children:[(0,V.jsx)(r,{className:`h-4 w-4 text-warning`}),o(`setup:screen.share.title`,{name:e.name})]}),(0,V.jsx)(O,{children:o(`setup:screen.share.description`)})]}),(0,V.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`text-sm text-center`,children:(0,V.jsxs)(`p`,{className:`font-medium text-warning`,children:[`🎁 `,e.referral.reward]})}),P?(0,V.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,V.jsx)(`img`,{src:P,alt:o(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,V.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,V.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,V.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://twitter.com/intent/tweet?text=${t}&url=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.twitter`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),`X`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`Check out ${e.name}! ${e.referral.reward}`);window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${t}&summary=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.linkedin`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`})}),`LinkedIn`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward} ${e.referral.url}`);window.open(`https://t.me/share/url?url=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.telegram`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`})}),`Telegram`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://wa.me/?text=${t}%20${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.whatsapp`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.134 1.585 5.934L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})}),`WhatsApp`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`${e.name} - ${e.referral.reward}`);window.open(`https://www.reddit.com/submit?url=${t}&title=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.reddit`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 0 1.108-.701 1.25 1.25 0 0 1 2.144.33zm-8.811 8.748c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754zm7.944 0c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754z`})}),`Reddit`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://www.facebook.com/sharer/sharer.php?u=${n}"e=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:o(`setup:screen.share.facebook`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{d:`M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z`})}),`Facebook`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`mailto:?subject=${t}&body=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-muted text-muted-foreground text-xs hover:bg-muted/80 transition-colors`,title:o(`setup:screen.share.email`),children:[(0,V.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25H4.5a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75`})}),`Email`]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(j,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,V.jsx)(A,{size:`sm`,variant:`outline`,onClick:R,className:`shrink-0`,children:te?(0,V.jsx)(c,{className:`h-4 w-4`}):(0,V.jsx)(x,{className:`h-4 w-4`})})]}),(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:o(`setup:screen.share.hint`)})]})]})})]})})]})}function U(){let{t:e}=ee(),{model:t,setProvider:r,setModel:l,wsConnected:d,wsUrl:f}=w(i(e=>({model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected,wsUrl:e.wsUrl})));te();let[h,y]=(0,z.useState)([]),[b,x]=(0,z.useState)({}),[D,ne]=(0,z.useState)([]),[re,O]=(0,z.useState)(!1),[k,j]=(0,z.useState)(null),[P,F]=(0,z.useState)(0),[L,R]=(0,z.useState)(new Set),[B,se]=(0,z.useState)({}),[U,le]=(0,z.useState)(H),[W,G]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(0),[fe,pe]=(0,z.useState)(0),[K,me]=(0,z.useState)(null),q=(0,z.useRef)(!0);(0,z.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`;return G(!0),ae(t,e.signal).then(t=>{if(t!==H){if(le(t),G(!1),!q.current){let e=t.length-fe;e>0?E.success(o.t(`setup:screen.toasts.providersLoadedNew`,{count:t.length,diff:e})):e<0?E.success(o.t(`setup:screen.toasts.providersLoadedRemoved`,{count:t.length,diff:Math.abs(e)})):E.success(o.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:t.length})),pe(t.length)}me(new Date);return}return ae(`https://raw.githubusercontent.com/WrongStack/WrongStack/main/packages/webui/public/providers.json`,e.signal)}).then(e=>{if(e){if(le(e),!q.current){let t=e.length-fe;t>0?E.success(o.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?E.success(o.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):E.success(o.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),pe(e.length)}me(new Date)}}).catch(()=>{q.current||E.error(o.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{G(!1),q.current=!1}),()=>e.abort()},[ue]);let[J,he]=(0,z.useState)(null),[Y,X]=(0,z.useState)(null),[ge,_e]=(0,z.useState)(!1);(0,z.useEffect)(()=>{if(!d)return;let e=S(f),n=setTimeout(()=>{n=null,O(!1),j(o.t(`setup:screen.errors.backendNotResponding`))},8e3),r=()=>{n&&=(clearTimeout(n),null)},i=e.on(`provider.catalog`,e=>{if(e.type===`provider.catalog`){r(),j(null);let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));y(t),O(!1)}}),a=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let n=e.payload;if(n.provider!==J)return;x(e=>({...e,[n.provider]:n.models})),_e(!1),n.models.length===1?X(n.models[0].id):t&&n.models.some(e=>e.id===t)&&X(t)}}),s=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));ne(t);let n=new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id));R(n)}}),c=e.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;se(e=>({...e,[t.providerId]:t}))});return j(null),O(!0),e.listProviders(),()=>{r(),i?.(),a?.(),s?.(),c?.()}},[d,f,t,P]);let ve=(0,z.useCallback)(()=>{j(null),F(e=>e+1)},[]),ye=(0,z.useCallback)(()=>{de(e=>e+1)},[]),be=(0,z.useCallback)(t=>oe(t,e),[e]),Z=(0,z.useCallback)(e=>{R(t=>new Set([...t,e])),he(e),X(null)},[]),xe=L.size>0;(0,z.useEffect)(()=>{if(!J||!d)return;let e=S(f);b[J]||(_e(!0),e.listProviderModels(J))},[J,d,f,b]);let Se=J?b[J]??[]:[],Ce=(0,z.useCallback)(async()=>{if(!J||!Y)return;if(!L.has(J)){E.error(`Please save the provider configuration before starting a session.`);return}r(J),l(Y);let e=S(f),t=await e.switchModel(J,Y,5e3);t.success?(e.newSession(),T(`chat`)):E.error(t.message||o.t(`setup:screen.errors.modelSwitchTimeout`))},[J,Y,r,l,f]),we=(0,z.useCallback)(async()=>{if(!J||!Y)return;r(J),l(Y);let e=await S(f).switchModel(J,Y,5e3);e.success?T(`chat`):E.error(e.message||o.t(`setup:screen.errors.modelSwitchTimeout`))},[J,Y,r,l,f]),Te=new Set(U.map(e=>e.id)),Ee=h.filter(e=>!Te.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),Q=M(Ee,10);M(D,9);let $=M(Se,12,J);return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,V.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b bg-card px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,V.jsx)(`img`,{src:`/wrongstack.svg`,alt:`WrongStack`,draggable:!1,className:`ws-brand-logo h-10 w-10 shrink-0 border border-border/70 shadow-sm`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`truncate text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground sm:truncate`,children:e(`setup:screen.header.subtitle`)})]})]}),xe&&J?(0,V.jsxs)(`span`,{className:`text-xs text-success/80`,children:[(0,V.jsx)(c,{className:`h-3 w-3 inline-block mr-1`}),e(`setup:screen.header.continue`)]}):null]}),(0,V.jsx)(I,{className:`min-h-0 flex-1`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-4 pb-4 sm:p-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,V.jsxs)(`div`,{className:C(`flex min-w-0 items-center gap-1.5`,xe?`text-success`:`text-primary font-medium`),children:[(0,V.jsx)(u,{className:`h-4 w-4`}),(0,V.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,V.jsx)(v,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`div`,{className:C(`flex min-w-0 items-center gap-1.5`,J?`text-primary font-medium`:`text-muted-foreground`),children:[(0,V.jsx)(_,{className:`h-4 w-4`}),(0,V.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,V.jsx)(v,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,V.jsxs)(`div`,{className:C(`flex min-w-0 items-center gap-1.5`,J&&Y?`text-primary font-medium`:`text-muted-foreground`),children:[(0,V.jsx)(s,{className:`h-4 w-4`}),(0,V.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,V.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,V.jsx)(n,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),k?(0,V.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-4 py-12 rounded-xl border border-destructive/30 bg-destructive/5 px-6`,children:[(0,V.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,V.jsx)(a,{className:`h-6 w-6 text-destructive`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:k})]}),(0,V.jsxs)(A,{onClick:ve,size:`sm`,variant:`outline`,children:[(0,V.jsx)(g,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[W&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,V.jsx)(g,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),K&&!W&&(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:K.toLocaleString(),children:be(K)}),(0,V.jsxs)(`button`,{type:`button`,onClick:ye,disabled:W,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`setup:screen.providers.refreshTitle`),children:[(0,V.jsx)(m,{className:C(`h-3 w-3`,W&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:U.map(e=>(0,V.jsx)(ce,{popular:e,catalogProvider:h.find(t=>t.id===e.id),savedProvider:D.find(t=>t.id===e.id),onKeySaved:Z,probeResult:B[e.id]},e.id))})]}),Ee.length>0&&(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Q.pageItems.map(t=>(0,V.jsx)(ce,{popular:{id:t.id,name:t.name,description:e(`setup:screen.providers.catalogDescription`,{family:t.family,count:t.modelCount}),icon:`🔗`,color:`from-muted/60 to-muted/20 border-border hover:border-primary/40`,keyPlaceholder:`API key`,family:t.family},catalogProvider:t,savedProvider:D.find(e=>e.id===t.id),onKeySaved:Z,probeResult:B[t.id]},t.id))}),(0,V.jsx)(N,{page:Q.page,pageSize:Q.pageSize,totalItems:Q.totalItems,onPageChange:Q.setPage,itemLabel:`providers`})]}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,V.jsx)(ie,{onKeySaved:Z})]})]}),re&&(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),J&&(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,V.jsx)(s,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{he(null),X(null)},className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)})]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:J})}),ge?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):Se.length>0?(0,V.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:$.pageItems.map(e=>{let t=e.contextWindow?`${(e.contextWindow/1e6).toFixed(0)}M ctx`:null;return(0,V.jsx)(`button`,{type:`button`,onClick:()=>X(e.id),className:C(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,Y===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,V.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:t}),e.capabilities.slice(0,3).map(e=>(0,V.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),Y===e.id&&(0,V.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary`,children:(0,V.jsx)(c,{className:`h-3 w-3 text-primary-foreground`})})]})},e.id)})}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)}),(0,V.jsx)(N,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,itemLabel:`models`})]}),J&&Y&&(0,V.jsxs)(`div`,{className:`sticky bottom-0 -mx-4 border-t bg-background/80 px-4 py-4 backdrop-blur-sm sm:-mx-6 sm:px-6`,children:[(0,V.jsx)(`div`,{className:`mb-3 flex min-w-0 items-center justify-between gap-2 text-sm text-muted-foreground`,children:(0,V.jsxs)(`span`,{className:`min-w-0 truncate`,children:[J,` / `,Y]})}),(0,V.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,V.jsxs)(A,{onClick:Ce,className:`flex-1`,size:`lg`,children:[(0,V.jsx)(_,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,V.jsx)(p,{className:`h-4 w-4 ml-2`})]}),(0,V.jsxs)(A,{onClick:we,variant:`outline`,className:`flex-1`,size:`lg`,children:[(0,V.jsx)(c,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.saveConfig`)]})]}),(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 text-center mt-2`,children:e(`setup:screen.start.saveConfigHint`)})]})]})})]})}export{U as SetupScreen};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-CxV3l5PQ.js","assets/rolldown-runtime-QTnfLwEv.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-sSmz-Ua_.js","assets/vendor-BMdWcCR4.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ia as t,Ji as n,Or as r,Pa as i,Tn as ee,Vr as te,Wt as ne,Xi as re,ca as ie,dt as a,gn as ae,ja as o,jt as s,kn as oe,lt as c,nr as l,pa as u,pi as se,qi as d,qr as ce,yi as le}from"./vendor-CxV3l5PQ.js";import"./i18n-DxnYsmc-.js";import{n as f}from"./ui-store-C4Ybfoon.js";import{s as p}from"./monaco-BLUV5g0U.js";import{t as ue}from"./useWebSocket-x8PMoTq8.js";import{t as m}from"./utils-_s0GyctV.js";import{o as de}from"./view-navigation-DLdE7qHU.js";import{a as fe,n as pe,o as me,t as he}from"./dialog-DsCmc6eL.js";import{p as h}from"./markdown-sSmz-Ua_.js";import{c as ge,g as _e,u as ve}from"./index-Bf75VrDE.js";import{t as ye}from"./empty-state-02bIS4x7.js";var g=e(t(),1),_=c(),be=(0,g.lazy)(()=>p(()=>import(`./vendor-CxV3l5PQ.js`).then(e=>e.S),__vite__mapDeps([0,1,2,3,4,5])));function v(e){return e===`project`||e===`user`}function xe(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function Se({source:e}){let{t}=o(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,_.jsx)(`span`,{className:m(`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`border-success/25 bg-success/8 text-success`,n===`user`&&`border-primary/25 bg-primary/10 text-primary`,n===`bundled`&&`border-border/70 bg-muted/60 text-muted-foreground`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function y({className:e}){let{t}=o(),{client:c}=ue(),p=f(e=>e.skillsState),y=f(e=>e.setSkillsState),b=p.selectedSkill,x=p.navHistory,S=p.historyIndex,[C,Ce]=(0,g.useState)(null),[we,w]=(0,g.useState)(!1),[Te,T]=(0,g.useState)(null),Ee=ge(`skill-detail`,!!C),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),[A,j]=(0,g.useState)(!1),[M,N]=(0,g.useState)(null),[P,F]=(0,g.useState)(!1),[I,L]=(0,g.useState)(null),[R,z]=(0,g.useState)(!1),B=(0,g.useRef)(``),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(null),[De,Oe]=(0,g.useState)(!1),[G,K]=(0,g.useState)(null),[q,ke]=(0,g.useState)(!1),[Ae,je]=(0,g.useState)([]),J=(0,g.useRef)(p);J.current=p;let Y=(0,g.useRef)(!1),X=(0,g.useMemo)(()=>O?{lines:O.split(`
|
|
3
|
-
`).length,words:O.trim()?O.trim().split(/\s+/).length:0,chars:O.length}:{lines:0,words:0,chars:0},[O]),Z=(0,g.useMemo)(()=>{if(!O)return null;let e=5*1024*1024,t=new Blob([O]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[O]);(0,g.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(null),2e3);return()=>clearTimeout(e)},[I]),(0,g.useEffect)(()=>{if(!E||!b)return;let e=setInterval(()=>{O&&O!==B.current&&(B.current=O,localStorage.setItem(`skills_draft_${b.name}`,JSON.stringify({content:O,savedAt:Date.now()})),L(Date.now()))},5e3);return()=>clearInterval(e)},[E,O,b]),(0,g.useEffect)(()=>{if(!b||!E)return;let e=localStorage.getItem(`skills_draft_${b.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==O&&t!==B.current&&(k(t),B.current=t,z(!0))}catch{}},[b?.name,E]),(0,g.useEffect)(()=>{if(!c||!b)return;w(!0),Ce(null),T(null);let e=setTimeout(()=>{w(!1),T(i.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?T(n.payload.error):n.payload.name&&Ce(n.payload),w(!1)},n=e=>{let t=e;H(!1);let n=J.current;if(t.payload.success){let e={...n.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;y({...n,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),c.send({type:`skills.list`},{echoToChat:!1})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??i.t(`activity:skillDetail.updateFailed`)}]})},r=e=>{let t=e;t.payload.skills&&je(t.payload.skills)};return c.on(`skills.content`,t),c.on(`skills.updated`,n),c.on(`skills.list`,r),c.send({type:`skills.content`,payload:{name:b.name,source:b.source}}),()=>{clearTimeout(e),c.off(`skills.content`,t),c.off(`skills.updated`,n),c.off(`skills.list`,r)}},[c,b?.name,b?.source]),(0,g.useEffect)(()=>{E&&(D(!1),k(``),N(null))},[b?.name]);let Q=(0,g.useCallback)(e=>Ae.find(t=>t.name.toLowerCase()===e.toLowerCase()),[Ae]),Me=(0,g.useCallback)(e=>{let t=Q(e);if(t){Y.current=!1;let e=x.slice(0,S+1);e.push(t),y({...J.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),D(!1),k(``),W(null)}},[Q,x,S,y]),Ne=(0,g.useCallback)(()=>{if(S<=0)return;Y.current=!0;let e=S-1,t=x[e];y({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[S,x,y]),Pe=(0,g.useCallback)(()=>{if(S>=x.length-1)return;Y.current=!0;let e=S+1,t=x[e];y({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[S,x,y]),$=(0,g.useCallback)(()=>{de(`chat`)},[]),Fe=(0,g.useCallback)(()=>{C&&(k(C.body),B.current=C.body,z(!1),N(null),D(!0),F(!1))},[C]),Ie=(0,g.useCallback)(()=>{D(!1),k(``),N(null),F(!1),z(!1),b&&localStorage.removeItem(`skills_draft_${b.name}`)},[b]),Le=(0,g.useCallback)(()=>{!b||!C||(z(!1),k(C.body),B.current=C.body,b&&localStorage.removeItem(`skills_draft_${b.name}`))},[b,C]),Re=(0,g.useCallback)(()=>{if(!c||!b||!O.trim())return;j(!0),N(null);let e=t=>{let n=t;j(!1),n.payload.success?(B.current=``,localStorage.removeItem(`skills_draft_${b.name}`),z(!1),D(!1),c.send({type:`skills.content`,payload:{name:b.name,source:b.source}}),c.send({type:`skills.list`},{echoToChat:!1})):N(n.payload.error??i.t(`activity:skillDetail.saveFailed`)),c.off(`skills.edited`,e)};c.on(`skills.edited`,e),c.editSkill(b.name,O)},[c,b,O]),ze=(0,g.useCallback)(()=>{!c||!b||(H(!0),W(null),c.checkForUpdates(b.name,b.source===`user`))},[c,b]),Be=(0,g.useCallback)(()=>{b?.sourceUrl&&navigator.clipboard.writeText(b.sourceUrl).then(()=>{Oe(!0),setTimeout(()=>Oe(!1),2e3)})},[b]),Ve=(0,g.useCallback)(()=>{if(!C?.body)return;let e=new Blob([C.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${C.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[C]),He=(0,g.useCallback)(async e=>{if(!c||!e)return;ke(!0);let t=e=>{let n=e;ke(!1),n.payload.success?(K(null),c.send({type:`skills.list`},{echoToChat:!1}),$()):N(n.payload.error??i.t(`activity:skillDetail.uninstallFailed`)),c.off(`skills.uninstalled`,t)};c.on(`skills.uninstalled`,t),c.uninstallSkill(e.name,e.source===`user`)},[c,$]);return b?(0,_.jsxs)(`div`,{className:m(`flex h-full min-h-0 min-w-0 flex-col gap-3 overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:[(0,_.jsxs)(`div`,{className:`shrink-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,_.jsx)(ne,{className:`h-4 w-4`})}),(0,_.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold`,children:b.name}),b.version&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,b.version]}),(0,_.jsx)(Se,{source:b.source})]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:b.description||b.trigger}),b.sourceUrl&&(0,_.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1`,children:[(0,_.jsxs)(`a`,{href:`https://${b.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,title:t(`activity:skillDetail.openSourceRepo`),children:[(0,_.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate font-mono`,children:b.sourceUrl})]}),(0,_.jsx)(`button`,{type:`button`,onClick:Be,className:`flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground`,title:t(`activity:skillDetail.copySourceUrl`),children:De?(0,_.jsx)(re,{className:`h-3 w-3 text-success`}):(0,_.jsx)(le,{className:`h-3 w-3`})})]}),b.scope.length>0&&(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:b.scope.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,_.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,_.jsx)(`div`,{className:`text-success`,children:t(`activity:skillDetail.updatedLabel`,{list:U.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),U.unchanged.length>0&&(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,_.jsx)(`div`,{className:`text-destructive`,children:t(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 lg:ml-auto lg:shrink-0 lg:justify-end`,children:[v(b.source)&&b.sourceUrl&&(0,_.jsx)(`button`,{type:`button`,onClick:ze,disabled:V,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,title:t(`activity:skillDetail.checkUpdatesTitle`),children:V?(0,_.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,_.jsx)(ae,{className:`h-3.5 w-3.5`})}),b.source!==`bundled`&&!E&&(0,_.jsx)(`button`,{type:`button`,onClick:Ve,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillDetail.exportTitle`),children:(0,_.jsx)(se,{className:`h-3.5 w-3.5`})}),v(b.source)&&!E&&(0,_.jsx)(`button`,{type:`button`,onClick:Fe,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillDetail.editTitle`),children:(0,_.jsx)(ee,{className:`h-3.5 w-3.5`})}),v(b.source)&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>K(b),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:t(`activity:skillDetail.uninstallTitle`),children:(0,_.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,_.jsx)(`button`,{type:`button`,onClick:$,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,title:t(`activity:skillDetail.closeTitle`),children:(0,_.jsx)(a,{className:`h-4 w-4`})})]})]}),x.length>1&&(0,_.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-1 rounded-lg border border-border/60 bg-muted/35 px-2 py-1`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:Ne,disabled:S<=0,className:m(`rounded p-1 transition-colors`,S<=0?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:t(`activity:skillDetail.backTitle`),children:(0,_.jsx)(n,{className:`h-4 w-4`})}),(0,_.jsx)(`button`,{type:`button`,onClick:Pe,disabled:S>=x.length-1,className:m(`rounded p-1 transition-colors`,S>=x.length-1?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:t(`activity:skillDetail.forwardTitle`),children:(0,_.jsx)(d,{className:`h-4 w-4`})}),(0,_.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:x.map((e,t)=>(0,_.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,_.jsx)(d,{className:`h-3 w-3 text-muted-foreground/65 mx-0.5 shrink-0`}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{t<S&&(Y.current=!0,y({...J.current,selectedSkill:e,historyIndex:t}),D(!1),k(``),W(null))},className:m(`hover:text-primary cursor-pointer transition-colors`,t===S?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),C&&(C.relatedFiles.length>0||C.references.length>0)&&(0,_.jsxs)(`div`,{className:`shrink-0 space-y-2 rounded-xl border border-border/70 bg-card/70 px-4 py-3 shadow-sm`,children:[C.relatedFiles.length>0&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,_.jsx)(te,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.relatedFiles`)})]}),C.relatedFiles.map(e=>{let n=xe(e);return n&&Q(n)?(0,_.jsxs)(`button`,{type:`button`,onClick:()=>Me(n),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] transition-colors hover:border-primary/40 hover:text-primary`,title:t(`activity:skillDetail.goToSkillTitle`,{name:n}),children:[(0,_.jsx)(u,{className:`h-2.5 w-2.5`}),e]},e):(0,_.jsx)(`span`,{className:`rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e)})]}),C.references.length>0&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,_.jsx)(ce,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.references`)})]}),C.references.map(e=>{let n=xe(e)??e.replace(/\.md$/,``);return Q(n)?(0,_.jsxs)(`button`,{type:`button`,onClick:()=>Me(n),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-[10px] text-primary transition-colors hover:border-primary/30 hover:bg-primary/10`,title:t(`activity:skillDetail.goToSkillTitle`,{name:n}),children:[(0,_.jsx)(u,{className:`h-2.5 w-2.5`}),n]},e):(0,_.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:n},e)})]})]}),(0,_.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/70 shadow-sm`,children:we?(0,_.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center text-muted-foreground`,children:[(0,_.jsx)(l,{className:`mx-auto mb-2 h-6 w-6 animate-spin text-primary`}),(0,_.jsx)(`p`,{children:t(`activity:skillDetail.loadingContent`)})]}):E?(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,_.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border/70 bg-muted/30 px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillDetail.editingLabel`,{name:b.name})}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t(`activity:skillDetail.editStats`,{lines:X.lines,words:X.words,chars:X.chars})}),Z&&(0,_.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`font-medium text-destructive`:`text-warning`}`,children:t(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/(1024*1024)).toFixed(1),limit:(Z.limit/(1024*1024)).toFixed(0)})}),I&&(0,_.jsx)(`span`,{className:`text-xs text-success animate-pulse`,children:t(`activity:skillDetail.draftSaved`)}),R&&(0,_.jsx)(`span`,{className:`animate-pulse text-xs text-warning`,children:t(`activity:skillDetail.draftRestored`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[M&&(0,_.jsx)(`span`,{className:`text-xs text-destructive`,children:M}),R&&(0,_.jsx)(`button`,{type:`button`,onClick:Le,className:`rounded-md border border-warning/35 px-2 py-1 text-[10px] text-warning transition-colors hover:bg-warning/10`,children:t(`activity:skillDetail.discardDraft`)}),(0,_.jsx)(`button`,{type:`button`,onClick:Ie,className:`rounded-md border border-border/70 px-2 py-1 text-xs transition-colors hover:bg-accent`,children:t(`common:action.cancel`)}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>F(e=>!e),title:t(P?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`rounded-md border px-2 py-1 text-xs transition-colors ${P?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 text-muted-foreground hover:bg-accent`}`,children:(0,_.jsx)(oe,{className:`h-3 w-3 inline`})}),(0,_.jsx)(`button`,{type:`button`,onClick:Re,disabled:A||!O.trim(),className:`rounded-md bg-primary px-3 py-1 text-xs text-primary-foreground shadow-sm shadow-primary/15 transition-colors hover:bg-primary/90 disabled:opacity-50`,children:A?(0,_.jsx)(l,{className:`h-3 w-3 animate-spin inline`}):t(`common:action.save`)})]})]}),P?(0,_.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,_.jsx)(g.Suspense,{fallback:null,children:(0,_.jsx)(be,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})})}),(0,_.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,_.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-background/45 p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,_.jsx)(ve,{rehypePlugins:[h],components:_e,children:O})})]}):(0,_.jsx)(g.Suspense,{fallback:null,children:(0,_.jsx)(be,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})})]}):C?(0,_.jsx)(`div`,{ref:Ee,className:`h-full min-h-0 overflow-y-auto overscroll-contain p-5 sm:p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,_.jsx)(ve,{rehypePlugins:[h],components:_e,children:C.body})}):Te?(0,_.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center`,children:[(0,_.jsx)(`p`,{className:`text-destructive mb-2`,children:t(`activity:skillDetail.loadFailed`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Te}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{c&&b&&(w(!0),T(null),c.send({type:`skills.content`,payload:{name:b.name,source:b.source}}))},className:`mt-4 rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(`common:action.retry`)})]}):(0,_.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center p-8 text-center text-muted-foreground`,children:t(`activity:skillDetail.noContent`)})}),(0,_.jsx)(he,{open:!!G,onOpenChange:e=>{e||K(null)},children:(0,_.jsxs)(pe,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,_.jsxs)(fe,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(s,{className:`h-4 w-4 text-destructive`}),(0,_.jsx)(me,{className:`font-semibold text-sm`,children:t(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>K(null),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,_.jsx)(a,{className:`h-4 w-4`})})]}),(0,_.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm`,children:G&&t(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G&&t(`activity:skillDetail.uninstallRemovePath`,{path:G.path})})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>K(null),disabled:q,className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent disabled:opacity-50`,children:t(`common:action.cancel`)}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>G&&He(G),disabled:q,className:`flex items-center gap-1.5 rounded-md bg-destructive px-3 py-1.5 text-xs text-destructive-foreground transition-colors hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[q&&(0,_.jsx)(l,{className:`h-3 w-3 animate-spin`}),t(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,_.jsx)(ye,{icon:(0,_.jsx)(ie,{className:`h-6 w-6`}),title:t(`activity:skillDetail.noSkillSelected`),description:t(`activity:skillDetail.selectSkillHint`),action:{label:t(`activity:skillDetail.goToChat`),onClick:$},className:e})}export{y as SkillDetailView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ca as t,Ei as n,Fn as r,Ia as i,Ir as a,Jt as o,M as s,Nr as c,Nt as l,Vn as u,Wt as d,aa as f,an as p,bi as m,ci as h,dt as ee,gn as g,ia as _,lt as te,nr as v,pi as ne,pn as y,ut as b,va as x,wi as S}from"./vendor-CxV3l5PQ.js";import{t as C}from"./utils-_s0GyctV.js";import{n as w}from"./stores-BS-Bdi-5.js";import{t as T}from"./button-DwmC7ENW.js";import{t as re}from"./input-UhWgodVi.js";import{C as E,S as D}from"./index-Bf75VrDE.js";var O=e(i(),1),k=te(),ie={current:{label:`Current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{label:`Update available`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{label:`Major update`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{label:`Vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{label:`Deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{label:`Yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{label:`Unmaintained?`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{label:`Blocked`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{label:`Private`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{label:`Local path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{label:`Git`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},ae={label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function A(e){return ie[e]??ae}var j={npm:{label:`npm / Node.js`,icon:r},python:{label:`Python`,icon:S},rust:{label:`Rust`,icon:o},go:{label:`Go`,icon:y},dotnet:{label:`.NET`,icon:u},php:{label:`PHP`,icon:l},dart:{label:`Dart / Flutter`,icon:m},maven:{label:`Maven`,icon:t},gradle:{label:`Gradle`,icon:f},ruby:{label:`Ruby`,icon:c},swift:{label:`Swift`,icon:b},elixir:{label:`Elixir`,icon:l},cpp:{label:`C / C++`,icon:n}},M={label:`Unknown`};function N(e){return j[e]??M}function P({ecosystem:e,className:t=`size-3.5 shrink-0`}){let n=N(e);if(!n.icon)return null;let r=n.icon;return(0,k.jsx)(r,{className:t})}function oe(e){return A(e.status).weight>=50}var F=[`critical`,`high`,`medium`,`low`,`info`],I={critical:{label:`Critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{label:`High`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{label:`Medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{label:`Low`,badge:`border-info/35 bg-info/10 text-info`},info:{label:`Info`,badge:`border-border/70 bg-muted text-muted-foreground`}},L={none:`No action`,upgrade_patch:`Patch upgrade`,upgrade_minor:`Minor upgrade`,upgrade_major:`Major upgrade`,replace:`Replace`,remove:`Remove`,investigate:`Investigate`},R={full:{label:`Full`,badge:`border-success/35 bg-success/10 text-success`,note:void 0},partial:{label:`Partial`,badge:`border-warning/35 bg-warning/10 text-warning`,note:`limited`},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,note:`best-effort`}};function z(e){return R[e]??R.unsupported}function B(e){if(!e)return null;let t=/^\D*(\d+)/.exec(e);if(!t?.[1])return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function V(e){let t=B(e.locked??e.installed??e.requested),n=B(e.latestStable);if(t===null||n===null||n<=t)return{majorsBehind:0,label:null};let r=n-t;return{majorsBehind:r,label:`${r} major${r===1?``:`s`} behind`}}function H(e){return e.locked??e.installed??e.requested??null}function U(e){return e.confidence<1}function W({className:e,children:t}){return(0,k.jsx)(`span`,{className:C(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function G({label:e,value:t,hint:n,tone:r=`default`}){let i={default:`text-foreground`,success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`}[r];return(0,k.jsxs)(`div`,{className:`border border-border/70 bg-card/55 px-3 py-2.5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.035)]`,children:[(0,k.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,k.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,k.jsx)(`p`,{className:C(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,k.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function se({dependency:e,findings:t,deepDive:n,onDeepDive:r,onBack:i,coverage:a}){let o=A(e.status),s=H(e),c=V(e),l=a?z(a).note:void 0;return(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`header`,{className:`shrink-0 border-b border-border/70 bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,k.jsx)(T,{variant:`ghost`,size:`icon`,onClick:i,"aria-label":`Back to dependency list`,className:`shrink-0 md:hidden`,children:(0,k.jsx)(x,{className:`size-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(`h2`,{className:`min-w-0 truncate font-mono text-sm font-bold text-foreground`,children:e.name}),(0,k.jsx)(W,{className:o.badge,children:o.label})]}),(0,k.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[N(e.ecosystem).label,` ·`,` `,e.direct?`direct`:`transitive`,` · `,e.scope,` ·`,` `,e.sourceType,l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,k.jsx)(`span`,{className:`text-warning`,children:l})]})]})]})]}),(0,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-baseline gap-2 font-mono text-xs`,children:[(0,k.jsx)(`span`,{className:`text-foreground`,children:s??`—`}),e.latestStable&&e.latestStable!==s&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,k.jsx)(`span`,{className:`text-info`,children:e.latestStable})]}),c.label&&(0,k.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[`(`,c.label,`)`]})]})]}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,k.jsxs)(`dl`,{className:`grid grid-cols-2 gap-px border border-border/70 bg-border/60`,children:[(0,k.jsx)(K,{label:`Constraint`,value:e.requested??`—`,mono:!0}),(0,k.jsx)(K,{label:`Locked`,value:e.locked??`—`,mono:!0}),(0,k.jsx)(K,{label:`Latest stable`,value:e.latestStable??`—`,mono:!0}),(0,k.jsx)(K,{label:`License`,value:e.license??`—`}),e.wanted&&(0,k.jsx)(K,{label:`Wanted`,value:e.wanted,mono:!0}),e.resolvable&&(0,k.jsx)(K,{label:`Resolvable`,value:e.resolvable,mono:!0}),e.purl&&(0,k.jsx)(K,{label:`PURL`,value:e.purl,mono:!0}),(0,k.jsx)(K,{label:`Registry flags`,value:[e.deprecated&&`deprecated`,e.yanked&&`yanked`].filter(Boolean).join(`, `)||`none`})]}),(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Findings`}),(0,k.jsxs)(T,{variant:`outline`,size:`sm`,onClick:()=>r(e),disabled:n.status===`loading`,className:`h-7 text-[10px]`,children:[n.status===`loading`?(0,k.jsx)(v,{className:`size-3 animate-spin`}):(0,k.jsx)(d,{className:`size-3`}),n.status===`loading`?`Researching…`:`Deep dive`]})]}),n.status===`error`&&n.error&&(0,k.jsx)(`p`,{role:`alert`,className:`mb-1.5 text-[10px] text-destructive`,children:n.error}),t.length===0?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Nothing flagged. Run a deep dive to have the model research this package against the web.`}):(0,k.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,k.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(W,{className:I[e.severity].badge,children:I[e.severity].label}),(0,k.jsx)(W,{className:`border-border/70 bg-muted text-muted-foreground`,children:L[e.action]??e.action}),U(e)&&(0,k.jsxs)(W,{className:`border-info/35 bg-info/10 text-info`,children:[(0,k.jsx)(d,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,k.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk})]},e.id))})]}),(0,k.jsxs)(`section`,{className:`mt-4`,children:[(0,k.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evidence`}),e.evidence.length===0?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No evidence recorded.`}):(0,k.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.evidence.map((t,n)=>(0,k.jsxs)(`li`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(W,{className:`border-border/70 bg-muted text-muted-foreground`,children:t.kind}),(0,k.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(t.retrievedAt).toLocaleString()})]}),t.source.startsWith(`http`)?(0,k.jsxs)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`mt-1 flex min-w-0 items-center gap-1 truncate text-[10px] text-info underline-offset-2 hover:underline`,children:[(0,k.jsx)(`span`,{className:`truncate`,children:t.source}),(0,k.jsx)(h,{className:`size-2.5 shrink-0`})]}):(0,k.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground`,children:t.source}),t.detail&&(0,k.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:t.detail})]},`${e.id}-evidence-${n}`))})]})]})]})}function K({label:e,value:t,mono:n}){return(0,k.jsxs)(`div`,{className:`bg-card/55 px-2.5 py-1.5`,children:[(0,k.jsx)(`dt`,{className:`text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,k.jsx)(`dd`,{className:C(`mt-0.5 truncate text-[11px] text-foreground`,n&&`font-mono`),children:t})]})}var q=`grid grid-cols-[minmax(0,2.2fr)_minmax(0,1.6fr)_minmax(0,1.1fr)] gap-2`;function ce({dependencies:e,selectedId:t,hasDependencies:n,coverageByWorkspaceId:r,onSelect:i}){let a=E(e,30);return e.length===0?(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,k.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:n?`No dependencies match the current filters.`:`No dependencies inventoried yet. Run a scan to populate the inventory.`})}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:C(q,`shrink-0 border-b border-border/70 bg-card/45 px-3 py-1.5 text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`),children:[(0,k.jsx)(`span`,{children:`Package`}),(0,k.jsx)(`span`,{children:`Installed → Latest`}),(0,k.jsx)(`span`,{children:`Status`})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,k.jsx)(s,{className:`h-full`,"aria-label":`Dependencies`,children:a.pageItems.map(e=>(0,k.jsx)(J,{dependency:e,selected:e.id===t,coverage:r?.get(e.workspaceId),onSelect:i},e.id))})}),(0,k.jsx)(D,{page:a.page,pageSize:a.pageSize,totalItems:a.totalItems,onPageChange:a.setPage,itemLabel:`dependencies`})]})}function J({dependency:e,selected:t,coverage:n,onSelect:r}){let i=A(e.status),a=H(e),o=V(e),s=n?z(n).note:void 0;return(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-current":t,className:C(q,`w-full items-center border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-accent/40`,t&&`bg-accent/60`),children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,k.jsx)(`span`,{className:C(`size-1.5 shrink-0`,i.dot),"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-xs text-foreground`,children:e.name})]}),(0,k.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[(0,k.jsx)(P,{ecosystem:e.ecosystem,className:`mr-0.5 inline-block size-3 align-text-bottom`}),N(e.ecosystem).label,` · `,e.direct?`direct`:`transitive`,` · `,e.scope,s&&(0,k.jsxs)(k.Fragment,{children:[` · `,(0,k.jsx)(`span`,{className:`text-warning`,children:s})]})]})]}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,children:[(0,k.jsx)(`span`,{className:`truncate text-foreground`,children:a??`—`}),e.latestStable&&e.latestStable!==a&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),(0,k.jsx)(`span`,{className:`truncate text-info`,children:e.latestStable})]})]}),o.label?(0,k.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-warning`,children:o.label}):e.requested&&(0,k.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:e.requested})]}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,k.jsx)(W,{className:i.badge,children:i.label}),e.deprecated&&(0,k.jsx)(W,{className:`border-destructive/35 bg-destructive/10 text-destructive`,children:`dep`}),e.yanked&&(0,k.jsx)(W,{className:`border-destructive/45 bg-destructive/15 text-destructive`,children:`yank`})]})]})}function le({findings:e,dependenciesById:t,onSelectDependency:n}){let r=E(e,20);return e.length===0?(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,k.jsxs)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:[`No findings. Run `,(0,k.jsx)(`span`,{className:`font-mono text-foreground`,children:`Analyze`}),` to check versions and advisories against upstream registries, then interpret the results.`]})}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:F.map(e=>[e,r.pageItems.filter(t=>t.severity===e)]).filter(([,e])=>e.length>0).map(([e,r])=>(0,k.jsxs)(`section`,{children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,k.jsx)(W,{className:I[e].badge,children:I[e].label}),(0,k.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:r.length})]}),(0,k.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>(0,k.jsx)(Y,{finding:e,dependency:t.get(e.dependencyId),onSelectDependency:n},e.id))})]},e))})}),(0,k.jsx)(D,{page:r.page,pageSize:r.pageSize,totalItems:r.totalItems,onPageChange:r.setPage,itemLabel:`findings`})]})}function Y({finding:e,dependency:t,onSelectDependency:n}){let r=U(e);return(0,k.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e.dependencyId),className:`min-w-0 truncate font-mono text-xs text-foreground underline-offset-2 hover:underline`,children:t?.name??e.dependencyId}),(0,k.jsx)(W,{className:`border-border/70 bg-muted text-muted-foreground`,children:L[e.action]??e.action}),r&&(0,k.jsxs)(W,{className:`border-info/35 bg-info/10 text-info`,children:[(0,k.jsx)(d,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,k.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,k.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk}),e.evidence.length>0&&(0,k.jsx)(`ul`,{className:C(`mt-1.5 flex flex-col gap-0.5`),children:e.evidence.slice(0,4).map((t,n)=>(0,k.jsx)(`li`,{className:`min-w-0 truncate text-[10px]`,children:t.source.startsWith(`http`)?(0,k.jsx)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`text-info underline-offset-2 hover:underline`,children:t.detail??t.source}):(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:t.detail??t.source})},`${e.id}-${n}`))})]})}function ue({searchQuery:e,ecosystemFilter:t,statusFilter:n,directOnly:r,sort:i,hasFilters:o,ecosystems:s,statuses:c,visibleCount:l,totalCount:u,onSearchChange:d,onEcosystemFilterChange:f,onStatusFilterChange:m,onToggleDirectOnly:h,onSortChange:g,onClearFilters:_}){return(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/70 bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,k.jsx)(p,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(re,{"aria-label":`Search dependencies`,value:e,onChange:e=>d(e.target.value),placeholder:`Search by package name…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,k.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>d(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,k.jsx)(ee,{className:`size-3.5`})})]}),(0,k.jsx)(T,{variant:r?`default`:`outline`,size:`sm`,onClick:h,"aria-pressed":r,title:`Show only dependencies this project declares itself`,className:`shrink-0`,children:`Direct only`}),o&&(0,k.jsx)(T,{variant:`ghost`,size:`icon`,onClick:_,"aria-label":`Clear all filters`,title:`Clear all filters`,className:`shrink-0`,children:(0,k.jsx)(a,{className:`size-4`})})]}),(0,k.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-ecosystem-filter`,children:`Filter by ecosystem`}),(0,k.jsxs)(`select`,{id:`techstack-ecosystem-filter`,value:t,onChange:e=>f(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All ecosystems`}),s.map(([e,t])=>(0,k.jsxs)(`option`,{value:e,children:[N(e).label,` · `,t]},e))]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-status-filter`,children:`Filter by status`}),(0,k.jsxs)(`select`,{id:`techstack-status-filter`,value:n,onChange:e=>m(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All statuses`}),c.map(([e,t])=>(0,k.jsxs)(`option`,{value:e,children:[A(e).label,` · `,t]},e))]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-sort`,children:`Sort dependencies`}),(0,k.jsxs)(`select`,{id:`techstack-sort`,value:i,onChange:e=>g(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,k.jsx)(`option`,{value:`attention`,children:`Sort: needs attention`}),(0,k.jsx)(`option`,{value:`drift`,children:`Sort: most out of date`}),(0,k.jsx)(`option`,{value:`name`,children:`Sort: name`})]})]})]}),(0,k.jsx)(`p`,{className:C(`text-[10px] text-muted-foreground`,o&&`text-info`),children:l===u?`${u} dependencies`:`${l} of ${u} dependencies`})]})}var de=[{id:`dependencies`,label:`Dependencies`},{id:`findings`,label:`Findings`},{id:`workspaces`,label:`Workspaces`},{id:`trends`,label:`Trends`},{id:`remediation`,label:`Remediation`}],X=new Set([`npm`,`python`,`rust`,`go`,`php`,`dotnet`]);function fe(){let e=w(e=>e.snapshot),t=w(e=>e.stale),n=w(e=>e.loading),r=w(e=>e.error),i=w(e=>e.activeJob),[a,o]=(0,O.useState)(`dependencies`),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(`all`),[f,p]=(0,O.useState)(`all`),[m,h]=(0,O.useState)(!1),[_,te]=(0,O.useState)(`attention`),[y,b]=(0,O.useState)(null),[x,S]=(0,O.useState)([]),[re,E]=(0,O.useState)({status:`idle`,error:null}),[D,ie]=(0,O.useState)(null),[ae,j]=(0,O.useState)(null),[M,N]=(0,O.useState)(new Set),[P,F]=(0,O.useState)(!1),I=(0,O.useCallback)(async()=>{let e=w.getState();e.setLoading(!0),e.setError(null);try{let t=await fetch(`/api/techstack/snapshot`);if(t.status===404){e.setSnapshot(null,!1);return}if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();e.setSnapshot(n.snapshot,n.stale)}catch(t){e.setError(t instanceof Error?t.message:String(t))}},[]),L=(0,O.useCallback)(async e=>{let t=w.getState();t.setLoading(!0),t.setError(null);try{let n=await fetch(`/api/techstack/${e}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.jobId)throw Error(r.error??`HTTP ${n.status}: ${n.statusText}`);t.jobStarted(r.jobId,e)}catch(e){t.setError(e instanceof Error?e.message:String(e))}},[]),R=(0,O.useCallback)(async()=>{let e=w.getState().activeJob;if(e)try{let t=await fetch(`/api/techstack/jobs/${encodeURIComponent(e.id)}/cancel`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);w.getState().jobCancelled(e.id)}catch(e){w.getState().setError(e instanceof Error?e.message:String(e))}},[]),z=(0,O.useCallback)(async e=>{E({status:`loading`,error:null});try{let t=await fetch(`/api/techstack/deps/${encodeURIComponent(e.id)}/research`,{method:`POST`}),n=await t.json();if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);S(n.findings??[]),E({status:`idle`,error:null})}catch(e){E({status:`error`,error:e instanceof Error?e.message:String(e)})}},[]);(0,O.useEffect)(()=>{I()},[I]),(0,O.useEffect)(()=>{a!==`trends`&&a!==`remediation`||fetch(`/api/techstack/${a===`trends`?`trends`:`remediation`}`).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);t.trend&&ie(t.trend),t.plan&&j(t.plan)}).catch(e=>w.getState().setError(e instanceof Error?e.message:String(e)))},[a,e?.id]);let B=(0,O.useCallback)(async()=>{if(M.size!==0){F(!0);try{let e=await fetch(`/api/techstack/remediation/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({approvedItems:[...M]})}),t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);N(new Set),await L(`inventory`)}catch(e){w.getState().setError(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[M,L]);(0,O.useEffect)(()=>{S([]),E({status:`idle`,error:null})},[e?.id]);let H=(0,O.useMemo)(()=>e?.dependencies??[],[e]),U=(0,O.useMemo)(()=>e?.findings??[],[e]),W=(0,O.useMemo)(()=>new Map(H.map(e=>[e.id,e])),[H]),K=(0,O.useMemo)(()=>Q(H.map(e=>e.ecosystem)),[H]),q=(0,O.useMemo)(()=>Q(H.map(e=>e.status)),[H]),J=(0,O.useMemo)(()=>new Map(e?.workspaces.map(e=>[e.id,e.coverage])??[]),[e]),Y=(0,O.useMemo)(()=>{let e=s.trim().toLowerCase(),t=[...H.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||l!==`all`&&t.ecosystem!==l||f!==`all`&&t.status!==f||m&&!t.direct))];return _===`name`?t.sort((e,t)=>e.name.localeCompare(t.name)):_===`drift`?t.sort((e,t)=>V(t).majorsBehind-V(e).majorsBehind||e.name.localeCompare(t.name)):t.sort((e,t)=>A(t.status).weight-A(e.status).weight||Number(t.direct)-Number(e.direct)||e.name.localeCompare(t.name)),t},[H,s,l,f,m,_]),X=y?W.get(y):void 0,fe=(0,O.useMemo)(()=>X?[...U.filter(e=>e.dependencyId===X.id),...x.filter(e=>e.dependencyId===X.id)]:[],[U,x,X]),ve=(0,O.useMemo)(()=>H.filter(oe).length,[H]),ye=(0,O.useMemo)(()=>H.filter(e=>V(e).majorsBehind>0).length,[H]),be=(0,O.useMemo)(()=>H.filter(e=>e.status===`vulnerable`).length,[H]),xe=s.trim()!==``||l!==`all`||f!==`all`||m,Se=(0,O.useCallback)(()=>{c(``),u(`all`),p(`all`),h(!1)},[]),$=!!(i&&![`completed`,`failed`,`cancelled`].includes(i.status)),Ce=(0,O.useCallback)(e=>{b(e),o(`dependencies`)},[]);return(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,k.jsx)(`header`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,k.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`TechStack`}),(0,k.jsx)(`span`,{className:`border border-info/35 bg-info/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-info`,children:e?`${e.workspaces.length} workspaces`:`no scan yet`}),t&&(0,k.jsx)(`span`,{className:`border border-warning/35 bg-warning/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-warning`,children:`stale >24h`})]}),(0,k.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground sm:text-xs`,children:e?`${e.targetRoot} · scanned ${new Date(e.createdAt).toLocaleString()}`:`Scan the open project to inventory its dependencies.`})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(T,{variant:`outline`,size:`sm`,onClick:()=>void L(`inventory`),disabled:$,title:`Offline: re-read manifests and lockfiles`,children:[(0,k.jsx)(g,{className:C(`size-3.5`,$&&`animate-spin`)}),(0,k.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,k.jsxs)(T,{size:`sm`,onClick:()=>void L(`analyze`),disabled:$,title:`Check registries and advisories, then interpret the results with the model`,children:[(0,k.jsx)(d,{className:`size-3.5`}),`Analyze`]}),$&&(0,k.jsx)(T,{variant:`ghost`,size:`icon`,onClick:()=>void R(),"aria-label":`Cancel job`,children:(0,k.jsx)(ee,{className:`size-4`})}),(0,k.jsx)(T,{variant:`ghost`,size:`icon`,onClick:()=>e&&_e(e),disabled:!e,"aria-label":`Export snapshot as JSON`,title:`Export snapshot as JSON`,children:(0,k.jsx)(ne,{className:`size-4`})})]})]})}),e&&(0,k.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,k.jsx)(G,{label:`Dependencies`,value:H.length,hint:`${Y.length} visible`}),(0,k.jsx)(G,{label:`Outdated`,value:ye,hint:`majors behind`,tone:ye>0?`warning`:`success`}),(0,k.jsx)(G,{label:`Vulnerable`,value:be,hint:`known advisories`,tone:be>0?`destructive`:`success`}),(0,k.jsx)(G,{label:`Findings`,value:U.length,hint:`${ve} need attention`,tone:U.length>0?`info`:`default`})]}),($||r)&&(0,k.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[$&&i&&(0,k.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-info`,children:[(0,k.jsx)(v,{className:`size-3.5 animate-spin`}),(0,k.jsx)(`span`,{className:`font-mono`,children:i.status}),i.progress&&(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[i.progress.completed,`/`,i.progress.total]})]}),r&&(0,k.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>void I(),className:`underline`,children:`Retry`})]})]}),n&&!e?(0,k.jsx)(Z,{}):e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`nav`,{className:`flex shrink-0 gap-1 border-b border-border/70 px-2`,children:de.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-current":a===e.id,className:C(`border-b-2 px-3 py-2 text-xs font-medium transition-colors`,a===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.label,e.id===`findings`&&U.length>0&&(0,k.jsx)(`span`,{className:`ml-1.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:U.length})]},e.id))}),a===`dependencies`&&(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(340px,1fr)_minmax(0,1.15fr)]`,children:[(0,k.jsxs)(`section`,{className:C(`min-h-0 border-r border-border/70`,X?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Dependency list`,children:[(0,k.jsx)(ue,{searchQuery:s,ecosystemFilter:l,statusFilter:f,directOnly:m,sort:_,hasFilters:xe,ecosystems:K,statuses:q,visibleCount:Y.length,totalCount:H.length,onSearchChange:c,onEcosystemFilterChange:u,onStatusFilterChange:p,onToggleDirectOnly:()=>h(e=>!e),onSortChange:te,onClearFilters:Se}),(0,k.jsx)(ce,{dependencies:Y,selectedId:y,hasDependencies:H.length>0,coverageByWorkspaceId:J,onSelect:e=>b(e.id)})]}),(0,k.jsx)(`section`,{className:C(`min-h-0`,X?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Dependency detail`,children:X?(0,k.jsx)(se,{dependency:X,findings:fe,deepDive:re,onDeepDive:z,onBack:()=>b(null),coverage:J.get(X.workspaceId)}):(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,k.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:`Select a dependency to see its versions, evidence, and findings.`})})})]}),a===`findings`&&(0,k.jsx)(le,{findings:U,dependenciesById:W,onSelectDependency:Ce}),a===`workspaces`&&(0,k.jsx)(he,{snapshot:e}),a===`trends`&&(0,k.jsx)(pe,{trend:D}),a===`remediation`&&(0,k.jsx)(me,{plan:ae,approved:M,applying:P,onToggle:e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onApply:()=>void B()})]}):(0,k.jsx)(ge,{onScan:()=>void L(`inventory`),disabled:$})]})}function pe({trend:e}){return e?(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,k.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[e.snapshots,` snapshots`,e.vulnerabilityHalfLifeMs===void 0?``:` · vulnerability half-life ${(e.vulnerabilityHalfLifeMs/864e5).toFixed(1)} days`]}),(0,k.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.points.map(e=>(0,k.jsxs)(`div`,{className:`grid grid-cols-4 border border-border/70 bg-card/40 p-2 text-xs`,children:[(0,k.jsx)(`span`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,k.jsxs)(`span`,{children:[e.dependencies,` deps`]}),(0,k.jsxs)(`span`,{className:`text-warning`,children:[e.outdated,` outdated`]}),(0,k.jsxs)(`span`,{className:`text-destructive`,children:[e.vulnerable,` vulnerable`]})]},e.snapshotId))})]}):(0,k.jsx)(Z,{})}function me({plan:e,approved:t,applying:n,onToggle:r,onApply:i}){return e?(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.warning}),(0,k.jsxs)(T,{size:`sm`,disabled:t.size===0||n,onClick:i,children:[n&&(0,k.jsx)(v,{className:`size-3.5 animate-spin`}),`Apply `,t.size>0?t.size:``]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.items.map(e=>{let n=`${e.workspaceId}:${e.ecosystem}:${e.dependencyName}:${e.action}`,i=e.action===`replace`||e.action===`investigate`||!X.has(e.ecosystem);return(0,k.jsxs)(`label`,{className:C(`flex gap-3 border border-border/70 bg-card/40 p-2.5`,i?`cursor-not-allowed opacity-65`:`cursor-pointer`),children:[(0,k.jsx)(`input`,{type:`checkbox`,disabled:i,checked:t.has(n),onChange:()=>r(n)}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`span`,{className:`block font-mono text-xs`,children:[e.dependencyName,` · `,e.action]}),(0,k.jsxs)(`span`,{className:`block text-[10px] text-muted-foreground`,children:[e.currentVersion??`?`,` → `,e.targetVersion??`latest`,` · `,e.rationale]}),i&&(0,k.jsx)(`span`,{className:`block text-[10px] text-warning`,children:`Requires a manual package choice.`})]})]},n)}),e.items.length===0&&(0,k.jsx)(`p`,{className:`p-8 text-center text-xs text-muted-foreground`,children:`No remediation needed.`})]})]}):(0,k.jsx)(Z,{})}function he({snapshot:e}){let t=(0,O.useMemo)(()=>{let t=new Map;for(let n of e.dependencies)t.set(n.workspaceId,(t.get(n.workspaceId)??0)+1);return t},[e]);return e.workspaces.length===0?(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No workspaces detected.`})}):(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,k.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.workspaces.map(e=>{let n=R[e.coverage];return(0,k.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate font-mono text-xs text-foreground`,children:e.relativeRoot}),(0,k.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-1 truncate text-[10px] text-muted-foreground`,children:[(0,k.jsx)(P,{ecosystem:e.ecosystem}),(0,k.jsx)(`span`,{children:N(e.ecosystem).label}),e.packageManager?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,k.jsx)(`span`,{children:e.packageManager})]}):null,(0,k.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,k.jsxs)(`span`,{children:[t.get(e.id)??0,` deps`]})]})]}),(0,k.jsx)(`span`,{className:C(`shrink-0 border px-1.5 py-0.5 text-[10px] font-medium`,n.badge),children:n.label})]}),e.manifests.length>0&&(0,k.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.manifests.map(e=>(0,k.jsx)(`span`,{className:`border border-border/70 bg-background/45 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.split(/[/\\]/).pop()},e))})]},e.id)})})})}function Z(){return(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,k.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,k.jsx)(v,{className:`size-5 animate-spin text-muted-foreground`}),(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading snapshot…`})]})})}function ge({onScan:e,disabled:t}){let n=(0,O.useMemo)(()=>Object.values(j).map(e=>e.label).join(`, `),[]);return(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,k.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-3 text-center`,children:[(0,k.jsx)(`div`,{className:`flex size-14 items-center justify-center border border-info/25 bg-info/5 text-info`,children:(0,k.jsx)(_,{className:`size-6`})}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:`No inventory yet`}),(0,k.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`TechStack reads every manifest and lockfile in the open project — `,n,` — and compares what you have against the upstream registries.`]}),(0,k.jsxs)(T,{size:`sm`,onClick:e,disabled:t,children:[(0,k.jsx)(g,{className:C(`size-3.5`,t&&`animate-spin`)}),`Scan this project`]})]})})}function Q(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function _e(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`techstack.json`,r.click(),URL.revokeObjectURL(n)}export{fe as TechStackView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Aa as e}from"./vendor-CxV3l5PQ.js";var t=e(e=>({generation:0,lastUpdatedAt:null,notifyIndexUpdated(t=Date.now()){e(e=>({generation:e.generation+1,lastUpdatedAt:t}))}}));export{t};
|