@wrongstack/webui 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/assets/{AgentRosterView-DMxOg0xX.js → AgentRosterView-CV9MW-4M.js} +4 -4
  2. package/dist/assets/AnalyticsDashboard-30brLbuz.js +1 -0
  3. package/dist/assets/{AudienceMemoryPanel-CyfpggCK.js → AudienceMemoryPanel-bKVydKg8.js} +1 -1
  4. package/dist/assets/ChangesView-Cv6svx-V.js +1 -0
  5. package/dist/assets/{ChimeraReviewsView-DencEMIY.js → ChimeraReviewsView-DLTrEJDS.js} +1 -1
  6. package/dist/assets/{ChronicleDashboard-CvDPqZKE.js → ChronicleDashboard-DhgWbaXj.js} +1 -1
  7. package/dist/assets/{CodeEditor-s0lHP0DZ.js → CodeEditor-JlvMbECd.js} +2 -2
  8. package/dist/assets/CodeMap-4swT3FIw.js +1 -0
  9. package/dist/assets/{CronJobsPanel-LoDmuRHl.js → CronJobsPanel-LSpFBceD.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-ByhAW_bl.js → DeadCodeScanPanel-ZRNNV02b.js} +1 -1
  11. package/dist/assets/{DebugDashboard-BP1Mia-L.js → DebugDashboard-DlH0QNPX.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-taDxRN63.js → DesignGalleryView-yZgVVEg9.js} +1 -1
  13. package/dist/assets/{GoalView-CcLxMYXe.js → GoalView-D1gxZre2.js} +1 -1
  14. package/dist/assets/{KanbanView-C-K6OBw8.js → KanbanView-Bh0T3p3J.js} +1 -1
  15. package/dist/assets/MailboxDetailView-C4lEW3f8.js +1 -0
  16. package/dist/assets/{MemoryDrawer-CuFQypU-.js → MemoryDrawer-arujfDSW.js} +1 -1
  17. package/dist/assets/MemoryManager-BmQYIRhD.js +1 -0
  18. package/dist/assets/ProcessMonitor-ByW-VKsX.js +1 -0
  19. package/dist/assets/{PromptJournalView-CdC4ldrv.js → PromptJournalView-0cHPeYXa.js} +1 -1
  20. package/dist/assets/{ProviderTestView-Dy7EQEI9.js → ProviderTestView-CQlwC6HG.js} +1 -1
  21. package/dist/assets/{QueuePanel-DE9ySxkR.js → QueuePanel-DJeK7xCh.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-Dbq_bHwj.js → RefreshDebugView-BfOjHodq.js} +1 -1
  23. package/dist/assets/RepositoryHistoryView-BYPPu5uv.js +2 -0
  24. package/dist/assets/RequirementIntakeView-CEwUB7VD.js +1 -0
  25. package/dist/assets/{SageTabs-Dwbux3im.js → SageTabs-Bt2kzPNB.js} +2 -2
  26. package/dist/assets/{SddFlowGraph-BZkvlaQ1.js → SddFlowGraph-CZSwcAtS.js} +1 -1
  27. package/dist/assets/SddHub-Cc79Ob7A.js +2 -0
  28. package/dist/assets/{SessionInspectView-Bak1hK82.js → SessionInspectView-BasxJ_5x.js} +1 -1
  29. package/dist/assets/{SessionList-xXaygO5X.js → SessionList-C9MRSj_-.js} +1 -1
  30. package/dist/assets/{SessionsDashboard-CaSXukNy.js → SessionsDashboard-BK95Zp6f.js} +1 -1
  31. package/dist/assets/{SetupScreen-BSEF1air.js → SetupScreen-rPKsBa9Z.js} +1 -1
  32. package/dist/assets/{SkillDetailView-OdtAJM43.js → SkillDetailView-LkJyIBPb.js} +1 -1
  33. package/dist/assets/{TechStackView-BUIbnU2F.js → TechStackView-xVR5dsSn.js} +1 -1
  34. package/dist/assets/{TerminalPanel-CfoKklMj.js → TerminalPanel-CBEZTuvV.js} +1 -1
  35. package/dist/assets/{activity-Bk7N_ZW5.js → activity-CDHIWIPJ.js} +4 -4
  36. package/dist/assets/{activity-BazcMhZZ.js → activity-CInOo57V.js} +4 -4
  37. package/dist/assets/{activity-VTOCX_jm.js → activity-D6XfckyA.js} +4 -4
  38. package/dist/assets/{activity-BWPWyp3o.js → activity-DapbBEf6.js} +4 -4
  39. package/dist/assets/{activity-DBsMiPsa.js → activity-E8vCWdG2.js} +4 -4
  40. package/dist/assets/{activity-Cmq0z33p.js → activity-e8OIpNGJ.js} +4 -4
  41. package/dist/assets/{activity-B-GYDVn2.js → activity-oTJsNfZu.js} +4 -4
  42. package/dist/assets/button-BbeB5Qm8.js +1 -0
  43. package/dist/assets/{chat-store-DNRce6sE.js → chat-store-BDVZSmod.js} +1 -1
  44. package/dist/assets/common-BXosnbIt.js +1 -0
  45. package/dist/assets/common-CzfPgMjC.js +1 -0
  46. package/dist/assets/common-DDDPz7Dv.js +1 -0
  47. package/dist/assets/common-DYx9oSoC.js +1 -0
  48. package/dist/assets/common-DZ-05t4z.js +1 -0
  49. package/dist/assets/common-MjX8fcng.js +1 -0
  50. package/dist/assets/common-ipsuLC3n.js +1 -0
  51. package/dist/assets/{config-store-BAUadwHd.js → config-store-mWuYCild.js} +1 -1
  52. package/dist/assets/dialog-b-Ai37sa.js +1 -0
  53. package/dist/assets/empty-state-pfuS5znr.js +1 -0
  54. package/dist/assets/{i18n-CbyUyl6G.js → i18n-CvJB4U4z.js} +3 -3
  55. package/dist/assets/{index-3TGBKeBP.js → index-DLjaZSCH.js} +80 -80
  56. package/dist/assets/index-DiX5j910.css +1 -0
  57. package/dist/assets/input-BA6D2L3K.js +1 -0
  58. package/dist/assets/mailbox-store-ZQO_Rv6E.js +1 -0
  59. package/dist/assets/{roster-ws-z8DKquaN.js → roster-ws-BRANim2Y.js} +1 -1
  60. package/dist/assets/stores-D5loyGLL.js +7 -0
  61. package/dist/assets/{vector-memory-panel-DZFEwwGM.js → vector-memory-panel-YWv6xcza.js} +1 -1
  62. package/dist/assets/view-navigation-DTs4cSQ6.js +1 -0
  63. package/dist/components/CodeMap.d.ts +1 -1
  64. package/dist/components/CodeMapCanvasSurface.d.ts +2 -1
  65. package/dist/components/ConfirmModal.d.ts +10 -0
  66. package/dist/components/FileExplorer/FileExplorerModals.d.ts +4 -5
  67. package/dist/components/MainViewSlot.d.ts +1 -1
  68. package/dist/components/MemoryManager/useMemoryManagerState.d.ts +2 -2
  69. package/dist/components/PanelSuspense.d.ts +0 -4
  70. package/dist/components/RepositoryHistoryView.d.ts +1 -1
  71. package/dist/components/RequirementIntakeView.d.ts +22 -1
  72. package/dist/components/SddHub.d.ts +3 -3
  73. package/dist/components/ui/dialog.d.ts +1 -1
  74. package/dist/components/ui/dropdown-menu.d.ts +1 -1
  75. package/dist/components/ui/empty-state.d.ts +1 -1
  76. package/dist/components/ui/tabs.d.ts +1 -1
  77. package/dist/index.html +12 -12
  78. package/dist/index.js +1989 -1473
  79. package/dist/lib/view-navigation.d.ts +2 -2
  80. package/dist/stores/index.d.ts +1 -1
  81. package/dist/stores/sdd-wizard-store.d.ts +7 -0
  82. package/package.json +9 -9
  83. package/dist/assets/AnalyticsDashboard-DGQk1vSi.js +0 -1
  84. package/dist/assets/ChangesView-C8x8tmpi.js +0 -1
  85. package/dist/assets/CodeMap-6mmDO9gJ.js +0 -1
  86. package/dist/assets/MailboxDetailView-N00dLbpr.js +0 -1
  87. package/dist/assets/MemoryManager-Bmz62aEV.js +0 -1
  88. package/dist/assets/ProcessMonitor-CkAtUjrR.js +0 -1
  89. package/dist/assets/RepositoryHistoryView-D0ynYRgu.js +0 -2
  90. package/dist/assets/RequirementIntakeView-CPRtncuJ.js +0 -1
  91. package/dist/assets/SddHub-CoRKeq7Q.js +0 -2
  92. package/dist/assets/button-9ewV4TF3.js +0 -1
  93. package/dist/assets/common-5rSj2oHt.js +0 -1
  94. package/dist/assets/common-B5Uslzr2.js +0 -1
  95. package/dist/assets/common-BnhmJl6b.js +0 -1
  96. package/dist/assets/common-CmkkiJUR.js +0 -1
  97. package/dist/assets/common-CpZ-DoXd.js +0 -1
  98. package/dist/assets/common-Ct-Iodid.js +0 -1
  99. package/dist/assets/common-D9w3BalB.js +0 -1
  100. package/dist/assets/dialog-C7EIBM_2.js +0 -1
  101. package/dist/assets/empty-state-5YP1rmE6.js +0 -1
  102. package/dist/assets/index-NBVZNAcU.css +0 -1
  103. package/dist/assets/input-ag1CrUiS.js +0 -1
  104. package/dist/assets/mailbox-store-C49LeBj8.js +0 -1
  105. package/dist/assets/stores-RkHrTaRO.js +0 -7
  106. package/dist/assets/view-navigation-DHtNFXIl.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,Z as n,t as r,w as i}from"./config-store-BAUadwHd.js";import{i as a,t as o}from"./react-core-wiHys0m2.js";import{Hi as s,Ka as c,Mr as l,Na as u,Pa as d,Sn as f,Vn as p,ao as m,ea as h,fn as g,go as _,hn as v,ja as y,li as b,qn as x,qr as S,ri as C,t as w,wo as T,xo as ee}from"./vendor-V3ydTHqN.js";import"./i18n-CbyUyl6G.js";import{t as E}from"./utils-CKsqCaP8.js";import{o as D}from"./view-navigation-DHtNFXIl.js";import"./stores-RkHrTaRO.js";import{a as O,n as te,o as ne,r as k,t as re}from"./dialog-C7EIBM_2.js";import{t as A}from"./button-9ewV4TF3.js";import{t as j}from"./input-ag1CrUiS.js";import{E as M,L as N,M as P,T as F,d as I,f as L,p as R,u as z}from"./index-3TGBKeBP.js";var B=e(a(),1);function V(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 H=o();function ie({onKeySaved:e}){let{t:i}=ee(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),[u,d]=(0,B.useState)(`openai-compatible`),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(!1),[v,b]=(0,B.useState)([]),{setFieldRef:S,handleKeyDown:C}=R(),w=async()=>{if(s.trim()){_(!0);try{let a=t(r.getState().wsUrl),l=V(a);a.send({type:`provider.add`,payload:{id:s.trim(),family:u,baseUrl:f.trim()||void 0,apiKey:m.trim()||void 0,models:v.length>0?v.map(e=>e.id):void 0,customModels:v.length>0?Object.fromEntries(v.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 d=await l;if(!d.success)throw Error(d.message);n.success(i(`setup:screen.toasts.providerAdded`,{id:s.trim()})),e(s.trim()),a.listSavedProviders(),a.probeProvider(s.trim()),c(``),p(``),h(``),b([]),o(!1)}catch(e){let t=e instanceof Error&&e.message&&e.message!==`timeout`?e.message:null;n.error(t??i(`setup:screen.toasts.providerAddFailed`))}finally{_(!1)}}};return(0,H.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,H.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,H.jsx)(x,{className:`h-5 w-5 text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`flex-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium`,children:i(`setup:screen.custom.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`setup:screen.custom.description`)})]}),(0,H.jsx)(y,{className:E(`h-4 w-4 text-muted-foreground transition-transform`,a&&`rotate-90`)})]}),a&&(0,H.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:i(`setup:screen.custom.localServers`)}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:z.map(e=>(0,H.jsx)(A,{type:`button`,size:`sm`,variant:s===e.id?`default`:`outline`,onClick:()=>{c(e.id),d(`openai-compatible`),p(e.defaultBaseUrl),e.noAuth&&h(``),b([])},title:e.hint,children:e.label},e.id))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.providerId`)}),(0,H.jsx)(j,{placeholder:i(`activity:customProviderSection.eGMyLlm`),value:s,onChange:e=>c(e.target.value),className:`text-sm`,ref:S(0),onKeyDown:e=>C(e,0)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.family`)}),(0,H.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,ref:S(1),onKeyDown:e=>C(e,1),children:[(0,H.jsx)(`option`,{value:`openai-compatible`,children:i(`setup:screen.custom.familyOpenAiCompatible`)}),(0,H.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,H.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,H.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.baseUrl`)}),(0,H.jsx)(j,{placeholder:i(`activity:customProviderSection.eGHttpLocalhost11434V1`),value:f,onChange:e=>p(e.target.value),className:`text-sm font-mono`,ref:S(2),onKeyDown:e=>C(e,2)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.apiKey`)}),(0,H.jsx)(j,{type:`password`,placeholder:i(`setup:screen.custom.apiKeyPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm font-mono`,ref:S(3),onKeyDown:e=>C(e,3)})]}),(0,H.jsx)(L,{models:v,onChange:b}),(0,H.jsxs)(A,{onClick:w,disabled:!s.trim()||g,size:`sm`,ref:S(4),onKeyDown:e=>C(e,4,w),children:[g?(0,H.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}):null,i(`setup:screen.custom.add`)]})]})]})}var U=I();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:U}catch{return U}}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(w(),1);function ce({popular:e,catalogProvider:i,savedProvider:a,onKeySaved:o,probeResult:c}){let{t:p}=ee(),[m,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!!a?.apiKeys.some(e=>e.isActive)),[C,w]=(0,B.useState)(!1),[T,D]=(0,B.useState)(!1),[M,N]=(0,B.useState)(!1),[P,F]=(0,B.useState)(null);(0,B.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(m.trim()){v(!0);try{let a=t(r.getState().wsUrl),s=V(a);i?a.addKey(e.id,`default`,m.trim()):a.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:m.trim()}});let c=await s;if(!c.success)throw Error(c.message);S(!0),g(``),n.success(p(`setup:screen.toasts.keySaved`,{name:e.name})),o(e.id),a.listSavedProviders(),a.probeProvider(e.id)}catch(t){let r=t instanceof Error&&t.message&&t.message!==`timeout`?t.message:null;n.error(r??p(`setup:screen.toasts.keySaveFailed`,{name:e.name}))}finally{v(!1)}}},L=e=>{e.key===`Enter`&&m.trim()&&I()},R=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),D(!0),n.success(p(`setup:screen.toasts.referralCopied`)),setTimeout(()=>D(!1),2e3)}catch{n.error(p(`setup:screen.toasts.referralCopyFailed`))}},z=i&&i.modelCount>0;return(0,H.jsxs)(`div`,{className:E(`rounded-xl border p-4 transition-all`,x?`border-success/30 bg-success/5`:`bg-gradient-to-br ${e.color}`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),x&&(0,H.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,H.jsx)(d,{className:`h-2.5 w-2.5`}),p(`setup:screen.card.keySaved`)]}),e.referral&&!x&&(0,H.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,H.jsx)(b,{className:`h-2.5 w-2.5`}),p(`setup:screen.card.referral`)]})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!x&&(0,H.jsxs)(`p`,{className:`text-[11px] text-warning/80 mt-1`,children:[`🎁 `,e.referral.reward]}),x?x?(0,H.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[a?.baseUrl&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 font-mono truncate`,title:a.baseUrl,children:[(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[p(`activity:providerKey.url`),` `]}),a.baseUrl]}),a?.models&&a.models.length>0&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[p(`activity:providerKey.models`),` `]}),a.pickedModelId??a.models[0],(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[` `,`(+`,a.models.length-1,` more)`]})]}),c===`probing`?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mt-1`,children:[(0,H.jsx)(l,{className:`h-3 w-3 animate-spin`}),p(`setup:screen.probe.checking`,`Checking connection…`)]}):c?.ok?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success mt-1`,children:[(0,H.jsx)(d,{className:`h-3 w-3`}),(0,H.jsxs)(`span`,{children:[p(`setup:screen.probe.connected`,`Connected`),c.modelCount!=null&&` · ${c.modelCount} ${p(`setup:screen.probe.models`,`models`)}`,c.elapsedMs!=null&&` · ${c.elapsedMs}ms`]})]}):c&&!c.ok?(0,H.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-destructive mt-1`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:`✕`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:p(`setup:screen.probe.failed`,`Probe failed`)}),c.status===`no_base_url`&&(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:p(`setup:screen.probe.noBaseUrl`,`No base URL configured`)}),c.status===`unreachable`&&(0,H.jsxs)(`span`,{className:`block text-destructive/70`,children:[p(`setup:screen.probe.unreachable`,`Could not connect`),c.detail?`: ${c.detail}`:``]}),c.status!==`no_base_url`&&c.status!==`unreachable`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:c.httpStatus==null?c.status:`${p(`setup:screen.probe.httpStatus`,`Status`)} ${c.httpStatus}`}),c.detail&&(0,H.jsx)(`span`,{className:`block text-destructive/70 truncate max-w-[250px]`,title:c.detail,children:c.detail})]})]})]}):null,z&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(!C),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[p(`setup:screen.providers.modelsAvailable`,{count:i?.modelCount??0}),C?(0,H.jsx)(u,{className:`h-3 w-3`}):(0,H.jsx)(y,{className:`h-3 w-3`})]})]}):null:(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(j,{type:`password`,placeholder:e.keyPlaceholder,value:m,onChange:e=>g(e.target.value),onKeyDown:L,className:`font-mono text-sm`}),(0,H.jsx)(A,{onClick:I,disabled:!m.trim()||_,size:`sm`,className:`shrink-0`,children:_?(0,H.jsx)(l,{className:`h-4 w-4 animate-spin`}):p(`setup:screen.card.save`)})]}),e.docsUrl&&(0,H.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:[p(`setup:screen.card.getKey`),` `,(0,H.jsx)(s,{className:`h-3 w-3`})]}),e.referral&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:R,className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:T?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(d,{className:`h-3 w-3`}),` `,p(`setup:screen.card.copied`)]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(h,{className:`h-3 w-3`}),` `,p(`setup:screen.card.copyReferral`)]})}),(0,H.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,H.jsx)(f,{className:`h-3 w-3`}),` `,p(`setup:screen.card.share`)]})]})]})]})]}),(0,H.jsx)(re,{open:M,onOpenChange:N,children:(0,H.jsxs)(te,{className:`sm:max-w-md`,children:[(0,H.jsxs)(O,{children:[(0,H.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,H.jsx)(b,{className:`h-4 w-4 text-warning`}),p(`setup:screen.share.title`,{name:e.name})]}),(0,H.jsx)(k,{children:p(`setup:screen.share.description`)})]}),(0,H.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`text-sm text-center`,children:(0,H.jsxs)(`p`,{className:`font-medium text-warning`,children:[`🎁 `,e.referral.reward]})}),P?(0,H.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,H.jsx)(`img`,{src:P,alt:p(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,H.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,H.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:p(`setup:screen.share.twitter`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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,H.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:p(`setup:screen.share.linkedin`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.linkedin`)]}),(0,H.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:p(`setup:screen.share.telegram`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.telegram`)]}),(0,H.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:p(`setup:screen.share.whatsapp`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.whatsapp`)]}),(0,H.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:p(`setup:screen.share.reddit`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.reddit`)]}),(0,H.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}&quote=${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:p(`setup:screen.share.facebook`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.facebook`)]}),(0,H.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:p(`setup:screen.share.email`),children:[(0,H.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,H.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`})}),p(`activity:providerKey.email`)]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,H.jsx)(A,{size:`sm`,variant:`outline`,onClick:R,className:`shrink-0`,children:T?(0,H.jsx)(d,{className:`h-4 w-4`}):(0,H.jsx)(h,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:p(`setup:screen.share.hint`)})]})]})})]})})]})}function W(){let{t:e}=ee(),{model:a,setProvider:o,setModel:s,wsConnected:u,wsUrl:f}=r(_(e=>({model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected,wsUrl:e.wsUrl})));N();let[h,b]=(0,B.useState)([]),[x,w]=(0,B.useState)({}),[O,te]=(0,B.useState)([]),[ne,k]=(0,B.useState)(!1),[re,j]=(0,B.useState)(null),[I,L]=(0,B.useState)(0),[R,z]=(0,B.useState)(new Set),[V,se]=(0,B.useState)({}),[W,le]=(0,B.useState)(U),[G,K]=(0,B.useState)(!1),[ue,de]=(0,B.useState)(0),[fe,pe]=(0,B.useState)(0),[q,me]=(0,B.useState)(null),J=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`;return K(!0),ae(t,e.signal).then(t=>{if(t!==U){if(le(t),K(!1),!J.current){let e=t.length-fe;e>0?n.success(T.t(`setup:screen.toasts.providersLoadedNew`,{count:t.length,diff:e})):e<0?n.success(T.t(`setup:screen.toasts.providersLoadedRemoved`,{count:t.length,diff:Math.abs(e)})):n.success(T.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),!J.current){let t=e.length-fe;t>0?n.success(T.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?n.success(T.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):n.success(T.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),pe(e.length)}me(new Date)}}).catch(()=>{J.current||n.error(T.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{K(!1),J.current=!1}),()=>e.abort()},[ue]);let[Y,he]=(0,B.useState)(null),[X,Z]=(0,B.useState)(null),[ge,_e]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!u)return;let e=t(f),n=setTimeout(()=>{n=null,k(!1),j(T.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));b(t),k(!1)}}),o=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let t=e.payload;if(t.provider!==Y)return;w(e=>({...e,[t.provider]:t.models})),_e(!1),t.models.length===1?Z(t.models[0].id):a&&t.models.some(e=>e.id===a)&&Z(a)}}),s=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));te(t);let n=new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id));z(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),k(!0),e.listProviders(),()=>{r(),i?.(),o?.(),s?.(),c?.()}},[u,f,a,I,Y]);let ve=(0,B.useCallback)(()=>{j(null),L(e=>e+1)},[]),ye=(0,B.useCallback)(()=>{de(e=>e+1)},[]),be=(0,B.useCallback)(t=>oe(t,e),[e]),xe=(0,B.useCallback)(e=>{z(t=>new Set([...t,e])),he(e),Z(null)},[]),Se=R.size>0;(0,B.useEffect)(()=>{if(!Y||!u)return;let e=t(f);x[Y]||(_e(!0),e.listProviderModels(Y))},[Y,u,f,x]);let Ce=Y?x[Y]??[]:[],we=(0,B.useCallback)(async()=>{if(!Y||!X)return;if(!R.has(Y)){n.error(`Please save the provider configuration before starting a session.`);return}o(Y),s(X);let e=await t(f).switchModel(Y,X,5e3);e.success?(i.getState().openPicker({startsSession:!0}),D(`chat`)):n.error(e.message||T.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,f]),Te=(0,B.useCallback)(async()=>{if(!Y||!X)return;o(Y),s(X);let e=await t(f).switchModel(Y,X,5e3);e.success?D(`chat`):n.error(e.message||T.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,f]),Ee=new Set(W.map(e=>e.id)),De=h.filter(e=>!Ee.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),Q=M(De,10);M(O,9);let $=M(Ce,12,Y);return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,H.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,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.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,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground sm:truncate`,children:e(`setup:screen.header.subtitle`)})]})]}),Se&&Y?(0,H.jsxs)(`span`,{className:`text-xs text-success/80`,children:[(0,H.jsx)(d,{className:`h-3 w-3 inline-block mr-1`}),e(`setup:screen.header.continue`)]}):null]}),(0,H.jsx)(P,{className:`min-h-0 flex-1`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-4 pb-4 sm:p-6`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Se?`text-success`:`text-primary font-medium`),children:[(0,H.jsx)(S,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,H.jsx)(y,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Y?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(c,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,H.jsx)(y,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Y&&X?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(g,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,H.jsx)(v,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),re?(0,H.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,H.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,H.jsx)(C,{className:`h-6 w-6 text-destructive`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:re})]}),(0,H.jsxs)(A,{onClick:ve,size:`sm`,variant:`outline`,children:[(0,H.jsx)(l,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[G&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(l,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),q&&!G&&(0,H.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:q.toLocaleString(),children:be(q)}),(0,H.jsxs)(`button`,{type:`button`,onClick:ye,disabled:G,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,H.jsx)(p,{className:E(`h-3 w-3`,G&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:W.map(e=>(0,H.jsx)(ce,{popular:e,catalogProvider:h.find(t=>t.id===e.id),savedProvider:O.find(t=>t.id===e.id),onKeySaved:xe,probeResult:V[e.id]},e.id))})]}),De.length>0&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Q.pageItems.map(t=>(0,H.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:O.find(e=>e.id===t.id),onKeySaved:xe,probeResult:V[t.id]},t.id))}),(0,H.jsx)(F,{page:Q.page,pageSize:Q.pageSize,totalItems:Q.totalItems,onPageChange:Q.setPage,itemLabel:`providers`})]}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,H.jsx)(ie,{onKeySaved:xe})]})]}),ne&&(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),Y&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,H.jsx)(g,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{he(null),Z(null)},className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:Y})}),ge?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):Ce.length>0?(0,H.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,H.jsx)(`button`,{type:`button`,onClick:()=>Z(e.id),className:E(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,X===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,H.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,H.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),X===e.id&&(0,H.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary`,children:(0,H.jsx)(d,{className:`h-3 w-3 text-primary-foreground`})})]})},e.id)})}):(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)}),(0,H.jsx)(F,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,itemLabel:`models`})]}),Y&&X&&(0,H.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,H.jsx)(`div`,{className:`mb-3 flex min-w-0 items-center justify-between gap-2 text-sm text-muted-foreground`,children:(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Y,` / `,X]})}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,H.jsxs)(A,{onClick:we,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(c,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,H.jsx)(m,{className:`h-4 w-4 ml-2`})]}),(0,H.jsxs)(A,{onClick:Te,variant:`outline`,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(d,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.saveConfig`)]})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 text-center mt-2`,children:e(`setup:screen.start.saveConfigHint`)})]})]})})]})}export{W as SetupScreen};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,Z as n,t as r,w as i}from"./config-store-mWuYCild.js";import{i as a,t as o}from"./react-core-wiHys0m2.js";import{Hi as s,Ka as c,Mr as l,Na as u,Pa as d,Sn as f,Vn as p,ao as m,ea as h,fn as g,go as _,hn as v,ja as y,li as b,qn as x,qr as S,ri as C,t as w,wo as T,xo as ee}from"./vendor-V3ydTHqN.js";import"./i18n-CvJB4U4z.js";import{t as E}from"./utils-CKsqCaP8.js";import{o as D}from"./view-navigation-DTs4cSQ6.js";import"./stores-D5loyGLL.js";import{a as O,n as te,o as ne,r as k,t as re}from"./dialog-b-Ai37sa.js";import{t as A}from"./button-BbeB5Qm8.js";import{t as j}from"./input-BA6D2L3K.js";import{E as M,L as N,M as P,T as F,d as I,f as L,p as R,u as z}from"./index-DLjaZSCH.js";var B=e(a(),1);function V(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 H=o();function ie({onKeySaved:e}){let{t:i}=ee(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),[u,d]=(0,B.useState)(`openai-compatible`),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(!1),[v,b]=(0,B.useState)([]),{setFieldRef:S,handleKeyDown:C}=R(),w=async()=>{if(s.trim()){_(!0);try{let a=t(r.getState().wsUrl),l=V(a);a.send({type:`provider.add`,payload:{id:s.trim(),family:u,baseUrl:f.trim()||void 0,apiKey:m.trim()||void 0,models:v.length>0?v.map(e=>e.id):void 0,customModels:v.length>0?Object.fromEntries(v.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 d=await l;if(!d.success)throw Error(d.message);n.success(i(`setup:screen.toasts.providerAdded`,{id:s.trim()})),e(s.trim()),a.listSavedProviders(),a.probeProvider(s.trim()),c(``),p(``),h(``),b([]),o(!1)}catch(e){let t=e instanceof Error&&e.message&&e.message!==`timeout`?e.message:null;n.error(t??i(`setup:screen.toasts.providerAddFailed`))}finally{_(!1)}}};return(0,H.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,H.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,H.jsx)(x,{className:`h-5 w-5 text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`flex-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium`,children:i(`setup:screen.custom.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`setup:screen.custom.description`)})]}),(0,H.jsx)(y,{className:E(`h-4 w-4 text-muted-foreground transition-transform`,a&&`rotate-90`)})]}),a&&(0,H.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:i(`setup:screen.custom.localServers`)}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:z.map(e=>(0,H.jsx)(A,{type:`button`,size:`sm`,variant:s===e.id?`default`:`outline`,onClick:()=>{c(e.id),d(`openai-compatible`),p(e.defaultBaseUrl),e.noAuth&&h(``),b([])},title:e.hint,children:e.label},e.id))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.providerId`)}),(0,H.jsx)(j,{placeholder:i(`activity:customProviderSection.eGMyLlm`),value:s,onChange:e=>c(e.target.value),className:`text-sm`,ref:S(0),onKeyDown:e=>C(e,0)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.family`)}),(0,H.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,ref:S(1),onKeyDown:e=>C(e,1),children:[(0,H.jsx)(`option`,{value:`openai-compatible`,children:i(`setup:screen.custom.familyOpenAiCompatible`)}),(0,H.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,H.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,H.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.baseUrl`)}),(0,H.jsx)(j,{placeholder:i(`activity:customProviderSection.eGHttpLocalhost11434V1`),value:f,onChange:e=>p(e.target.value),className:`text-sm font-mono`,ref:S(2),onKeyDown:e=>C(e,2)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:i(`setup:screen.custom.apiKey`)}),(0,H.jsx)(j,{type:`password`,placeholder:i(`setup:screen.custom.apiKeyPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm font-mono`,ref:S(3),onKeyDown:e=>C(e,3)})]}),(0,H.jsx)(L,{models:v,onChange:b}),(0,H.jsxs)(A,{onClick:w,disabled:!s.trim()||g,size:`sm`,ref:S(4),onKeyDown:e=>C(e,4,w),children:[g?(0,H.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}):null,i(`setup:screen.custom.add`)]})]})]})}var U=I();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:U}catch{return U}}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(w(),1);function ce({popular:e,catalogProvider:i,savedProvider:a,onKeySaved:o,probeResult:c}){let{t:p}=ee(),[m,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!!a?.apiKeys.some(e=>e.isActive)),[C,w]=(0,B.useState)(!1),[T,D]=(0,B.useState)(!1),[M,N]=(0,B.useState)(!1),[P,F]=(0,B.useState)(null);(0,B.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(m.trim()){v(!0);try{let a=t(r.getState().wsUrl),s=V(a);i?a.addKey(e.id,`default`,m.trim()):a.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:m.trim()}});let c=await s;if(!c.success)throw Error(c.message);S(!0),g(``),n.success(p(`setup:screen.toasts.keySaved`,{name:e.name})),o(e.id),a.listSavedProviders(),a.probeProvider(e.id)}catch(t){let r=t instanceof Error&&t.message&&t.message!==`timeout`?t.message:null;n.error(r??p(`setup:screen.toasts.keySaveFailed`,{name:e.name}))}finally{v(!1)}}},L=e=>{e.key===`Enter`&&m.trim()&&I()},R=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),D(!0),n.success(p(`setup:screen.toasts.referralCopied`)),setTimeout(()=>D(!1),2e3)}catch{n.error(p(`setup:screen.toasts.referralCopyFailed`))}},z=i&&i.modelCount>0;return(0,H.jsxs)(`div`,{className:E(`rounded-xl border p-4 transition-all`,x?`border-success/30 bg-success/5`:`bg-gradient-to-br ${e.color}`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),x&&(0,H.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,H.jsx)(d,{className:`h-2.5 w-2.5`}),p(`setup:screen.card.keySaved`)]}),e.referral&&!x&&(0,H.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,H.jsx)(b,{className:`h-2.5 w-2.5`}),p(`setup:screen.card.referral`)]})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!x&&(0,H.jsxs)(`p`,{className:`text-[11px] text-warning/80 mt-1`,children:[`🎁 `,e.referral.reward]}),x?x?(0,H.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[a?.baseUrl&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 font-mono truncate`,title:a.baseUrl,children:[(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[p(`activity:providerKey.url`),` `]}),a.baseUrl]}),a?.models&&a.models.length>0&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[p(`activity:providerKey.models`),` `]}),a.pickedModelId??a.models[0],(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[` `,`(+`,a.models.length-1,` more)`]})]}),c===`probing`?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mt-1`,children:[(0,H.jsx)(l,{className:`h-3 w-3 animate-spin`}),p(`setup:screen.probe.checking`,`Checking connection…`)]}):c?.ok?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success mt-1`,children:[(0,H.jsx)(d,{className:`h-3 w-3`}),(0,H.jsxs)(`span`,{children:[p(`setup:screen.probe.connected`,`Connected`),c.modelCount!=null&&` · ${c.modelCount} ${p(`setup:screen.probe.models`,`models`)}`,c.elapsedMs!=null&&` · ${c.elapsedMs}ms`]})]}):c&&!c.ok?(0,H.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-destructive mt-1`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:`✕`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:p(`setup:screen.probe.failed`,`Probe failed`)}),c.status===`no_base_url`&&(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:p(`setup:screen.probe.noBaseUrl`,`No base URL configured`)}),c.status===`unreachable`&&(0,H.jsxs)(`span`,{className:`block text-destructive/70`,children:[p(`setup:screen.probe.unreachable`,`Could not connect`),c.detail?`: ${c.detail}`:``]}),c.status!==`no_base_url`&&c.status!==`unreachable`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:c.httpStatus==null?c.status:`${p(`setup:screen.probe.httpStatus`,`Status`)} ${c.httpStatus}`}),c.detail&&(0,H.jsx)(`span`,{className:`block text-destructive/70 truncate max-w-[250px]`,title:c.detail,children:c.detail})]})]})]}):null,z&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(!C),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[p(`setup:screen.providers.modelsAvailable`,{count:i?.modelCount??0}),C?(0,H.jsx)(u,{className:`h-3 w-3`}):(0,H.jsx)(y,{className:`h-3 w-3`})]})]}):null:(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(j,{type:`password`,placeholder:e.keyPlaceholder,value:m,onChange:e=>g(e.target.value),onKeyDown:L,className:`font-mono text-sm`}),(0,H.jsx)(A,{onClick:I,disabled:!m.trim()||_,size:`sm`,className:`shrink-0`,children:_?(0,H.jsx)(l,{className:`h-4 w-4 animate-spin`}):p(`setup:screen.card.save`)})]}),e.docsUrl&&(0,H.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:[p(`setup:screen.card.getKey`),` `,(0,H.jsx)(s,{className:`h-3 w-3`})]}),e.referral&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:R,className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:T?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(d,{className:`h-3 w-3`}),` `,p(`setup:screen.card.copied`)]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(h,{className:`h-3 w-3`}),` `,p(`setup:screen.card.copyReferral`)]})}),(0,H.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,H.jsx)(f,{className:`h-3 w-3`}),` `,p(`setup:screen.card.share`)]})]})]})]})]}),(0,H.jsx)(re,{open:M,onOpenChange:N,children:(0,H.jsxs)(te,{className:`sm:max-w-md`,children:[(0,H.jsxs)(O,{children:[(0,H.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,H.jsx)(b,{className:`h-4 w-4 text-warning`}),p(`setup:screen.share.title`,{name:e.name})]}),(0,H.jsx)(k,{children:p(`setup:screen.share.description`)})]}),(0,H.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`text-sm text-center`,children:(0,H.jsxs)(`p`,{className:`font-medium text-warning`,children:[`🎁 `,e.referral.reward]})}),P?(0,H.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,H.jsx)(`img`,{src:P,alt:p(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,H.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,H.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:p(`setup:screen.share.twitter`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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,H.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:p(`setup:screen.share.linkedin`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.linkedin`)]}),(0,H.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:p(`setup:screen.share.telegram`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.telegram`)]}),(0,H.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:p(`setup:screen.share.whatsapp`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.whatsapp`)]}),(0,H.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:p(`setup:screen.share.reddit`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.reddit`)]}),(0,H.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}&quote=${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:p(`setup:screen.share.facebook`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.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`})}),p(`activity:providerKey.facebook`)]}),(0,H.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:p(`setup:screen.share.email`),children:[(0,H.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,H.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`})}),p(`activity:providerKey.email`)]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,H.jsx)(A,{size:`sm`,variant:`outline`,onClick:R,className:`shrink-0`,children:T?(0,H.jsx)(d,{className:`h-4 w-4`}):(0,H.jsx)(h,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:p(`setup:screen.share.hint`)})]})]})})]})})]})}function W(){let{t:e}=ee(),{model:a,setProvider:o,setModel:s,wsConnected:u,wsUrl:f}=r(_(e=>({model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected,wsUrl:e.wsUrl})));N();let[h,b]=(0,B.useState)([]),[x,w]=(0,B.useState)({}),[O,te]=(0,B.useState)([]),[ne,k]=(0,B.useState)(!1),[re,j]=(0,B.useState)(null),[I,L]=(0,B.useState)(0),[R,z]=(0,B.useState)(new Set),[V,se]=(0,B.useState)({}),[W,le]=(0,B.useState)(U),[G,K]=(0,B.useState)(!1),[ue,de]=(0,B.useState)(0),[fe,pe]=(0,B.useState)(0),[q,me]=(0,B.useState)(null),J=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`;return K(!0),ae(t,e.signal).then(t=>{if(t!==U){if(le(t),K(!1),!J.current){let e=t.length-fe;e>0?n.success(T.t(`setup:screen.toasts.providersLoadedNew`,{count:t.length,diff:e})):e<0?n.success(T.t(`setup:screen.toasts.providersLoadedRemoved`,{count:t.length,diff:Math.abs(e)})):n.success(T.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),!J.current){let t=e.length-fe;t>0?n.success(T.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?n.success(T.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):n.success(T.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),pe(e.length)}me(new Date)}}).catch(()=>{J.current||n.error(T.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{K(!1),J.current=!1}),()=>e.abort()},[ue]);let[Y,he]=(0,B.useState)(null),[X,Z]=(0,B.useState)(null),[ge,_e]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!u)return;let e=t(f),n=setTimeout(()=>{n=null,k(!1),j(T.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));b(t),k(!1)}}),o=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let t=e.payload;if(t.provider!==Y)return;w(e=>({...e,[t.provider]:t.models})),_e(!1),t.models.length===1?Z(t.models[0].id):a&&t.models.some(e=>e.id===a)&&Z(a)}}),s=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));te(t);let n=new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id));z(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),k(!0),e.listProviders(),()=>{r(),i?.(),o?.(),s?.(),c?.()}},[u,f,a,I,Y]);let ve=(0,B.useCallback)(()=>{j(null),L(e=>e+1)},[]),ye=(0,B.useCallback)(()=>{de(e=>e+1)},[]),be=(0,B.useCallback)(t=>oe(t,e),[e]),xe=(0,B.useCallback)(e=>{z(t=>new Set([...t,e])),he(e),Z(null)},[]),Se=R.size>0;(0,B.useEffect)(()=>{if(!Y||!u)return;let e=t(f);x[Y]||(_e(!0),e.listProviderModels(Y))},[Y,u,f,x]);let Ce=Y?x[Y]??[]:[],we=(0,B.useCallback)(async()=>{if(!Y||!X)return;if(!R.has(Y)){n.error(`Please save the provider configuration before starting a session.`);return}o(Y),s(X);let e=await t(f).switchModel(Y,X,5e3);e.success?(i.getState().openPicker({startsSession:!0}),D(`chat`)):n.error(e.message||T.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,f]),Te=(0,B.useCallback)(async()=>{if(!Y||!X)return;o(Y),s(X);let e=await t(f).switchModel(Y,X,5e3);e.success?D(`chat`):n.error(e.message||T.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,f]),Ee=new Set(W.map(e=>e.id)),De=h.filter(e=>!Ee.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),Q=M(De,10);M(O,9);let $=M(Ce,12,Y);return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,H.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,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.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,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground sm:truncate`,children:e(`setup:screen.header.subtitle`)})]})]}),Se&&Y?(0,H.jsxs)(`span`,{className:`text-xs text-success/80`,children:[(0,H.jsx)(d,{className:`h-3 w-3 inline-block mr-1`}),e(`setup:screen.header.continue`)]}):null]}),(0,H.jsx)(P,{className:`min-h-0 flex-1`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-4 pb-4 sm:p-6`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Se?`text-success`:`text-primary font-medium`),children:[(0,H.jsx)(S,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,H.jsx)(y,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Y?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(c,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,H.jsx)(y,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:E(`flex min-w-0 items-center gap-1.5`,Y&&X?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(g,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,H.jsx)(v,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),re?(0,H.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,H.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,H.jsx)(C,{className:`h-6 w-6 text-destructive`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:re})]}),(0,H.jsxs)(A,{onClick:ve,size:`sm`,variant:`outline`,children:[(0,H.jsx)(l,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[G&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(l,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),q&&!G&&(0,H.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:q.toLocaleString(),children:be(q)}),(0,H.jsxs)(`button`,{type:`button`,onClick:ye,disabled:G,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,H.jsx)(p,{className:E(`h-3 w-3`,G&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:W.map(e=>(0,H.jsx)(ce,{popular:e,catalogProvider:h.find(t=>t.id===e.id),savedProvider:O.find(t=>t.id===e.id),onKeySaved:xe,probeResult:V[e.id]},e.id))})]}),De.length>0&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Q.pageItems.map(t=>(0,H.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:O.find(e=>e.id===t.id),onKeySaved:xe,probeResult:V[t.id]},t.id))}),(0,H.jsx)(F,{page:Q.page,pageSize:Q.pageSize,totalItems:Q.totalItems,onPageChange:Q.setPage,itemLabel:`providers`})]}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,H.jsx)(ie,{onKeySaved:xe})]})]}),ne&&(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),Y&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,H.jsx)(g,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{he(null),Z(null)},className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:Y})}),ge?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):Ce.length>0?(0,H.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,H.jsx)(`button`,{type:`button`,onClick:()=>Z(e.id),className:E(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,X===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,H.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,H.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),X===e.id&&(0,H.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary`,children:(0,H.jsx)(d,{className:`h-3 w-3 text-primary-foreground`})})]})},e.id)})}):(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)}),(0,H.jsx)(F,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,itemLabel:`models`})]}),Y&&X&&(0,H.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,H.jsx)(`div`,{className:`mb-3 flex min-w-0 items-center justify-between gap-2 text-sm text-muted-foreground`,children:(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Y,` / `,X]})}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,H.jsxs)(A,{onClick:we,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(c,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,H.jsx)(m,{className:`h-4 w-4 ml-2`})]}),(0,H.jsxs)(A,{onClick:Te,variant:`outline`,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(d,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.saveConfig`)]})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 text-center mt-2`,children:e(`setup:screen.start.saveConfigHint`)})]})]})})]})}export{W as SetupScreen};
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-V3ydTHqN.js","assets/rolldown-runtime-hePW80VL.js","assets/react-core-wiHys0m2.js","assets/xyflow-BqDBClm9.js","assets/xyflow-DLioOiRN.css","assets/markdown-CXRzjX3p.js","assets/vendor-jL-bRT8f.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Ja as r,Ma as i,Mr as a,Mt as o,Pa as ee,Qt as te,Ti as ne,Vn as re,Zn as ie,bi as ae,ea as oe,fn as se,ja as s,no as c,qi as ce,ri as le,tr as ue,wo as l,xo as u}from"./vendor-V3ydTHqN.js";import"./i18n-CbyUyl6G.js";import{t as d}from"./vite-preload-BZ1Pz5am.js";import{t as f}from"./utils-CKsqCaP8.js";import{o as de}from"./view-navigation-DHtNFXIl.js";import{n as fe}from"./ui-store-DC3mkswy.js";import{S as pe}from"./fonts-DRGbd-AM.js";import{a as me,n as he,o as ge,t as _e}from"./dialog-C7EIBM_2.js";import{u as ve}from"./markdown-CXRzjX3p.js";import{L as ye,o as p,x as m,y as be}from"./index-3TGBKeBP.js";import{t as xe}from"./empty-state-5YP1rmE6.js";var h=e(t(),1),g=n(),_=(0,h.lazy)(()=>d(()=>import(`./vendor-V3ydTHqN.js`).then(e=>e.r),__vite__mapDeps([0,1,2,3,4,5,6])));function v(e){return e===`project`||e===`user`}function Se(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function Ce({source:e}){let{t}=u(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,g.jsx)(`span`,{className:f(`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}=u(),{client:n}=ye(),d=fe(e=>e.skillsState),y=fe(e=>e.setSkillsState),b=d.selectedSkill,x=d.navHistory,S=d.historyIndex,[C,w]=(0,h.useState)(null),[we,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(null),Te=be(`skill-detail`,!!C),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[I,L]=(0,h.useState)(!1),[R,z]=(0,h.useState)(null),[B,V]=(0,h.useState)(!1),H=(0,h.useRef)(``),[Ee,De]=(0,h.useState)(!1),[U,W]=(0,h.useState)(null),[Oe,ke]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,Ae]=(0,h.useState)(!1),[je,Me]=(0,h.useState)([]),J=(0,h.useRef)(d);J.current=d;let Y=(0,h.useRef)(!1),X=(0,h.useMemo)(()=>A?{lines:A.split(`
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Ja as r,Ma as i,Mr as a,Mt as o,Pa as ee,Qt as te,Ti as ne,Vn as re,Zn as ie,bi as ae,ea as oe,fn as se,ja as s,no as c,qi as ce,ri as le,tr as ue,wo as l,xo as u}from"./vendor-V3ydTHqN.js";import"./i18n-CvJB4U4z.js";import{t as d}from"./vite-preload-BZ1Pz5am.js";import{t as f}from"./utils-CKsqCaP8.js";import{o as de}from"./view-navigation-DTs4cSQ6.js";import{n as fe}from"./ui-store-DC3mkswy.js";import{S as pe}from"./fonts-DRGbd-AM.js";import{a as me,n as he,o as ge,t as _e}from"./dialog-b-Ai37sa.js";import{u as ve}from"./markdown-CXRzjX3p.js";import{L as ye,o as p,x as m,y as be}from"./index-DLjaZSCH.js";import{t as xe}from"./empty-state-pfuS5znr.js";var h=e(t(),1),g=n(),_=(0,h.lazy)(()=>d(()=>import(`./vendor-V3ydTHqN.js`).then(e=>e.r),__vite__mapDeps([0,1,2,3,4,5,6])));function v(e){return e===`project`||e===`user`}function Se(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function Ce({source:e}){let{t}=u(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,g.jsx)(`span`,{className:f(`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}=u(),{client:n}=ye(),d=fe(e=>e.skillsState),y=fe(e=>e.setSkillsState),b=d.selectedSkill,x=d.navHistory,S=d.historyIndex,[C,w]=(0,h.useState)(null),[we,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(null),Te=be(`skill-detail`,!!C),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[I,L]=(0,h.useState)(!1),[R,z]=(0,h.useState)(null),[B,V]=(0,h.useState)(!1),H=(0,h.useRef)(``),[Ee,De]=(0,h.useState)(!1),[U,W]=(0,h.useState)(null),[Oe,ke]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,Ae]=(0,h.useState)(!1),[je,Me]=(0,h.useState)([]),J=(0,h.useRef)(d);J.current=d;let Y=(0,h.useRef)(!1),X=(0,h.useMemo)(()=>A?{lines:A.split(`
3
3
  `).length,words:A.trim()?A.trim().split(/\s+/).length:0,chars:A.length}:{lines:0,words:0,chars:0},[A]),Z=(0,h.useMemo)(()=>{if(!A)return null;let e=5242880,t=new Blob([A]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[A]);(0,h.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),2e3);return()=>clearTimeout(e)},[R]),(0,h.useEffect)(()=>{if(!O||!b)return;let e=setInterval(()=>{A&&A!==H.current&&(H.current=A,localStorage.setItem(`skills_draft_${b.name}`,JSON.stringify({content:A,savedAt:Date.now()})),z(Date.now()))},5e3);return()=>clearInterval(e)},[O,A,b]),(0,h.useEffect)(()=>{if(!b||!O)return;let e=localStorage.getItem(`skills_draft_${b.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==A&&t!==H.current&&(j(t),H.current=t,V(!0))}catch{}},[b?.name,O]),(0,h.useEffect)(()=>{if(!n||!b)return;T(!0),w(null),D(null);let e=setTimeout(()=>{T(!1),D(l.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?D(n.payload.error):n.payload.name&&w(n.payload),T(!1)},r=e=>{let t=e;De(!1);let r=J.current;if(t.payload.success){let e={...r.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;y({...r,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),n.send({type:`skills.list`},{echoToChat:!1})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??l.t(`activity:skillDetail.updateFailed`)}]})},i=e=>{let t=e;t.payload.skills&&Me(t.payload.skills)};return n.on(`skills.content`,t),n.on(`skills.updated`,r),n.on(`skills.list`,i),n.send({type:`skills.content`,payload:{name:b.name,source:b.source}}),()=>{clearTimeout(e),n.off(`skills.content`,t),n.off(`skills.updated`,r),n.off(`skills.list`,i)}},[n,b?.name,b?.source]),(0,h.useEffect)(()=>{O&&(k(!1),j(``),F(null))},[b?.name]);let Q=(0,h.useCallback)(e=>je.find(t=>t.name.toLowerCase()===e.toLowerCase()),[je]),Ne=(0,h.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}),k(!1),j(``),W(null)}},[Q,x,S,y]),Pe=(0,h.useCallback)(()=>{if(S<=0)return;Y.current=!0;let e=S-1,t=x[e];y({...J.current,selectedSkill:t,historyIndex:e}),k(!1),j(``),W(null)},[S,x,y]),Fe=(0,h.useCallback)(()=>{if(S>=x.length-1)return;Y.current=!0;let e=S+1,t=x[e];y({...J.current,selectedSkill:t,historyIndex:e}),k(!1),j(``),W(null)},[S,x,y]),$=(0,h.useCallback)(()=>{de(`chat`)},[]),Ie=(0,h.useCallback)(()=>{C&&(j(C.body),H.current=C.body,V(!1),F(null),k(!0),L(!1))},[C]),Le=(0,h.useCallback)(()=>{k(!1),j(``),F(null),L(!1),V(!1),b&&localStorage.removeItem(`skills_draft_${b.name}`)},[b]),Re=(0,h.useCallback)(()=>{b&&C&&(V(!1),j(C.body),H.current=C.body,b&&localStorage.removeItem(`skills_draft_${b.name}`))},[b,C]),ze=(0,h.useCallback)(()=>{if(!n||!b||!A.trim())return;N(!0),F(null);let e=t=>{let r=t;N(!1),r.payload.success?(H.current=``,localStorage.removeItem(`skills_draft_${b.name}`),V(!1),k(!1),n.send({type:`skills.content`,payload:{name:b.name,source:b.source}}),n.send({type:`skills.list`},{echoToChat:!1})):F(r.payload.error??l.t(`activity:skillDetail.saveFailed`)),n.off(`skills.edited`,e)};n.on(`skills.edited`,e),n.editSkill(b.name,A)},[n,b,A]),Be=(0,h.useCallback)(()=>{n&&b&&(De(!0),W(null),n.checkForUpdates(b.name,b.source===`user`))},[n,b]),Ve=(0,h.useCallback)(()=>{b?.sourceUrl&&navigator.clipboard.writeText(b.sourceUrl).then(()=>{ke(!0),setTimeout(()=>ke(!1),2e3)})},[b]),He=(0,h.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]),Ue=(0,h.useCallback)(async e=>{if(!n||!e)return;Ae(!0);let t=e=>{let r=e;Ae(!1),r.payload.success?(K(null),n.send({type:`skills.list`},{echoToChat:!1}),$()):F(r.payload.error??l.t(`activity:skillDetail.uninstallFailed`)),n.off(`skills.uninstalled`,t)};n.on(`skills.uninstalled`,t),n.uninstallSkill(e.name,e.source===`user`)},[n,$]);return b?(0,g.jsxs)(`div`,{className:f(`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,g.jsxs)(`div`,{className:`shrink-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,g.jsx)(se,{className:`h-4 w-4`})}),(0,g.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold`,children:b.name}),b.version&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,b.version]}),(0,g.jsx)(Ce,{source:b.source})]}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:b.description||b.trigger}),b.sourceUrl&&(0,g.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1`,children:[(0,g.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,g.jsx)(le,{className:`h-3 w-3 shrink-0`}),(0,g.jsx)(`span`,{className:`truncate font-mono`,children:b.sourceUrl})]}),(0,g.jsx)(`button`,{type:`button`,onClick:Ve,className:`flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground`,title:t(`activity:skillDetail.copySourceUrl`),children:Oe?(0,g.jsx)(ee,{className:`h-3 w-3 text-success`}):(0,g.jsx)(oe,{className:`h-3 w-3`})})]}),b.scope.length>0&&(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:b.scope.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,g.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,g.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,g.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,g.jsx)(`div`,{className:`text-destructive`,children:t(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,g.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,g.jsx)(`button`,{type:`button`,onClick:Be,disabled:Ee,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:Ee?(0,g.jsx)(a,{className:`h-3.5 w-3.5 animate-spin`}):(0,g.jsx)(re,{className:`h-3.5 w-3.5`})}),b.source!==`bundled`&&!O&&(0,g.jsx)(`button`,{type:`button`,onClick:He,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,g.jsx)(ce,{className:`h-3.5 w-3.5`})}),v(b.source)&&!O&&(0,g.jsx)(`button`,{type:`button`,onClick:Ie,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,g.jsx)(ie,{className:`h-3.5 w-3.5`})}),v(b.source)&&(0,g.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,g.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,g.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,g.jsx)(o,{className:`h-4 w-4`})})]})]}),x.length>1&&(0,g.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,g.jsx)(`button`,{type:`button`,onClick:Pe,disabled:S<=0,className:f(`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,g.jsx)(i,{className:`h-4 w-4`})}),(0,g.jsx)(`button`,{type:`button`,onClick:Fe,disabled:S>=x.length-1,className:f(`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,g.jsx)(s,{className:`h-4 w-4`})}),(0,g.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:x.map((e,t)=>(0,g.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,g.jsx)(s,{className:`h-3 w-3 text-muted-foreground/65 mx-0.5 shrink-0`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{t<S&&(Y.current=!0,y({...J.current,selectedSkill:e,historyIndex:t}),k(!1),j(``),W(null))},className:f(`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,g.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,g.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,g.jsx)(ae,{className:`h-3 w-3`}),(0,g.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.relatedFiles`)})]}),C.relatedFiles.map(e=>{let n=Se(e);return n&&Q(n)?(0,g.jsxs)(`button`,{type:`button`,onClick:()=>Ne(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,g.jsx)(c,{className:`h-2.5 w-2.5`}),e]},e):(0,g.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,g.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,g.jsx)(ne,{className:`h-3 w-3`}),(0,g.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.references`)})]}),C.references.map(e=>{let n=Se(e)??e.replace(/\.md$/,``);return Q(n)?(0,g.jsxs)(`button`,{type:`button`,onClick:()=>Ne(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,g.jsx)(c,{className:`h-2.5 w-2.5`}),n]},e):(0,g.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:n},e)})]})]}),(0,g.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,g.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center text-muted-foreground`,children:[(0,g.jsx)(a,{className:`mx-auto mb-2 h-6 w-6 animate-spin text-primary`}),(0,g.jsx)(`p`,{children:t(`activity:skillDetail.loadingContent`)})]}):O?(0,g.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,g.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,g.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillDetail.editingLabel`,{name:b.name})}),(0,g.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,g.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`font-medium text-destructive`:`text-warning`}`,children:t(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/1048576).toFixed(1),limit:(Z.limit/1048576).toFixed(0)})}),R&&(0,g.jsx)(`span`,{className:`text-xs text-success animate-pulse`,children:t(`activity:skillDetail.draftSaved`)}),B&&(0,g.jsx)(`span`,{className:`animate-pulse text-xs text-warning`,children:t(`activity:skillDetail.draftRestored`)})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[P&&(0,g.jsx)(`span`,{className:`text-xs text-destructive`,children:P}),B&&(0,g.jsx)(`button`,{type:`button`,onClick:Re,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,g.jsx)(`button`,{type:`button`,onClick:Le,className:`rounded-md border border-border/70 px-2 py-1 text-xs transition-colors hover:bg-accent`,children:t(`common:action.cancel`)}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>L(e=>!e),title:t(I?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`rounded-md border px-2 py-1 text-xs transition-colors ${I?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 text-muted-foreground hover:bg-accent`}`,children:(0,g.jsx)(ue,{className:`h-3 w-3 inline`})}),(0,g.jsx)(`button`,{type:`button`,onClick:ze,disabled:M||!A.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:M?(0,g.jsx)(a,{className:`h-3 w-3 animate-spin inline`}):t(`common:action.save`)})]})]}),I?(0,g.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,g.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,g.jsx)(h.Suspense,{fallback:null,children:(0,g.jsx)(_,{value:A,onChange:e=>j(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:pe(12),fontFamily:`var(--font-editor)`,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})})}),(0,g.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,g.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,g.jsx)(p,{rehypePlugins:[ve],components:m,children:A})})]}):(0,g.jsx)(h.Suspense,{fallback:null,children:(0,g.jsx)(_,{value:A,onChange:e=>j(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:pe(12),fontFamily:`var(--font-editor)`,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})})]}):C?(0,g.jsx)(`div`,{ref:Te,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,g.jsx)(p,{rehypePlugins:[ve],components:m,children:C.body})}):E?(0,g.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center`,children:[(0,g.jsx)(`p`,{className:`text-destructive mb-2`,children:t(`activity:skillDetail.loadFailed`)}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{n&&b&&(T(!0),D(null),n.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,g.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,g.jsx)(_e,{open:!!G,onOpenChange:e=>{e||K(null)},children:(0,g.jsxs)(he,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,g.jsxs)(me,{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,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(te,{className:`h-4 w-4 text-destructive`}),(0,g.jsx)(ge,{className:`font-semibold text-sm`,children:t(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,g.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,g.jsx)(o,{className:`h-4 w-4`})})]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-4`,children:[(0,g.jsx)(`p`,{className:`text-sm`,children:G&&t(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G&&t(`activity:skillDetail.uninstallRemovePath`,{path:G.path})})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,g.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,g.jsxs)(`button`,{type:`button`,onClick:()=>G&&Ue(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,g.jsx)(a,{className:`h-3 w-3 animate-spin`}),t(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,g.jsx)(xe,{icon:(0,g.jsx)(r,{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,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Dn as r,Fi as i,Ga as a,Hi as o,Mr as s,Mt as c,Q as l,Rn as u,Ti as d,Vn as f,Wa as p,ca as m,di as h,fn as g,hn as _,jt as v,la as y,mi as b,mr as x,po as ee,qi as te,so as S,sr as ne,ta as C,tn as w,xo as T,yn as re}from"./vendor-V3ydTHqN.js";import"./i18n-CbyUyl6G.js";import{t as E}from"./utils-CKsqCaP8.js";import{n as D}from"./stores-RkHrTaRO.js";import{t as O}from"./button-9ewV4TF3.js";import{t as k}from"./input-ag1CrUiS.js";import{B as ie,E as A,H as ae,T as oe,V as j,z as se}from"./index-3TGBKeBP.js";var M=e(t(),1),N=n(),P={current:{labelKey:`activity:techStackStatus.current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{labelKey:`activity:techStackStatus.update_available_safe`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{labelKey:`activity:techStackStatus.update_available_breaking`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{labelKey:`activity:techStackStatus.vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{labelKey:`activity:techStackStatus.deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{labelKey:`activity:techStackStatus.yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{labelKey:`activity:techStackStatus.unmaintained_suspected`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{labelKey:`activity:techStackStatus.blocked_by_constraints`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{labelKey:`activity:techStackStatus.private_or_unresolved`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{labelKey:`activity:techStackStatus.local_path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{labelKey:`activity:techStackStatus.git_dependency`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{labelKey:`activity:techStackStatus.unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{labelKey:`activity:techStackStatus.unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},ce={labelKey:`activity:techStackStatus.unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function F(e){return P[e]??ce}var le={npm:{label:`npm / Node.js`,icon:ne},python:{label:`Python`,icon:y},rust:{label:`Rust`,icon:_},go:{label:`Go`,icon:u},dotnet:{label:`.NET`,icon:x},php:{label:`PHP`,icon:w},dart:{label:`Dart / Flutter`,icon:C},maven:{label:`Maven`,icon:ee},gradle:{label:`Gradle`,icon:a},ruby:{label:`Ruby`,icon:h},swift:{label:`Swift`,icon:v},elixir:{label:`Elixir`,icon:w},cpp:{label:`C / C++`,icon:m}},ue={labelKey:`activity:techStackStatus.unknown`};function I(e,t){let n=L(e);return n.labelKey?t(n.labelKey):n.label??e}function L(e){return le[e]??ue}function R({ecosystem:e,className:t=`size-3.5 shrink-0`}){let n=L(e);if(!n.icon)return null;let r=n.icon;return(0,N.jsx)(r,{className:t})}function de(e){return F(e.status).weight>=50}var fe=[`critical`,`high`,`medium`,`low`,`info`],z={critical:{labelKey:`activity:techStackSeverity.critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{labelKey:`activity:techStackSeverity.high`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{labelKey:`activity:techStackSeverity.medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{labelKey:`activity:techStackSeverity.low`,badge:`border-info/35 bg-info/10 text-info`},info:{labelKey:`activity:techStackSeverity.info`,badge:`border-border/70 bg-muted text-muted-foreground`}},B={none:`activity:techStackAction.none`,upgrade_patch:`activity:techStackAction.upgrade_patch`,upgrade_minor:`activity:techStackAction.upgrade_minor`,upgrade_major:`activity:techStackAction.upgrade_major`,replace:`activity:techStackAction.replace`,remove:`activity:techStackAction.remove`,investigate:`activity:techStackAction.investigate`},V={full:{labelKey:`activity:techStackCoverage.full`,badge:`border-success/35 bg-success/10 text-success`,noteKey:void 0},partial:{labelKey:`activity:techStackCoverage.partial`,badge:`border-warning/35 bg-warning/10 text-warning`,noteKey:`activity:techStackCoverage.partialNote`},unsupported:{labelKey:`activity:techStackCoverage.unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,noteKey:`activity:techStackCoverage.unsupportedNote`}};function H(e){return V[e]??V.unsupported}function U(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 W(e){let t=U(e.locked??e.installed??e.requested),n=U(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 G(e){return e.locked??e.installed??e.requested??null}function K(e){return e.confidence<1}function q({className:e,children:t}){return(0,N.jsx)(`span`,{className:E(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function J({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,N.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,N.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,N.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:E(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,N.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function Y(e,t){let n,r,i;if(t===`json`)n=JSON.stringify(e,null,2),r=`techstack.json`,i=`application/json`;else if(t===`spdx`){let t={spdxVersion:`SPDX-2.3`,dataLicense:`CC0-1.0`,SPDXID:`SPDXRef-DOCUMENT`,name:`TechStack-SBOM-${e.projectId}`,documentNamespace:`https://wrongstack.dev/spdx/${e.id}`,creationInfo:{created:e.createdAt,creators:[`Tool: WrongStack TechStack Engine`]},packages:e.dependencies.map((e,t)=>({name:e.name,SPDXID:`SPDXRef-Package-${t}`,versionInfo:e.locked??e.requested,downloadLocation:e.purl?`https://purl.io/${e.purl}`:`NOASSERTION`,licenseConcluded:e.license??`NOASSERTION`}))};n=JSON.stringify(t,null,2),r=`techstack-sbom-spdx.json`,i=`application/json`}else if(t===`cyclonedx`){let t={bomFormat:`CycloneDX`,specVersion:`1.5`,version:1,metadata:{timestamp:e.createdAt,tools:[{name:`WrongStack TechStack Engine`,version:e.adapterVersion}]},components:e.dependencies.map(e=>({type:`library`,name:e.name,version:e.locked??e.requested,...e.purl?{purl:e.purl}:{},...e.license?{licenses:[{license:{id:e.license}}]}:{}}))};n=JSON.stringify(t,null,2),r=`techstack-sbom-cyclonedx.json`,i=`application/json`}else{let t=[`# TechStack Report`,``,`**Generated:** ${e.createdAt}`,`**Target:** ${e.targetRoot}`,`**Fingerprint:** ${e.fingerprint}`,`**Workspaces:** ${e.workspaces.length}`,`**Dependencies:** ${e.dependencies.length}`,`**Findings:** ${e.findings.length}`,`**Coverage:** ${e.coverage}`,``];if(e.workspaces.length>0){t.push(`## Workspaces`,``,`| Workspace | Ecosystem | Coverage | Deps |`,`|---|---|---|---|`);for(let n of e.workspaces){let r=e.dependencies.filter(e=>e.workspaceId===n.id).length;t.push(`| ${n.relativeRoot} | ${n.ecosystem} | ${n.coverage} | ${r} |`)}t.push(``)}if(e.findings.length>0){t.push(`## Findings`,``);let n=new Map;for(let t of e.findings)n.set(t.severity,[...n.get(t.severity)??[],t]);for(let r of[`critical`,`high`,`medium`,`low`,`info`]){let i=n.get(r);if(i?.length){t.push(`### ${r.charAt(0).toUpperCase()+r.slice(1)} (${i.length})`,``);for(let n of i){let r=e.dependencies.find(e=>e.id===n.dependencyId);t.push(`- **${r?.name??n.dependencyId}** — ${n.type} — ${n.rationale}`)}t.push(``)}}}if(e.dependencies.length>0){t.push(`## Dependencies`,``,`| Name | Ecosystem | Status | Locked | Latest |`,`|---|---|---|---|---|`);for(let n of e.dependencies)t.push(`| ${n.name} | ${n.ecosystem} | ${n.status} | ${n.locked??`—`} | ${n.latestStable??`—`} |`)}n=t.join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Dn as r,Fi as i,Ga as a,Hi as o,Mr as s,Mt as c,Q as l,Rn as u,Ti as d,Vn as f,Wa as p,ca as m,di as h,fn as g,hn as _,jt as v,la as y,mi as b,mr as x,po as ee,qi as te,so as S,sr as ne,ta as C,tn as w,xo as T,yn as re}from"./vendor-V3ydTHqN.js";import"./i18n-CvJB4U4z.js";import{t as E}from"./utils-CKsqCaP8.js";import{n as D}from"./stores-D5loyGLL.js";import{t as O}from"./button-BbeB5Qm8.js";import{t as k}from"./input-BA6D2L3K.js";import{B as ie,E as A,H as ae,T as oe,V as j,z as se}from"./index-DLjaZSCH.js";var M=e(t(),1),N=n(),P={current:{labelKey:`activity:techStackStatus.current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{labelKey:`activity:techStackStatus.update_available_safe`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{labelKey:`activity:techStackStatus.update_available_breaking`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{labelKey:`activity:techStackStatus.vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{labelKey:`activity:techStackStatus.deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{labelKey:`activity:techStackStatus.yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{labelKey:`activity:techStackStatus.unmaintained_suspected`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{labelKey:`activity:techStackStatus.blocked_by_constraints`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{labelKey:`activity:techStackStatus.private_or_unresolved`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{labelKey:`activity:techStackStatus.local_path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{labelKey:`activity:techStackStatus.git_dependency`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{labelKey:`activity:techStackStatus.unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{labelKey:`activity:techStackStatus.unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},ce={labelKey:`activity:techStackStatus.unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function F(e){return P[e]??ce}var le={npm:{label:`npm / Node.js`,icon:ne},python:{label:`Python`,icon:y},rust:{label:`Rust`,icon:_},go:{label:`Go`,icon:u},dotnet:{label:`.NET`,icon:x},php:{label:`PHP`,icon:w},dart:{label:`Dart / Flutter`,icon:C},maven:{label:`Maven`,icon:ee},gradle:{label:`Gradle`,icon:a},ruby:{label:`Ruby`,icon:h},swift:{label:`Swift`,icon:v},elixir:{label:`Elixir`,icon:w},cpp:{label:`C / C++`,icon:m}},ue={labelKey:`activity:techStackStatus.unknown`};function I(e,t){let n=L(e);return n.labelKey?t(n.labelKey):n.label??e}function L(e){return le[e]??ue}function R({ecosystem:e,className:t=`size-3.5 shrink-0`}){let n=L(e);if(!n.icon)return null;let r=n.icon;return(0,N.jsx)(r,{className:t})}function de(e){return F(e.status).weight>=50}var fe=[`critical`,`high`,`medium`,`low`,`info`],z={critical:{labelKey:`activity:techStackSeverity.critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{labelKey:`activity:techStackSeverity.high`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{labelKey:`activity:techStackSeverity.medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{labelKey:`activity:techStackSeverity.low`,badge:`border-info/35 bg-info/10 text-info`},info:{labelKey:`activity:techStackSeverity.info`,badge:`border-border/70 bg-muted text-muted-foreground`}},B={none:`activity:techStackAction.none`,upgrade_patch:`activity:techStackAction.upgrade_patch`,upgrade_minor:`activity:techStackAction.upgrade_minor`,upgrade_major:`activity:techStackAction.upgrade_major`,replace:`activity:techStackAction.replace`,remove:`activity:techStackAction.remove`,investigate:`activity:techStackAction.investigate`},V={full:{labelKey:`activity:techStackCoverage.full`,badge:`border-success/35 bg-success/10 text-success`,noteKey:void 0},partial:{labelKey:`activity:techStackCoverage.partial`,badge:`border-warning/35 bg-warning/10 text-warning`,noteKey:`activity:techStackCoverage.partialNote`},unsupported:{labelKey:`activity:techStackCoverage.unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,noteKey:`activity:techStackCoverage.unsupportedNote`}};function H(e){return V[e]??V.unsupported}function U(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 W(e){let t=U(e.locked??e.installed??e.requested),n=U(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 G(e){return e.locked??e.installed??e.requested??null}function K(e){return e.confidence<1}function q({className:e,children:t}){return(0,N.jsx)(`span`,{className:E(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function J({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,N.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,N.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,N.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:E(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,N.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function Y(e,t){let n,r,i;if(t===`json`)n=JSON.stringify(e,null,2),r=`techstack.json`,i=`application/json`;else if(t===`spdx`){let t={spdxVersion:`SPDX-2.3`,dataLicense:`CC0-1.0`,SPDXID:`SPDXRef-DOCUMENT`,name:`TechStack-SBOM-${e.projectId}`,documentNamespace:`https://wrongstack.dev/spdx/${e.id}`,creationInfo:{created:e.createdAt,creators:[`Tool: WrongStack TechStack Engine`]},packages:e.dependencies.map((e,t)=>({name:e.name,SPDXID:`SPDXRef-Package-${t}`,versionInfo:e.locked??e.requested,downloadLocation:e.purl?`https://purl.io/${e.purl}`:`NOASSERTION`,licenseConcluded:e.license??`NOASSERTION`}))};n=JSON.stringify(t,null,2),r=`techstack-sbom-spdx.json`,i=`application/json`}else if(t===`cyclonedx`){let t={bomFormat:`CycloneDX`,specVersion:`1.5`,version:1,metadata:{timestamp:e.createdAt,tools:[{name:`WrongStack TechStack Engine`,version:e.adapterVersion}]},components:e.dependencies.map(e=>({type:`library`,name:e.name,version:e.locked??e.requested,...e.purl?{purl:e.purl}:{},...e.license?{licenses:[{license:{id:e.license}}]}:{}}))};n=JSON.stringify(t,null,2),r=`techstack-sbom-cyclonedx.json`,i=`application/json`}else{let t=[`# TechStack Report`,``,`**Generated:** ${e.createdAt}`,`**Target:** ${e.targetRoot}`,`**Fingerprint:** ${e.fingerprint}`,`**Workspaces:** ${e.workspaces.length}`,`**Dependencies:** ${e.dependencies.length}`,`**Findings:** ${e.findings.length}`,`**Coverage:** ${e.coverage}`,``];if(e.workspaces.length>0){t.push(`## Workspaces`,``,`| Workspace | Ecosystem | Coverage | Deps |`,`|---|---|---|---|`);for(let n of e.workspaces){let r=e.dependencies.filter(e=>e.workspaceId===n.id).length;t.push(`| ${n.relativeRoot} | ${n.ecosystem} | ${n.coverage} | ${r} |`)}t.push(``)}if(e.findings.length>0){t.push(`## Findings`,``);let n=new Map;for(let t of e.findings)n.set(t.severity,[...n.get(t.severity)??[],t]);for(let r of[`critical`,`high`,`medium`,`low`,`info`]){let i=n.get(r);if(i?.length){t.push(`### ${r.charAt(0).toUpperCase()+r.slice(1)} (${i.length})`,``);for(let n of i){let r=e.dependencies.find(e=>e.id===n.dependencyId);t.push(`- **${r?.name??n.dependencyId}** — ${n.type} — ${n.rationale}`)}t.push(``)}}}if(e.dependencies.length>0){t.push(`## Dependencies`,``,`| Name | Ecosystem | Status | Locked | Latest |`,`|---|---|---|---|---|`);for(let n of e.dependencies)t.push(`| ${n.name} | ${n.ecosystem} | ${n.status} | ${n.locked??`—`} | ${n.latestStable??`—`} |`)}n=t.join(`
2
2
  `),r=`techstack-report.md`,i=`text/markdown`}let a=new Blob([n],{type:i}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=r,s.click(),URL.revokeObjectURL(o)}function pe({dependency:e,findings:t,deepDive:n,onDeepDive:r,onBack:i,coverage:a}){let{t:c}=T(),l=F(e.status),u=G(e),d=W(e),f=a?H(a).noteKey:void 0;return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,N.jsxs)(`header`,{className:`shrink-0 border-b border-border/70 bg-card/45 p-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,N.jsx)(O,{variant:`ghost`,size:`icon`,onClick:i,"aria-label":c(`activity:techStack.backToDependencyList`),className:`shrink-0 md:hidden`,children:(0,N.jsx)(S,{className:`size-4`})}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,N.jsx)(`h2`,{className:`min-w-0 truncate font-mono text-sm font-bold text-foreground`,children:e.name}),(0,N.jsx)(q,{className:l.badge,children:c(l.labelKey)})]}),(0,N.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[I(e.ecosystem,c),` ·`,` `,e.direct?`direct`:`transitive`,` · `,e.scope,` ·`,` `,e.sourceType,f&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,N.jsx)(`span`,{className:`text-warning`,children:c(f)})]})]})]})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-baseline gap-2 font-mono text-xs`,children:[(0,N.jsx)(`span`,{className:`text-foreground`,children:u??`—`}),e.latestStable&&e.latestStable!==u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,N.jsx)(`span`,{className:`text-info`,children:e.latestStable})]}),d.label&&(0,N.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[`(`,d.label,`)`]})]})]}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,N.jsxs)(`dl`,{className:`grid grid-cols-2 gap-px border border-border/70 bg-border/60`,children:[(0,N.jsx)(X,{label:c(`activity:techStack.constraint`),value:e.requested??`—`,mono:!0}),(0,N.jsx)(X,{label:c(`activity:techStack.locked`),value:e.locked??`—`,mono:!0}),(0,N.jsx)(X,{label:c(`activity:techStack.latestStable`),value:e.latestStable??`—`,mono:!0}),(0,N.jsx)(X,{label:c(`activity:techStack.license`),value:e.license??`—`}),e.wanted&&(0,N.jsx)(X,{label:c(`activity:techStack.wanted`),value:e.wanted,mono:!0}),e.resolvable&&(0,N.jsx)(X,{label:c(`activity:techStack.resolvable`),value:e.resolvable,mono:!0}),e.purl&&(0,N.jsx)(X,{label:c(`activity:techStack.purl`),value:e.purl,mono:!0}),(0,N.jsx)(X,{label:c(`activity:techStack.registryFlags`),value:[e.deprecated&&`deprecated`,e.yanked&&`yanked`].filter(Boolean).join(`, `)||`none`})]}),(0,N.jsxs)(`section`,{className:`mt-4`,children:[(0,N.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:c(`activity:techStack.findings`)}),(0,N.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>r(e),disabled:n.status===`loading`,className:`h-7 text-[10px]`,children:[n.status===`loading`?(0,N.jsx)(s,{className:`size-3 animate-spin`}):(0,N.jsx)(g,{className:`size-3`}),n.status===`loading`?`Researching…`:`Deep dive`]})]}),n.status===`error`&&n.error&&(0,N.jsx)(`p`,{role:`alert`,className:`mb-1.5 text-[10px] text-destructive`,children:n.error}),t.length===0?(0,N.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:c(`activity:techStack.nothingFlaggedRunADeepDive`)}):(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,N.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,N.jsx)(q,{className:z[e.severity].badge,children:c(z[e.severity].labelKey)}),(0,N.jsx)(q,{className:`border-border/70 bg-muted text-muted-foreground`,children:B[e.action]?c(B[e.action]):e.action}),K(e)&&(0,N.jsxs)(q,{className:`border-info/35 bg-info/10 text-info`,children:[(0,N.jsx)(g,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,N.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,N.jsxs)(`section`,{className:`mt-4`,children:[(0,N.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:c(`activity:techStack.evidence`)}),e.evidence.length===0?(0,N.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:c(`activity:techStack.noEvidenceRecorded`)}):(0,N.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.evidence.map((t,n)=>(0,N.jsxs)(`li`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,N.jsx)(q,{className:`border-border/70 bg-muted text-muted-foreground`,children:t.kind}),(0,N.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(t.retrievedAt).toLocaleString()})]}),t.source.startsWith(`http`)?(0,N.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,N.jsx)(`span`,{className:`truncate`,children:t.source}),(0,N.jsx)(o,{className:`size-2.5 shrink-0`})]}):(0,N.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground`,children:t.source}),t.detail&&(0,N.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:t.detail})]},`${e.id}-evidence-${n}`))})]})]})]})}function X({label:e,value:t,mono:n}){return(0,N.jsxs)(`div`,{className:`bg-card/55 px-2.5 py-1.5`,children:[(0,N.jsx)(`dt`,{className:`text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,N.jsx)(`dd`,{className:E(`mt-0.5 truncate text-[11px] text-foreground`,n&&`font-mono`),children:t})]})}var me=`grid grid-cols-[minmax(0,2.2fr)_minmax(0,1.6fr)_minmax(0,1.1fr)] gap-2`;function he({dependencies:e,selectedId:t,hasDependencies:n,coverageByWorkspaceId:r,onSelect:i}){let{t:a}=T(),o=A(e,30);return e.length===0?(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,N.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,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,N.jsxs)(`div`,{className:E(me,`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,N.jsx)(`span`,{children:a(`activity:techStack.package`)}),(0,N.jsx)(`span`,{children:a(`activity:techStack.installedLatest`)}),(0,N.jsx)(`span`,{children:a(`activity:techStack.status`)})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,N.jsx)(l,{className:`h-full`,"aria-label":a(`activity:techStack.dependencies`),children:o.pageItems.map(e=>(0,N.jsx)(ge,{dependency:e,selected:e.id===t,coverage:r?.get(e.workspaceId),onSelect:i},e.id))})}),(0,N.jsx)(oe,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,itemLabel:`dependencies`})]})}function ge({dependency:e,selected:t,coverage:n,onSelect:r}){let{t:i}=T(),a=F(e.status),o=G(e),s=W(e),c=n?H(n).noteKey:void 0;return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-current":t,className:E(me,`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,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:E(`size-1.5 shrink-0`,a.dot),"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`truncate font-mono text-xs text-foreground`,children:e.name})]}),(0,N.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[(0,N.jsx)(R,{ecosystem:e.ecosystem,className:`mr-0.5 inline-block size-3 align-text-bottom`}),I(e.ecosystem,i),` · `,e.direct?`direct`:`transitive`,` · `,e.scope,c&&(0,N.jsxs)(N.Fragment,{children:[` · `,(0,N.jsx)(`span`,{className:`text-warning`,children:i(c)})]})]})]}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,children:[(0,N.jsx)(`span`,{className:`truncate text-foreground`,children:o??`—`}),e.latestStable&&e.latestStable!==o&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),(0,N.jsx)(`span`,{className:`truncate text-info`,children:e.latestStable})]})]}),s.label?(0,N.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-warning`,children:s.label}):e.requested&&(0,N.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:e.requested})]}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,N.jsx)(q,{className:a.badge,children:i(a.labelKey)}),e.deprecated&&(0,N.jsx)(q,{className:`border-destructive/35 bg-destructive/10 text-destructive`,children:`dep`}),e.yanked&&(0,N.jsx)(q,{className:`border-destructive/45 bg-destructive/15 text-destructive`,children:`yank`})]})]})}function _e({findings:e,dependenciesById:t,onSelectDependency:n}){let{t:r}=T(),i=A(e,20);if(e.length===0)return(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,N.jsxs)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:[r(`activity:techStack.noFindingsRun`),` `,(0,N.jsx)(`span`,{className:`font-mono text-foreground`,children:r(`activity:techStack.analyze`)}),` `,r(`activity:techStack.toCheckVersionsAndAdvisoriesAgainst`)]})});let a=fe.map(e=>[e,i.pageItems.filter(t=>t.severity===e)]).filter(([,e])=>e.length>0);return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,N.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.map(([e,i])=>(0,N.jsxs)(`section`,{children:[(0,N.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,N.jsx)(q,{className:z[e].badge,children:r(z[e].labelKey)}),(0,N.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:i.length})]}),(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:i.map(e=>(0,N.jsx)(ve,{finding:e,dependency:t.get(e.dependencyId),onSelectDependency:n},e.id))})]},e))})}),(0,N.jsx)(oe,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,itemLabel:`findings`})]})}function ve({finding:e,dependency:t,onSelectDependency:n}){let{t:r}=T(),i=K(e);return(0,N.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,N.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,N.jsx)(q,{className:`border-border/70 bg-muted text-muted-foreground`,children:B[e.action]?r(B[e.action]):e.action}),i&&(0,N.jsxs)(q,{className:`border-info/35 bg-info/10 text-info`,children:[(0,N.jsx)(g,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,N.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,N.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,N.jsx)(`ul`,{className:E(`mt-1.5 flex flex-col gap-0.5`),children:e.evidence.slice(0,4).map((t,n)=>(0,N.jsx)(`li`,{className:`min-w-0 truncate text-[10px]`,children:t.source.startsWith(`http`)?(0,N.jsx)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`text-info underline-offset-2 hover:underline`,children:t.detail??t.source}):(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:t.detail??t.source})},`${e.id}-${n}`))})]})}function ye({searchQuery:e,ecosystemFilter:t,statusFilter:n,directOnly:i,sort:a,hasFilters:o,ecosystems:s,statuses:l,visibleCount:u,totalCount:d,onSearchChange:f,onEcosystemFilterChange:p,onStatusFilterChange:m,onToggleDirectOnly:h,onSortChange:g,onClearFilters:_}){let{t:v}=T();return(0,N.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/70 bg-card/45 p-3`,children:[(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,N.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,N.jsx)(k,{"aria-label":v(`activity:techStack.searchDependencies`),value:e,onChange:e=>f(e.target.value),placeholder:v(`activity:techStack.searchByPackageName`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,N.jsx)(`button`,{type:`button`,"aria-label":v(`activity:techStack.clearSearch`),onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,N.jsx)(c,{className:`size-3.5`})})]}),(0,N.jsx)(O,{variant:i?`default`:`outline`,size:`sm`,onClick:h,"aria-pressed":i,title:v(`activity:techStack.showOnlyDependenciesThisProjectDeclaresItself`),className:`shrink-0`,children:v(`activity:techStack.directOnly`)}),o&&(0,N.jsx)(O,{variant:`ghost`,size:`icon`,onClick:_,"aria-label":v(`activity:techStack.clearAllFilters`),title:v(`activity:techStack.clearAllFilters`),className:`shrink-0`,children:(0,N.jsx)(b,{className:`size-4`})})]}),(0,N.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-ecosystem-filter`,children:v(`activity:techStack.filterByEcosystem`)}),(0,N.jsxs)(`select`,{id:`techstack-ecosystem-filter`,value:t,onChange:e=>p(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,N.jsx)(`option`,{value:`all`,children:v(`activity:techStack.allEcosystems`)}),s.map(([e,t])=>(0,N.jsxs)(`option`,{value:e,children:[I(e,v),` · `,t]},e))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-status-filter`,children:v(`activity:techStack.filterByStatus`)}),(0,N.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,N.jsx)(`option`,{value:`all`,children:v(`activity:techStack.allStatuses`)}),l.map(([e,t])=>(0,N.jsxs)(`option`,{value:e,children:[v(F(e).labelKey),` · `,t]},e))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-sort`,children:v(`activity:techStack.sortDependencies`)}),(0,N.jsxs)(`select`,{id:`techstack-sort`,value:a,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,N.jsx)(`option`,{value:`attention`,children:v(`activity:techStack.sortNeedsAttention`)}),(0,N.jsx)(`option`,{value:`drift`,children:v(`activity:techStack.sortMostOutOfDate`)}),(0,N.jsx)(`option`,{value:`name`,children:v(`activity:techStack.sortName`)})]})]})]}),(0,N.jsx)(`p`,{className:E(`text-[10px] text-muted-foreground`,o&&`text-info`),children:u===d?`${d} dependencies`:`${u} of ${d} dependencies`})]})}var be=[{id:`dependencies`,labelKey:`activity:techStack.tabDependencies`},{id:`findings`,labelKey:`activity:techStack.tabFindings`},{id:`workspaces`,labelKey:`activity:techStack.tabWorkspaces`},{id:`trends`,labelKey:`activity:techStack.tabTrends`},{id:`remediation`,labelKey:`activity:techStack.tabRemediation`}],Z=new Set([`npm`,`python`,`rust`,`go`,`php`,`dotnet`]);function Q(){let{t:e}=T(),t=D(e=>e.snapshot),n=D(e=>e.stale),r=D(e=>e.loading),a=D(e=>e.error),o=D(e=>e.activeJob),[l,u]=(0,M.useState)(`dependencies`),[p,m]=(0,M.useState)(``),[h,v]=(0,M.useState)(`all`),[y,b]=(0,M.useState)(`all`),[x,ee]=(0,M.useState)(!1),[S,ne]=(0,M.useState)(`attention`),[C,w]=(0,M.useState)(null),[k,A]=(0,M.useState)([]),[oe,P]=(0,M.useState)({status:`idle`,error:null}),[ce,le]=(0,M.useState)(null),[ue,I]=(0,M.useState)(null),[L,R]=(0,M.useState)(new Set),[fe,z]=(0,M.useState)(!1),B=(0,M.useCallback)(async()=>{let e=D.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))}},[]),V=(0,M.useCallback)(async e=>{let t=D.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))}},[]),H=(0,M.useCallback)(async()=>{let e=D.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}`);D.getState().jobCancelled(e.id)}catch(e){D.getState().setError(e instanceof Error?e.message:String(e))}},[]),U=(0,M.useCallback)(async e=>{P({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}`);A(n.findings??[]),P({status:`idle`,error:null})}catch(e){P({status:`error`,error:e instanceof Error?e.message:String(e)})}},[]);(0,M.useEffect)(()=>{B()},[B]),(0,M.useEffect)(()=>{(l===`trends`||l===`remediation`)&&fetch(`/api/techstack/${l===`trends`?`trends`:`remediation`}`).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);t.trend&&le(t.trend),t.plan&&I(t.plan)}).catch(e=>D.getState().setError(e instanceof Error?e.message:String(e)))},[l,t?.id]);let G=(0,M.useCallback)(async()=>{if(L.size!==0){z(!0);try{let e=await fetch(`/api/techstack/remediation/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({approvedItems:[...L]})}),t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);R(new Set),await V(`inventory`)}catch(e){D.getState().setError(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[L,V]);(0,M.useEffect)(()=>{A([]),P({status:`idle`,error:null})},[t?.id]);let K=(0,M.useMemo)(()=>t?.dependencies??[],[t]),q=(0,M.useMemo)(()=>t?.findings??[],[t]),X=(0,M.useMemo)(()=>new Map(K.map(e=>[e.id,e])),[K]),me=(0,M.useMemo)(()=>Ee(K.map(e=>e.ecosystem)),[K]),ge=(0,M.useMemo)(()=>Ee(K.map(e=>e.status)),[K]),ve=(0,M.useMemo)(()=>new Map(t?.workspaces.map(e=>[e.id,e.coverage])??[]),[t]),Z=(0,M.useMemo)(()=>{let e=p.trim().toLowerCase(),t=[...K.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||h!==`all`&&t.ecosystem!==h||y!==`all`&&t.status!==y||x&&!t.direct))];return S===`name`?t.sort((e,t)=>e.name.localeCompare(t.name)):S===`drift`?t.sort((e,t)=>W(t).majorsBehind-W(e).majorsBehind||e.name.localeCompare(t.name)):t.sort((e,t)=>F(t.status).weight-F(e.status).weight||Number(t.direct)-Number(e.direct)||e.name.localeCompare(t.name)),t},[K,p,h,y,x,S]),Q=C?X.get(C):void 0,De=(0,M.useMemo)(()=>Q?[...q.filter(e=>e.dependencyId===Q.id),...k.filter(e=>e.dependencyId===Q.id)]:[],[q,k,Q]),Oe=(0,M.useMemo)(()=>K.filter(de).length,[K]),ke=(0,M.useMemo)(()=>K.filter(e=>W(e).majorsBehind>0).length,[K]),Ae=(0,M.useMemo)(()=>K.filter(e=>e.status===`vulnerable`).length,[K]),je=p.trim()!==``||h!==`all`||y!==`all`||x,Me=(0,M.useCallback)(()=>{m(``),v(`all`),b(`all`),ee(!1)},[]),$=!(!o||[`completed`,`failed`,`cancelled`].includes(o.status)),Ne=(0,M.useCallback)(e=>{w(e),u(`dependencies`)},[]);return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsx)(`header`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:e(`activity:techStack.techstack`)}),(0,N.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:t?`${t.workspaces.length} workspaces`:`no scan yet`}),n&&(0,N.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:e(`activity:techStack.staleGt24h`)})]}),(0,N.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground sm:text-xs`,children:t?`${t.targetRoot} · scanned ${new Date(t.createdAt).toLocaleString()}`:`Scan the open project to inventory its dependencies.`})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>void V(`inventory`),disabled:$,title:e(`activity:techStack.offlineReReadManifestsAndLockfiles`),children:[(0,N.jsx)(f,{className:E(`size-3.5`,$&&`animate-spin`)}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:e(`activity:techStack.refresh`)})]}),(0,N.jsxs)(O,{size:`sm`,onClick:()=>void V(`analyze`),disabled:$,title:e(`activity:techStack.checkRegistriesAndAdvisoriesThenInterpretTheResultsWithTheModel`),children:[(0,N.jsx)(g,{className:`size-3.5`}),e(`activity:techStack.analyze`)]}),$&&(0,N.jsx)(O,{variant:`ghost`,size:`icon`,onClick:()=>void H(),"aria-label":e(`activity:techStack.cancelJob`),children:(0,N.jsx)(c,{className:`size-4`})}),(0,N.jsxs)(se,{children:[(0,N.jsx)(ae,{asChild:!0,children:(0,N.jsx)(O,{variant:`ghost`,size:`icon`,disabled:!t,"aria-label":e(`activity:techStack.exportOptions`),title:e(`activity:techStack.exportOptions`),children:(0,N.jsx)(te,{className:`size-4`})})}),(0,N.jsxs)(ie,{align:`end`,className:`w-60`,children:[(0,N.jsxs)(j,{onClick:()=>t&&Y(t,`json`),children:[(0,N.jsx)(i,{className:`mr-2 size-4`}),e(`activity:techStack.exportSnapshotAsJson`)]}),(0,N.jsxs)(j,{onClick:()=>t&&Y(t,`spdx`),children:[(0,N.jsx)(_,{className:`mr-2 size-4`}),e(`activity:techStack.exportSbomSpdx`)]}),(0,N.jsxs)(j,{onClick:()=>t&&Y(t,`cyclonedx`),children:[(0,N.jsx)(re,{className:`mr-2 size-4`}),e(`activity:techStack.exportSbomCycloneDx`)]}),(0,N.jsxs)(j,{onClick:()=>t&&Y(t,`md`),children:[(0,N.jsx)(d,{className:`mr-2 size-4`}),e(`activity:techStack.exportReportMd`)]})]})]})]})]})}),t&&(0,N.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,N.jsx)(J,{label:e(`activity:techStack.dependencies`),value:K.length,hint:`${Z.length} visible`}),(0,N.jsx)(J,{label:e(`activity:techStack.outdated`),value:ke,hint:e(`activity:techStack.majorsBehind`),tone:ke>0?`warning`:`success`}),(0,N.jsx)(J,{label:e(`activity:techStack.vulnerable`),value:Ae,hint:e(`activity:techStack.knownAdvisories`),tone:Ae>0?`destructive`:`success`}),(0,N.jsx)(J,{label:e(`activity:techStack.findings`),value:q.length,hint:`${Oe} need attention`,tone:q.length>0?`info`:`default`})]}),($||a)&&(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[$&&o&&(0,N.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-info`,children:[(0,N.jsx)(s,{className:`size-3.5 animate-spin`}),(0,N.jsx)(`span`,{className:`font-mono`,children:o.status}),o.progress&&(0,N.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.progress.completed,`/`,o.progress.total]})]}),a&&(0,N.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void B(),className:`underline`,children:e(`activity:techStack.retry`)})]})]}),r&&!t?(0,N.jsx)(we,{}):t?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`nav`,{className:`flex shrink-0 gap-1 border-b border-border/70 px-2`,children:be.map(t=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>u(t.id),"aria-current":l===t.id,className:E(`border-b-2 px-3 py-2 text-xs font-medium transition-colors`,l===t.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e(t.labelKey),t.id===`findings`&&q.length>0&&(0,N.jsx)(`span`,{className:`ml-1.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:q.length})]},t.id))}),l===`dependencies`&&(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(340px,1fr)_minmax(0,1.15fr)]`,children:[(0,N.jsxs)(`section`,{className:E(`min-h-0 border-r border-border/70`,Q?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:techStack.dependencyList`),children:[(0,N.jsx)(ye,{searchQuery:p,ecosystemFilter:h,statusFilter:y,directOnly:x,sort:S,hasFilters:je,ecosystems:me,statuses:ge,visibleCount:Z.length,totalCount:K.length,onSearchChange:m,onEcosystemFilterChange:v,onStatusFilterChange:b,onToggleDirectOnly:()=>ee(e=>!e),onSortChange:ne,onClearFilters:Me}),(0,N.jsx)(he,{dependencies:Z,selectedId:C,hasDependencies:K.length>0,coverageByWorkspaceId:ve,onSelect:e=>w(e.id)})]}),(0,N.jsx)(`section`,{className:E(`min-h-0`,Q?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:techStack.dependencyDetail`),children:Q?(0,N.jsx)(pe,{dependency:Q,findings:De,deepDive:oe,onDeepDive:U,onBack:()=>w(null),coverage:ve.get(Q.workspaceId)}):(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,N.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:e(`activity:techStack.selectADependencyToSeeIts`)})})})]}),l===`findings`&&(0,N.jsx)(_e,{findings:q,dependenciesById:X,onSelectDependency:Ne}),l===`workspaces`&&(0,N.jsx)(Ce,{snapshot:t}),l===`trends`&&(0,N.jsx)(xe,{trend:ce}),l===`remediation`&&(0,N.jsx)(Se,{plan:ue,approved:L,applying:fe,onToggle:e=>R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onApply:()=>void G()})]}):(0,N.jsx)(Te,{onScan:()=>void V(`inventory`),disabled:$})]})}function xe({trend:e}){return e?(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,N.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,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.points.map(e=>(0,N.jsxs)(`div`,{className:`grid grid-cols-4 border border-border/70 bg-card/40 p-2 text-xs`,children:[(0,N.jsx)(`span`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,N.jsxs)(`span`,{children:[e.dependencies,` deps`]}),(0,N.jsxs)(`span`,{className:`text-warning`,children:[e.outdated,` outdated`]}),(0,N.jsxs)(`span`,{className:`text-destructive`,children:[e.vulnerable,` vulnerable`]})]},e.snapshotId))})]}):(0,N.jsx)(we,{})}function Se({plan:e,approved:t,applying:n,onToggle:r,onApply:i}){let{t:a}=T();return e?(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.warning}),(0,N.jsxs)(O,{size:`sm`,disabled:t.size===0||n,onClick:i,children:[n&&(0,N.jsx)(s,{className:`size-3.5 animate-spin`}),`Apply `,t.size>0?t.size:``]})]}),(0,N.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`||!Z.has(e.ecosystem);return(0,N.jsxs)(`label`,{className:E(`flex gap-3 border border-border/70 bg-card/40 p-2.5`,i?`cursor-not-allowed opacity-65`:`cursor-pointer`),children:[(0,N.jsx)(`input`,{type:`checkbox`,disabled:i,checked:t.has(n),onChange:()=>r(n)}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`span`,{className:`block font-mono text-xs`,children:[e.dependencyName,` · `,e.action]}),(0,N.jsxs)(`span`,{className:`block text-[10px] text-muted-foreground`,children:[e.currentVersion??`?`,` → `,e.targetVersion??`latest`,` · `,e.rationale]}),i&&(0,N.jsx)(`span`,{className:`block text-[10px] text-warning`,children:a(`activity:techStack.requiresAManualPackageChoice`)})]})]},n)}),e.items.length===0&&(0,N.jsx)(`p`,{className:`p-8 text-center text-xs text-muted-foreground`,children:a(`activity:techStack.noRemediationNeeded`)})]})]}):(0,N.jsx)(we,{})}function Ce({snapshot:e}){let{t}=T(),n=(0,M.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,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:techStack.noWorkspacesDetected`)})}):(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,N.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.workspaces.map(e=>{let r=V[e.coverage];return(0,N.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`p`,{className:`truncate font-mono text-xs text-foreground`,children:e.relativeRoot}),(0,N.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-1 truncate text-[10px] text-muted-foreground`,children:[(0,N.jsx)(R,{ecosystem:e.ecosystem}),(0,N.jsx)(`span`,{children:I(e.ecosystem,t)}),e.packageManager?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,N.jsx)(`span`,{children:e.packageManager})]}):null,(0,N.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,N.jsxs)(`span`,{children:[n.get(e.id)??0,` deps`]})]})]}),(0,N.jsx)(`span`,{className:E(`shrink-0 border px-1.5 py-0.5 text-[10px] font-medium`,r.badge),children:t(r.labelKey)})]}),e.manifests.length>0&&(0,N.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.manifests.map(e=>(0,N.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 we(){let{t:e}=T();return(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,N.jsx)(s,{className:`size-5 animate-spin text-muted-foreground`}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:techStack.loadingSnapshot`)})]})})}function Te({onScan:e,disabled:t}){let{t:n}=T(),r=(0,M.useMemo)(()=>Object.values(le).map(e=>e.label??``).filter(Boolean).join(`, `),[]);return(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-3 text-center`,children:[(0,N.jsx)(`div`,{className:`flex size-14 items-center justify-center border border-info/25 bg-info/5 text-info`,children:(0,N.jsx)(p,{className:`size-6`})}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`activity:techStack.noInventoryYet`)}),(0,N.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`TechStack reads every manifest and lockfile in the open project — `,r,` — and compares what you have against the upstream registries.`]}),(0,N.jsxs)(O,{size:`sm`,onClick:e,disabled:t,children:[(0,N.jsx)(f,{className:E(`size-3.5`,t&&`animate-spin`)}),n(`activity:techStack.scanThisProject`)]})]})})}function Ee(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]))}export{Q as TechStackView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,t as n,tt as r}from"./config-store-BAUadwHd.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{In as o,Mt as s,Qt as c,ln as l,qn as u,wo as d,xo as f}from"./vendor-V3ydTHqN.js";import"./i18n-CbyUyl6G.js";import{n as p,t as m}from"./utils-CKsqCaP8.js";import{n as h}from"./ui-store-DC3mkswy.js";import"./stores-RkHrTaRO.js";import{w as g}from"./fonts-DRGbd-AM.js";import{m as _}from"./index-3TGBKeBP.js";import{n as v,t as y}from"./xterm-DA3G7037.js";var b=e(i(),1),x=`wrongstack.terminalDockHeight`,S=260;function C(e){let t=typeof window>`u`?640:Math.max(140,Math.min(640,Math.floor(window.innerHeight*.55),window.innerHeight-S));return Math.min(Math.max(Math.round(e),140),t)}var w=a(),T={background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,selectionBackground:`#585b70`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`},E=8;function D(e=!1){return typeof window>`u`?300:C(window.innerHeight*(e?.32:.4))}function O(e=!1){if(typeof window>`u`)return D(e);try{let t=window.localStorage.getItem(x),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)?C(n):D(e)}catch{return D(e)}}function k(e){try{window.localStorage.setItem(x,String(C(e)))}catch{}}function A(){return p()}function j(e){return{id:A(),name:`Terminal ${e}`,status:`starting`}}function M({desktopShell:e=!1,onClose:t}){let n=(0,b.useRef)(null),{t:i}=f(),a=(0,b.useRef)(1),[d,p]=(0,b.useState)(()=>O(e)),[g,_]=(0,b.useState)(()=>[j(1)]),[v,y]=(0,b.useState)(()=>g[0]?.id??``),x=h(e=>e.terminalCreateNonce),S=(0,b.useRef)(x),T=r(e=>e.projectName),D=r(e=>e.cwd);(0,b.useEffect)(()=>{let e=()=>{p(e=>{let t=C(e);return k(t),t})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let M=e=>{e.preventDefault(),n.current?.();let t=e.clientY,r=d,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=C(r+t-e.clientY);p(n),k(n)},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),n.current===s&&(n.current=null)};n.current=s,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0}),window.addEventListener(`pointercancel`,s,{once:!0})};(0,b.useEffect)(()=>()=>n.current?.(),[]);let P=()=>{if(g.length>=E)return;a.current+=1;let e=j(a.current);_([...g,e]),y(e.id)};(0,b.useEffect)(()=>{x!==S.current&&(S.current=x,P())},[x]);let F=e=>{let n=g.findIndex(t=>t.id===e);if(n===-1)return;let r=g.filter(t=>t.id!==e);if(_(r),r.length===0){queueMicrotask(t);return}v===e&&y(r[Math.max(0,n-1)]?.id??r[0]?.id??``)},I=e=>{let t=A();g.some(t=>t.id===e)&&(_(g.map(n=>n.id===e?{...n,id:t,status:`starting`,exitCode:void 0}:n)),y(t))},L=()=>{_([]),y(``),queueMicrotask(t)},R=(e,t)=>{_(n=>n.map(n=>n.id===e?{...n,...t}:n))},z=g.find(e=>e.id===v)??g[0]??null;return(0,w.jsxs)(`div`,{"data-terminal-dock":!0,style:{height:d},"data-shell":e?`desktop`:`browser`,className:m(`z-30 flex min-h-0 shrink-0 flex-col border-t border-border/70 bg-card shadow-2xl`,e&&`ws-terminal-desktop`),children:[(0,w.jsx)(`hr`,{"aria-orientation":`horizontal`,tabIndex:0,title:i(`activity:terminal.resize`),onPointerDown:M,className:`h-1.5 cursor-ns-resize bg-muted/70 transition-colors hover:bg-primary/35 border-0`}),(0,w.jsxs)(`div`,{className:m(`flex min-w-0 items-center justify-between gap-3 border-b border-border/70 bg-card/85`,e?`px-2 py-1`:`px-3 py-1.5`),children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-foreground`,children:[(0,w.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,w.jsx)(`span`,{className:`font-medium`,children:i(e?`activity:terminal.labelSingular`:`activity:terminal.labelPlural`)}),(0,w.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:T||D||i(`activity:terminal.projectShell`)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(`button`,{type:`button`,onClick:P,disabled:g.length>=E,title:g.length>=E?i(`activity:terminal.maxTerminals`,{count:E}):i(`activity:terminal.newTerminal`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>z&&I(z.id),disabled:!z,title:i(`activity:terminal.restart`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,w.jsx)(`button`,{type:`button`,onClick:L,disabled:g.length===0,title:i(`activity:terminal.closeAll`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,w.jsx)(`button`,{type:`button`,onClick:t,title:i(`activity:terminal.closeDock`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,w.jsx)(s,{className:`h-4 w-4`})})]})]}),(0,w.jsx)(`div`,{className:m(`flex min-w-0 items-center gap-1 overflow-x-auto border-b border-border/70 bg-[hsl(var(--surface-2)/0.45)]`,e?`px-1.5 py-0.5`:`px-2 py-1`),children:g.map(t=>(0,w.jsxs)(`div`,{className:m(`group inline-flex items-center rounded border text-xs transition-colors`,e?`h-6 min-w-[92px] max-w-[148px]`:`h-7 min-w-[112px] max-w-[180px]`,v===t.id?`border-primary/35 bg-primary/10 text-primary`:`border-transparent bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,w.jsxs)(`button`,{type:`button`,onClick:()=>y(t.id),title:t.status===`exited`?`${t.name} exited`:t.name,className:`inline-flex min-w-0 flex-1 items-center gap-2 px-2 text-left`,children:[(0,w.jsx)(`span`,{className:m(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`&&`bg-success`,t.status===`starting`&&`bg-primary`,t.status===`exited`&&`bg-destructive`)}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.name,t.status===`exited`&&typeof t.exitCode==`number`?` (${t.exitCode})`:``]})]}),(0,w.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),F(t.id)},className:`mr-1 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground opacity-70 hover:bg-accent hover:text-foreground hover:opacity-100`,title:i(`activity:terminal.closeTab`,{name:t.name}),children:(0,w.jsx)(s,{className:`h-3 w-3`})})]},t.id))}),D&&!e&&(0,w.jsx)(`div`,{className:`min-w-0 truncate border-b border-border/60 bg-muted/30 px-3 py-1 text-[11px] font-mono text-muted-foreground`,children:D}),(0,w.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:g.map(e=>(0,w.jsx)(N,{id:e.id,active:e.id===v,onRunning:()=>R(e.id,{status:`running`}),onExit:t=>R(e.id,{status:`exited`,exitCode:t})},e.id))})]})}function N({id:e,active:r,onRunning:i,onExit:a}){let o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(i),u=(0,b.useRef)(a),f=n(e=>e.wsConnected),{terminal:p}=_();return(0,b.useEffect)(()=>{l.current=i,u.current=a},[a,i]),(0,b.useEffect)(()=>{let e=s.current;if(e){e.options.fontFamily===p.fontFamily&&(e.options.fontFamily=`monospace`),e.options.fontFamily=p.fontFamily,e.options.fontSize=p.fontSize,e.options.lineHeight=p.lineHeight;try{c.current?.fit()}catch{}}},[p]),(0,b.useEffect)(()=>{let r=o.current;if(!r)return;let i=new y({...g(n.getState().fonts),cursorBlink:!0,theme:T,scrollback:5e3}),a=new v;s.current=i,c.current=a,i.loadAddon(a),i.open(r);try{a.fit()}catch{}let f=t(n.getState().wsUrl);f.send({type:`terminal.create`,payload:{id:e,cols:i.cols,rows:i.rows}});let p=!1,m=f.on(`terminal.output`,t=>{t.type===`terminal.output`&&t.payload.id===e&&(p||(p=!0,l.current()),i.write(t.payload.data))}),h=f.on(`terminal.exit`,t=>{t.type===`terminal.exit`&&t.payload.id===e&&(i.write(`\r\n\x1b[2m${d.t(`activity:terminal.processExited`,{code:t.payload.exitCode})}\x1b[0m\r\n`),u.current(t.payload.exitCode))}),_=i.onData(t=>{f.send({type:`terminal.input`,payload:{id:e,data:t}})}),b=new ResizeObserver(()=>{if(r.offsetParent)try{a.fit(),f.send({type:`terminal.resize`,payload:{id:e,cols:i.cols,rows:i.rows}})}catch{}});return b.observe(r),()=>{m(),h(),_.dispose(),b.disconnect(),f.send({type:`terminal.close`,payload:{id:e}}),i.dispose(),s.current=null,c.current=null}},[e,f]),(0,b.useEffect)(()=>{r&&window.requestAnimationFrame(()=>{try{c.current?.fit();let r=s.current;r&&(t(n.getState().wsUrl).send({type:`terminal.resize`,payload:{id:e,cols:r.cols,rows:r.rows}}),r.focus())}catch{}})},[r,e]),(0,w.jsx)(`div`,{ref:o,className:m(`absolute inset-0 min-h-0 min-w-0 overflow-hidden px-2 py-1`,r?`block`:`hidden`)})}export{M as TerminalPanel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,t as n,tt as r}from"./config-store-mWuYCild.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{In as o,Mt as s,Qt as c,ln as l,qn as u,wo as d,xo as f}from"./vendor-V3ydTHqN.js";import"./i18n-CvJB4U4z.js";import{n as p,t as m}from"./utils-CKsqCaP8.js";import{n as h}from"./ui-store-DC3mkswy.js";import"./stores-D5loyGLL.js";import{w as g}from"./fonts-DRGbd-AM.js";import{m as _}from"./index-DLjaZSCH.js";import{n as v,t as y}from"./xterm-DA3G7037.js";var b=e(i(),1),x=`wrongstack.terminalDockHeight`,S=260;function C(e){let t=typeof window>`u`?640:Math.max(140,Math.min(640,Math.floor(window.innerHeight*.55),window.innerHeight-S));return Math.min(Math.max(Math.round(e),140),t)}var w=a(),T={background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,selectionBackground:`#585b70`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`},E=8;function D(e=!1){return typeof window>`u`?300:C(window.innerHeight*(e?.32:.4))}function O(e=!1){if(typeof window>`u`)return D(e);try{let t=window.localStorage.getItem(x),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)?C(n):D(e)}catch{return D(e)}}function k(e){try{window.localStorage.setItem(x,String(C(e)))}catch{}}function A(){return p()}function j(e){return{id:A(),name:`Terminal ${e}`,status:`starting`}}function M({desktopShell:e=!1,onClose:t}){let n=(0,b.useRef)(null),{t:i}=f(),a=(0,b.useRef)(1),[d,p]=(0,b.useState)(()=>O(e)),[g,_]=(0,b.useState)(()=>[j(1)]),[v,y]=(0,b.useState)(()=>g[0]?.id??``),x=h(e=>e.terminalCreateNonce),S=(0,b.useRef)(x),T=r(e=>e.projectName),D=r(e=>e.cwd);(0,b.useEffect)(()=>{let e=()=>{p(e=>{let t=C(e);return k(t),t})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let M=e=>{e.preventDefault(),n.current?.();let t=e.clientY,r=d,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=C(r+t-e.clientY);p(n),k(n)},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),n.current===s&&(n.current=null)};n.current=s,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0}),window.addEventListener(`pointercancel`,s,{once:!0})};(0,b.useEffect)(()=>()=>n.current?.(),[]);let P=()=>{if(g.length>=E)return;a.current+=1;let e=j(a.current);_([...g,e]),y(e.id)};(0,b.useEffect)(()=>{x!==S.current&&(S.current=x,P())},[x]);let F=e=>{let n=g.findIndex(t=>t.id===e);if(n===-1)return;let r=g.filter(t=>t.id!==e);if(_(r),r.length===0){queueMicrotask(t);return}v===e&&y(r[Math.max(0,n-1)]?.id??r[0]?.id??``)},I=e=>{let t=A();g.some(t=>t.id===e)&&(_(g.map(n=>n.id===e?{...n,id:t,status:`starting`,exitCode:void 0}:n)),y(t))},L=()=>{_([]),y(``),queueMicrotask(t)},R=(e,t)=>{_(n=>n.map(n=>n.id===e?{...n,...t}:n))},z=g.find(e=>e.id===v)??g[0]??null;return(0,w.jsxs)(`div`,{"data-terminal-dock":!0,style:{height:d},"data-shell":e?`desktop`:`browser`,className:m(`z-30 flex min-h-0 shrink-0 flex-col border-t border-border/70 bg-card shadow-2xl`,e&&`ws-terminal-desktop`),children:[(0,w.jsx)(`hr`,{"aria-orientation":`horizontal`,tabIndex:0,title:i(`activity:terminal.resize`),onPointerDown:M,className:`h-1.5 cursor-ns-resize bg-muted/70 transition-colors hover:bg-primary/35 border-0`}),(0,w.jsxs)(`div`,{className:m(`flex min-w-0 items-center justify-between gap-3 border-b border-border/70 bg-card/85`,e?`px-2 py-1`:`px-3 py-1.5`),children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-foreground`,children:[(0,w.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,w.jsx)(`span`,{className:`font-medium`,children:i(e?`activity:terminal.labelSingular`:`activity:terminal.labelPlural`)}),(0,w.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:T||D||i(`activity:terminal.projectShell`)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(`button`,{type:`button`,onClick:P,disabled:g.length>=E,title:g.length>=E?i(`activity:terminal.maxTerminals`,{count:E}):i(`activity:terminal.newTerminal`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>z&&I(z.id),disabled:!z,title:i(`activity:terminal.restart`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,w.jsx)(`button`,{type:`button`,onClick:L,disabled:g.length===0,title:i(`activity:terminal.closeAll`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,w.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,w.jsx)(`button`,{type:`button`,onClick:t,title:i(`activity:terminal.closeDock`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,w.jsx)(s,{className:`h-4 w-4`})})]})]}),(0,w.jsx)(`div`,{className:m(`flex min-w-0 items-center gap-1 overflow-x-auto border-b border-border/70 bg-[hsl(var(--surface-2)/0.45)]`,e?`px-1.5 py-0.5`:`px-2 py-1`),children:g.map(t=>(0,w.jsxs)(`div`,{className:m(`group inline-flex items-center rounded border text-xs transition-colors`,e?`h-6 min-w-[92px] max-w-[148px]`:`h-7 min-w-[112px] max-w-[180px]`,v===t.id?`border-primary/35 bg-primary/10 text-primary`:`border-transparent bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,w.jsxs)(`button`,{type:`button`,onClick:()=>y(t.id),title:t.status===`exited`?`${t.name} exited`:t.name,className:`inline-flex min-w-0 flex-1 items-center gap-2 px-2 text-left`,children:[(0,w.jsx)(`span`,{className:m(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`&&`bg-success`,t.status===`starting`&&`bg-primary`,t.status===`exited`&&`bg-destructive`)}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.name,t.status===`exited`&&typeof t.exitCode==`number`?` (${t.exitCode})`:``]})]}),(0,w.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),F(t.id)},className:`mr-1 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground opacity-70 hover:bg-accent hover:text-foreground hover:opacity-100`,title:i(`activity:terminal.closeTab`,{name:t.name}),children:(0,w.jsx)(s,{className:`h-3 w-3`})})]},t.id))}),D&&!e&&(0,w.jsx)(`div`,{className:`min-w-0 truncate border-b border-border/60 bg-muted/30 px-3 py-1 text-[11px] font-mono text-muted-foreground`,children:D}),(0,w.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:g.map(e=>(0,w.jsx)(N,{id:e.id,active:e.id===v,onRunning:()=>R(e.id,{status:`running`}),onExit:t=>R(e.id,{status:`exited`,exitCode:t})},e.id))})]})}function N({id:e,active:r,onRunning:i,onExit:a}){let o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(i),u=(0,b.useRef)(a),f=n(e=>e.wsConnected),{terminal:p}=_();return(0,b.useEffect)(()=>{l.current=i,u.current=a},[a,i]),(0,b.useEffect)(()=>{let e=s.current;if(e){e.options.fontFamily===p.fontFamily&&(e.options.fontFamily=`monospace`),e.options.fontFamily=p.fontFamily,e.options.fontSize=p.fontSize,e.options.lineHeight=p.lineHeight;try{c.current?.fit()}catch{}}},[p]),(0,b.useEffect)(()=>{let r=o.current;if(!r)return;let i=new y({...g(n.getState().fonts),cursorBlink:!0,theme:T,scrollback:5e3}),a=new v;s.current=i,c.current=a,i.loadAddon(a),i.open(r);try{a.fit()}catch{}let f=t(n.getState().wsUrl);f.send({type:`terminal.create`,payload:{id:e,cols:i.cols,rows:i.rows}});let p=!1,m=f.on(`terminal.output`,t=>{t.type===`terminal.output`&&t.payload.id===e&&(p||(p=!0,l.current()),i.write(t.payload.data))}),h=f.on(`terminal.exit`,t=>{t.type===`terminal.exit`&&t.payload.id===e&&(i.write(`\r\n\x1b[2m${d.t(`activity:terminal.processExited`,{code:t.payload.exitCode})}\x1b[0m\r\n`),u.current(t.payload.exitCode))}),_=i.onData(t=>{f.send({type:`terminal.input`,payload:{id:e,data:t}})}),b=new ResizeObserver(()=>{if(r.offsetParent)try{a.fit(),f.send({type:`terminal.resize`,payload:{id:e,cols:i.cols,rows:i.rows}})}catch{}});return b.observe(r),()=>{m(),h(),_.dispose(),b.disconnect(),f.send({type:`terminal.close`,payload:{id:e}}),i.dispose(),s.current=null,c.current=null}},[e,f]),(0,b.useEffect)(()=>{r&&window.requestAnimationFrame(()=>{try{c.current?.fit();let r=s.current;r&&(t(n.getState().wsUrl).send({type:`terminal.resize`,payload:{id:e,cols:r.cols,rows:r.rows}}),r.focus())}catch{}})},[r,e]),(0,w.jsx)(`div`,{ref:o,className:m(`absolute inset-0 min-h-0 min-w-0 overflow-hidden px-2 py-1`,r?`block`:`hidden`)})}export{M as TerminalPanel};