specrails-desktop 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/client/dist/assets/{ActivityFeedPage-Gy4x8dBt.js → ActivityFeedPage-CzMoyXH1.js} +1 -1
  2. package/client/dist/assets/{AgentsPage-CPgu--Fb.js → AgentsPage-ClIs2Gio.js} +1 -1
  3. package/client/dist/assets/{AnalyticsPage-B5sJEee2.js → AnalyticsPage-1oKv_dqQ.js} +1 -1
  4. package/client/dist/assets/{BarChart-7IMQ8HY1.js → BarChart-Cx2nKLkI.js} +1 -1
  5. package/client/dist/assets/{CodePage-CBdFvbwe.js → CodePage-sMBftx0a.js} +1 -1
  6. package/client/dist/assets/{DesktopAnalyticsPage-w0rdTq4w.js → DesktopAnalyticsPage-zeI2hEc4.js} +1 -1
  7. package/client/dist/assets/{DocsDialog-BZUYM7wm.js → DocsDialog-DZAg7yxC.js} +1 -1
  8. package/client/dist/assets/{DocsPage-9QglWl46.js → DocsPage-Bv5oHAxO.js} +1 -1
  9. package/client/dist/assets/{ExportDropdown-BLZFXtNi.js → ExportDropdown-lHMFeaal.js} +1 -1
  10. package/client/dist/assets/{IntegrationsPage-BxBE4y99.js → IntegrationsPage-WQ2Tzm5R.js} +1 -1
  11. package/client/dist/assets/{JobDetailPage-DydWx_5S.js → JobDetailPage-D59Uhx1u.js} +1 -1
  12. package/client/dist/assets/{JobsPage-20ibw0IO.js → JobsPage-CF03VyL2.js} +1 -1
  13. package/client/dist/assets/{dist-js-BY-Fv_fg.js → dist-js-DAazzqbg.js} +1 -1
  14. package/client/dist/assets/{dist-js-Bakc4uxT.js → dist-js-DM8sRRAb.js} +1 -1
  15. package/client/dist/assets/{index-XGZaKl_u.js → index-D_VMXR78.js} +45 -45
  16. package/client/dist/assets/{lib-CPxTMOAq.js → lib-pFaBHHQU.js} +1 -1
  17. package/client/dist/assets/{settings-D3e_bDoW.js → settings-BSze3_9q.js} +1 -1
  18. package/client/dist/assets/{settings-nu68QukM.js → settings-Bg0A3zoS.js} +1 -1
  19. package/client/dist/assets/{settings-Dxpo6_w7.js → settings-BgPqg2nv.js} +1 -1
  20. package/client/dist/assets/{settings-Bd4Tq1RB.js → settings-CSJ0ahZ8.js} +1 -1
  21. package/client/dist/assets/{settings-DKbTkbn7.js → settings-CTcwN9RE.js} +1 -1
  22. package/client/dist/assets/{settings-bt84e3Aa.js → settings-DDcfx_ca.js} +1 -1
  23. package/client/dist/assets/{settings-CCSM-Fhn.js → settings-DYIV89nV.js} +1 -1
  24. package/client/dist/assets/{settings-55oDcbSh.js → settings-D_dujJZI.js} +1 -1
  25. package/client/dist/assets/setup--FMCsnQS.js +1 -0
  26. package/client/dist/assets/setup-B19ZpBNi.js +1 -0
  27. package/client/dist/assets/setup-BZPmkjSN.js +1 -0
  28. package/client/dist/assets/setup-BqYA02rS.js +1 -0
  29. package/client/dist/assets/setup-ChKQDHN9.js +1 -0
  30. package/client/dist/assets/setup-D2n9jMfM.js +1 -0
  31. package/client/dist/assets/setup-P3r6YP1D.js +1 -0
  32. package/client/dist/assets/setup-fnfEbwlv.js +1 -0
  33. package/client/dist/assets/{useProjectCache-DSaiGFjV.js → useProjectCache-CqO7QEtg.js} +1 -1
  34. package/client/dist/index.html +3 -3
  35. package/package.json +1 -1
  36. package/client/dist/assets/setup-BMqwfbW9.js +0 -1
  37. package/client/dist/assets/setup-Bb5LcG28.js +0 -1
  38. package/client/dist/assets/setup-BeEx2_da.js +0 -1
  39. package/client/dist/assets/setup-CCCrB53Q.js +0 -1
  40. package/client/dist/assets/setup-CJA0ATmd.js +0 -1
  41. package/client/dist/assets/setup-CeiDbZcb.js +0 -1
  42. package/client/dist/assets/setup-Cus7TApA.js +0 -1
  43. package/client/dist/assets/setup-D9qOs2Xo.js +0 -1
@@ -1,3 +1,3 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{H as t,K as n,Mt as r,N as i,Nt as a,P as o,Yt as s,at as c,bt as l,jt as u,ot as d,qt as f,tn as p,tt as m}from"./index-XGZaKl_u.js";import{t as h}from"./useProjectCache-DSaiGFjV.js";var g=e(p(),1),_=r();function v(){let{t:e}=f(`integrations`),{activeProjectId:n}=l(),{registerHandler:r,unregisterHandler:o}=u(),s=(0,g.useRef)(n);(0,g.useEffect)(()=>{s.current=n},[n]);let[c,d]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),{data:v,isLoading:b,isFirstLoad:x,refresh:S}=h({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,g.useCallback)(async()=>{let e=await fetch(`${a()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,g.useEffect)(()=>(r(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==s.current||t.type.startsWith(`plugin.`)&&S())}),()=>o(`integrations-page`)),[r,o,S]),(0,g.useEffect)(()=>{d(!b&&!v?`Failed to load plugins`:null)},[b,v]);let C=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status!==`orphan`),[v]),T=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status===`orphan`),[v]);return n?(0,_.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,_.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-4 h-4 text-accent-primary`}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,_.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&b?(0,_.jsx)(O,{}):c?(0,_.jsx)(k,{onRetry:S}):(v?.length??0)===0?(0,_.jsx)(A,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,_.jsx)(y,{plugin:e,isInstalling:p===e.name,onInstall:()=>m(e.name),onCloseInstall:()=>{m(null),S()}},e.name))}),T.length>0&&(0,_.jsxs)(`div`,{className:`mt-10`,children:[(0,_.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:T.map(e=>(0,_.jsx)(w,{plugin:e,onRemoved:S},e.name))})]})]})})]}):(0,_.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function y({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:a}=f(`integrations`),[l,u]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3`,children:[(0,_.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,_.jsx)(d,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,_.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,_.jsx)(i,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,_.jsx)(m,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,_.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,_.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,_.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,_.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,_.jsx)(s,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,_.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,_.jsx)(C,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,_.jsx)(x,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,_.jsx)(S,{pluginName:e.name}),(0,_.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b,{pluginName:e.name,active:e.status===`installed`}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,_.jsx)(T,{pluginName:e.name,onClose:r}),l&&(0,_.jsx)(E,{pluginName:e.name,onClose:()=>u(!1),onUninstalled:()=>{u(!1)}})]})}function b({pluginName:e,active:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),s(null);try{let n=`${a()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){s(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,_.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),o&&(0,_.jsx)(`span`,{className:`text-[10px] text-destructive`,children:o})]})}function x({keys:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,_.jsx)(`strong`,{}),code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,_.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,_.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function S({pluginName:e}){let{t}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(m,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`update.body`,components:{code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),c(null);try{let t=await fetch(`${a()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){c(e.message)}finally{i(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[r&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t,i18nKey:`update.button`,components:{code:(0,_.jsx)(`code`,{})}})]}),o&&(0,_.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function C({pluginName:e,conflicts:t}){let{t:r}=f(`integrations`),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=async e=>{c(e),u(null);try{let t=await fetch(`${a()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){u(e.message)}finally{c(null)}};return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,_.jsx)(`strong`,{})}})})]}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:o===e,onClick:()=>d(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 hover:bg-yellow-500/10 disabled:opacity-50 flex items-center gap-1`,children:[o===e&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,_.jsx)(`code`,{})}})]},e))}),l&&(0,_.jsx)(`div`,{className:`text-destructive`,children:l})]})}function w({plugin:e,onRemoved:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 bg-yellow-500/5 p-4 flex flex-col gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-500`,children:n(`orphan.badge`)})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${a()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function T({pluginName:e,onClose:t}){let{t:r}=f(`integrations`),[o,s]=(0,g.useState)(null),[l,p]=(0,g.useState)(null),[h,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)([]),{registerHandler:O,unregisterHandler:k}=u(),A=(0,g.useCallback)(()=>{s(null),p(null),fetch(`${a()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>s(e)).catch(e=>p(e.message))},[e]);(0,g.useEffect)(()=>{A()},[A]),(0,g.useEffect)(()=>(O(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&E(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){w(null);let e=n.reason;e&&E(t=>[...t,`► ${e}`]),n.ok&&A()}}),()=>k(`install-${e}`)),[e,O,k,A]);let j=async e=>{w(e),E([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${a()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){E(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),w(null)}},M=(o?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,_.jsxs)(D,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),!o&&!l&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),o&&(0,_.jsxs)(_.Fragment,{children:[o.platformNote&&(0,_.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 bg-yellow-500/5 text-[11px] leading-relaxed`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:o.platformNote})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:o.files.map((e,t)=>(0,_.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),o.requirements.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-1`,children:o.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,_.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,_.jsx)(d,{className:`w-3 h-3 text-accent-success`}):(0,_.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,_.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&i&&(0,_.jsxs)(`button`,{type:`button`,disabled:C===e.name,onClick:()=>j(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[C===e.name&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),T.length>0&&(0,_.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:T.join(`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{H as t,K as n,Mt as r,N as i,Nt as a,P as o,Yt as s,at as c,bt as l,jt as u,ot as d,qt as f,tn as p,tt as m}from"./index-D_VMXR78.js";import{t as h}from"./useProjectCache-CqO7QEtg.js";var g=e(p(),1),_=r();function v(){let{t:e}=f(`integrations`),{activeProjectId:n}=l(),{registerHandler:r,unregisterHandler:o}=u(),s=(0,g.useRef)(n);(0,g.useEffect)(()=>{s.current=n},[n]);let[c,d]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),{data:v,isLoading:b,isFirstLoad:x,refresh:S}=h({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,g.useCallback)(async()=>{let e=await fetch(`${a()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,g.useEffect)(()=>(r(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==s.current||t.type.startsWith(`plugin.`)&&S())}),()=>o(`integrations-page`)),[r,o,S]),(0,g.useEffect)(()=>{d(!b&&!v?`Failed to load plugins`:null)},[b,v]);let C=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status!==`orphan`),[v]),T=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status===`orphan`),[v]);return n?(0,_.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,_.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-4 h-4 text-accent-primary`}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,_.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&b?(0,_.jsx)(O,{}):c?(0,_.jsx)(k,{onRetry:S}):(v?.length??0)===0?(0,_.jsx)(A,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,_.jsx)(y,{plugin:e,isInstalling:p===e.name,onInstall:()=>m(e.name),onCloseInstall:()=>{m(null),S()}},e.name))}),T.length>0&&(0,_.jsxs)(`div`,{className:`mt-10`,children:[(0,_.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:T.map(e=>(0,_.jsx)(w,{plugin:e,onRemoved:S},e.name))})]})]})})]}):(0,_.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function y({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:a}=f(`integrations`),[l,u]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3`,children:[(0,_.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,_.jsx)(d,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,_.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,_.jsx)(i,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,_.jsx)(m,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,_.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,_.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,_.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,_.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,_.jsx)(s,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,_.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,_.jsx)(C,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,_.jsx)(x,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,_.jsx)(S,{pluginName:e.name}),(0,_.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b,{pluginName:e.name,active:e.status===`installed`}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,_.jsx)(T,{pluginName:e.name,onClose:r}),l&&(0,_.jsx)(E,{pluginName:e.name,onClose:()=>u(!1),onUninstalled:()=>{u(!1)}})]})}function b({pluginName:e,active:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),s(null);try{let n=`${a()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){s(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,_.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),o&&(0,_.jsx)(`span`,{className:`text-[10px] text-destructive`,children:o})]})}function x({keys:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,_.jsx)(`strong`,{}),code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,_.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,_.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function S({pluginName:e}){let{t}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(m,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`update.body`,components:{code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),c(null);try{let t=await fetch(`${a()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){c(e.message)}finally{i(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[r&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t,i18nKey:`update.button`,components:{code:(0,_.jsx)(`code`,{})}})]}),o&&(0,_.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function C({pluginName:e,conflicts:t}){let{t:r}=f(`integrations`),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=async e=>{c(e),u(null);try{let t=await fetch(`${a()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){u(e.message)}finally{c(null)}};return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,_.jsx)(`strong`,{})}})})]}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:o===e,onClick:()=>d(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 hover:bg-yellow-500/10 disabled:opacity-50 flex items-center gap-1`,children:[o===e&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,_.jsx)(`code`,{})}})]},e))}),l&&(0,_.jsx)(`div`,{className:`text-destructive`,children:l})]})}function w({plugin:e,onRemoved:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 bg-yellow-500/5 p-4 flex flex-col gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-500`,children:n(`orphan.badge`)})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${a()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function T({pluginName:e,onClose:t}){let{t:r}=f(`integrations`),[o,s]=(0,g.useState)(null),[l,p]=(0,g.useState)(null),[h,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)([]),{registerHandler:O,unregisterHandler:k}=u(),A=(0,g.useCallback)(()=>{s(null),p(null),fetch(`${a()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>s(e)).catch(e=>p(e.message))},[e]);(0,g.useEffect)(()=>{A()},[A]),(0,g.useEffect)(()=>(O(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&E(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){w(null);let e=n.reason;e&&E(t=>[...t,`► ${e}`]),n.ok&&A()}}),()=>k(`install-${e}`)),[e,O,k,A]);let j=async e=>{w(e),E([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${a()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){E(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),w(null)}},M=(o?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,_.jsxs)(D,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),!o&&!l&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),o&&(0,_.jsxs)(_.Fragment,{children:[o.platformNote&&(0,_.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 bg-yellow-500/5 text-[11px] leading-relaxed`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:o.platformNote})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:o.files.map((e,t)=>(0,_.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),o.requirements.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-1`,children:o.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,_.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,_.jsx)(d,{className:`w-3 h-3 text-accent-success`}):(0,_.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,_.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&i&&(0,_.jsxs)(`button`,{type:`button`,disabled:C===e.name,onClick:()=>j(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[C===e.name&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),T.length>0&&(0,_.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:T.join(`
2
2
  `)})]}),x.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,_.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:x.join(`
3
3
  `)})]}),y&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:y})]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,_.jsxs)(`button`,{type:`button`,disabled:!o||!M||h,onClick:async()=>{v(!0),b(null);try{let n=await fetch(`${a()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){b(e.message)}finally{v(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[h?(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}):(0,_.jsx)(m,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function E({pluginName:e,onClose:t,onUninstalled:r}){let{t:i}=f(`integrations`),[o,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(null);return(0,_.jsxs)(D,{onClose:t,title:i(`uninstallDialog.title`,{name:e}),children:[(0,_.jsx)(`p`,{className:`text-xs`,children:(0,_.jsx)(s,{t:i,i18nKey:`uninstallDialog.body`,components:{code:(0,_.jsx)(`code`,{})}})}),l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:i(`common:actions.cancel`)}),(0,_.jsxs)(`button`,{type:`button`,disabled:o,onClick:async()=>{c(!0);try{let t=await fetch(`${a()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);r()}catch(e){u(e.message)}finally{c(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[o&&(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),i(`card.uninstall`)]})]})]})}function D({title:e,onClose:t,children:n}){return(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:t,children:(0,_.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),n]})})}function O(){return(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,_.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function k({onRetry:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,_.jsx)(i,{className:`w-5 h-5 text-destructive`}),(0,_.jsx)(`p`,{children:t(`page.loadError`)}),(0,_.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function A(){let{t:e}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(t,{className:`w-6 h-6`}),(0,_.jsx)(`p`,{children:e(`page.empty`)})]})}export{v as default};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{A as t,B as n,K as r,Kt as i,L as a,Mt as o,Nt as s,O as c,Qt as l,St as u,Xt as d,Zt as f,_ as p,a as m,at as h,bt as g,c as _,ct as v,d as y,f as b,it as x,jt as S,k as C,l as w,lt as T,nt as E,ot as D,qt as O,tn as k,tt as A,ut as j,v as M,vt as N,xt as ee,y as P}from"./index-XGZaKl_u.js";import{t as F}from"./lib-CPxTMOAq.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=N(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),I=e(k(),1),L=o();function re({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,L.jsx)(`div`,{className:`flex items-center`,children:n.map((r,i)=>{let a=e[r.key]??`idle`,o=i<n.length-1?e[n[i+1].key]??`idle`:null;return(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,L.jsx)(R,{state:a}),(0,L.jsx)(`span`,{className:t(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:r.label})]})}),(0,L.jsxs)(M,{side:`bottom`,className:`max-w-[200px]`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,L.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),o!==null&&(0,L.jsx)(`div`,{className:t(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},r.key)})})}function R({state:e}){return(0,L.jsxs)(`div`,{className:t(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,L.jsx)(r,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,L.jsx)(D,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,L.jsx)(h,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,L.jsx)(x,{className:`w-6 h-6 text-muted-foreground/20`})]})}function z(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function B(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var V={turns:0,tokens:0,lastSeenIdx:0};function H(e,t){if(t.type===`reset`)return V;if(t.type===`consume`){let{events:n}=t;if(n.length<=e.lastSeenIdx)return e;let{turns:r,tokens:i}=e;for(let t=e.lastSeenIdx;t<n.length;t++){let e=n[t];if(e.event_type===`assistant`){r+=1;try{let t=JSON.parse(e.payload)?.message?.usage,n=e=>typeof e==`number`?e:0;i+=n(t?.input_tokens)+n(t?.output_tokens)+n(t?.cache_read_input_tokens)+n(t?.cache_creation_input_tokens)}catch{}}}return{turns:r,tokens:i,lastSeenIdx:n.length}}return e}var U=new Set([`completed`,`failed`,`canceled`,`zombie_terminated`,`skipped`]);function ie({job:e,events:n,defaultOpen:i=!0,pipelineTotals:a}){let{t:o}=O(`jobs`),[s,c]=(0,I.useState)(i),l=(0,I.useMemo)(()=>B(n),[n]),u=e.status===`running`,d=e.status===`completed`,f=U.has(e.status),[p,m]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[g,_]=(0,I.useReducer)(H,V),v=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:n})},[e.id,n]);let y=e.num_turns??(f?null:g.turns),b=e.tokens_in==null?f?null:g.tokens:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),x=e.tokens_in==null&&!f&&b!=null,S=e.num_turns==null&&!f&&y!=null,C=e.finished_at?z(e.started_at,e.finished_at):u?z(e.started_at,p):`—`,w=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),T=u?`border-accent-info/20 bg-accent-info/5`:d?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`,E=u?r:d?D:h,k=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`w-4 h-4 text-emerald-400 shrink-0`:`w-4 h-4 text-red-400 shrink-0`,A=!!e.total_cost_usd_estimated,M=e.total_cost_usd==null?`—`:`${A?`~`:``}$${e.total_cost_usd.toFixed(4)}`,N=e.total_cost_usd==null;return(0,L.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border`,T),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(E,{className:k,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:w}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:C}),N?(0,L.jsx)(`span`,{className:`tabular-nums`,children:`—`}):(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400`,children:M}),l.length>0&&(0,L.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:l.length})})]}),(0,L.jsx)(j,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,L.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,L.jsx)(W,{label:o(`statusPanel.duration`),value:C}),(0,L.jsx)(W,{label:o(`statusPanel.cost`),value:M,valueClass:N?`text-muted-foreground`:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.turns`),value:y==null?`—`:`${S?`~`:``}${y}`}),(0,L.jsx)(W,{label:o(`statusPanel.tokens`),value:b==null?`—`:`${x?`~`:``}${(b/1e3).toFixed(1)}k`})]}),a&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:a.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(W,{label:o(`statusPanel.totalCost`),value:`$${a.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.totalTokens`),value:`${((a.totalTokensIn+a.totalTokensOut+a.totalTokensCacheRead+a.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),l.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,L.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})]})}function W({label:e,value:n,valueClass:r}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}var G=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=O(`jobs`),[r,i]=(0,I.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,L.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,L.jsx)(K,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,L.jsx)(j,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,L.jsx)(v,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:n}){let{t:r}=O(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:t(a,`text-muted-foreground bg-muted/20 select-none`),title:r(`ticketHeader.deletedTooltip`),children:r(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,L.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,L.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function q(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function J(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:q(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(u.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${u.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function Y(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function X(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function oe({events:e,isLoading:t}){let{t:n,i18n:r}=O(`jobs`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(!0),[u,d]=(0,I.useState)(new Set),f=(0,I.useRef)(null),p=(0,I.useRef)(null),{processedLines:h,groups:g,totalLines:_}=(0,I.useMemo)(()=>{let t=e.map((e,t)=>J(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{A as t,B as n,K as r,Kt as i,L as a,Mt as o,Nt as s,O as c,Qt as l,St as u,Xt as d,Zt as f,_ as p,a as m,at as h,bt as g,c as _,ct as v,d as y,f as b,it as x,jt as S,k as C,l as w,lt as T,nt as E,ot as D,qt as O,tn as k,tt as A,ut as j,v as M,vt as N,xt as ee,y as P}from"./index-D_VMXR78.js";import{t as F}from"./lib-pFaBHHQU.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=N(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),I=e(k(),1),L=o();function re({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,L.jsx)(`div`,{className:`flex items-center`,children:n.map((r,i)=>{let a=e[r.key]??`idle`,o=i<n.length-1?e[n[i+1].key]??`idle`:null;return(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,L.jsx)(R,{state:a}),(0,L.jsx)(`span`,{className:t(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:r.label})]})}),(0,L.jsxs)(M,{side:`bottom`,className:`max-w-[200px]`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,L.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),o!==null&&(0,L.jsx)(`div`,{className:t(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},r.key)})})}function R({state:e}){return(0,L.jsxs)(`div`,{className:t(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,L.jsx)(r,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,L.jsx)(D,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,L.jsx)(h,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,L.jsx)(x,{className:`w-6 h-6 text-muted-foreground/20`})]})}function z(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function B(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var V={turns:0,tokens:0,lastSeenIdx:0};function H(e,t){if(t.type===`reset`)return V;if(t.type===`consume`){let{events:n}=t;if(n.length<=e.lastSeenIdx)return e;let{turns:r,tokens:i}=e;for(let t=e.lastSeenIdx;t<n.length;t++){let e=n[t];if(e.event_type===`assistant`){r+=1;try{let t=JSON.parse(e.payload)?.message?.usage,n=e=>typeof e==`number`?e:0;i+=n(t?.input_tokens)+n(t?.output_tokens)+n(t?.cache_read_input_tokens)+n(t?.cache_creation_input_tokens)}catch{}}}return{turns:r,tokens:i,lastSeenIdx:n.length}}return e}var U=new Set([`completed`,`failed`,`canceled`,`zombie_terminated`,`skipped`]);function ie({job:e,events:n,defaultOpen:i=!0,pipelineTotals:a}){let{t:o}=O(`jobs`),[s,c]=(0,I.useState)(i),l=(0,I.useMemo)(()=>B(n),[n]),u=e.status===`running`,d=e.status===`completed`,f=U.has(e.status),[p,m]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[g,_]=(0,I.useReducer)(H,V),v=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:n})},[e.id,n]);let y=e.num_turns??(f?null:g.turns),b=e.tokens_in==null?f?null:g.tokens:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),x=e.tokens_in==null&&!f&&b!=null,S=e.num_turns==null&&!f&&y!=null,C=e.finished_at?z(e.started_at,e.finished_at):u?z(e.started_at,p):`—`,w=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),T=u?`border-accent-info/20 bg-accent-info/5`:d?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`,E=u?r:d?D:h,k=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`w-4 h-4 text-emerald-400 shrink-0`:`w-4 h-4 text-red-400 shrink-0`,A=!!e.total_cost_usd_estimated,M=e.total_cost_usd==null?`—`:`${A?`~`:``}$${e.total_cost_usd.toFixed(4)}`,N=e.total_cost_usd==null;return(0,L.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border`,T),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(E,{className:k,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:w}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:C}),N?(0,L.jsx)(`span`,{className:`tabular-nums`,children:`—`}):(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400`,children:M}),l.length>0&&(0,L.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:l.length})})]}),(0,L.jsx)(j,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,L.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,L.jsx)(W,{label:o(`statusPanel.duration`),value:C}),(0,L.jsx)(W,{label:o(`statusPanel.cost`),value:M,valueClass:N?`text-muted-foreground`:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.turns`),value:y==null?`—`:`${S?`~`:``}${y}`}),(0,L.jsx)(W,{label:o(`statusPanel.tokens`),value:b==null?`—`:`${x?`~`:``}${(b/1e3).toFixed(1)}k`})]}),a&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:a.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(W,{label:o(`statusPanel.totalCost`),value:`$${a.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.totalTokens`),value:`${((a.totalTokensIn+a.totalTokensOut+a.totalTokensCacheRead+a.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),l.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,L.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})]})}function W({label:e,value:n,valueClass:r}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}var G=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=O(`jobs`),[r,i]=(0,I.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,L.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,L.jsx)(K,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,L.jsx)(j,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,L.jsx)(v,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:n}){let{t:r}=O(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:t(a,`text-muted-foreground bg-muted/20 select-none`),title:r(`ticketHeader.deletedTooltip`),children:r(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,L.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,L.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function q(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function J(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:q(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(u.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${u.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function Y(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function X(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function oe({events:e,isLoading:t}){let{t:n,i18n:r}=O(`jobs`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(!0),[u,d]=(0,I.useState)(new Set),f=(0,I.useRef)(null),p=(0,I.useRef)(null),{processedLines:h,groups:g,totalLines:_}=(0,I.useMemo)(()=>{let t=e.map((e,t)=>J(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
2
2
  `+e.content:n.push({...e})}let r=Y(n);return{processedLines:r,groups:X(r),totalLines:r.length}},[e,r.language]),v=(0,I.useMemo)(()=>{if(!o)return _;let e=o.toLowerCase();return h.filter(t=>t.content.toLowerCase().includes(e)).length},[o,h,_]),y=(0,I.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,I.useEffect)(()=>{c&&y()},[e.length,c,y]);function b(){let e=p.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function x(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.loading`)})}):_===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.empty`)})}):(0,L.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,L.jsx)(a,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,L.jsx)(m,{placeholder:n(`logViewer.filterPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`pl-7 h-7`})]}),(0,L.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=h.map(e=>e.content).join(`
3
3
  `);navigator.clipboard.writeText(e).then(()=>{i.success(n(`logViewer.copySuccess`))}).catch(()=>{i.error(n(`logViewer.copyFailed`))})},children:(0,L.jsx)(E,{className:`w-3.5 h-3.5`})}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`logViewer.lineCount`,{filtered:v,total:_})})]}),(0,L.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:b,children:[g.map(e=>(0,L.jsx)(Z,{group:e,filter:o,collapsed:u.has(e.key),onToggle:()=>x(e.key)},e.key)),(0,L.jsx)(`div`,{ref:f})]}),!c&&(0,L.jsxs)(C,{size:`sm`,variant:`secondary`,onClick:()=>{l(!0),y()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,L.jsx)(j,{className:`w-3 h-3`}),n(`logViewer.jumpToBottom`)]})]})}var Z=(0,I.memo)(function({group:e,filter:n,collapsed:r,onToggle:i}){let{t:a}=O(`jobs`),o=n?e.lines.filter(e=>e.content.toLowerCase().includes(n.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,L.jsx)(`div`,{children:o.map((e,t)=>(0,L.jsx)($,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,L.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:i,className:t(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,L.jsx)(T,{className:t(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!r&&`rotate-90`)}),(0,L.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!r&&(0,L.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,L.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(n?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,L.jsx)($,{line:e,even:t%2==0},e.id))})]})}),Q=[F],$=(0,I.memo)(function({line:e,even:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`;return(0,L.jsxs)(`div`,{className:t(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(i||a||o||s)&&(n?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 border-l-2 border-emerald-500/40 mt-2 py-2`,i&&`bg-emerald-500/8 border-l-2 border-emerald-500/50`,a&&`bg-red-500/8 border-l-2 border-red-500/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),r?(0,L.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
4
4
  prose-p:my-1 prose-p:leading-relaxed
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{C as t,Kt as n,M as r,Mt as i,Nt as a,O as o,P as s,S as c,T as l,Zt as u,_ as d,at as f,b as p,bt as m,d as ee,f as h,k as g,l as _,ot as v,q as y,qt as b,rt as x,t as S,tn as C,v as w,vt as T,w as E,x as D,xt as O,y as k}from"./index-XGZaKl_u.js";import{t as A}from"./ExportDropdown-BLZFXtNi.js";import{t as j}from"./useProjectCache-DSaiGFjV.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=T(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),M=e(C(),1),N=i();function P(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function F(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function I(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function L({label:e,a:t,b:n,highlight:r}){return(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function R(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function re({jobIds:e,onClose:t}){let{t:n}=b(`jobs`),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(!0),[l,u]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=new AbortController;return fetch(`${a()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),c(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),c(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,N.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,N.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,N.jsx)(v,{className:`w-3 h-3 text-emerald-400`}):(0,N.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,N.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,N.jsx)(r,{className:`w-4 h-4`})})]}),s&&(0,N.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,N.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,N.jsx)(`p`,{className:`text-xs text-red-400`,children:n(`comparison.loadFailed`,{error:l})}),i&&(()=>{let[e,t]=i.jobs,r=R(e.durationMs,t.durationMs,!0),a=R(e.totalCostUsd,t.totalCostUsd,!0),o=R(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,N.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,N.jsx)(L,{label:n(`comparison.duration`),a:P(e.durationMs),b:P(t.durationMs),highlight:r}),(0,N.jsx)(L,{label:n(`comparison.cost`),a:F(e.totalCostUsd),b:F(t.totalCostUsd),highlight:a}),(0,N.jsx)(L,{label:n(`comparison.tokensOut`),a:I(e.tokensOut),b:I(t.tokensOut),highlight:o}),(0,N.jsx)(L,{label:n(`comparison.tokensIn`),a:I(e.tokensIn),b:I(t.tokensIn),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.cacheRead`),a:I(e.tokensCacheRead),b:I(t.tokensCacheRead),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,N.jsx)(L,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),i&&(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]})})}var ie={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ae=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],oe={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,labelKey:`recent.priority.low`}};function se(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ce(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function le(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ue(e){try{return _(new Date(e),{addSuffix:!0,locale:O()})}catch{return e}}var z=10;function B({jobs:e,isLoading:r,onJobsCleared:i,onProposalClick:f,onProposalDelete:ee}){let{t:h}=b(`jobs`),_=u(),{activeProjectId:v,projects:S}=m(),C=S.find(e=>e.id===v)?.provider,[T,O]=(0,M.useState)(null),[A,j]=(0,M.useState)(``),[P,F]=(0,M.useState)(``),[I,L]=(0,M.useState)(!1),[R,B]=(0,M.useState)(``),[V,H]=(0,M.useState)(``),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(null),[q,J]=(0,M.useState)(z),[Y,de]=(0,M.useState)(!1),[X,Z]=(0,M.useState)([]),[fe,Q]=(0,M.useState)(null);(0,M.useEffect)(()=>{J(z)},[e.length]);function pe(){de(e=>!e),Z([])}function me(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(T&&e.status!==T||A&&e.started_at<A||P&&e.started_at>`${P}T23:59:59`)),he=e.filter(e=>!(R&&e.started_at<R||V&&e.started_at>`${V}T23:59:59`)).length;async function ge(e){W(!0);try{let t={};e===`range`&&(R&&(t.from=R),V&&(t.to=V));let r=await fetch(`${a()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();n.success(h(`recent.toast.cleared`,{count:e.deleted})),L(!1),B(``),H(``),i?.()}else n.error(h(`recent.toast.clearFailed`))}catch{n.error(h(`recent.toast.networkError`))}finally{W(!1)}}return r?(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,N.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,N.jsx)(x,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,N.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:h(`recent.emptyTitle`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:h(`recent.emptyDescription`)})]}):(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterAll`,{count:e.length})}),ae.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterStatus`,{status:h(`statusName.${t}`),count:n})},t)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.fromDate`)}),(0,N.jsx)(`input`,{type:`date`,value:P,onChange:e=>F(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.toDate`)}),(A||P)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{j(``),F(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:h(`recent.clear`)}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:pe,children:(0,N.jsx)(ne,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>L(!0),children:(0,N.jsx)(s,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(`recent.clearJobs`)})]})]})]}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,N.jsxs)(`span`,{children:[X.length===0&&h(`recent.selectTwoToCompare`),X.length===1&&h(`recent.selectOneMore`),X.length===2&&h(`recent.readyToCompare`)]}),X.length===2&&(0,N.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:h(`recent.compareAction`)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,N.jsx)(`span`,{className:`w-14`,children:h(`recent.colStatus`)}),(0,N.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`recent.colCommand`)}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:h(`recent.colDuration`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colTokens`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colCost`)}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:h(`recent.colStarted`)})]})]}),(0,N.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,q).map(e=>{let t=ie[e.status]??ie.queued,n=se(e.total_cost_usd),r=ce(e.started_at,e.finished_at),i=le((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),c=a?e.id.replace(`proposal:`,``):null,l=X.includes(e.id),u=Y&&!a&&X.length===2&&!l;return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(Y&&!a){me(e.id);return}a&&c?f?.(c):_(`/jobs/${e.id}`)},children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`div`,{children:(0,N.jsx)(o,{variant:t.variant,children:h(t.labelKey)})})}),(0,N.jsx)(w,{children:h(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${oe[e.priority].className}`,children:h(oe[e.priority].labelKey)}),e.profile_name&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,N.jsx)(w,{children:h(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(y,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,N.jsxs)(w,{children:[h(`recent.pipelinePart`),e.depends_on_job_id&&` ${h(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,N.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:te(e.command,C)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:ue(e.started_at)}),a&&c&&(0,N.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),K(c)},title:h(`recent.deleteProposal`),children:(0,N.jsx)(s,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>q&&(0,N.jsx)(`div`,{className:`pt-1 text-center`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>J(e=>e+z),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:h(`recent.loadMore`,{count:$.length-q})})}),I&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>L(!1),children:(0,N.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:h(`recent.clearModal.title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:h(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:U,onClick:()=>ge(`all`),children:h(`recent.clearModal.clearAll`,{count:e.length})}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`recent.clearModal.orByRange`)}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:R,onChange:e=>B(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.fromPlaceholder`)}),(0,N.jsx)(`input`,{type:`date`,value:V,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.toPlaceholder`)})]}),(0,N.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:U||!R&&!V,onClick:()=>ge(`range`),children:R||V?h(`recent.clearModal.clearInRange`,{count:he}):h(`recent.clearModal.clearRange`)})]}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>L(!1),children:h(`common:actions.cancel`)})]})}),(0,N.jsx)(p,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,N.jsxs)(D,{className:`max-w-sm`,children:[(0,N.jsxs)(E,{children:[(0,N.jsx)(l,{children:h(`recent.deleteProposalConfirm.title`)}),(0,N.jsx)(c,{children:h(`recent.deleteProposalConfirm.description`)})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:h(`common:actions.cancel`)}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&ee?.(G),K(null)},children:h(`common:actions.delete`)})]})]})}),fe&&(0,N.jsx)(re,{jobIds:fe,onClose:()=>{Q(null),Z([]),de(!1)}})]})}function V(){let{t:e}=b(`jobs`),{activeProjectId:r}=m(),{recentJobs:i}=S(r),{data:s,isFirstLoad:c,refresh:u}=j({namespace:`jobs`,projectId:r,initialValue:i,fetcher:async()=>{let e=await fetch(`${a()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:d}=j({namespace:`proposals`,projectId:r,initialValue:[],fetcher:async()=>{let e=await fetch(`${a()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),f={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},_=d.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:f[e.status]??`queued`})),v=[...s,..._].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,x]=(0,M.useState)(null),C=(0,M.useCallback)(async e=>{try{let t=await fetch(`${a()}/propose/${e}`);if(!t.ok)return;x((await t.json()).proposal)}catch{}},[]),w=(0,M.useCallback)(async t=>{try{(await fetch(`${a()}/propose/${t}`,{method:`DELETE`})).ok&&(n.success(e(`page.proposalDeleted`)),u())}catch{}},[u,e]);return(0,N.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,N.jsx)(A,{baseUrl:`${a()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,N.jsx)(B,{jobs:v,isLoading:c,onJobsCleared:u,onProposalClick:C,onProposalDelete:w}),(0,N.jsx)(p,{open:y!==null,onOpenChange:e=>!e&&x(null),children:(0,N.jsx)(D,{className:`max-w-3xl glass-card`,children:y&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(l,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,N.jsx)(o,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,N.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,N.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,N.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,N.jsx)(h,{remarkPlugins:[ee],children:y.result_markdown})})}):(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,N.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,N.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{w(y.id),x(null)},children:e(`common:actions.delete`)}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>x(null),children:e(`common:actions.close`)})]})]})})})]})}export{V as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{C as t,Kt as n,M as r,Mt as i,Nt as a,O as o,P as s,S as c,T as l,Zt as u,_ as d,at as f,b as p,bt as m,d as ee,f as h,k as g,l as _,ot as v,q as y,qt as b,rt as x,t as S,tn as C,v as w,vt as T,w as E,x as D,xt as O,y as k}from"./index-D_VMXR78.js";import{t as A}from"./ExportDropdown-lHMFeaal.js";import{t as j}from"./useProjectCache-CqO7QEtg.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=T(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),M=e(C(),1),N=i();function P(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function F(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function I(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function L({label:e,a:t,b:n,highlight:r}){return(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function R(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function re({jobIds:e,onClose:t}){let{t:n}=b(`jobs`),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(!0),[l,u]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=new AbortController;return fetch(`${a()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),c(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),c(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,N.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,N.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,N.jsx)(v,{className:`w-3 h-3 text-emerald-400`}):(0,N.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,N.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,N.jsx)(r,{className:`w-4 h-4`})})]}),s&&(0,N.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,N.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,N.jsx)(`p`,{className:`text-xs text-red-400`,children:n(`comparison.loadFailed`,{error:l})}),i&&(()=>{let[e,t]=i.jobs,r=R(e.durationMs,t.durationMs,!0),a=R(e.totalCostUsd,t.totalCostUsd,!0),o=R(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,N.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,N.jsx)(L,{label:n(`comparison.duration`),a:P(e.durationMs),b:P(t.durationMs),highlight:r}),(0,N.jsx)(L,{label:n(`comparison.cost`),a:F(e.totalCostUsd),b:F(t.totalCostUsd),highlight:a}),(0,N.jsx)(L,{label:n(`comparison.tokensOut`),a:I(e.tokensOut),b:I(t.tokensOut),highlight:o}),(0,N.jsx)(L,{label:n(`comparison.tokensIn`),a:I(e.tokensIn),b:I(t.tokensIn),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.cacheRead`),a:I(e.tokensCacheRead),b:I(t.tokensCacheRead),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,N.jsx)(L,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),i&&(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]})})}var ie={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ae=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],oe={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,labelKey:`recent.priority.low`}};function se(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ce(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function le(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ue(e){try{return _(new Date(e),{addSuffix:!0,locale:O()})}catch{return e}}var z=10;function B({jobs:e,isLoading:r,onJobsCleared:i,onProposalClick:f,onProposalDelete:ee}){let{t:h}=b(`jobs`),_=u(),{activeProjectId:v,projects:S}=m(),C=S.find(e=>e.id===v)?.provider,[T,O]=(0,M.useState)(null),[A,j]=(0,M.useState)(``),[P,F]=(0,M.useState)(``),[I,L]=(0,M.useState)(!1),[R,B]=(0,M.useState)(``),[V,H]=(0,M.useState)(``),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(null),[q,J]=(0,M.useState)(z),[Y,de]=(0,M.useState)(!1),[X,Z]=(0,M.useState)([]),[fe,Q]=(0,M.useState)(null);(0,M.useEffect)(()=>{J(z)},[e.length]);function pe(){de(e=>!e),Z([])}function me(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(T&&e.status!==T||A&&e.started_at<A||P&&e.started_at>`${P}T23:59:59`)),he=e.filter(e=>!(R&&e.started_at<R||V&&e.started_at>`${V}T23:59:59`)).length;async function ge(e){W(!0);try{let t={};e===`range`&&(R&&(t.from=R),V&&(t.to=V));let r=await fetch(`${a()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();n.success(h(`recent.toast.cleared`,{count:e.deleted})),L(!1),B(``),H(``),i?.()}else n.error(h(`recent.toast.clearFailed`))}catch{n.error(h(`recent.toast.networkError`))}finally{W(!1)}}return r?(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,N.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,N.jsx)(x,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,N.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:h(`recent.emptyTitle`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:h(`recent.emptyDescription`)})]}):(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterAll`,{count:e.length})}),ae.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterStatus`,{status:h(`statusName.${t}`),count:n})},t)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.fromDate`)}),(0,N.jsx)(`input`,{type:`date`,value:P,onChange:e=>F(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.toDate`)}),(A||P)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{j(``),F(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:h(`recent.clear`)}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:pe,children:(0,N.jsx)(ne,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>L(!0),children:(0,N.jsx)(s,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(`recent.clearJobs`)})]})]})]}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,N.jsxs)(`span`,{children:[X.length===0&&h(`recent.selectTwoToCompare`),X.length===1&&h(`recent.selectOneMore`),X.length===2&&h(`recent.readyToCompare`)]}),X.length===2&&(0,N.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:h(`recent.compareAction`)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,N.jsx)(`span`,{className:`w-14`,children:h(`recent.colStatus`)}),(0,N.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`recent.colCommand`)}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:h(`recent.colDuration`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colTokens`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colCost`)}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:h(`recent.colStarted`)})]})]}),(0,N.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,q).map(e=>{let t=ie[e.status]??ie.queued,n=se(e.total_cost_usd),r=ce(e.started_at,e.finished_at),i=le((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),c=a?e.id.replace(`proposal:`,``):null,l=X.includes(e.id),u=Y&&!a&&X.length===2&&!l;return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(Y&&!a){me(e.id);return}a&&c?f?.(c):_(`/jobs/${e.id}`)},children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`div`,{children:(0,N.jsx)(o,{variant:t.variant,children:h(t.labelKey)})})}),(0,N.jsx)(w,{children:h(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${oe[e.priority].className}`,children:h(oe[e.priority].labelKey)}),e.profile_name&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,N.jsx)(w,{children:h(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(y,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,N.jsxs)(w,{children:[h(`recent.pipelinePart`),e.depends_on_job_id&&` ${h(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,N.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:te(e.command,C)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:ue(e.started_at)}),a&&c&&(0,N.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),K(c)},title:h(`recent.deleteProposal`),children:(0,N.jsx)(s,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>q&&(0,N.jsx)(`div`,{className:`pt-1 text-center`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>J(e=>e+z),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:h(`recent.loadMore`,{count:$.length-q})})}),I&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>L(!1),children:(0,N.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:h(`recent.clearModal.title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:h(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:U,onClick:()=>ge(`all`),children:h(`recent.clearModal.clearAll`,{count:e.length})}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`recent.clearModal.orByRange`)}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:R,onChange:e=>B(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.fromPlaceholder`)}),(0,N.jsx)(`input`,{type:`date`,value:V,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.toPlaceholder`)})]}),(0,N.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:U||!R&&!V,onClick:()=>ge(`range`),children:R||V?h(`recent.clearModal.clearInRange`,{count:he}):h(`recent.clearModal.clearRange`)})]}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>L(!1),children:h(`common:actions.cancel`)})]})}),(0,N.jsx)(p,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,N.jsxs)(D,{className:`max-w-sm`,children:[(0,N.jsxs)(E,{children:[(0,N.jsx)(l,{children:h(`recent.deleteProposalConfirm.title`)}),(0,N.jsx)(c,{children:h(`recent.deleteProposalConfirm.description`)})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:h(`common:actions.cancel`)}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&ee?.(G),K(null)},children:h(`common:actions.delete`)})]})]})}),fe&&(0,N.jsx)(re,{jobIds:fe,onClose:()=>{Q(null),Z([]),de(!1)}})]})}function V(){let{t:e}=b(`jobs`),{activeProjectId:r}=m(),{recentJobs:i}=S(r),{data:s,isFirstLoad:c,refresh:u}=j({namespace:`jobs`,projectId:r,initialValue:i,fetcher:async()=>{let e=await fetch(`${a()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:d}=j({namespace:`proposals`,projectId:r,initialValue:[],fetcher:async()=>{let e=await fetch(`${a()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),f={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},_=d.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:f[e.status]??`queued`})),v=[...s,..._].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,x]=(0,M.useState)(null),C=(0,M.useCallback)(async e=>{try{let t=await fetch(`${a()}/propose/${e}`);if(!t.ok)return;x((await t.json()).proposal)}catch{}},[]),w=(0,M.useCallback)(async t=>{try{(await fetch(`${a()}/propose/${t}`,{method:`DELETE`})).ok&&(n.success(e(`page.proposalDeleted`)),u())}catch{}},[u,e]);return(0,N.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,N.jsx)(A,{baseUrl:`${a()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,N.jsx)(B,{jobs:v,isLoading:c,onJobsCleared:u,onProposalClick:C,onProposalDelete:w}),(0,N.jsx)(p,{open:y!==null,onOpenChange:e=>!e&&x(null),children:(0,N.jsx)(D,{className:`max-w-3xl glass-card`,children:y&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(l,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,N.jsx)(o,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,N.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,N.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,N.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,N.jsx)(h,{remarkPlugins:[ee],children:y.result_markdown})})}):(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,N.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,N.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{w(y.id),x(null)},children:e(`common:actions.delete`)}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>x(null),children:e(`common:actions.close`)})]})]})})})]})}export{V as default};
@@ -1 +1 @@
1
- import{r as e}from"./index-XGZaKl_u.js";function t(e){if(e!==void 0){if(typeof e==`string`)return e;if(`ok`in e&&`cancel`in e)return{OkCancelCustom:[e.ok,e.cancel]};if(`yes`in e&&`no`in e&&`cancel`in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if(`ok`in e)return{OkCustom:e.ok}}}async function n(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|open`,{options:t})}async function r(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|save`,{options:t})}async function i(n,r){return await e(`plugin:dialog|message`,{message:n,title:r?.title,kind:r?.kind,buttons:t(r?.buttons)})}async function a(e,t){let n=typeof t==`string`?{title:t}:t;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),i(e,n)}async function o(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Yes`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`No`}:`YesNo`})===a}async function s(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Ok`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`Cancel`}:`OkCancel`})===a}export{o as ask,s as confirm,a as message,n as open,r as save};
1
+ import{r as e}from"./index-D_VMXR78.js";function t(e){if(e!==void 0){if(typeof e==`string`)return e;if(`ok`in e&&`cancel`in e)return{OkCancelCustom:[e.ok,e.cancel]};if(`yes`in e&&`no`in e&&`cancel`in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if(`ok`in e)return{OkCustom:e.ok}}}async function n(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|open`,{options:t})}async function r(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|save`,{options:t})}async function i(n,r){return await e(`plugin:dialog|message`,{message:n,title:r?.title,kind:r?.kind,buttons:t(r?.buttons)})}async function a(e,t){let n=typeof t==`string`?{title:t}:t;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),i(e,n)}async function o(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Yes`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`No`}:`YesNo`})===a}async function s(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Ok`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`Cancel`}:`OkCancel`})===a}export{o as ask,s as confirm,a as message,n as open,r as save};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./index-XGZaKl_u.js";var n=class{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.addListener(e,n)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(e=>e!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){let n=this.eventListeners[e];for(let e of n)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.prependListener(e,n)}},r=class{constructor(e){this.pid=e}async write(e){await t(`plugin:shell|stdin_write`,{pid:this.pid,buffer:e})}async kill(){await t(`plugin:shell|kill`,{cmd:`killChild`,pid:this.pid})}},i=class i extends n{constructor(e,t=[],r){super(),this.stdout=new n,this.stderr=new n,this.program=e,this.args=typeof t==`string`?[t]:t,this.options=r??{}}static create(e,t=[],n){return new i(e,t,n)}static sidecar(e,t=[],n){let r=new i(e,t,n);return r.options.sidecar=!0,r}async spawn(){let n=this.program,i=this.args,a=this.options;typeof i==`object`&&Object.freeze(i);let o=new e;return o.onmessage=e=>{switch(e.event){case`Error`:this.emit(`error`,e.payload);break;case`Terminated`:this.emit(`close`,e.payload);break;case`Stdout`:this.stdout.emit(`data`,e.payload);break;case`Stderr`:this.stderr.emit(`data`,e.payload);break}},await t(`plugin:shell|spawn`,{program:n,args:i,options:a,onEvent:o}).then(e=>new r(e))}async execute(){let e=this.program,n=this.args,r=this.options;return typeof n==`object`&&Object.freeze(n),await t(`plugin:shell|execute`,{program:e,args:n,options:r})}};async function a(e,n){await t(`plugin:shell|open`,{path:e,with:n})}export{r as Child,i as Command,n as EventEmitter,a as open};
1
+ import{n as e,r as t}from"./index-D_VMXR78.js";var n=class{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.addListener(e,n)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(e=>e!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){let n=this.eventListeners[e];for(let e of n)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.prependListener(e,n)}},r=class{constructor(e){this.pid=e}async write(e){await t(`plugin:shell|stdin_write`,{pid:this.pid,buffer:e})}async kill(){await t(`plugin:shell|kill`,{cmd:`killChild`,pid:this.pid})}},i=class i extends n{constructor(e,t=[],r){super(),this.stdout=new n,this.stderr=new n,this.program=e,this.args=typeof t==`string`?[t]:t,this.options=r??{}}static create(e,t=[],n){return new i(e,t,n)}static sidecar(e,t=[],n){let r=new i(e,t,n);return r.options.sidecar=!0,r}async spawn(){let n=this.program,i=this.args,a=this.options;typeof i==`object`&&Object.freeze(i);let o=new e;return o.onmessage=e=>{switch(e.event){case`Error`:this.emit(`error`,e.payload);break;case`Terminated`:this.emit(`close`,e.payload);break;case`Stdout`:this.stdout.emit(`data`,e.payload);break;case`Stderr`:this.stderr.emit(`data`,e.payload);break}},await t(`plugin:shell|spawn`,{program:n,args:i,options:a,onEvent:o}).then(e=>new r(e))}async execute(){let e=this.program,n=this.args,r=this.options;return typeof n==`object`&&Object.freeze(n),await t(`plugin:shell|execute`,{program:e,args:n,options:r})}};async function a(e,n){await t(`plugin:shell|open`,{path:e,with:n})}export{r as Child,i as Command,n as EventEmitter,a as open};