specrails-desktop 2.43.0 → 2.43.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DoEMumQS.js → ActivityFeedPage-C7XJ5-bJ.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-DIh4K0gh.js → AgentBrowserCapture-C_WpXceT.js} +1 -1
  3. package/client/dist/assets/{AgentModeAnalyticsPane-mbq4WEoO.js → AgentModeAnalyticsPane-PEZKjyZS.js} +2 -2
  4. package/client/dist/assets/{AgentModeCodePane-CKh7zuA4.js → AgentModeCodePane-D_Xcq5t5.js} +2 -2
  5. package/client/dist/assets/{AgentModeJobsPane-BDokPiLJ.js → AgentModeJobsPane-CDSkOuNP.js} +1 -1
  6. package/client/dist/assets/{AgentsPage-BFVAZbBj.js → AgentsPage-D577NzIM.js} +1 -1
  7. package/client/dist/assets/{AnalyticsPage-3Y9LuWwz.js → AnalyticsPage-C6ZZI_zg.js} +1 -1
  8. package/client/dist/assets/{CodePage-C9KyuV_C.js → CodePage-B5z5oLnP.js} +1 -1
  9. package/client/dist/assets/{DesktopAnalyticsPage-Bhi54bXQ.js → DesktopAnalyticsPage-D_V9RuGg.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-Dj6mt4ga.js → DocsDialog-Beg82MEe.js} +1 -1
  11. package/client/dist/assets/{DocsPage-24yWglNI.js → DocsPage-BkE4m4wp.js} +1 -1
  12. package/client/dist/assets/{InteractiveJobComposer-C1ucmxQh.js → InteractiveJobComposer-wBBBNaJn.js} +1 -1
  13. package/client/dist/assets/JobDetailModal-BCxue_Do.js +1 -0
  14. package/client/dist/assets/{JobDetailPage-BcajZyuu.js → JobDetailPage-_rIDpNfo.js} +1 -1
  15. package/client/dist/assets/{JobsPage-B9nTZw6e.js → JobsPage-C6xcijbs.js} +1 -1
  16. package/client/dist/assets/{LoopBuilderPage-Oc48iOFW.js → LoopBuilderPage-A-Mt6EjT.js} +1 -1
  17. package/client/dist/assets/{LoopPreviewModal-ae0Fr6SU.js → LoopPreviewModal-DqHiG4Dt.js} +1 -1
  18. package/client/dist/assets/{LoopsPage-CUEqzUBI.js → LoopsPage-B-ketPET.js} +1 -1
  19. package/client/dist/assets/{PluginsPage-C1xtARIx.js → PluginsPage-Dn2jPvJL.js} +1 -1
  20. package/client/dist/assets/{ProjectSettingsDialog-JZzrXFBN.js → ProjectSettingsDialog-CVTj4VLt.js} +1 -1
  21. package/client/dist/assets/{RepositoryDeliveries-CSDsiVUz.js → RepositoryDeliveries-IiQCcndQ.js} +1 -1
  22. package/client/dist/assets/{ReviewPacketPage-x5EfGTiL.js → ReviewPacketPage-BBd617OM.js} +1 -1
  23. package/client/dist/assets/{TemplatePreviewModal-BSyuZxGq.js → TemplatePreviewModal-COHFkUS4.js} +1 -1
  24. package/client/dist/assets/{TicketDetailModalContext-DqyF0so-.js → TicketDetailModalContext-BNa1mdXq.js} +3 -3
  25. package/client/dist/assets/{button-DCBqEaZl.js → button-Ccc9Dc-D.js} +1 -1
  26. package/client/dist/assets/dialog-xXB2q5HJ.js +45 -0
  27. package/client/dist/assets/index-D5n_jg_I.css +2 -0
  28. package/client/dist/assets/index-m5pKr1T6.js +76 -0
  29. package/client/dist/index.html +6 -6
  30. package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +11 -0
  31. package/docs/internals/core-runtime-updates.md +7 -0
  32. package/docs/internals/interactive-jobs.md +53 -0
  33. package/package.json +1 -1
  34. package/server/dist/loop-executors.js +14 -1
  35. package/server/dist/loop-factory.js +24 -5
  36. package/server/dist/loop-run-manager.js +12 -0
  37. package/server/dist/loop-templates.js +14 -33
  38. package/server/dist/rails-router.js +2 -2
  39. package/server/dist/workspace-manager.js +54 -3
  40. package/client/dist/assets/JobDetailModal-DNWmgVHD.js +0 -1
  41. package/client/dist/assets/dialog-SRw01_QU.js +0 -45
  42. package/client/dist/assets/index-DwAmL7m5.css +0 -2
  43. package/client/dist/assets/index-EzrkUb8B.js +0 -76
@@ -1,2 +1,2 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,r as i}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s,r as c,s as l}from"./useDesktop-RSMTyy7V.js";import{t as u}from"./download-CFHyyHcw.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./search-Cq_gE3Ik.js";import{t as p}from"./trash-2-BOU3WdZZ.js";import{t as m}from"./triangle-alert-H9T4jAmh.js";import{n as h,t as g}from"./jira-api-CSCqGr-Q.js";import{i as _,l as v,o as y,r as b,t as x}from"./dialog-SRw01_QU.js";import{t as S}from"./utils-BC4DHlz2.js";import{t as C}from"./button-DCBqEaZl.js";import{r as w}from"./provider-capabilities-B-wOHfLP.js";import{F as T,Nt as E,at as D,jt as O,ot as k,pt as A,st as j}from"./index-EzrkUb8B.js";var M=o(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ee=o(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),te=o(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),N=o(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),P=o(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),F=e(t(),1),I=n(),ne=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],L={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function R({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=a(`jira`),[i,o]=(0,F.useState)(1),[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(`idle`),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(`cloud`),[x,S]=(0,F.useState)([]),[w,E]=(0,F.useState)(``),[D,O]=(0,F.useState)(``),[k,A]=(0,F.useState)(``),[j,M]=(0,F.useState)(!1),[ee,te]=(0,F.useState)([]),[N,P]=(0,F.useState)({}),[R,re]=(0,F.useState)(``),[H,U]=(0,F.useState)(!1),W=()=>({baseUrl:s.trim(),accountEmail:u.trim()||null,token:f});async function G(){h(`testing`);try{let e=await g.test(W(),n);h(`ok`),v(e.displayName),b(e.deployment)}catch(e){h(`error`),l.error(V(e,r))}}async function K(){o(2),M(!0);try{let{projects:e}=await g.discoverProjects({...W(),query:w.trim()||void 0},n);S(e)}catch(e){l.error(V(e,r))}finally{M(!1)}}async function q(){if(o(3),D)try{let{statuses:e}=await g.discoverStatuses({...W(),projectKey:D},n);te(e)}catch{te([])}}async function J(){U(!0);try{let t=Object.fromEntries(Object.entries(N).filter(([,e])=>e));await g.connect({...W(),jiraProjectKey:D.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:R.trim()||null},n),l.success(r(`status.connected`,{key:D.trim()})),e()}catch(e){l.error(V(e,r))}finally{U(!1)}}return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-muted-foreground hover:text-foreground hover:underline`,"data-testid":`jira-later`,children:r(`wizard.later`)})]}),i===1&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,I.jsx)(z,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,I.jsx)(T,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,I.jsx)(z,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,I.jsx)(T,{value:u,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,I.jsx)(z,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,I.jsx)(T,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(C,{size:`sm`,variant:`outline`,onClick:G,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,I.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:_??``}),` · `,r(y===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(C,{size:`sm`,onClick:K,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(T,{value:w,onChange:e=>E(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,I.jsx)(C,{size:`sm`,variant:`outline`,onClick:K,children:r(`project.searchPlaceholder`)})]}),j?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,I.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{O(e.key),A(e.name)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${D===e.key?`bg-muted`:``}`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,I.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,I.jsx)(z,{label:r(`project.manualLabel`),children:(0,I.jsx)(T,{value:D,onChange:e=>{O(e.target.value.toUpperCase()),A(``)},placeholder:r(`project.manualPlaceholder`)})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(1),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:q,disabled:!D.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),ne.map(e=>(0,I.jsx)(z,{label:r(`mapping.${L[e]}`),children:(0,I.jsxs)(`select`,{value:N[e]??``,onChange:t=>P(n=>({...n,[e]:t.target.value||void 0})),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,children:[(0,I.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),ee.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,I.jsx)(z,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,I.jsxs)(`select`,{value:R,onChange:e=>re(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),ee.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(2),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:()=>o(4),children:r(`wizard.next`)})]})]}),i===4&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,I.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,I.jsx)(B,{label:r(`review.site`),value:s}),(0,I.jsx)(B,{label:r(`review.project`),value:k?`${D} — ${k}`:D}),(0,I.jsx)(B,{label:r(`review.account`),value:_??u}),(0,I.jsx)(B,{label:r(`review.type`),value:r(y===`cloud`?`review.cloud`:`review.dc`)}),(0,I.jsx)(B,{label:r(`discard.reviewLabel`),value:R||r(`discard.configNone`)})]}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(3),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:J,disabled:H,children:r(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function z({label:e,help:t,children:n}){return(0,I.jsxs)(`label`,{className:`block space-y-1`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,I.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function B({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,I.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function V(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var re=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],H={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function U({state:e,onChanged:t,apiBase:n}){let{t:r}=a(`jira`),i=e.connection,[o,s]=(0,F.useState)(i.enabled),[c,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)([]),[h,_]=(0,F.useState)([]),[v,y]=(0,F.useState)(i.discardStatus??``),[b,x]=(0,F.useState)(i.statusMap??{}),S=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,F.useCallback)(async()=>{try{let{ops:e}=n?await g.listOutbox(`dead`,n):await g.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,F.useEffect)(()=>{w()},[w]),(0,F.useEffect)(()=>{let e=!1;return g.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let i=v;y(e);try{n?await g.patchConnection({discardStatus:e||null},n):await g.patchConnection({discardStatus:e||null}),t()}catch(e){y(i),l.error(G(e,r))}}async function E(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{n?await g.patchConnection({statusMap:Object.keys(s).length?s:null},n):await g.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){x(a),l.error(G(e,r))}}async function D(){let e=!o;s(e),f(!0);try{n?await g.setEnabled(e,n):await g.setEnabled(e)}catch(t){s(!e),l.error(G(t,r))}finally{f(!1)}}async function O(){u(!0);try{let e=n?await g.syncNow(n):await g.syncNow();l.success(r(`status.syncedToast`,{count:e.upserted}))}catch(e){l.error(G(e,r))}finally{u(!1)}}async function k(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{n?await g.disconnect(n):await g.disconnect(),l.success(r(`status.disconnectedToast`)),t()}catch(e){l.error(G(e,r))}finally{f(!1)}}}async function A(e){try{n?await g.retryOutbox(e,n):await g.retryOutbox(e),await w()}catch(e){l.error(G(e,r))}}let j=S.pending+S.inflight;return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,I.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:r(`badge.openInJira`)})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(o?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${o?`bg-accent-success`:`bg-input`}`,children:(0,I.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${o?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),(0,I.jsx)(`div`,{className:`space-y-2`,children:re.map(e=>(0,I.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${H[e]}`)}),(0,I.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,I.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,I.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,I.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!h.some(e=>e.name===v)&&(0,I.jsx)(`option`,{value:v,children:v})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(C,{variant:`outline`,size:`sm`,onClick:O,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,I.jsx)(C,{variant:`ghost`,size:`sm`,onClick:k,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`outbox.title`)}),S.dead>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:r(`outbox.dead`,{count:S.dead})}):j>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.pending`,{count:j})}):(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.allSynced`)}),p.length>0&&(0,I.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`outbox.deadHelp`)}),p.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,I.jsxs)(`span`,{className:`truncate text-xs`,children:[W(e,r),` · `,e.deadReason??e.lastError??``]}),(0,I.jsx)(C,{variant:`outline`,size:`sm`,onClick:()=>A(e.id),children:r(`outbox.retry`)})]},e.id))]})]})]})}function W(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var K=new Set([`claude`,`codex`,`kimi`]);function q(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function J(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:q(`codex`),claude:q(`claude`)},lastIssue:null}}var Y={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:J(),lastIssue:null,updatedAt:null};function ie(e){let t=e?.metrics??J();return{...Y,...e,activeProviders:{...Y.activeProviders,...e?.activeProviders},availableProviders:{...Y.availableProviders,...e?.availableProviders},detectedRoutes:{...Y.detectedRoutes,...e?.detectedRoutes},learning:{...Y.learning,...e?.learning},metrics:{...J(),...t,providers:{codex:{...q(`codex`),...t.providers?.codex},claude:{...q(`claude`),...t.providers?.claude}}}}}async function X(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function Z(e){return`${r}/api/projects/${e}`}function Q(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function $(e,t,n){return`${Q(e,t)} ${n}`}function ae(){let{t:e}=a(`integrations`),{projects:t}=c(),{registerHandler:n,unregisterHandler:o}=i(),[s,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(`all`),[p,m]=(0,F.useState)(Y),[h,g]=(0,F.useState)(!0),[C,w]=(0,F.useState)(null),[T,E]=(0,F.useState)([]),[O,M]=(0,F.useState)(!1),[N,P]=(0,F.useState)(!1),[ne,L]=(0,F.useState)(null),[R,z]=(0,F.useState)({jira:0,serena:0,projects:0}),B=(0,F.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>X(e));m(ie(e.state))}finally{g(!1)}},[]);(0,F.useEffect)(()=>{B()},[B]),(0,F.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),B())}),()=>o(`plugins-page`)),[n,o,B]),(0,F.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${Z(e.id)}/jira/connection`).then(e=>X(e)).catch(()=>({connected:!1})),fetch(`${Z(e.id)}/plugins`).then(e=>X(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||z({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function V(e,t){w(e),E([]);try{let e=(await t()).state;e&&m(ie(e))}catch(e){let t=e.payload;t?.state&&m(ie(t.state))}finally{w(null),B()}}let re=(0,F.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:te,description:e(`plugins.catalog.headroom.description`),installed:p.installed,status:p.lastIssue?`attention`:p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?`external-active`:`active`:p.installSource===`system`?`external`:`installed`:`available`,statusLabel:p.lastIssue?e(`plugins.status.attention`):p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):p.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:p.lastIssue?`review`:p.installed?`manage`:`install`,actionLabel:p.lastIssue?e(`plugins.actions.review`):p.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(p.lastIssue||p.installed){M(!0);return}V(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e)))}}],[p,C,e]),H=(0,F.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ee,description:e(`plugins.catalog.jira.description`),installed:R.jira>0,status:R.jira>0?`configured`:`available`,statusLabel:R.jira>0?e(`plugins.status.configuredCount`,{count:R.jira}):e(`plugins.status.available`),actionKind:R.jira>0?`manage`:`install`,actionLabel:R.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:D,description:e(`plugins.catalog.serena.description`),installed:R.serena>0,status:R.serena>0?`installed`:`available`,statusLabel:R.serena>0?e(`plugins.status.installedCount`,{count:R.serena}):e(`plugins.status.available`),actionKind:R.serena>0?`manage`:`install`,actionLabel:R.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`serena`)}],[R,e]),U=s.trim().toLowerCase(),W=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(U),G=[...re,...H].filter(e=>u!==`all`&&e.scope!==u?!1:W(e)),K=G.filter(e=>e.scope===`global`&&e.installed),q=G.filter(e=>e.scope===`project`&&e.installed),J=G.filter(e=>e.scope===`global`&&!e.installed),Q=G.filter(e=>e.scope===`project`&&!e.installed),$=K.length>0||q.length>0,ae=J.length>0||Q.length>0,ce=[p.installed,R.jira>0,R.serena>0].filter(Boolean).length;return(0,I.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(A,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,I.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,I.jsx)(j,{className:`h-3.5 w-3.5 text-accent-success`}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:ce})})]})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,I.jsxs)(`label`,{className:`relative flex-1`,children:[(0,I.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,I.jsx)(`input`,{value:s,onChange:e=>l(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,I.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:S(`rounded-md px-3 text-xs capitalize transition-colors`,u===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,I.jsxs)(`section`,{className:`mb-6`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(k,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),$?(0,I.jsx)(oe,{globalPlugins:K,projectPlugins:q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(A,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),ae?(0,I.jsx)(oe,{globalPlugins:J,projectPlugins:Q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,I.jsx)(x,{open:O,onOpenChange:M,children:(0,I.jsxs)(b,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,I.jsxs)(y,{children:[(0,I.jsx)(v,{children:e(`plugins.headroom.title`)}),(0,I.jsx)(_,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,I.jsx)(de,{state:p,loading:h,busy:C,logs:T,onInstall:()=>V(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e))),onToggleProvider:(e,t)=>V(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${r}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>X(e))),onDeactivateAll:()=>V(`deactivate-all`,async()=>{let e={state:p};for(let t of[`codex`,`claude`])p.activeProviders[t]&&(e=await fetch(`${r}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>X(e)));return e}),onUninstall:()=>V(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>X(e))),onSetPort:e=>V(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>X(e))),onOpenDiagnostics:()=>P(!0)})]})}),(0,I.jsx)(ve,{plugin:ne,projects:t,onClose:()=>L(null)}),(0,I.jsx)(xe,{open:N,onClose:()=>P(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=a(`integrations`);return(0,I.jsxs)(`div`,{className:S(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]}),t.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,I.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function ce({scope:e}){let{t}=a(`integrations`);return(0,I.jsx)(`span`,{className:S(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function le({title:e,detail:t,scope:n}){return(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,I.jsx)(ce,{scope:n}),(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,I.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,I.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function ue({plugin:e}){let{t}=a(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,o=e.busy?d:e.actionKind===`install`?u:e.actionKind===`review`?m:P,s=S(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,i?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,I.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,I.jsx)(`div`,{className:S(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,r?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,I.jsx)(n,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,I.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,I.jsx)(ce,{scope:e.scope}),(0,I.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,I.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,I.jsx)(o,{className:S(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function de({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:o,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:f}){let{t:m}=a(`integrations`),[g,_]=(0,F.useState)(String(e.port)),[v,y]=(0,F.useState)(!1);(0,F.useEffect)(()=>_(String(e.port)),[e.port]),(0,F.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,I.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(te,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,I.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,I.jsx)(pe,{issue:e.lastIssue}),e.installed?(0,I.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,I.jsx)(_e,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>o(`codex`,e.activeProviders.codex)}),(0,I.jsx)(_e,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>o(`claude`,e.activeProviders.claude)}),b&&(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:s,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(N,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:i,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(u,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,I.jsx)(me,{state:e}),(0,I.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,I.jsx)(`button`,{type:`button`,disabled:!!n||Number(g)===e.port,onClick:()=>l(Number(g)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,I.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:r.join(`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,r as i}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s,r as c,s as l}from"./useDesktop-RSMTyy7V.js";import{t as u}from"./download-CFHyyHcw.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./search-Cq_gE3Ik.js";import{t as p}from"./trash-2-BOU3WdZZ.js";import{t as m}from"./triangle-alert-H9T4jAmh.js";import{n as h,t as g}from"./jira-api-CSCqGr-Q.js";import{i as _,l as v,o as y,r as b,t as x}from"./dialog-xXB2q5HJ.js";import{t as S}from"./utils-BC4DHlz2.js";import{t as C}from"./button-Ccc9Dc-D.js";import{r as w}from"./provider-capabilities-B-wOHfLP.js";import{F as T,Nt as E,at as D,jt as O,ot as k,pt as A,st as j}from"./index-m5pKr1T6.js";var M=o(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ee=o(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),te=o(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),N=o(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),P=o(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),F=e(t(),1),I=n(),ne=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],L={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function R({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=a(`jira`),[i,o]=(0,F.useState)(1),[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(`idle`),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(`cloud`),[x,S]=(0,F.useState)([]),[w,E]=(0,F.useState)(``),[D,O]=(0,F.useState)(``),[k,A]=(0,F.useState)(``),[j,M]=(0,F.useState)(!1),[ee,te]=(0,F.useState)([]),[N,P]=(0,F.useState)({}),[R,re]=(0,F.useState)(``),[H,U]=(0,F.useState)(!1),W=()=>({baseUrl:s.trim(),accountEmail:u.trim()||null,token:f});async function G(){h(`testing`);try{let e=await g.test(W(),n);h(`ok`),v(e.displayName),b(e.deployment)}catch(e){h(`error`),l.error(V(e,r))}}async function K(){o(2),M(!0);try{let{projects:e}=await g.discoverProjects({...W(),query:w.trim()||void 0},n);S(e)}catch(e){l.error(V(e,r))}finally{M(!1)}}async function q(){if(o(3),D)try{let{statuses:e}=await g.discoverStatuses({...W(),projectKey:D},n);te(e)}catch{te([])}}async function J(){U(!0);try{let t=Object.fromEntries(Object.entries(N).filter(([,e])=>e));await g.connect({...W(),jiraProjectKey:D.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:R.trim()||null},n),l.success(r(`status.connected`,{key:D.trim()})),e()}catch(e){l.error(V(e,r))}finally{U(!1)}}return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-muted-foreground hover:text-foreground hover:underline`,"data-testid":`jira-later`,children:r(`wizard.later`)})]}),i===1&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,I.jsx)(z,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,I.jsx)(T,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,I.jsx)(z,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,I.jsx)(T,{value:u,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,I.jsx)(z,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,I.jsx)(T,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(C,{size:`sm`,variant:`outline`,onClick:G,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,I.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:_??``}),` · `,r(y===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(C,{size:`sm`,onClick:K,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(T,{value:w,onChange:e=>E(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,I.jsx)(C,{size:`sm`,variant:`outline`,onClick:K,children:r(`project.searchPlaceholder`)})]}),j?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,I.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{O(e.key),A(e.name)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${D===e.key?`bg-muted`:``}`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,I.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,I.jsx)(z,{label:r(`project.manualLabel`),children:(0,I.jsx)(T,{value:D,onChange:e=>{O(e.target.value.toUpperCase()),A(``)},placeholder:r(`project.manualPlaceholder`)})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(1),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:q,disabled:!D.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),ne.map(e=>(0,I.jsx)(z,{label:r(`mapping.${L[e]}`),children:(0,I.jsxs)(`select`,{value:N[e]??``,onChange:t=>P(n=>({...n,[e]:t.target.value||void 0})),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,children:[(0,I.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),ee.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,I.jsx)(z,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,I.jsxs)(`select`,{value:R,onChange:e=>re(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),ee.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(2),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:()=>o(4),children:r(`wizard.next`)})]})]}),i===4&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,I.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,I.jsx)(B,{label:r(`review.site`),value:s}),(0,I.jsx)(B,{label:r(`review.project`),value:k?`${D} — ${k}`:D}),(0,I.jsx)(B,{label:r(`review.account`),value:_??u}),(0,I.jsx)(B,{label:r(`review.type`),value:r(y===`cloud`?`review.cloud`:`review.dc`)}),(0,I.jsx)(B,{label:r(`discard.reviewLabel`),value:R||r(`discard.configNone`)})]}),(0,I.jsxs)(`div`,{className:`flex justify-between`,children:[(0,I.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(3),children:r(`wizard.back`)}),(0,I.jsx)(C,{size:`sm`,onClick:J,disabled:H,children:r(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function z({label:e,help:t,children:n}){return(0,I.jsxs)(`label`,{className:`block space-y-1`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,I.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function B({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,I.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,I.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function V(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var re=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],H={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function U({state:e,onChanged:t,apiBase:n}){let{t:r}=a(`jira`),i=e.connection,[o,s]=(0,F.useState)(i.enabled),[c,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)([]),[h,_]=(0,F.useState)([]),[v,y]=(0,F.useState)(i.discardStatus??``),[b,x]=(0,F.useState)(i.statusMap??{}),S=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,F.useCallback)(async()=>{try{let{ops:e}=n?await g.listOutbox(`dead`,n):await g.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,F.useEffect)(()=>{w()},[w]),(0,F.useEffect)(()=>{let e=!1;return g.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let i=v;y(e);try{n?await g.patchConnection({discardStatus:e||null},n):await g.patchConnection({discardStatus:e||null}),t()}catch(e){y(i),l.error(G(e,r))}}async function E(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{n?await g.patchConnection({statusMap:Object.keys(s).length?s:null},n):await g.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){x(a),l.error(G(e,r))}}async function D(){let e=!o;s(e),f(!0);try{n?await g.setEnabled(e,n):await g.setEnabled(e)}catch(t){s(!e),l.error(G(t,r))}finally{f(!1)}}async function O(){u(!0);try{let e=n?await g.syncNow(n):await g.syncNow();l.success(r(`status.syncedToast`,{count:e.upserted}))}catch(e){l.error(G(e,r))}finally{u(!1)}}async function k(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{n?await g.disconnect(n):await g.disconnect(),l.success(r(`status.disconnectedToast`)),t()}catch(e){l.error(G(e,r))}finally{f(!1)}}}async function A(e){try{n?await g.retryOutbox(e,n):await g.retryOutbox(e),await w()}catch(e){l.error(G(e,r))}}let j=S.pending+S.inflight;return(0,I.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,I.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:r(`badge.openInJira`)})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(o?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${o?`bg-accent-success`:`bg-input`}`,children:(0,I.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${o?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),(0,I.jsx)(`div`,{className:`space-y-2`,children:re.map(e=>(0,I.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${H[e]}`)}),(0,I.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,I.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,I.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,I.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,I.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,I.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!h.some(e=>e.name===v)&&(0,I.jsx)(`option`,{value:v,children:v})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(C,{variant:`outline`,size:`sm`,onClick:O,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,I.jsx)(C,{variant:`ghost`,size:`sm`,onClick:k,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,I.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:r(`outbox.title`)}),S.dead>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:r(`outbox.dead`,{count:S.dead})}):j>0?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.pending`,{count:j})}):(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.allSynced`)}),p.length>0&&(0,I.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`outbox.deadHelp`)}),p.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,I.jsxs)(`span`,{className:`truncate text-xs`,children:[W(e,r),` · `,e.deadReason??e.lastError??``]}),(0,I.jsx)(C,{variant:`outline`,size:`sm`,onClick:()=>A(e.id),children:r(`outbox.retry`)})]},e.id))]})]})]})}function W(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var K=new Set([`claude`,`codex`,`kimi`]);function q(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function J(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:q(`codex`),claude:q(`claude`)},lastIssue:null}}var Y={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:J(),lastIssue:null,updatedAt:null};function ie(e){let t=e?.metrics??J();return{...Y,...e,activeProviders:{...Y.activeProviders,...e?.activeProviders},availableProviders:{...Y.availableProviders,...e?.availableProviders},detectedRoutes:{...Y.detectedRoutes,...e?.detectedRoutes},learning:{...Y.learning,...e?.learning},metrics:{...J(),...t,providers:{codex:{...q(`codex`),...t.providers?.codex},claude:{...q(`claude`),...t.providers?.claude}}}}}async function X(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function Z(e){return`${r}/api/projects/${e}`}function Q(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function $(e,t,n){return`${Q(e,t)} ${n}`}function ae(){let{t:e}=a(`integrations`),{projects:t}=c(),{registerHandler:n,unregisterHandler:o}=i(),[s,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(`all`),[p,m]=(0,F.useState)(Y),[h,g]=(0,F.useState)(!0),[C,w]=(0,F.useState)(null),[T,E]=(0,F.useState)([]),[O,M]=(0,F.useState)(!1),[N,P]=(0,F.useState)(!1),[ne,L]=(0,F.useState)(null),[R,z]=(0,F.useState)({jira:0,serena:0,projects:0}),B=(0,F.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>X(e));m(ie(e.state))}finally{g(!1)}},[]);(0,F.useEffect)(()=>{B()},[B]),(0,F.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),B())}),()=>o(`plugins-page`)),[n,o,B]),(0,F.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${Z(e.id)}/jira/connection`).then(e=>X(e)).catch(()=>({connected:!1})),fetch(`${Z(e.id)}/plugins`).then(e=>X(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||z({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function V(e,t){w(e),E([]);try{let e=(await t()).state;e&&m(ie(e))}catch(e){let t=e.payload;t?.state&&m(ie(t.state))}finally{w(null),B()}}let re=(0,F.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:te,description:e(`plugins.catalog.headroom.description`),installed:p.installed,status:p.lastIssue?`attention`:p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?`external-active`:`active`:p.installSource===`system`?`external`:`installed`:`available`,statusLabel:p.lastIssue?e(`plugins.status.attention`):p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):p.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:p.lastIssue?`review`:p.installed?`manage`:`install`,actionLabel:p.lastIssue?e(`plugins.actions.review`):p.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(p.lastIssue||p.installed){M(!0);return}V(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e)))}}],[p,C,e]),H=(0,F.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ee,description:e(`plugins.catalog.jira.description`),installed:R.jira>0,status:R.jira>0?`configured`:`available`,statusLabel:R.jira>0?e(`plugins.status.configuredCount`,{count:R.jira}):e(`plugins.status.available`),actionKind:R.jira>0?`manage`:`install`,actionLabel:R.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:D,description:e(`plugins.catalog.serena.description`),installed:R.serena>0,status:R.serena>0?`installed`:`available`,statusLabel:R.serena>0?e(`plugins.status.installedCount`,{count:R.serena}):e(`plugins.status.available`),actionKind:R.serena>0?`manage`:`install`,actionLabel:R.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>L(`serena`)}],[R,e]),U=s.trim().toLowerCase(),W=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(U),G=[...re,...H].filter(e=>u!==`all`&&e.scope!==u?!1:W(e)),K=G.filter(e=>e.scope===`global`&&e.installed),q=G.filter(e=>e.scope===`project`&&e.installed),J=G.filter(e=>e.scope===`global`&&!e.installed),Q=G.filter(e=>e.scope===`project`&&!e.installed),$=K.length>0||q.length>0,ae=J.length>0||Q.length>0,ce=[p.installed,R.jira>0,R.serena>0].filter(Boolean).length;return(0,I.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(A,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,I.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,I.jsx)(j,{className:`h-3.5 w-3.5 text-accent-success`}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:ce})})]})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,I.jsxs)(`label`,{className:`relative flex-1`,children:[(0,I.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,I.jsx)(`input`,{value:s,onChange:e=>l(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,I.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:S(`rounded-md px-3 text-xs capitalize transition-colors`,u===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,I.jsxs)(`section`,{className:`mb-6`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(k,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),$?(0,I.jsx)(oe,{globalPlugins:K,projectPlugins:q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(A,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),ae?(0,I.jsx)(oe,{globalPlugins:J,projectPlugins:Q}):(0,I.jsx)(se,{text:e(U?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,I.jsx)(x,{open:O,onOpenChange:M,children:(0,I.jsxs)(b,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,I.jsxs)(y,{children:[(0,I.jsx)(v,{children:e(`plugins.headroom.title`)}),(0,I.jsx)(_,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,I.jsx)(de,{state:p,loading:h,busy:C,logs:T,onInstall:()=>V(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>X(e))),onToggleProvider:(e,t)=>V(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${r}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>X(e))),onDeactivateAll:()=>V(`deactivate-all`,async()=>{let e={state:p};for(let t of[`codex`,`claude`])p.activeProviders[t]&&(e=await fetch(`${r}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>X(e)));return e}),onUninstall:()=>V(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>X(e))),onSetPort:e=>V(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>X(e))),onOpenDiagnostics:()=>P(!0)})]})}),(0,I.jsx)(ve,{plugin:ne,projects:t,onClose:()=>L(null)}),(0,I.jsx)(xe,{open:N,onClose:()=>P(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=a(`integrations`);return(0,I.jsxs)(`div`,{className:S(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]}),t.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(le,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,I.jsx)(ue,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,I.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function ce({scope:e}){let{t}=a(`integrations`);return(0,I.jsx)(`span`,{className:S(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function le({title:e,detail:t,scope:n}){return(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,I.jsx)(ce,{scope:n}),(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,I.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,I.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function ue({plugin:e}){let{t}=a(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,o=e.busy?d:e.actionKind===`install`?u:e.actionKind===`review`?m:P,s=S(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,i?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,I.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,I.jsx)(`div`,{className:S(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,r?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,I.jsx)(n,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,I.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,I.jsx)(ce,{scope:e.scope}),(0,I.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,I.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,I.jsx)(o,{className:S(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function de({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:o,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:f}){let{t:m}=a(`integrations`),[g,_]=(0,F.useState)(String(e.port)),[v,y]=(0,F.useState)(!1);(0,F.useEffect)(()=>_(String(e.port)),[e.port]),(0,F.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,I.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,I.jsx)(te,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,I.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,I.jsx)(fe,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,I.jsx)(pe,{issue:e.lastIssue}),e.installed?(0,I.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,I.jsx)(_e,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>o(`codex`,e.activeProviders.codex)}),(0,I.jsx)(_e,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>o(`claude`,e.activeProviders.claude)}),b&&(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:s,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(N,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:i,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(u,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,I.jsx)(me,{state:e}),(0,I.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,I.jsx)(`button`,{type:`button`,disabled:!!n||Number(g)===e.port,onClick:()=>l(Number(g)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,I.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:r.join(`
2
2
  `)}),(0,I.jsxs)(`button`,{type:`button`,onClick:f,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,I.jsx)(h,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,I.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:v?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(x?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:c,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(p,{className:`h-3.5 w-3.5`}),m(x?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,I.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,I.jsx)(p,{className:`h-3.5 w-3.5`}),m(x?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function fe({label:e,value:t,good:n}){return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,I.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,I.jsx)(`div`,{className:S(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function pe({issue:e}){let{t}=a(`integrations`),n=`plugins.headroom.issues.${e.code}`,r=t(`${n}.title`,{defaultValue:e.title}),i=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,I.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(m,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:r}),(0,I.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:i}),(0,I.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function me({state:e}){let{t,i18n:n}=a(`integrations`),r=e.metrics,i=r.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:r.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(i?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=i||l;return(0,I.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(E,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,I.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,I.jsx)(`span`,{className:S(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,I.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(he,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?$(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:$(c.inputTokensSaved,n.language,s)}),(0,I.jsx)(he,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?$(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:i?$(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,I.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,I.jsx)(ge,{metric:t,outputAvailable:r.outputSavingsAvailable},e))}),(0,I.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:r.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function he({label:e,processed:t,saved:n,detail:r,align:i=`left`}){let{t:o}=a(`integrations`);return(0,I.jsxs)(`div`,{className:S(`min-w-0`,i===`right`&&`text-right`),children:[(0,I.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,I.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,I.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,I.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),r&&(0,I.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:r})]})}function ge({metric:e,outputAvailable:t}){let{t:n,i18n:r}=a(`integrations`),i=!e.available,o=i||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?$(e.inputTokens,r.language,s):n(`plugins.headroom.savings.noData`),l=$(e.inputTokensSaved,r.language,s),u=e.outputTokens>0?$(e.outputTokens,r.language,s):n(`plugins.headroom.savings.noData`),d=t?$(e.outputTokensSaved,r.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:Q(e.requests,r.language)}):i?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,I.jsxs)(`div`,{className:S(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,I.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,I.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,I.jsx)(he,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,I.jsx)(he,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function _e({provider:e,active:t,available:n,detectedRoute:r,busy:i,onClick:o}){let{t:s}=a(`integrations`),c=s(n?t?`plugins.headroom.provider.routedThroughHeadroom`:r?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,I.jsxs)(`button`,{type:`button`,onClick:o,disabled:i||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,I.jsx)(`div`,{className:S(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:i?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(M,{className:`h-3.5 w-3.5`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:c})]}),(0,I.jsx)(`span`,{className:S(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,I.jsx)(`span`,{className:S(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ve({plugin:e,projects:t,onClose:n}){let{t:r}=a(`integrations`),[i,o]=(0,F.useState)(``);(0,F.useEffect)(()=>o(``),[e]);let c=t.find(e=>e.id===i)??null;return(0,I.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,I.jsxs)(b,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,I.jsxs)(y,{children:[(0,I.jsx)(v,{children:r(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,I.jsx)(_,{children:r(`plugins.projectWizard.description`)})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:r(`plugins.projectWizard.chooseProject`)}),(0,I.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!s(t).some(e=>K.has(e));return(0,I.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:S(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===i?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,I.jsx)(`div`,{className:`truncate text-[10px]`,children:n?r(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude, Codex, or Kimi`}):t.path})]},t.id)})})]}),(0,I.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:c?e===`jira`?(0,I.jsx)(ye,{project:c,onDone:n}):(0,I.jsx)(be,{project:c,onDone:n}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function ye({project:e,onDone:t}){let{t:n}=a(`integrations`),r=Z(e.id),[i,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!0),[l,u]=(0,F.useState)(null),f=(0,F.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch(`${r}/jira/connection`).then(e=>X(e));o(e)}catch(e){o({connected:!1}),u(e.message)}finally{c(!1)}},[r]);return(0,F.useEffect)(()=>{f()},[f]),s?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,I.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):i?.connected&&i.connection?(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,I.jsx)(U,{state:i,apiBase:r,onChanged:()=>{f()}})]}):(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l?n(`plugins.jira.loadFailed`,{message:l,defaultValue:`Could not load the current Jira configuration: ${l}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,I.jsx)(R,{apiBase:r,onConnected:()=>{f()},onSkip:t})]})}function be({project:e,onDone:t}){let{t:n}=a(`integrations`),r=(0,F.useMemo)(()=>s(e).filter(e=>K.has(e)),[e]),i=r.includes(e.provider)?e.provider:r[0]??e.provider,[o,c]=(0,F.useState)(i),[l,f]=(0,F.useState)(null),[p,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(null),b=(0,F.useRef)(0);(0,F.useEffect)(()=>{c(i),f(null),h(null)},[e.id,i]);let x=(0,F.useCallback)(async()=>{let t=++b.current;y(null);try{let n=`?provider=${encodeURIComponent(o)}`,r=await fetch(`${Z(e.id)}/plugins${n}`).then(e=>X(e));if(t!==b.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(f(i),h(null),i?.status===`not-installed`){let r=await fetch(`${Z(e.id)}/plugins/serena/preview-install${n}`).then(e=>X(e));t===b.current&&h(r)}}catch(e){t===b.current&&y(e.message)}},[e.id,o]);(0,F.useEffect)(()=>{x()},[x]);async function S(){_(!0),y(null);try{await fetch(`${Z(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:o})}).then(e=>X(e)),await x(),t()}catch(e){y(e.message)}finally{_(!1)}}let C=(p?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),T=l?n(`plugins.projectStatus.${l.status}`,{defaultValue:l.status}):``,E=l?.name===`serena`?n(`plugins.catalog.serena.description`):l?.description;return!l&&!v?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,I.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,I.jsxs)(`label`,{className:`block space-y-1`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,I.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:o,disabled:g,onChange:e=>{f(null),h(null),c(e.target.value)},className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:r.map(e=>(0,I.jsx)(`option`,{value:e,children:w(e)},e))})]}),l&&(0,I.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:T})}),E&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:E})]}),p&&(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,I.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:p.files.map(e=>(0,I.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,I.jsx)(`ul`,{className:`space-y-1 text-xs`,children:p.requirements.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,I.jsx)(O,{className:`h-3 w-3 text-accent-success`}):(0,I.jsx)(m,{className:`h-3 w-3 text-accent-warning`}),(0,I.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),v&&(0,I.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:v}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,I.jsxs)(`button`,{type:`button`,disabled:g||l?.status!==`not-installed`||!C,onClick:S,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[g?(0,I.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(u,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function xe({open:e,onClose:t}){let{t:n}=a(`integrations`),[i,o]=(0,F.useState)(null);return(0,F.useEffect)(()=>{e&&fetch(`${r}/api/global-plugins/headroom/diagnostics`).then(e=>X(e)).then(o).catch(e=>o({error:e.message}))},[e]),(0,I.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,I.jsxs)(b,{className:`max-w-3xl`,children:[(0,I.jsxs)(y,{children:[(0,I.jsxs)(v,{className:`flex items-center gap-2`,children:[(0,I.jsx)(P,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,I.jsx)(_,{children:n(`plugins.diagnostics.description`)})]}),(0,I.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{ae as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{r as a}from"./useDesktop-RSMTyy7V.js";import{t as o}from"./git-branch-BRM0F5GN.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-SRw01_QU.js";import{t as f}from"./utils-BC4DHlz2.js";import{a as p,at as m,c as h,ct as g,i as _,n as v,nt as y,o as b,ot as x,r as S,s as C,zt as w}from"./index-EzrkUb8B.js";var T=i(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),E=e(t(),1),D=n(),O=[{id:`general`,icon:x,labelKey:`projectDialog.nav.general`},{id:`branch`,icon:o,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:T,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:y,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:w,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:m,labelKey:`projectDialog.nav.terminal`}];function k({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:o}=a(),m=o.find(e=>e.id===i),[y,x]=(0,E.useState)(`general`),w=e=>f(`space-y-5`,y===e?``:`hidden`);return(0,D.jsx)(d,{open:e,onOpenChange:e=>{e||t()},children:(0,D.jsxs)(u,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,D.jsxs)(l,{children:[(0,D.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,D.jsx)(g,{className:`w-4 h-4`}),m?n(`projectDialog.title`,{name:m.name}):n(`page.title`)]}),(0,D.jsx)(s,{children:n(`projectDialog.description`)})]}),(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,D.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:O.map(e=>{let t=e.icon;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>x(e.id),className:f(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,y===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,D.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,D.jsxs)(`div`,{className:w(`general`),children:[(0,D.jsx)(C,{}),(0,D.jsx)(_,{})]}),(0,D.jsx)(`div`,{className:w(`branch`),children:(0,D.jsx)(S,{})}),(0,D.jsx)(`div`,{className:w(`environment`),children:(0,D.jsx)(b,{})}),(0,D.jsx)(`div`,{className:w(`budget`),children:(0,D.jsx)(v,{})}),(0,D.jsx)(`div`,{className:w(`telemetry`),children:(0,D.jsx)(p,{})}),(0,D.jsx)(`div`,{className:w(`terminal`),children:(0,D.jsx)(h,{mode:`project`})})]})]})]})})}export{k as ProjectSettingsDialog};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{r as a}from"./useDesktop-RSMTyy7V.js";import{t as o}from"./git-branch-BRM0F5GN.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-xXB2q5HJ.js";import{t as f}from"./utils-BC4DHlz2.js";import{a as p,at as m,c as h,ct as g,i as _,n as v,nt as y,o as b,ot as x,r as S,s as C,zt as w}from"./index-m5pKr1T6.js";var T=i(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),E=e(t(),1),D=n(),O=[{id:`general`,icon:x,labelKey:`projectDialog.nav.general`},{id:`branch`,icon:o,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:T,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:y,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:w,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:m,labelKey:`projectDialog.nav.terminal`}];function k({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:o}=a(),m=o.find(e=>e.id===i),[y,x]=(0,E.useState)(`general`),w=e=>f(`space-y-5`,y===e?``:`hidden`);return(0,D.jsx)(d,{open:e,onOpenChange:e=>{e||t()},children:(0,D.jsxs)(u,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,D.jsxs)(l,{children:[(0,D.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,D.jsx)(g,{className:`w-4 h-4`}),m?n(`projectDialog.title`,{name:m.name}):n(`page.title`)]}),(0,D.jsx)(s,{children:n(`projectDialog.description`)})]}),(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,D.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:O.map(e=>{let t=e.icon;return(0,D.jsxs)(`button`,{type:`button`,onClick:()=>x(e.id),className:f(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,y===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,D.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,D.jsxs)(`div`,{className:w(`general`),children:[(0,D.jsx)(C,{}),(0,D.jsx)(_,{})]}),(0,D.jsx)(`div`,{className:w(`branch`),children:(0,D.jsx)(S,{})}),(0,D.jsx)(`div`,{className:w(`environment`),children:(0,D.jsx)(b,{})}),(0,D.jsx)(`div`,{className:w(`budget`),children:(0,D.jsx)(v,{})}),(0,D.jsx)(`div`,{className:w(`telemetry`),children:(0,D.jsx)(p,{})}),(0,D.jsx)(`div`,{className:w(`terminal`),children:(0,D.jsx)(h,{mode:`project`})})]})]})]})})}export{k as ProjectSettingsDialog};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{i as o}from"./useDesktop-RSMTyy7V.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-SRw01_QU.js";import{t as p}from"./button-DCBqEaZl.js";var m=new Set([`building`,`on_review`,`pr_draft`,`pr_ready`,`no_changes`,`completed`,`pr_closed`,`superseded`,`merged`,`discarded`,`implementation_failed`,`pr_failed`]),h=new Set([`none`,`local-only`,`pushed`,`pr-created`]),g=new Set([`running`,`succeeded`,`partially_succeeded`,`failed`,`unknown`]),_=new Set([`pending`,`ready`,`delivered`,`partial`,`no_changes`,`retryable_failure`,`blocked`,`not_started`,`unknown`]),v=new Set([`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`,`checkout`]),y=new Set([`implementation_running`,`implementation_failed`,`ready_for_review`,`partial_success`,`partial_delivery`,`existing_pr_updated`,`no_changes`,`commit_failed`,`branch_verification_failed`,`push_failed`,`settlement_interrupted`,`recovery_unavailable`,`operation_interrupted`,`delivery_failed`,`pr_draft_ready`,`pr_ready`,`pr_closed`,`merged`,`discarded`,`superseded`,`cleanup_incomplete`,`status_failed`,`ref_mismatch`]);function b(e){return typeof e==`string`&&y.has(e)}var x=`previous delivery action was interrupted by restart`;function S(e,t){return e===`operation_interrupted`||typeof t==`string`&&t.toLowerCase().includes(x)}var C=e=>typeof e==`string`&&e.length>0?e:null,w=e=>typeof e==`string`&&e.length>0?e:null;function T(e){if(!e)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e)?`${e.replace(` `,`T`)}Z`:e,n=Date.parse(t);return Number.isFinite(n)?n:null}function ee(e,t){let n=T(e),r=T(t);return n==null||r==null?null:r<n?-1:+(r>n)}function te(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.ticketId!=`number`||!Number.isFinite(t.ticketId)||typeof t.branch!=`string`)return null;let n=typeof t.implementationOutcome==`string`&&g.has(t.implementationOutcome)?t.implementationOutcome:void 0,r=typeof t.deliveryOutcome==`string`&&_.has(t.deliveryOutcome)?t.deliveryOutcome:void 0;return{ticketId:t.ticketId,branch:t.branch,succeeded:t.succeeded===!0,...C(t.runId)?{runId:C(t.runId)}:{},...n?{implementationOutcome:n}:{},...r?{deliveryOutcome:r}:{},initialSha:w(t.initialSha),finalSha:w(t.finalSha),...typeof t.changed==`boolean`?{changed:t.changed}:{},failureCode:w(t.failureCode),...t.branchOwnership===`created`||t.branchOwnership===`preexisting`||t.branchOwnership===`borrowed-pr`?{branchOwnership:t.branchOwnership}:{},worktreePath:w(t.worktreePath)}}function E(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=C(n.prDeliveryId)??C(n.id),i=typeof n.railIndex==`number`&&Number.isFinite(n.railIndex)?n.railIndex:t;if(!r||i==null||typeof n.decision!=`string`||!m.has(n.decision))return null;let a=typeof n.implementationOutcome==`string`&&g.has(n.implementationOutcome)?n.implementationOutcome:void 0,o=typeof n.deliveryOutcome==`string`&&_.has(n.deliveryOutcome)?n.deliveryOutcome:void 0,s=(Array.isArray(n.units)?n.units:Array.isArray(n.branches)?n.branches:[]).map(te).filter(e=>e!==null);return{prDeliveryId:r,railIndex:i,railKey:typeof n.railKey==`string`?n.railKey:``,ticketIds:Array.isArray(n.ticketIds)?n.ticketIds.filter(e=>typeof e==`number`&&Number.isFinite(e)):[],baseBranch:typeof n.baseBranch==`string`?n.baseBranch:``,branch:w(n.branch),prUrl:w(n.prUrl),prNumber:typeof n.prNumber==`number`&&Number.isInteger(n.prNumber)&&n.prNumber>0?n.prNumber:null,prState:typeof n.prState==`string`&&h.has(n.prState)?n.prState:`none`,decision:n.decision,runIds:Array.isArray(n.runIds)?n.runIds.filter(e=>typeof e==`string`&&e.length>0):s.map(e=>e.runId).filter(e=>typeof e==`string`&&e.length>0),originConversationId:w(n.originConversationId),createdAt:typeof n.createdAt==`string`?n.createdAt:void 0,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:void 0,...a?{implementationOutcome:a}:{},...o?{deliveryOutcome:o}:{},statusCode:w(n.statusCode),statusDetail:w(n.statusDetail),deliverySha:w(n.deliverySha),isContinuation:n.isContinuation===!0,supersedesDeliveryId:w(n.supersedesDeliveryId),restoredFromDeliveryId:w(n.restoredFromDeliveryId),operation:typeof n.operation==`string`&&v.has(n.operation)?n.operation:null,cleanupWarnings:Array.isArray(n.cleanupWarnings)?n.cleanupWarnings.filter(e=>typeof e==`string`&&e.length>0):[],safetyArchives:Array.isArray(n.safetyArchives)?n.safetyArchives.filter(e=>typeof e==`string`&&e.length>0):[],units:s,executionManifest:n.executionManifest&&typeof n.executionManifest==`object`&&n.executionManifest.version===1?n.executionManifest:void 0,repositoryDeliveries:Array.isArray(n.repositoryDeliveries)?n.repositoryDeliveries.slice(0,100).flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.repositoryId!=`string`||typeof t.deliveryId!=`string`||typeof t.name!=`string`||typeof t.path!=`string`)return[];let n=E({...t,prDeliveryId:t.deliveryId,repositoryDeliveries:void 0},i);return n?[{repositoryId:t.repositoryId,deliveryId:t.deliveryId,name:t.name,path:t.path,baseBranch:n.baseBranch,...C(t.integrationBranch)?{integrationBranch:C(t.integrationBranch)}:{},branch:n.branch,deliverySha:n.deliverySha??null,decision:n.decision,implementationOutcome:n.implementationOutcome??`unknown`,deliveryOutcome:n.deliveryOutcome??`unknown`,statusCode:n.statusCode??null,statusDetail:n.statusDetail??null,prUrl:n.prUrl,prNumber:n.prNumber,runIds:n.runIds,worktreeIds:Array.isArray(t.worktreeIds)?t.worktreeIds.filter(e=>typeof e==`string`):[]}]:[]}):void 0}}function ne(e){let t=D(e);if(t.terminal||t.deliveryBlocked||t.implementationFailed||t.noChanges||e.decision===`building`||e.decision===`implementation_failed`)return null;if(e.branch||e.deliverySha)return e.branch&&/^[0-9a-f]{40,64}$/i.test(e.deliverySha??``)?e.branch:null;let n=e.units??[];if(n.length!==1)return null;let r=n[0];return!r.succeeded||r.implementationOutcome===`failed`||r.deliveryOutcome===`blocked`||r.deliveryOutcome===`no_changes`||r.changed===!1?null:r.branch&&/^[0-9a-f]{40,64}$/i.test(r.finalSha??``)?r.branch:null}function D(e){let t=e.units??[],n=t.length>0?t.filter(e=>e.implementationOutcome===`succeeded`||e.implementationOutcome==null&&e.succeeded).length:e.implementationOutcome===`failed`?0:e.ticketIds.length,r=t.length>0?t.filter(e=>e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded).length:e.implementationOutcome===`failed`?e.ticketIds.length:0,i=e.decision===`no_changes`||e.decision===`completed`||e.deliveryOutcome===`no_changes`||e.statusCode===`no_changes`,a=e.implementationOutcome===`partially_succeeded`||e.deliveryOutcome===`partial`||n>0&&r>0,o=t.length>0?t.filter(e=>e.deliveryOutcome===`ready`||e.deliveryOutcome===`delivered`||e.deliveryOutcome==null&&e.succeeded).length:a?0:n,s=a&&o===0,c=e.implementationOutcome===`failed`||e.implementationOutcome==null&&e.decision===`implementation_failed`,l=e.deliveryOutcome===`retryable_failure`,u=!c&&!l&&(s||e.deliveryOutcome===`blocked`||[`commit_failed`,`branch_verification_failed`,`settlement_interrupted`,`recovery_unavailable`,`status_failed`,`ref_mismatch`,`delivery_failed`].includes(e.statusCode??``)),d=e.isContinuation===!0,f=[...new Set((e.runIds??[]).filter(e=>typeof e==`string`&&e.length>0))],p=f.length===1?f[0]:null,m=p&&e.branch?t.filter(t=>t.runId===p&&t.branch===e.branch):[],h=[...new Set(m.map(e=>e.worktreePath).filter(e=>!!e))],g=(e.statusCode===`settlement_interrupted`||e.statusCode===`recovery_unavailable`)&&d?h:[...new Set(t.map(e=>e.worktreePath).filter(e=>!!e))],_=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&e.statusCode===`settlement_interrupted`&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),v=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&e.statusCode===`recovery_unavailable`,y=v&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),b=g.length>0||v&&!!e.deliverySha,x=!c&&l&&(e.statusCode===`push_failed`||d||!!e.prUrl),S=!c&&l&&!x,C=e.decision===`pr_closed`,w=e.decision===`superseded`;return{noChanges:i,partial:a,partialUndeliverable:s,implementationFailed:c,deliveryBlocked:u,retryablePush:x,retryablePrCreation:S,manualRecovery:_,recoveryUnavailable:v,recoveryRecheck:y,hasDiscardableRecoveryResult:b,continuation:d,localOnly:e.prState===`local-only`,closed:C,superseded:w,terminal:e.decision===`merged`||e.decision===`discarded`||e.decision===`completed`||w,succeededCount:n,deliverableCount:o,failedCount:r,totalCount:t.length>0?t.length:e.ticketIds.length,units:t,cleanupWarnings:e.cleanupWarnings??[],safetyArchives:e.safetyArchives??[],recoveryWorktreePaths:g}}var re=a(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),O=`specrails:git-changed`;function ie(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(O,{detail:{projectId:e}}))}function ae(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail?.projectId;typeof n==`string`&&n&&e(n)};return window.addEventListener(O,t),()=>window.removeEventListener(O,t)}var k=e(t(),1),oe=`"\\/bfnrtu`;function A(e){return e===` `||e===` `||e===`\r`||e===`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{i as o}from"./useDesktop-RSMTyy7V.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-xXB2q5HJ.js";import{t as p}from"./button-Ccc9Dc-D.js";var m=new Set([`building`,`on_review`,`pr_draft`,`pr_ready`,`no_changes`,`completed`,`pr_closed`,`superseded`,`merged`,`discarded`,`implementation_failed`,`pr_failed`]),h=new Set([`none`,`local-only`,`pushed`,`pr-created`]),g=new Set([`running`,`succeeded`,`partially_succeeded`,`failed`,`unknown`]),_=new Set([`pending`,`ready`,`delivered`,`partial`,`no_changes`,`retryable_failure`,`blocked`,`not_started`,`unknown`]),v=new Set([`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`,`checkout`]),y=new Set([`implementation_running`,`implementation_failed`,`ready_for_review`,`partial_success`,`partial_delivery`,`existing_pr_updated`,`no_changes`,`commit_failed`,`branch_verification_failed`,`push_failed`,`settlement_interrupted`,`recovery_unavailable`,`operation_interrupted`,`delivery_failed`,`pr_draft_ready`,`pr_ready`,`pr_closed`,`merged`,`discarded`,`superseded`,`cleanup_incomplete`,`status_failed`,`ref_mismatch`]);function b(e){return typeof e==`string`&&y.has(e)}var x=`previous delivery action was interrupted by restart`;function S(e,t){return e===`operation_interrupted`||typeof t==`string`&&t.toLowerCase().includes(x)}var C=e=>typeof e==`string`&&e.length>0?e:null,w=e=>typeof e==`string`&&e.length>0?e:null;function T(e){if(!e)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e)?`${e.replace(` `,`T`)}Z`:e,n=Date.parse(t);return Number.isFinite(n)?n:null}function ee(e,t){let n=T(e),r=T(t);return n==null||r==null?null:r<n?-1:+(r>n)}function te(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.ticketId!=`number`||!Number.isFinite(t.ticketId)||typeof t.branch!=`string`)return null;let n=typeof t.implementationOutcome==`string`&&g.has(t.implementationOutcome)?t.implementationOutcome:void 0,r=typeof t.deliveryOutcome==`string`&&_.has(t.deliveryOutcome)?t.deliveryOutcome:void 0;return{ticketId:t.ticketId,branch:t.branch,succeeded:t.succeeded===!0,...C(t.runId)?{runId:C(t.runId)}:{},...n?{implementationOutcome:n}:{},...r?{deliveryOutcome:r}:{},initialSha:w(t.initialSha),finalSha:w(t.finalSha),...typeof t.changed==`boolean`?{changed:t.changed}:{},failureCode:w(t.failureCode),...t.branchOwnership===`created`||t.branchOwnership===`preexisting`||t.branchOwnership===`borrowed-pr`?{branchOwnership:t.branchOwnership}:{},worktreePath:w(t.worktreePath)}}function E(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=C(n.prDeliveryId)??C(n.id),i=typeof n.railIndex==`number`&&Number.isFinite(n.railIndex)?n.railIndex:t;if(!r||i==null||typeof n.decision!=`string`||!m.has(n.decision))return null;let a=typeof n.implementationOutcome==`string`&&g.has(n.implementationOutcome)?n.implementationOutcome:void 0,o=typeof n.deliveryOutcome==`string`&&_.has(n.deliveryOutcome)?n.deliveryOutcome:void 0,s=(Array.isArray(n.units)?n.units:Array.isArray(n.branches)?n.branches:[]).map(te).filter(e=>e!==null);return{prDeliveryId:r,railIndex:i,railKey:typeof n.railKey==`string`?n.railKey:``,ticketIds:Array.isArray(n.ticketIds)?n.ticketIds.filter(e=>typeof e==`number`&&Number.isFinite(e)):[],baseBranch:typeof n.baseBranch==`string`?n.baseBranch:``,branch:w(n.branch),prUrl:w(n.prUrl),prNumber:typeof n.prNumber==`number`&&Number.isInteger(n.prNumber)&&n.prNumber>0?n.prNumber:null,prState:typeof n.prState==`string`&&h.has(n.prState)?n.prState:`none`,decision:n.decision,runIds:Array.isArray(n.runIds)?n.runIds.filter(e=>typeof e==`string`&&e.length>0):s.map(e=>e.runId).filter(e=>typeof e==`string`&&e.length>0),originConversationId:w(n.originConversationId),createdAt:typeof n.createdAt==`string`?n.createdAt:void 0,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:void 0,...a?{implementationOutcome:a}:{},...o?{deliveryOutcome:o}:{},statusCode:w(n.statusCode),statusDetail:w(n.statusDetail),deliverySha:w(n.deliverySha),isContinuation:n.isContinuation===!0,supersedesDeliveryId:w(n.supersedesDeliveryId),restoredFromDeliveryId:w(n.restoredFromDeliveryId),operation:typeof n.operation==`string`&&v.has(n.operation)?n.operation:null,cleanupWarnings:Array.isArray(n.cleanupWarnings)?n.cleanupWarnings.filter(e=>typeof e==`string`&&e.length>0):[],safetyArchives:Array.isArray(n.safetyArchives)?n.safetyArchives.filter(e=>typeof e==`string`&&e.length>0):[],units:s,executionManifest:n.executionManifest&&typeof n.executionManifest==`object`&&n.executionManifest.version===1?n.executionManifest:void 0,repositoryDeliveries:Array.isArray(n.repositoryDeliveries)?n.repositoryDeliveries.slice(0,100).flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.repositoryId!=`string`||typeof t.deliveryId!=`string`||typeof t.name!=`string`||typeof t.path!=`string`)return[];let n=E({...t,prDeliveryId:t.deliveryId,repositoryDeliveries:void 0},i);return n?[{repositoryId:t.repositoryId,deliveryId:t.deliveryId,name:t.name,path:t.path,baseBranch:n.baseBranch,...C(t.integrationBranch)?{integrationBranch:C(t.integrationBranch)}:{},branch:n.branch,deliverySha:n.deliverySha??null,decision:n.decision,implementationOutcome:n.implementationOutcome??`unknown`,deliveryOutcome:n.deliveryOutcome??`unknown`,statusCode:n.statusCode??null,statusDetail:n.statusDetail??null,prUrl:n.prUrl,prNumber:n.prNumber,runIds:n.runIds,worktreeIds:Array.isArray(t.worktreeIds)?t.worktreeIds.filter(e=>typeof e==`string`):[]}]:[]}):void 0}}function ne(e){let t=D(e);if(t.terminal||t.deliveryBlocked||t.implementationFailed||t.noChanges||e.decision===`building`||e.decision===`implementation_failed`)return null;if(e.branch||e.deliverySha)return e.branch&&/^[0-9a-f]{40,64}$/i.test(e.deliverySha??``)?e.branch:null;let n=e.units??[];if(n.length!==1)return null;let r=n[0];return!r.succeeded||r.implementationOutcome===`failed`||r.deliveryOutcome===`blocked`||r.deliveryOutcome===`no_changes`||r.changed===!1?null:r.branch&&/^[0-9a-f]{40,64}$/i.test(r.finalSha??``)?r.branch:null}function D(e){let t=e.units??[],n=t.length>0?t.filter(e=>e.implementationOutcome===`succeeded`||e.implementationOutcome==null&&e.succeeded).length:e.implementationOutcome===`failed`?0:e.ticketIds.length,r=t.length>0?t.filter(e=>e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded).length:e.implementationOutcome===`failed`?e.ticketIds.length:0,i=e.decision===`no_changes`||e.decision===`completed`||e.deliveryOutcome===`no_changes`||e.statusCode===`no_changes`,a=e.implementationOutcome===`partially_succeeded`||e.deliveryOutcome===`partial`||n>0&&r>0,o=t.length>0?t.filter(e=>e.deliveryOutcome===`ready`||e.deliveryOutcome===`delivered`||e.deliveryOutcome==null&&e.succeeded).length:a?0:n,s=a&&o===0,c=e.implementationOutcome===`failed`||e.implementationOutcome==null&&e.decision===`implementation_failed`,l=e.deliveryOutcome===`retryable_failure`,u=!c&&!l&&(s||e.deliveryOutcome===`blocked`||[`commit_failed`,`branch_verification_failed`,`settlement_interrupted`,`recovery_unavailable`,`status_failed`,`ref_mismatch`,`delivery_failed`].includes(e.statusCode??``)),d=e.isContinuation===!0,f=[...new Set((e.runIds??[]).filter(e=>typeof e==`string`&&e.length>0))],p=f.length===1?f[0]:null,m=p&&e.branch?t.filter(t=>t.runId===p&&t.branch===e.branch):[],h=[...new Set(m.map(e=>e.worktreePath).filter(e=>!!e))],g=(e.statusCode===`settlement_interrupted`||e.statusCode===`recovery_unavailable`)&&d?h:[...new Set(t.map(e=>e.worktreePath).filter(e=>!!e))],_=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&e.statusCode===`settlement_interrupted`&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),v=e.decision===`pr_failed`&&e.deliveryOutcome===`blocked`&&u&&d&&e.statusCode===`recovery_unavailable`,y=v&&!!e.prUrl&&!!e.branch&&f.length===1&&m.length>0&&h.length<=1&&(e.implementationOutcome===`succeeded`||e.implementationOutcome===`partially_succeeded`),b=g.length>0||v&&!!e.deliverySha,x=!c&&l&&(e.statusCode===`push_failed`||d||!!e.prUrl),S=!c&&l&&!x,C=e.decision===`pr_closed`,w=e.decision===`superseded`;return{noChanges:i,partial:a,partialUndeliverable:s,implementationFailed:c,deliveryBlocked:u,retryablePush:x,retryablePrCreation:S,manualRecovery:_,recoveryUnavailable:v,recoveryRecheck:y,hasDiscardableRecoveryResult:b,continuation:d,localOnly:e.prState===`local-only`,closed:C,superseded:w,terminal:e.decision===`merged`||e.decision===`discarded`||e.decision===`completed`||w,succeededCount:n,deliverableCount:o,failedCount:r,totalCount:t.length>0?t.length:e.ticketIds.length,units:t,cleanupWarnings:e.cleanupWarnings??[],safetyArchives:e.safetyArchives??[],recoveryWorktreePaths:g}}var re=a(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),O=`specrails:git-changed`;function ie(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(O,{detail:{projectId:e}}))}function ae(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail?.projectId;typeof n==`string`&&n&&e(n)};return window.addEventListener(O,t),()=>window.removeEventListener(O,t)}var k=e(t(),1),oe=`"\\/bfnrtu`;function A(e){return e===` `||e===` `||e===`\r`||e===`
2
2
  `}function se(e){let t=new Set,n=e.trim(),r=/^```[A-Za-z0-9_-]*[ \t]*\r?\n/.exec(n);r&&(n=n.slice(r[0].length),t.add(`nested_fence`));let i=/\r?\n[ \t]*```[ \t]*$/.exec(n);i&&(n=n.slice(0,i.index),t.add(`nested_fence`));let a=n.indexOf(`{`),o=n.lastIndexOf(`}`);a!==-1&&o>a&&(a>0||o<n.length-1)&&(n=n.slice(a,o+1),t.add(`trimmed_wrapper`));let s=``,c=!1;for(let e=0;e<n.length;e++){let r=n[e];if(c){if(r===`\\`){let i=n[e+1];if(i===void 0){t.add(`dangling_escape`);break}if(oe.includes(i)){s+=r+i,e+=1;continue}s+=i===`
3
3
  `?`\\n`:i,e+=1,t.add(`invalid_escape`);continue}if(r===`"`){let i=e+1;for(;i<n.length&&A(n[i]);)i+=1;let a=n[i];if(a===void 0||a===`,`||a===`}`||a===`]`||a===`:`){c=!1,s+=r;continue}s+=`\\"`,t.add(`inner_quote`);continue}if(r===`
4
4
  `){s+=`\\n`,t.add(`raw_newline`);continue}if(r===`\r`){t.add(`raw_newline`);continue}if(r===` `){s+=`\\t`,t.add(`raw_control`);continue}let i=r.charCodeAt(0);if(i<32){s+=`\\u`+i.toString(16).padStart(4,`0`),t.add(`raw_control`);continue}s+=r;continue}if(r===`"`){c=!0,s+=r;continue}if(r===`,`){let i=e+1;for(;i<n.length&&A(n[i]);)i+=1;if(n[i]===`}`||n[i]===`]`){t.add(`trailing_comma`);continue}s+=r;continue}if(r===`/`&&n[e+1]===`/`){let r=n.indexOf(`
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,f as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{B as ee,U as te,n as ne}from"./TicketDetailModalContext-DqyF0so-.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,r as re}from"./useDesktop-RSMTyy7V.js";import{C as ie,S as ae,T as oe,b as se,r as ce,t as le}from"./RepositoryDeliveries-CSDsiVUz.js";import{n as ue}from"./save-B6wGWwBR.js";import{d as de,u as l}from"./MinimizedChatsContext-Deg39peL.js";import{n as u}from"./file-text-BcLCfcWZ.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./sparkles-DrY8hb0X.js";import{t as p}from"./triangle-alert-H9T4jAmh.js";import{Lt as fe,St as pe,st as m,u as me}from"./index-EzrkUb8B.js";var he=s(`circle-dollar-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]),h=s(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),g=e(t(),1),_=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ge(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return _({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return _({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return _({fineControlOnly:!0});if(n.noChanges)return _({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return _({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return _(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return _({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return _({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return _({fineControlOnly:!0})}function _e(e,t){if(e===`discard`)return`discard`;if(e===`request-changes`)return null;switch(t.acceptMeaning){case`create-pr`:return`create-pr`;case`publish`:return`publish`;case`merge-local`:return`merge-local`;case`mark-done`:return`acknowledge-no-changes`;default:return null}}var v=n(),ve=[`app-verified`,`ai-reported`,`reviewer-score`],ye={"app-verified":m,"ai-reported":f,"reviewer-score":h},be={"app-verified":`text-accent-success border-accent-success/30 bg-accent-success/5`,"ai-reported":`text-accent-highlight border-accent-highlight/30 bg-accent-highlight/5`,"reviewer-score":`text-accent-info border-accent-info/30 bg-accent-info/5`};function y({item:e}){let{t}=o(`packet`);return(0,v.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,v.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,v.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded border border-border/60 bg-background-deep/60 p-2 text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawExcerpt}):null]})}function b({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,g.useState)(n);return(0,v.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-3 text-left`,"aria-expanded":i,children:[i?(0,v.jsx)(l,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,v.jsx)(u,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,v.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,v.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function x(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:s}=o([`packet`,`common`]),l=a(),[u,f]=i(),m=u.get(`repositoryId`),h=(0,g.useRef)(0),_=e.onClose??(()=>l(`/`)),{activeProjectId:x}=re(),xe=ce(x),Se=n?xe.has(n):!1,{act:S,checkout:Ce}=me(),{openTicketDetail:we}=ne(),C=JSON.stringify([x,n,m]),w=(0,g.useRef)({key:C,epoch:0});w.current.key!==C&&(w.current={key:C,epoch:w.current.epoch+1});let T=w.current.epoch,E=(0,g.useRef)(!0);(0,g.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);let D=(0,g.useCallback)(()=>E.current&&w.current.key===C&&w.current.epoch===T,[C,T]),[O,k]=(0,g.useState)(null),A=O?.key===C&&O.epoch===T?O:null,j=A?.data??null,M=A?.loading??!0,N=A?.error??null,[P,F]=(0,g.useState)(null),[Te,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(``),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(null),[G,K]=(0,g.useState)(!1),q=(0,g.useCallback)(async()=>{if(!n||!x||!D())return;let e=++h.current,t=()=>D()&&h.current===e;k(e=>({key:C,epoch:T,data:e?.key===C&&e.epoch===T?e.data:null,loading:!0,error:null}));try{let e=m?`?repositoryId=${encodeURIComponent(m)}`:``,r=await fetch(`${c()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){k({key:C,epoch:T,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;k({key:C,epoch:T,data:i,loading:!1,error:null})}catch{if(!t())return;k({key:C,epoch:T,data:null,loading:!1,error:`loadFailed`})}},[n,x,m,C,T,D]);(0,g.useEffect)(()=>(q(),I(!1),K(!1),F(null),R(null),W(null),H(!1),B(``),()=>{h.current++}),[q]);let J=(0,g.useMemo)(()=>ie(j?.snapshot),[j?.snapshot]),Y=j?.packet??null,X=M||P!==null||V||!!J?.operation,Z=j?.acceptCapability??null,Q=(0,g.useMemo)(()=>{if(!Y)return null;let e=oe({decision:Y.decision,ticketIds:Y.ticketIds,prState:Y.prUrl?`pr-created`:`none`,statusCode:Y.statusCode,prUrl:Y.prUrl,runIds:Y.runIds});return ge({decision:Y.decision,presentation:e,prUrl:Y.prUrl,canCreatePr:Z?.target===`create-pr`})},[Y,Z]),$=(0,g.useCallback)(async e=>{if(!Y||!Q||X||!D())return;let t=_e(e,Q);if(t){R(null),F(e);try{let e=await(m&&J?S(J.railIndex,t,J.decision,J.prDeliveryId,m):S(Y.railIndex,t,Y.decision,Y.prDeliveryId));if(!D())return;e.ok?x&&se(x):R(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await q()}finally{D()&&(F(null),I(!1))}}},[S,x,q,Y,Q,J,m,X,D]),Ee=(0,g.useCallback)(async()=>{if(!(!Y||!z.trim()||!x||X||!D())){W(null),H(!0);try{let e=await fetch(`${c()}/rails/${Y.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({revisionOfDeliveryId:J?.prDeliveryId??Y.prDeliveryId,revisionNote:z.trim(),...J?.executionManifest?{repositoryIds:J.executionManifest.selectedRepositoryIds}:{}})});if(!D())return;if(!e.ok){let t=await e.json().catch(()=>null);if(!D())return;W(t?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}B(``),K(!1),await q()}catch{D()&&W(`revisionFailed`)}finally{D()&&H(!1)}}},[x,q,Y,z,J,X,D]);if(M&&!Y)return(0,v.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,v.jsx)(d,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),s(`common:states.loading`)]});if(N||!Y||!Q)return(0,v.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,v.jsx)(p,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(N===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:s(`backToBoard`)})]});let De=ve.map(e=>({tier:e,items:Y.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Oe=Y.cost.totalUsd===null?`—`:`${Y.cost.estimated?`~`:``}$${Y.cost.totalUsd.toFixed(2)}`;return(0,v.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:_,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,v.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),s(`backToBoard`)]}),J?.repositoryDeliveries?.length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[s(`common:repositories.select`),(0,v.jsxs)(`select`,{value:m??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),f(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,v.jsx)(`option`,{value:``,children:s(`common:repositories.all`)}),J.repositoryDeliveries.map(e=>(0,v.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,v.jsx)(le,{deliveryId:J.prDeliveryId,repositories:J.repositoryDeliveries,busy:X,onAct:async(e,t)=>{if(!(X||!D())){F(`accept`);try{let n=await S(J.railIndex,e,J.decision,J.prDeliveryId,t);if(!D())return;n.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}},onCheckout:async e=>{if(!(X||!D())){F(`accept`);try{let t=await Ce(J.railIndex,J.prDeliveryId,e);if(!D())return;t.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}}})]}):null,(0,v.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,v.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:s(Y.headlineCode,{count:Y.totalCount,succeeded:Y.succeededCount,total:Y.totalCount,defaultValue:Y.headlineCode})}),(0,v.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[Y.confidence?.overall!==null&&Y.confidence?.overall!==void 0?(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/30 bg-accent-info/10 px-2 py-0.5 text-accent-info`,title:s(`confidence.tooltip`),children:s(`confidence.pill`,{overall:Y.confidence.overall})}):(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-muted-foreground`,children:s(`confidence.unavailable`)}),(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,v.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),s(`cost.thisBuild`,{amount:Oe})]}),Y.prUrl?(0,v.jsxs)(`a`,{href:Y.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,v.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),s(`openPr`,{number:Y.prNumber??``})]}):null]}),Q.fineControlOnly?(0,v.jsx)(`p`,{className:`mt-4 rounded-md border border-accent-warning/30 bg-accent-warning/5 px-3 py-2 text-xs text-accent-warning`,children:s(`fineControlOnly`)}):Q.inFlight?(0,v.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}),s(`stillWorking`)]}):Q.terminal?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:s(`alreadyResolved`)}):(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!J?.repositoryDeliveries?.length||m)?Te?(0,v.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground`,children:s(`accept.irreversibleWarning`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:X,className:`rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept-confirm`,children:s(`accept.irreversibleConfirm`)}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>I(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:s(`common:actions.cancel`)})]})]}):(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?I(!0):$(`accept`)},disabled:X,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-success px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept`,children:[P===`accept`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(de,{className:`size-4`,"aria-hidden":!0}),s(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K(e=>!e),disabled:X||V,"aria-expanded":G,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-request-changes`,children:[(0,v.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:X,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-discard`,children:[P===`discard`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),s(`discard.label`)]}):null]}),Se&&Q.verbs.includes(`discard`)?(0,v.jsx)(`p`,{className:`mt-3 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-accent-warning`,"data-testid":`packet-discard-stacked-note`,children:s(`discard.stackedNote`)}):null,L?(0,v.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:s(`error.${L}`)}):null,G?(0,v.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,v.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:s(`requestChanges.prompt`)}),(0,v.jsx)(`textarea`,{id:`packet-revision-note`,value:z,onChange:e=>B(e.target.value),rows:2,placeholder:s(`requestChanges.placeholder`),className:`resize-y rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground`,"data-testid":`packet-revision-input`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(),disabled:X||z.trim().length===0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-revision-submit`,children:[V?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.submit`)]}),(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`requestChanges.hint`)})]}),U?(0,v.jsx)(`p`,{className:`text-xs text-accent-warning`,children:s(`error.${U}`)}):null]}):null]}),Y.driftNudges.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,v.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:s(`drift.title`)}),(0,v.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:Y.driftNudges.map(e=>(0,v.jsx)(`li`,{children:s(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,v.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:s(`drift.advisory`)})]}):null,Y.versions.length>1?(0,v.jsxs)(b,{title:s(`versions.title`,{count:Y.versions.length}),badge:(0,v.jsx)(pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,v.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:Y.versions.map(e=>(0,v.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:s(`versions.label`,{version:e.version})}),e.current?(0,v.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:s(`versions.current`)}):null,(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??s(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:s(`cost.allVersions`,{amount:Y.chainCostUsd===null?`—`:`${Y.chainCostEstimated?`~`:``}$${Y.chainCostUsd.toFixed(2)}`})})]}):null,Y.watchOut.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,v.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,v.jsx)(p,{className:`size-4`,"aria-hidden":!0}),s(`watchOut.title`)]}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Y.watchOut.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]}):null,(0,v.jsx)(b,{title:s(`sections.whatYouAsked`),defaultOpen:!0,children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>we(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,v.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.problem}):null]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.whatIDid`),children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),` `,e.solution??(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:s(`noSolutionRecorded`)}),e.churn?(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines})}):(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.batchNotSplittable`)})]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.howItWasChecked`),badge:Y.evidenceUnavailable?(0,v.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:s(`proof.evidenceUnavailable`)}):void 0,children:(0,v.jsx)(`div`,{className:`space-y-4`,children:De.map(({tier:e,items:t})=>{let n=ye[e];return(0,v.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${be[e]}`,children:[(0,v.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,v.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),s(`tier.${e}.title`)]}),(0,v.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:s(`tier.${e}.caveat`)}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{x as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,f as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{B as ee,U as te,n as ne}from"./TicketDetailModalContext-BNa1mdXq.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,r as re}from"./useDesktop-RSMTyy7V.js";import{C as ie,S as ae,T as oe,b as se,r as ce,t as le}from"./RepositoryDeliveries-IiQCcndQ.js";import{n as ue}from"./save-B6wGWwBR.js";import{d as de,u as l}from"./MinimizedChatsContext-Deg39peL.js";import{n as u}from"./file-text-BcLCfcWZ.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./sparkles-DrY8hb0X.js";import{t as p}from"./triangle-alert-H9T4jAmh.js";import{Lt as fe,St as pe,st as m,u as me}from"./index-m5pKr1T6.js";var he=s(`circle-dollar-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]),h=s(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),g=e(t(),1),_=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ge(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return _({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return _({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return _({fineControlOnly:!0});if(n.noChanges)return _({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return _({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return _(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return _({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return _({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return _({fineControlOnly:!0})}function _e(e,t){if(e===`discard`)return`discard`;if(e===`request-changes`)return null;switch(t.acceptMeaning){case`create-pr`:return`create-pr`;case`publish`:return`publish`;case`merge-local`:return`merge-local`;case`mark-done`:return`acknowledge-no-changes`;default:return null}}var v=n(),ve=[`app-verified`,`ai-reported`,`reviewer-score`],ye={"app-verified":m,"ai-reported":f,"reviewer-score":h},be={"app-verified":`text-accent-success border-accent-success/30 bg-accent-success/5`,"ai-reported":`text-accent-highlight border-accent-highlight/30 bg-accent-highlight/5`,"reviewer-score":`text-accent-info border-accent-info/30 bg-accent-info/5`};function y({item:e}){let{t}=o(`packet`);return(0,v.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,v.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,v.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded border border-border/60 bg-background-deep/60 p-2 text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawExcerpt}):null]})}function b({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,g.useState)(n);return(0,v.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-3 text-left`,"aria-expanded":i,children:[i?(0,v.jsx)(l,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,v.jsx)(u,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,v.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,v.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function x(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:s}=o([`packet`,`common`]),l=a(),[u,f]=i(),m=u.get(`repositoryId`),h=(0,g.useRef)(0),_=e.onClose??(()=>l(`/`)),{activeProjectId:x}=re(),xe=ce(x),Se=n?xe.has(n):!1,{act:S,checkout:Ce}=me(),{openTicketDetail:we}=ne(),C=JSON.stringify([x,n,m]),w=(0,g.useRef)({key:C,epoch:0});w.current.key!==C&&(w.current={key:C,epoch:w.current.epoch+1});let T=w.current.epoch,E=(0,g.useRef)(!0);(0,g.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);let D=(0,g.useCallback)(()=>E.current&&w.current.key===C&&w.current.epoch===T,[C,T]),[O,k]=(0,g.useState)(null),A=O?.key===C&&O.epoch===T?O:null,j=A?.data??null,M=A?.loading??!0,N=A?.error??null,[P,F]=(0,g.useState)(null),[Te,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(``),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(null),[G,K]=(0,g.useState)(!1),q=(0,g.useCallback)(async()=>{if(!n||!x||!D())return;let e=++h.current,t=()=>D()&&h.current===e;k(e=>({key:C,epoch:T,data:e?.key===C&&e.epoch===T?e.data:null,loading:!0,error:null}));try{let e=m?`?repositoryId=${encodeURIComponent(m)}`:``,r=await fetch(`${c()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){k({key:C,epoch:T,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;k({key:C,epoch:T,data:i,loading:!1,error:null})}catch{if(!t())return;k({key:C,epoch:T,data:null,loading:!1,error:`loadFailed`})}},[n,x,m,C,T,D]);(0,g.useEffect)(()=>(q(),I(!1),K(!1),F(null),R(null),W(null),H(!1),B(``),()=>{h.current++}),[q]);let J=(0,g.useMemo)(()=>ie(j?.snapshot),[j?.snapshot]),Y=j?.packet??null,X=M||P!==null||V||!!J?.operation,Z=j?.acceptCapability??null,Q=(0,g.useMemo)(()=>{if(!Y)return null;let e=oe({decision:Y.decision,ticketIds:Y.ticketIds,prState:Y.prUrl?`pr-created`:`none`,statusCode:Y.statusCode,prUrl:Y.prUrl,runIds:Y.runIds});return ge({decision:Y.decision,presentation:e,prUrl:Y.prUrl,canCreatePr:Z?.target===`create-pr`})},[Y,Z]),$=(0,g.useCallback)(async e=>{if(!Y||!Q||X||!D())return;let t=_e(e,Q);if(t){R(null),F(e);try{let e=await(m&&J?S(J.railIndex,t,J.decision,J.prDeliveryId,m):S(Y.railIndex,t,Y.decision,Y.prDeliveryId));if(!D())return;e.ok?x&&se(x):R(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await q()}finally{D()&&(F(null),I(!1))}}},[S,x,q,Y,Q,J,m,X,D]),Ee=(0,g.useCallback)(async()=>{if(!(!Y||!z.trim()||!x||X||!D())){W(null),H(!0);try{let e=await fetch(`${c()}/rails/${Y.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({revisionOfDeliveryId:J?.prDeliveryId??Y.prDeliveryId,revisionNote:z.trim(),...J?.executionManifest?{repositoryIds:J.executionManifest.selectedRepositoryIds}:{}})});if(!D())return;if(!e.ok){let t=await e.json().catch(()=>null);if(!D())return;W(t?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}B(``),K(!1),await q()}catch{D()&&W(`revisionFailed`)}finally{D()&&H(!1)}}},[x,q,Y,z,J,X,D]);if(M&&!Y)return(0,v.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,v.jsx)(d,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),s(`common:states.loading`)]});if(N||!Y||!Q)return(0,v.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,v.jsx)(p,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(N===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:s(`backToBoard`)})]});let De=ve.map(e=>({tier:e,items:Y.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Oe=Y.cost.totalUsd===null?`—`:`${Y.cost.estimated?`~`:``}$${Y.cost.totalUsd.toFixed(2)}`;return(0,v.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:_,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,v.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),s(`backToBoard`)]}),J?.repositoryDeliveries?.length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[s(`common:repositories.select`),(0,v.jsxs)(`select`,{value:m??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),f(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,v.jsx)(`option`,{value:``,children:s(`common:repositories.all`)}),J.repositoryDeliveries.map(e=>(0,v.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,v.jsx)(le,{deliveryId:J.prDeliveryId,repositories:J.repositoryDeliveries,busy:X,onAct:async(e,t)=>{if(!(X||!D())){F(`accept`);try{let n=await S(J.railIndex,e,J.decision,J.prDeliveryId,t);if(!D())return;n.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}},onCheckout:async e=>{if(!(X||!D())){F(`accept`);try{let t=await Ce(J.railIndex,J.prDeliveryId,e);if(!D())return;t.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}}})]}):null,(0,v.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,v.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:s(Y.headlineCode,{count:Y.totalCount,succeeded:Y.succeededCount,total:Y.totalCount,defaultValue:Y.headlineCode})}),(0,v.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[Y.confidence?.overall!==null&&Y.confidence?.overall!==void 0?(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/30 bg-accent-info/10 px-2 py-0.5 text-accent-info`,title:s(`confidence.tooltip`),children:s(`confidence.pill`,{overall:Y.confidence.overall})}):(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-muted-foreground`,children:s(`confidence.unavailable`)}),(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,v.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),s(`cost.thisBuild`,{amount:Oe})]}),Y.prUrl?(0,v.jsxs)(`a`,{href:Y.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,v.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),s(`openPr`,{number:Y.prNumber??``})]}):null]}),Q.fineControlOnly?(0,v.jsx)(`p`,{className:`mt-4 rounded-md border border-accent-warning/30 bg-accent-warning/5 px-3 py-2 text-xs text-accent-warning`,children:s(`fineControlOnly`)}):Q.inFlight?(0,v.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}),s(`stillWorking`)]}):Q.terminal?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:s(`alreadyResolved`)}):(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!J?.repositoryDeliveries?.length||m)?Te?(0,v.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground`,children:s(`accept.irreversibleWarning`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:X,className:`rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept-confirm`,children:s(`accept.irreversibleConfirm`)}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>I(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:s(`common:actions.cancel`)})]})]}):(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?I(!0):$(`accept`)},disabled:X,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-success px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept`,children:[P===`accept`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(de,{className:`size-4`,"aria-hidden":!0}),s(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K(e=>!e),disabled:X||V,"aria-expanded":G,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-request-changes`,children:[(0,v.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:X,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-discard`,children:[P===`discard`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),s(`discard.label`)]}):null]}),Se&&Q.verbs.includes(`discard`)?(0,v.jsx)(`p`,{className:`mt-3 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-accent-warning`,"data-testid":`packet-discard-stacked-note`,children:s(`discard.stackedNote`)}):null,L?(0,v.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:s(`error.${L}`)}):null,G?(0,v.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,v.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:s(`requestChanges.prompt`)}),(0,v.jsx)(`textarea`,{id:`packet-revision-note`,value:z,onChange:e=>B(e.target.value),rows:2,placeholder:s(`requestChanges.placeholder`),className:`resize-y rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground`,"data-testid":`packet-revision-input`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(),disabled:X||z.trim().length===0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-revision-submit`,children:[V?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.submit`)]}),(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`requestChanges.hint`)})]}),U?(0,v.jsx)(`p`,{className:`text-xs text-accent-warning`,children:s(`error.${U}`)}):null]}):null]}),Y.driftNudges.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,v.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:s(`drift.title`)}),(0,v.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:Y.driftNudges.map(e=>(0,v.jsx)(`li`,{children:s(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,v.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:s(`drift.advisory`)})]}):null,Y.versions.length>1?(0,v.jsxs)(b,{title:s(`versions.title`,{count:Y.versions.length}),badge:(0,v.jsx)(pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,v.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:Y.versions.map(e=>(0,v.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:s(`versions.label`,{version:e.version})}),e.current?(0,v.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:s(`versions.current`)}):null,(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??s(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:s(`cost.allVersions`,{amount:Y.chainCostUsd===null?`—`:`${Y.chainCostEstimated?`~`:``}$${Y.chainCostUsd.toFixed(2)}`})})]}):null,Y.watchOut.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,v.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,v.jsx)(p,{className:`size-4`,"aria-hidden":!0}),s(`watchOut.title`)]}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Y.watchOut.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]}):null,(0,v.jsx)(b,{title:s(`sections.whatYouAsked`),defaultOpen:!0,children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>we(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,v.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.problem}):null]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.whatIDid`),children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),` `,e.solution??(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:s(`noSolutionRecorded`)}),e.churn?(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines})}):(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.batchNotSplittable`)})]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.howItWasChecked`),badge:Y.evidenceUnavailable?(0,v.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:s(`proof.evidenceUnavailable`)}):void 0,children:(0,v.jsx)(`div`,{className:`space-y-4`,children:De.map(({tier:e,items:t})=>{let n=ye[e];return(0,v.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${be[e]}`,children:[(0,v.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,v.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),s(`tier.${e}.title`)]}),(0,v.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:s(`tier.${e}.caveat`)}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{x as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{n as a,t as o}from"./square-Ci-PFcFe.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-SRw01_QU.js";import{t as p}from"./button-DCBqEaZl.js";import{kt as m,m as h,rt as g}from"./index-EzrkUb8B.js";var _=e(),v={start:a,"ai-step":n,shell:g,decider:i,condition:i,end:o};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:g=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(d,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(u,{children:[(0,_.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(c,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??o,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(p,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(p,{onClick:()=>a(e.id),children:[g===`fork`?(0,_.jsx)(m,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(g===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};
1
+ import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{n as a,t as o}from"./square-Ci-PFcFe.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-xXB2q5HJ.js";import{t as p}from"./button-Ccc9Dc-D.js";import{kt as m,m as h,rt as g}from"./index-m5pKr1T6.js";var _=e(),v={start:a,"ai-step":n,shell:g,decider:i,condition:i,end:o};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:g=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(d,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(u,{children:[(0,_.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(c,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??o,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(p,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(p,{onClick:()=>a(e.id),children:[g===`fork`?(0,_.jsx)(m,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(g===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};