specrails-desktop 2.64.0 → 2.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-D23wXKgy.js → ActivityFeedPage-Dtp7EyHc.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DQzS4XcK.js → AgentBrowserCapture-CLqlEFw8.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-CFTiSl8T.js → AgentModeAnalyticsPane-B8_hM3Tw.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-DAaSzIPA.js → AgentModeCodePane-CNF8ZNjE.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-C29YpixV.js → AgentModeJobsPane-CJpJbO9m.js} +1 -1
- package/client/dist/assets/AgentsPage-BC8XSR79.js +120 -0
- package/client/dist/assets/{AnalyticsPage-81fI80nA.js → AnalyticsPage-Cdv4jLtW.js} +1 -1
- package/client/dist/assets/{CodePage-Ct4XEPdx.js → CodePage-DI1kegAr.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-Bt37XOLF.js → DesktopAnalyticsPage-Bdp8E8U6.js} +1 -1
- package/client/dist/assets/{DocsDialog-_IEr8umI.js → DocsDialog-Bm4RS7FX.js} +1 -1
- package/client/dist/assets/{DocsPage-DX9WOqt2.js → DocsPage-DihYcU8r.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-DDI6TdsS.js → InteractiveJobComposer-BO6ASN-2.js} +1 -1
- package/client/dist/assets/{JobDetailModal-CkD0PBaZ.js → JobDetailModal-CuPYq7tP.js} +1 -1
- package/client/dist/assets/{JobDetailPage-B8Rd4U5J.js → JobDetailPage-BusMjJi9.js} +1 -1
- package/client/dist/assets/{JobsPage-ChOiSbJn.js → JobsPage-C0QbsF2d.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-6Xwt2G6G.js → LoopBuilderPage-B7TlU4iS.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-CyDapSvB.js → LoopPreviewModal-BRWtXOD2.js} +1 -1
- package/client/dist/assets/{LoopWindowSurface-gRdx4nmg.js → LoopWindowSurface-DE0v2K1p.js} +1 -1
- package/client/dist/assets/{LoopsPage-BPGVFsH-.js → LoopsPage-C4q1DmCE.js} +1 -1
- package/client/dist/assets/{PluginsPage-DQRRdCUi.js → PluginsPage-Z1JHSMdR.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-Ce8DSG6H.js → ProjectSettingsDialog-BUNj0tvN.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-WVoio8GJ.js → ReviewPacketPage-hwfPNjyy.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-CTBZUXAN.js → TemplatePreviewModal-V7FpMWuw.js} +1 -1
- package/client/dist/assets/{index-IdGpV21X.js → index-Ce4yZtKf.js} +6 -6
- package/client/dist/index.html +1 -1
- package/docs/internals/core-runtime-updates.md +3 -3
- package/local-runner/dist/specrails-local-runner.js +487 -148
- package/mcp-bridge/dist/specrails-mcp.js +330 -42
- package/package.json +6 -3
- package/client/dist/assets/AgentsPage-B-sSTP1I.js +0 -118
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{l as r,r as i,t as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{n as c,r as l,s as u}from"./useDesktop-BjLT0_EE.js";import{s as d}from"./provider-capabilities-lePfeT_Y.js";import{t as f}from"./download-C9wP_42h.js";import{t as p}from"./external-link-CZ6Q-v1-.js";import{t as m}from"./loader-circle-BqV9xYGf.js";import{t as h}from"./search-BDVp3fkH.js";import{t as g}from"./trash-D8zYUmTg.js";import{t as _}from"./triangle-alert-Cxpn8bqr.js";import{n as v,t as y}from"./jira-api-Cabj-H0J.js";import{i as b,l as x,o as S,r as C,t as w}from"./dialog-DtdR05v1.js";import{t as T}from"./utils-BC4DHlz2.js";import{t as E}from"./button-4FS1ZDTp.js";import{Ct as D,Jt as O,Ot as k,W as A,Zt as j,bt as M,kt as N,ln as ee,un as te,xt as ne,yt as re}from"./index-IdGpV21X.js";var P={name:`earth`,size:24,node:[[`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`}]],aliases:[`globe-2`]};P.node;var ie=s(P),F={name:`folder-kanban`,size:24,node:[[`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`}]]};F.node;var ae=s(F),I={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};I.node;var L=s(I),R=e(t(),1),z=n(),B=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],oe={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function V(e){let{activeProjectId:t}=l();return(0,z.jsx)(H,{...e},e.apiBase??t??`legacy`)}function H({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=o(`jira`),[i,a]=(0,R.useState)(1),[s,c]=(0,R.useState)(``),[l,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(`idle`),[g,_]=(0,R.useState)(null),[v,b]=(0,R.useState)(`cloud`),[x,S]=(0,R.useState)([]),[C,w]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,k]=(0,R.useState)(``),[j,M]=(0,R.useState)(!1),[N,ee]=(0,R.useState)([]),[te,ne]=(0,R.useState)({}),[re,P]=(0,R.useState)(``),[ie,F]=(0,R.useState)(!1),[ae,I]=(0,R.useState)(!1),L=(0,R.useRef)(0),V=(0,R.useRef)(!0);(0,R.useEffect)(()=>(V.current=!0,()=>{V.current=!1,L.current++}),[]);let[H,se]=(0,R.useState)(!1),K=()=>({baseUrl:s.trim(),accountEmail:l.trim()||null,token:f});async function ce(){h(`testing`);try{let e=await y.test(K(),n);if(!V.current)return;h(`ok`),_(e.displayName),b(e.deployment)}catch(e){if(!V.current)return;h(`error`),u.error(G(e,r))}}async function q(){a(2),M(!0);try{let{projects:e}=await y.discoverProjects({...K(),query:C.trim()||void 0},n);if(!V.current)return;S(e)}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&M(!1)}}async function le(){a(3),await J()}async function J(){if(!T)return;let e=++L.current;F(!0);try{let{statuses:t}=await y.discoverStatuses({...K(),projectKey:T},n);if(!V.current||e!==L.current)return;ee(t),I(!1)}catch{V.current&&e===L.current&&I(!0)}finally{V.current&&e===L.current&&F(!1)}}function ue(e,t){e!==T&&(L.current++,ee([]),ne({}),P(``),I(!1),F(!1)),D(e),k(t)}async function Y(){se(!0);try{let t=Object.fromEntries(Object.entries(te).filter(([,e])=>e));if(await y.connect({...K(),jiraProjectKey:T.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:re.trim()||null},n),!V.current)return;u.success(r(`status.connected`,{key:T.trim()})),e()}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&se(!1)}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,z.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,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,z.jsx)(U,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,z.jsx)(A,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,z.jsx)(A,{value:l,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,z.jsx)(A,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:ce,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,z.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:g??``}),` · `,r(v===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(E,{size:`sm`,onClick:q,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(A,{value:C,onChange:e=>w(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:q,children:r(`project.searchPlaceholder`)})]}),j?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,z.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>ue(e.key,e.name),className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${T===e.key?`bg-muted`:``}`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,z.jsx)(U,{label:r(`project.manualLabel`),children:(0,z.jsx)(A,{value:T,onChange:e=>ue(e.target.value.toUpperCase(),``),placeholder:r(`project.manualPlaceholder`)})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(1),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:le,disabled:!T.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),ae&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,disabled:ie,onClick:()=>void J(),children:r(`mapping.retry`)})]}),ie&&(0,z.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r(`mapping.loading`)}),B.map(e=>(0,z.jsx)(U,{label:r(`mapping.${oe[e]}`),children:(0,z.jsxs)(`select`,{value:te[e]??``,onChange:t=>ne(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,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,z.jsx)(U,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,z.jsxs)(`select`,{value:re,onChange:e=>P(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,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(2),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:()=>a(4),children:r(`wizard.next`)})]})]}),i===4&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,z.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,z.jsx)(W,{label:r(`review.site`),value:s}),(0,z.jsx)(W,{label:r(`review.project`),value:O?`${T} — ${O}`:T}),(0,z.jsx)(W,{label:r(`review.account`),value:g??l}),(0,z.jsx)(W,{label:r(`review.type`),value:r(v===`cloud`?`review.cloud`:`review.dc`)}),(0,z.jsx)(W,{label:r(`discard.reviewLabel`),value:re||r(`discard.configNone`)})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(3),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:Y,disabled:H,children:r(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function U({label:e,help:t,children:n}){return(0,z.jsxs)(`label`,{className:`block space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function W({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var se={pending:0,inflight:0,done:0,dead:0};function K({projectId:e,baseUrl:t,apiBase:n,initialCounts:r,refreshToken:i}){let{t:s}=o(`jira`),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(()=>new Set),h=(0,R.useRef)(!0),g=(0,R.useRef)(0),_=(0,R.useContext)(a),v=(0,R.useId)(),b=(0,R.useCallback)(async()=>{if(!h.current)return;let e=++g.current;try{let t=n?await y.listOutbox(`dead`,n):await y.listOutbox(`dead`);if(!h.current||e!==g.current)return;l({...t,ops:t.ops.filter(e=>e.state===`dead`)}),f(!1)}catch{h.current&&e===g.current&&f(!0)}},[n]);(0,R.useEffect)(()=>(h.current=!0,b(),()=>{h.current=!1,g.current++}),[b,i,r?.dead,r?.pending,r?.inflight,r?.done,r?.superseded]),(0,R.useEffect)(()=>{if(_)return _.registerHandler(v,t=>{if(!t||typeof t!=`object`)return;let n=t;n.type===`jira.outbox_changed`&&n.projectId===e&&b()}),()=>_.unregisterHandler(v)},[_,v,e,b]);async function x(e){if(!p.has(e)){m(t=>new Set(t).add(e));try{n?await y.retryOutbox(e,n):await y.retryOutbox(e),h.current&&await b()}catch(e){h.current&&u.error(e instanceof Error?e.message:s(`errors.generic`))}finally{h.current&&m(t=>{let n=new Set(t);return n.delete(e),n})}}}let S=c?.counts??r??se,C=S.pending+S.inflight;return(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:s(`outbox.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs ${S.dead>0?`text-accent-warning`:`text-muted-foreground`}`,children:S.dead>0?s(`outbox.dead`,{count:S.dead}):C>0?s(`outbox.pending`,{count:C}):s(S.superseded?`outbox.nonePending`:`outbox.allSynced`)}),d&&(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:s(`outbox.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:s(`outbox.retry`)})]}),!!c?.ops.length&&(0,z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`outbox.deadHelp`)}),c.ops.map(e=>{let n=e.targetStatus||(e.logicalState?s(`mapping.${ce(e.logicalState)}`):null),r=e.deadReason??e.lastError??``;return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2 rounded border border-border/60 px-2 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-1 text-xs`,children:[(0,z.jsxs)(`p`,{className:`break-words`,children:[e.jiraKey?(0,z.jsx)(`a`,{href:`${t.replace(/\/$/,``)}/browse/${encodeURIComponent(e.jiraKey)}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent-primary hover:underline`,children:e.jiraKey}):(0,z.jsx)(`span`,{className:`font-medium`,children:s(`outbox.issueFallback`,{id:e.jiraIssueId})}),` · `,s(e.opType===`transition`?`outbox.opTransition`:e.opType===`comment`?`outbox.opComment`:e.opType===`update`?`outbox.opUpdate`:`outbox.opCreate`)]}),n&&(0,z.jsx)(`p`,{className:`break-words text-muted-foreground`,children:s(`outbox.target`,{status:n})}),(0,z.jsx)(`p`,{className:`max-h-32 overflow-y-auto whitespace-pre-wrap break-words text-muted-foreground`,children:r})]}),(0,z.jsx)(E,{className:`shrink-0`,variant:`outline`,size:`sm`,disabled:p.has(e.id),onClick:()=>void x(e.id),children:s(p.has(e.id)?`outbox.retrying`:`outbox.retry`)})]},e.id)})]})]})}function ce(e){return e===`in_progress`?`inProgress`:e===`on_review`?`onReview`:e}var q=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],le={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function J(e){let{activeProjectId:t}=l(),n=`${e.apiBase??t??``}:${e.state.connection.projectId}`;return(0,z.jsx)(ue,{...e},n)}function ue({state:e,onChanged:t,apiBase:n}){let{t:r}=o(`jira`),i=e.connection,[a,s]=(0,R.useState)(i.enabled),[c,l]=(0,R.useState)(!1),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(0),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(i.discardStatus??``),[b,x]=(0,R.useState)(i.statusMap??{}),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(!1),D=(0,R.useRef)(0),O=(0,R.useRef)(!0),k=(0,R.useCallback)(async()=>{let e=++D.current;T(!0);try{let{statuses:t}=await y.listStatuses(n);if(!O.current||e!==D.current)return;g(t),C(!1)}catch{O.current&&e===D.current&&C(!0)}finally{O.current&&e===D.current&&T(!1)}},[n]);(0,R.useEffect)(()=>(O.current=!0,k(),()=>{O.current=!1,D.current++}),[k]);async function A(e){let i=_;v(e);try{if(n?await y.patchConnection({discardStatus:e||null},n):await y.patchConnection({discardStatus:e||null}),!O.current)return;t()}catch(e){if(!O.current)return;v(i),u.error(Y(e,r))}}async function j(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{if(n?await y.patchConnection({statusMap:Object.keys(s).length?s:null},n):await y.patchConnection({statusMap:Object.keys(s).length?s:null}),!O.current)return;m(e=>e+1),t()}catch(e){if(!O.current)return;x(a),u.error(Y(e,r))}}async function M(){let e=!a;s(e),f(!0);try{n?await y.setEnabled(e,n):await y.setEnabled(e)}catch(t){if(!O.current)return;s(!e),u.error(Y(t,r))}finally{O.current&&f(!1)}}async function N(){l(!0);try{let e=n?await y.syncNow(n):await y.syncNow();if(!O.current)return;u.success(r(`status.syncedToast`,{count:e.upserted})),m(e=>e+1)}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&l(!1)}}async function ee(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{if(n?await y.disconnect(n):await y.disconnect(),!O.current)return;u.success(r(`status.disconnectedToast`)),t()}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&f(!1)}}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,z.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,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,z.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:M,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 ${a?`bg-accent-success`:`bg-input`}`,children:(0,z.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),S&&(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,disabled:w,onClick:()=>void k(),children:r(`mapping.retry`)})]}),w&&(0,z.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:r(`mapping.loading`)}),(0,z.jsx)(`div`,{className:`space-y-2`,children:q.map(e=>(0,z.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${le[e]}`)}),(0,z.jsxs)(`select`,{value:b[e]??``,onChange:t=>void j(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,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,z.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,z.jsxs)(`select`,{value:_,onChange:e=>void A(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,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,z.jsx)(`option`,{value:_,children:_})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:N,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,z.jsx)(E,{variant:`ghost`,size:`sm`,onClick:ee,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,z.jsx)(K,{projectId:i.projectId,baseUrl:i.baseUrl,apiBase:n,initialCounts:e.outbox,refreshToken:p})]})}function Y(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var de=new Set([`claude`,`codex`,`kimi`]);function fe(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 pe(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:fe(`codex`),claude:fe(`claude`)},lastIssue:null}}var X={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:pe(),lastIssue:null,updatedAt:null};function me(e){let t=e?.metrics??pe();return{...X,...e,activeProviders:{...X.activeProviders,...e?.activeProviders},availableProviders:{...X.availableProviders,...e?.availableProviders},detectedRoutes:{...X.detectedRoutes,...e?.detectedRoutes},learning:{...X.learning,...e?.learning},metrics:{...pe(),...t,providers:{codex:{...fe(`codex`),...t.providers?.codex},claude:{...fe(`claude`),...t.providers?.claude}}}}}async function Z(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 Q(e){return`${r}/api/projects/${e}`}function he(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`${he(e,t)} ${n}`}function ge({onWindowOpened:e}={}){let{t}=o(`integrations`),{projects:n}=l(),{registerHandler:a,unregisterHandler:s}=i(),[c,d]=(0,R.useState)(``),[f,m]=(0,R.useState)(`all`),[g,_]=(0,R.useState)(X),[v,y]=(0,R.useState)(!0),[E,D]=(0,R.useState)(null),[O,A]=(0,R.useState)([]),[j,P]=(0,R.useState)(!1),[ie,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(null),[B,oe]=(0,R.useState)({jira:0,serena:0,projects:0}),V=(0,R.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>Z(e));_(me(e.state))}finally{y(!1)}},[]);(0,R.useEffect)(()=>{V()},[V]),(0,R.useEffect)(()=>(a(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&A(e=>[...e.slice(-80),t.line]),V())}),()=>s(`plugins-page`)),[a,s,V]),(0,R.useEffect)(()=>{let e=!1;async function t(){let t=await Promise.all(n.map(async e=>{let[t,n]=await Promise.all([fetch(`${Q(e.id)}/jira/connection`).then(e=>Z(e)).catch(()=>({connected:!1})),fetch(`${Q(e.id)}/plugins`).then(e=>Z(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||oe({jira:t.reduce((e,t)=>e+t.jira,0),serena:t.reduce((e,t)=>e+t.serena,0),projects:n.length})}return t(),()=>{e=!0}},[n]);async function H(e,t){D(e),A([]);try{let e=(await t()).state;e&&_(me(e))}catch(e){let t=e.payload;t?.state&&_(me(t.state))}finally{D(null),V()}}let U=(0,R.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:N,description:t(`plugins.catalog.headroom.description`),installed:g.installed,status:g.lastIssue?`attention`:g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?`external-active`:`active`:g.installSource===`system`?`external`:`installed`:`available`,statusLabel:g.lastIssue?t(`plugins.status.attention`):g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?t(`plugins.status.externalActive`):t(`plugins.status.active`):g.installSource===`system`?t(`plugins.status.external`):t(`plugins.status.installed`):t(`plugins.status.available`),actionKind:g.lastIssue?`review`:g.installed?`manage`:`install`,actionLabel:g.lastIssue?t(`plugins.actions.review`):g.installed?t(`plugins.actions.manage`):t(`plugins.actions.install`),busy:E===`install`,action:()=>{if(g.lastIssue||g.installed){P(!0);return}H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e)))}}],[g,E,t]),W=(0,R.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ae,description:t(`plugins.catalog.jira.description`),installed:B.jira>0,status:B.jira>0?`configured`:`available`,statusLabel:B.jira>0?t(`plugins.status.configuredCount`,{count:B.jira}):t(`plugins.status.available`),actionKind:B.jira>0?`manage`:`install`,actionLabel:B.jira>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:re,description:t(`plugins.catalog.serena.description`),installed:B.serena>0,status:B.serena>0?`installed`:`available`,statusLabel:B.serena>0?t(`plugins.status.installedCount`,{count:B.serena}):t(`plugins.status.available`),actionKind:B.serena>0?`manage`:`install`,actionLabel:B.serena>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`serena`)}],[B,t]),G=c.trim().toLowerCase(),se=e=>`${e.title} ${e.description} ${e.statusLabel} ${t(`plugins.scope.${e.scope}`)}`.toLowerCase().includes(G),K=[...U,...W].filter(e=>f!==`all`&&e.scope!==f?!1:se(e)),ce=K.filter(e=>e.scope===`global`&&e.installed),q=K.filter(e=>e.scope===`project`&&e.installed),le=K.filter(e=>e.scope===`global`&&!e.installed),J=K.filter(e=>e.scope===`project`&&!e.installed),ue=ce.length>0||q.length>0,Y=le.length>0||J.length>0,de=[g.installed,B.jira>0,B.serena>0].filter(Boolean).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,z.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.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,z.jsx)(k,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:t(`plugins.page.title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t(`plugins.page.subtitle`)})]}),!ee()&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void te().then(()=>e?.()).catch(e=>u.error(String(e))),className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-xs hover:bg-muted`,children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),t(`plugins.page.openWindow`)]}),(0,z.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,z.jsx)(ne,{className:`h-3.5 w-3.5 text-accent-success`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:t(`plugins.page.readyCount`,{count:de})})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,z.jsxs)(`label`,{className:`relative flex-1`,children:[(0,z.jsx)(h,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),placeholder:t(`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,z.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:T(`rounded-md px-3 text-xs capitalize transition-colors`,f===e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:t(`plugins.filters.${e}`)},e))})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,z.jsxs)(`section`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(M,{className:`h-3.5 w-3.5`}),t(`plugins.sections.installed`)]}),ue?(0,z.jsx)(_e,{globalPlugins:ce,projectPlugins:q}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(k,{className:`h-3.5 w-3.5`}),t(`plugins.sections.available`)]}),Y?(0,z.jsx)(_e,{globalPlugins:le,projectPlugins:J}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,z.jsx)(w,{open:j,onOpenChange:P,children:(0,z.jsxs)(C,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(x,{children:t(`plugins.headroom.title`)}),(0,z.jsx)(b,{children:t(`plugins.headroom.dialogDescription`)})]}),(0,z.jsx)(Se,{state:g,loading:v,busy:E,logs:O,onInstall:()=>H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e))),onToggleProvider:(e,t)=>H(`${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=>Z(e))),onDeactivateAll:()=>H(`deactivate-all`,async()=>{let e={state:g};for(let t of[`codex`,`claude`])g.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=>Z(e)));return e}),onUninstall:()=>H(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>Z(e))),onSetPort:e=>H(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>Z(e))),onOpenDiagnostics:()=>F(!0)})]})}),(0,z.jsx)(ke,{plugin:I,projects:n,onClose:()=>L(null)}),(0,z.jsx)(Me,{open:ie,onClose:()=>F(!1)})]})}function _e({globalPlugins:e,projectPlugins:t}){let{t:n}=o(`integrations`);return(0,z.jsxs)(`div`,{className:T(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]}),t.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]})]})}function ve({text:e}){return(0,z.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 ye({scope:e}){let{t}=o(`integrations`);return(0,z.jsx)(`span`,{className:T(`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 be({title:e,detail:t,scope:n}){return(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,z.jsx)(ye,{scope:n}),(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,z.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function xe({plugin:e}){let{t}=o(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,a=e.busy?m:e.actionKind===`install`?f:e.actionKind===`review`?_:D,s=T(`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,z.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,z.jsx)(`div`,{className:T(`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,z.jsx)(n,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,z.jsx)(ye,{scope:e.scope}),(0,z.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,z.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,z.jsx)(a,{className:T(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function Se({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:a,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:u}){let{t:d}=o(`integrations`),[p,h]=(0,R.useState)(String(e.port)),[_,y]=(0,R.useState)(!1);(0,R.useEffect)(()=>h(String(e.port)),[e.port]),(0,R.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,z.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,z.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,z.jsx)(N,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:d(`plugins.headroom.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:d(`plugins.headroom.panelDescription`)})]})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.install`),value:t?d(`plugins.headroom.metrics.checking`):e.installed?d(`plugins.headroom.metrics.ready`):d(`plugins.headroom.metrics.missing`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.source`),value:e.installSource===`system`?d(`plugins.headroom.metrics.system`):e.installSource===`managed`?d(`plugins.headroom.metrics.specrails`):d(`plugins.headroom.metrics.none`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:d(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,z.jsx)(we,{issue:e.lastIssue}),e.installed?(0,z.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,z.jsx)(Oe,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>a(`codex`,e.activeProviders.codex)}),(0,z.jsx)(Oe,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>a(`claude`,e.activeProviders.claude)}),b&&(0,z.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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(L,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,z.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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,z.jsx)(Te,{state:e}),(0,z.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:d(`plugins.headroom.port.label`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,z.jsx)(`button`,{type:`button`,disabled:!!n||Number(p)===e.port,onClick:()=>l(Number(p)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:d(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,z.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-BbYvbtY8.js";import{l as r,r as i,t as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{n as c,r as l,s as u}from"./useDesktop-BjLT0_EE.js";import{s as d}from"./provider-capabilities-lePfeT_Y.js";import{t as f}from"./download-C9wP_42h.js";import{t as p}from"./external-link-CZ6Q-v1-.js";import{t as m}from"./loader-circle-BqV9xYGf.js";import{t as h}from"./search-BDVp3fkH.js";import{t as g}from"./trash-D8zYUmTg.js";import{t as _}from"./triangle-alert-Cxpn8bqr.js";import{n as v,t as y}from"./jira-api-Cabj-H0J.js";import{i as b,l as x,o as S,r as C,t as w}from"./dialog-DtdR05v1.js";import{t as T}from"./utils-BC4DHlz2.js";import{t as E}from"./button-4FS1ZDTp.js";import{Ct as D,Jt as O,Ot as k,W as A,Zt as j,bt as M,kt as N,ln as ee,un as te,xt as ne,yt as re}from"./index-Ce4yZtKf.js";var P={name:`earth`,size:24,node:[[`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`}]],aliases:[`globe-2`]};P.node;var ie=s(P),F={name:`folder-kanban`,size:24,node:[[`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`}]]};F.node;var ae=s(F),I={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};I.node;var L=s(I),R=e(t(),1),z=n(),B=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],oe={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function V(e){let{activeProjectId:t}=l();return(0,z.jsx)(H,{...e},e.apiBase??t??`legacy`)}function H({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=o(`jira`),[i,a]=(0,R.useState)(1),[s,c]=(0,R.useState)(``),[l,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(`idle`),[g,_]=(0,R.useState)(null),[v,b]=(0,R.useState)(`cloud`),[x,S]=(0,R.useState)([]),[C,w]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,k]=(0,R.useState)(``),[j,M]=(0,R.useState)(!1),[N,ee]=(0,R.useState)([]),[te,ne]=(0,R.useState)({}),[re,P]=(0,R.useState)(``),[ie,F]=(0,R.useState)(!1),[ae,I]=(0,R.useState)(!1),L=(0,R.useRef)(0),V=(0,R.useRef)(!0);(0,R.useEffect)(()=>(V.current=!0,()=>{V.current=!1,L.current++}),[]);let[H,se]=(0,R.useState)(!1),K=()=>({baseUrl:s.trim(),accountEmail:l.trim()||null,token:f});async function ce(){h(`testing`);try{let e=await y.test(K(),n);if(!V.current)return;h(`ok`),_(e.displayName),b(e.deployment)}catch(e){if(!V.current)return;h(`error`),u.error(G(e,r))}}async function q(){a(2),M(!0);try{let{projects:e}=await y.discoverProjects({...K(),query:C.trim()||void 0},n);if(!V.current)return;S(e)}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&M(!1)}}async function le(){a(3),await J()}async function J(){if(!T)return;let e=++L.current;F(!0);try{let{statuses:t}=await y.discoverStatuses({...K(),projectKey:T},n);if(!V.current||e!==L.current)return;ee(t),I(!1)}catch{V.current&&e===L.current&&I(!0)}finally{V.current&&e===L.current&&F(!1)}}function ue(e,t){e!==T&&(L.current++,ee([]),ne({}),P(``),I(!1),F(!1)),D(e),k(t)}async function Y(){se(!0);try{let t=Object.fromEntries(Object.entries(te).filter(([,e])=>e));if(await y.connect({...K(),jiraProjectKey:T.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:re.trim()||null},n),!V.current)return;u.success(r(`status.connected`,{key:T.trim()})),e()}catch(e){V.current&&u.error(G(e,r))}finally{V.current&&se(!1)}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,z.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,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,z.jsx)(U,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,z.jsx)(A,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,z.jsx)(A,{value:l,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,z.jsx)(U,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,z.jsx)(A,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:ce,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,z.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:g??``}),` · `,r(v===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(E,{size:`sm`,onClick:q,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(A,{value:C,onChange:e=>w(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,onClick:q,children:r(`project.searchPlaceholder`)})]}),j?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,z.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>ue(e.key,e.name),className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${T===e.key?`bg-muted`:``}`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,z.jsx)(U,{label:r(`project.manualLabel`),children:(0,z.jsx)(A,{value:T,onChange:e=>ue(e.target.value.toUpperCase(),``),placeholder:r(`project.manualPlaceholder`)})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(1),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:le,disabled:!T.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),ae&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{size:`sm`,variant:`outline`,disabled:ie,onClick:()=>void J(),children:r(`mapping.retry`)})]}),ie&&(0,z.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r(`mapping.loading`)}),B.map(e=>(0,z.jsx)(U,{label:r(`mapping.${oe[e]}`),children:(0,z.jsxs)(`select`,{value:te[e]??``,onChange:t=>ne(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,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,z.jsx)(U,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,z.jsxs)(`select`,{value:re,onChange:e=>P(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,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),N.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(2),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:()=>a(4),children:r(`wizard.next`)})]})]}),i===4&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,z.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,z.jsx)(W,{label:r(`review.site`),value:s}),(0,z.jsx)(W,{label:r(`review.project`),value:O?`${T} — ${O}`:T}),(0,z.jsx)(W,{label:r(`review.account`),value:g??l}),(0,z.jsx)(W,{label:r(`review.type`),value:r(v===`cloud`?`review.cloud`:`review.dc`)}),(0,z.jsx)(W,{label:r(`discard.reviewLabel`),value:re||r(`discard.configNone`)})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>a(3),children:r(`wizard.back`)}),(0,z.jsx)(E,{size:`sm`,onClick:Y,disabled:H,children:r(H?`wizard.connecting`:`wizard.connect`)})]})]})]})}function U({label:e,help:t,children:n}){return(0,z.jsxs)(`label`,{className:`block space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function W({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function G(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var se={pending:0,inflight:0,done:0,dead:0};function K({projectId:e,baseUrl:t,apiBase:n,initialCounts:r,refreshToken:i}){let{t:s}=o(`jira`),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(()=>new Set),h=(0,R.useRef)(!0),g=(0,R.useRef)(0),_=(0,R.useContext)(a),v=(0,R.useId)(),b=(0,R.useCallback)(async()=>{if(!h.current)return;let e=++g.current;try{let t=n?await y.listOutbox(`dead`,n):await y.listOutbox(`dead`);if(!h.current||e!==g.current)return;l({...t,ops:t.ops.filter(e=>e.state===`dead`)}),f(!1)}catch{h.current&&e===g.current&&f(!0)}},[n]);(0,R.useEffect)(()=>(h.current=!0,b(),()=>{h.current=!1,g.current++}),[b,i,r?.dead,r?.pending,r?.inflight,r?.done,r?.superseded]),(0,R.useEffect)(()=>{if(_)return _.registerHandler(v,t=>{if(!t||typeof t!=`object`)return;let n=t;n.type===`jira.outbox_changed`&&n.projectId===e&&b()}),()=>_.unregisterHandler(v)},[_,v,e,b]);async function x(e){if(!p.has(e)){m(t=>new Set(t).add(e));try{n?await y.retryOutbox(e,n):await y.retryOutbox(e),h.current&&await b()}catch(e){h.current&&u.error(e instanceof Error?e.message:s(`errors.generic`))}finally{h.current&&m(t=>{let n=new Set(t);return n.delete(e),n})}}}let S=c?.counts??r??se,C=S.pending+S.inflight;return(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:s(`outbox.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs ${S.dead>0?`text-accent-warning`:`text-muted-foreground`}`,children:S.dead>0?s(`outbox.dead`,{count:S.dead}):C>0?s(`outbox.pending`,{count:C}):s(S.superseded?`outbox.nonePending`:`outbox.allSynced`)}),d&&(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:s(`outbox.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:s(`outbox.retry`)})]}),!!c?.ops.length&&(0,z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`outbox.deadHelp`)}),c.ops.map(e=>{let n=e.targetStatus||(e.logicalState?s(`mapping.${ce(e.logicalState)}`):null),r=e.deadReason??e.lastError??``;return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2 rounded border border-border/60 px-2 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-1 text-xs`,children:[(0,z.jsxs)(`p`,{className:`break-words`,children:[e.jiraKey?(0,z.jsx)(`a`,{href:`${t.replace(/\/$/,``)}/browse/${encodeURIComponent(e.jiraKey)}`,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent-primary hover:underline`,children:e.jiraKey}):(0,z.jsx)(`span`,{className:`font-medium`,children:s(`outbox.issueFallback`,{id:e.jiraIssueId})}),` · `,s(e.opType===`transition`?`outbox.opTransition`:e.opType===`comment`?`outbox.opComment`:e.opType===`update`?`outbox.opUpdate`:`outbox.opCreate`)]}),n&&(0,z.jsx)(`p`,{className:`break-words text-muted-foreground`,children:s(`outbox.target`,{status:n})}),(0,z.jsx)(`p`,{className:`max-h-32 overflow-y-auto whitespace-pre-wrap break-words text-muted-foreground`,children:r})]}),(0,z.jsx)(E,{className:`shrink-0`,variant:`outline`,size:`sm`,disabled:p.has(e.id),onClick:()=>void x(e.id),children:s(p.has(e.id)?`outbox.retrying`:`outbox.retry`)})]},e.id)})]})]})}function ce(e){return e===`in_progress`?`inProgress`:e===`on_review`?`onReview`:e}var q=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],le={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function J(e){let{activeProjectId:t}=l(),n=`${e.apiBase??t??``}:${e.state.connection.projectId}`;return(0,z.jsx)(ue,{...e},n)}function ue({state:e,onChanged:t,apiBase:n}){let{t:r}=o(`jira`),i=e.connection,[a,s]=(0,R.useState)(i.enabled),[c,l]=(0,R.useState)(!1),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(0),[h,g]=(0,R.useState)([]),[_,v]=(0,R.useState)(i.discardStatus??``),[b,x]=(0,R.useState)(i.statusMap??{}),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(!1),D=(0,R.useRef)(0),O=(0,R.useRef)(!0),k=(0,R.useCallback)(async()=>{let e=++D.current;T(!0);try{let{statuses:t}=await y.listStatuses(n);if(!O.current||e!==D.current)return;g(t),C(!1)}catch{O.current&&e===D.current&&C(!0)}finally{O.current&&e===D.current&&T(!1)}},[n]);(0,R.useEffect)(()=>(O.current=!0,k(),()=>{O.current=!1,D.current++}),[k]);async function A(e){let i=_;v(e);try{if(n?await y.patchConnection({discardStatus:e||null},n):await y.patchConnection({discardStatus:e||null}),!O.current)return;t()}catch(e){if(!O.current)return;v(i),u.error(Y(e,r))}}async function j(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{if(n?await y.patchConnection({statusMap:Object.keys(s).length?s:null},n):await y.patchConnection({statusMap:Object.keys(s).length?s:null}),!O.current)return;m(e=>e+1),t()}catch(e){if(!O.current)return;x(a),u.error(Y(e,r))}}async function M(){let e=!a;s(e),f(!0);try{n?await y.setEnabled(e,n):await y.setEnabled(e)}catch(t){if(!O.current)return;s(!e),u.error(Y(t,r))}finally{O.current&&f(!1)}}async function N(){l(!0);try{let e=n?await y.syncNow(n):await y.syncNow();if(!O.current)return;u.success(r(`status.syncedToast`,{count:e.upserted})),m(e=>e+1)}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&l(!1)}}async function ee(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{if(n?await y.disconnect(n):await y.disconnect(),!O.current)return;u.success(r(`status.disconnectedToast`)),t()}catch(e){O.current&&u.error(Y(e,r))}finally{O.current&&f(!1)}}}return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,z.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,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,z.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:M,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 ${a?`bg-accent-success`:`bg-input`}`,children:(0,z.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),S&&(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:r(`mapping.loadFailed`)}),(0,z.jsx)(E,{variant:`outline`,size:`sm`,disabled:w,onClick:()=>void k(),children:r(`mapping.retry`)})]}),w&&(0,z.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:r(`mapping.loading`)}),(0,z.jsx)(`div`,{className:`space-y-2`,children:q.map(e=>(0,z.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${le[e]}`)}),(0,z.jsxs)(`select`,{value:b[e]??``,onChange:t=>void j(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,z.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,z.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,z.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,z.jsxs)(`select`,{value:_,onChange:e=>void A(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,z.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,z.jsx)(`option`,{value:_,children:_})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(E,{variant:`outline`,size:`sm`,onClick:N,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,z.jsx)(E,{variant:`ghost`,size:`sm`,onClick:ee,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,z.jsx)(K,{projectId:i.projectId,baseUrl:i.baseUrl,apiBase:n,initialCounts:e.outbox,refreshToken:p})]})}function Y(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var de=new Set([`claude`,`codex`,`kimi`]);function fe(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 pe(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:fe(`codex`),claude:fe(`claude`)},lastIssue:null}}var X={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:pe(),lastIssue:null,updatedAt:null};function me(e){let t=e?.metrics??pe();return{...X,...e,activeProviders:{...X.activeProviders,...e?.activeProviders},availableProviders:{...X.availableProviders,...e?.availableProviders},detectedRoutes:{...X.detectedRoutes,...e?.detectedRoutes},learning:{...X.learning,...e?.learning},metrics:{...pe(),...t,providers:{codex:{...fe(`codex`),...t.providers?.codex},claude:{...fe(`claude`),...t.providers?.claude}}}}}async function Z(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 Q(e){return`${r}/api/projects/${e}`}function he(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`${he(e,t)} ${n}`}function ge({onWindowOpened:e}={}){let{t}=o(`integrations`),{projects:n}=l(),{registerHandler:a,unregisterHandler:s}=i(),[c,d]=(0,R.useState)(``),[f,m]=(0,R.useState)(`all`),[g,_]=(0,R.useState)(X),[v,y]=(0,R.useState)(!0),[E,D]=(0,R.useState)(null),[O,A]=(0,R.useState)([]),[j,P]=(0,R.useState)(!1),[ie,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(null),[B,oe]=(0,R.useState)({jira:0,serena:0,projects:0}),V=(0,R.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>Z(e));_(me(e.state))}finally{y(!1)}},[]);(0,R.useEffect)(()=>{V()},[V]),(0,R.useEffect)(()=>(a(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&A(e=>[...e.slice(-80),t.line]),V())}),()=>s(`plugins-page`)),[a,s,V]),(0,R.useEffect)(()=>{let e=!1;async function t(){let t=await Promise.all(n.map(async e=>{let[t,n]=await Promise.all([fetch(`${Q(e.id)}/jira/connection`).then(e=>Z(e)).catch(()=>({connected:!1})),fetch(`${Q(e.id)}/plugins`).then(e=>Z(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||oe({jira:t.reduce((e,t)=>e+t.jira,0),serena:t.reduce((e,t)=>e+t.serena,0),projects:n.length})}return t(),()=>{e=!0}},[n]);async function H(e,t){D(e),A([]);try{let e=(await t()).state;e&&_(me(e))}catch(e){let t=e.payload;t?.state&&_(me(t.state))}finally{D(null),V()}}let U=(0,R.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:N,description:t(`plugins.catalog.headroom.description`),installed:g.installed,status:g.lastIssue?`attention`:g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?`external-active`:`active`:g.installSource===`system`?`external`:`installed`:`available`,statusLabel:g.lastIssue?t(`plugins.status.attention`):g.installed?g.activeProviders.codex||g.activeProviders.claude?g.installSource===`system`?t(`plugins.status.externalActive`):t(`plugins.status.active`):g.installSource===`system`?t(`plugins.status.external`):t(`plugins.status.installed`):t(`plugins.status.available`),actionKind:g.lastIssue?`review`:g.installed?`manage`:`install`,actionLabel:g.lastIssue?t(`plugins.actions.review`):g.installed?t(`plugins.actions.manage`):t(`plugins.actions.install`),busy:E===`install`,action:()=>{if(g.lastIssue||g.installed){P(!0);return}H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e)))}}],[g,E,t]),W=(0,R.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ae,description:t(`plugins.catalog.jira.description`),installed:B.jira>0,status:B.jira>0?`configured`:`available`,statusLabel:B.jira>0?t(`plugins.status.configuredCount`,{count:B.jira}):t(`plugins.status.available`),actionKind:B.jira>0?`manage`:`install`,actionLabel:B.jira>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:re,description:t(`plugins.catalog.serena.description`),installed:B.serena>0,status:B.serena>0?`installed`:`available`,statusLabel:B.serena>0?t(`plugins.status.installedCount`,{count:B.serena}):t(`plugins.status.available`),actionKind:B.serena>0?`manage`:`install`,actionLabel:B.serena>0?t(`plugins.actions.manage`):t(`plugins.actions.install`),action:()=>L(`serena`)}],[B,t]),G=c.trim().toLowerCase(),se=e=>`${e.title} ${e.description} ${e.statusLabel} ${t(`plugins.scope.${e.scope}`)}`.toLowerCase().includes(G),K=[...U,...W].filter(e=>f!==`all`&&e.scope!==f?!1:se(e)),ce=K.filter(e=>e.scope===`global`&&e.installed),q=K.filter(e=>e.scope===`project`&&e.installed),le=K.filter(e=>e.scope===`global`&&!e.installed),J=K.filter(e=>e.scope===`project`&&!e.installed),ue=ce.length>0||q.length>0,Y=le.length>0||J.length>0,de=[g.installed,B.jira>0,B.serena>0].filter(Boolean).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,z.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.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,z.jsx)(k,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:t(`plugins.page.title`)}),(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t(`plugins.page.subtitle`)})]}),!ee()&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void te().then(()=>e?.()).catch(e=>u.error(String(e))),className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-2 text-xs hover:bg-muted`,children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),t(`plugins.page.openWindow`)]}),(0,z.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,z.jsx)(ne,{className:`h-3.5 w-3.5 text-accent-success`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:t(`plugins.page.readyCount`,{count:de})})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,z.jsxs)(`label`,{className:`relative flex-1`,children:[(0,z.jsx)(h,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),placeholder:t(`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,z.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:T(`rounded-md px-3 text-xs capitalize transition-colors`,f===e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:t(`plugins.filters.${e}`)},e))})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,z.jsxs)(`section`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(M,{className:`h-3.5 w-3.5`}),t(`plugins.sections.installed`)]}),ue?(0,z.jsx)(_e,{globalPlugins:ce,projectPlugins:q}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(k,{className:`h-3.5 w-3.5`}),t(`plugins.sections.available`)]}),Y?(0,z.jsx)(_e,{globalPlugins:le,projectPlugins:J}):(0,z.jsx)(ve,{text:t(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,z.jsx)(w,{open:j,onOpenChange:P,children:(0,z.jsxs)(C,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(x,{children:t(`plugins.headroom.title`)}),(0,z.jsx)(b,{children:t(`plugins.headroom.dialogDescription`)})]}),(0,z.jsx)(Se,{state:g,loading:v,busy:E,logs:O,onInstall:()=>H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e))),onToggleProvider:(e,t)=>H(`${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=>Z(e))),onDeactivateAll:()=>H(`deactivate-all`,async()=>{let e={state:g};for(let t of[`codex`,`claude`])g.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=>Z(e)));return e}),onUninstall:()=>H(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>Z(e))),onSetPort:e=>H(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>Z(e))),onOpenDiagnostics:()=>F(!0)})]})}),(0,z.jsx)(ke,{plugin:I,projects:n,onClose:()=>L(null)}),(0,z.jsx)(Me,{open:ie,onClose:()=>F(!1)})]})}function _e({globalPlugins:e,projectPlugins:t}){let{t:n}=o(`integrations`);return(0,z.jsxs)(`div`,{className:T(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]}),t.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsx)(be,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,z.jsx)(xe,{plugin:e},e.id))})]})]})}function ve({text:e}){return(0,z.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 ye({scope:e}){let{t}=o(`integrations`);return(0,z.jsx)(`span`,{className:T(`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 be({title:e,detail:t,scope:n}){return(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,z.jsx)(ye,{scope:n}),(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,z.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,z.jsx)(`div`,{className:T(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function xe({plugin:e}){let{t}=o(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,a=e.busy?m:e.actionKind===`install`?f:e.actionKind===`review`?_:D,s=T(`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,z.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,z.jsx)(`div`,{className:T(`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,z.jsx)(n,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,z.jsx)(ye,{scope:e.scope}),(0,z.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,z.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,z.jsx)(a,{className:T(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function Se({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:a,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:u}){let{t:d}=o(`integrations`),[p,h]=(0,R.useState)(String(e.port)),[_,y]=(0,R.useState)(!1);(0,R.useEffect)(()=>h(String(e.port)),[e.port]),(0,R.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,z.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,z.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,z.jsx)(N,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:d(`plugins.headroom.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:d(`plugins.headroom.panelDescription`)})]})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.install`),value:t?d(`plugins.headroom.metrics.checking`):e.installed?d(`plugins.headroom.metrics.ready`):d(`plugins.headroom.metrics.missing`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.source`),value:e.installSource===`system`?d(`plugins.headroom.metrics.system`):e.installSource===`managed`?d(`plugins.headroom.metrics.specrails`):d(`plugins.headroom.metrics.none`),good:e.installed}),(0,z.jsx)(Ce,{label:d(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:d(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,z.jsx)(we,{issue:e.lastIssue}),e.installed?(0,z.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,z.jsx)(Oe,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>a(`codex`,e.activeProviders.codex)}),(0,z.jsx)(Oe,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>a(`claude`,e.activeProviders.claude)}),b&&(0,z.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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(L,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,z.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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,z.jsx)(Te,{state:e}),(0,z.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:d(`plugins.headroom.port.label`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,z.jsx)(`button`,{type:`button`,disabled:!!n||Number(p)===e.port,onClick:()=>l(Number(p)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:d(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,z.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,z.jsxs)(`button`,{type:`button`,onClick:u,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,z.jsx)(v,{className:`h-3.5 w-3.5`}),d(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:d(x?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.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:d(`plugins.actions.cancel`)}),(0,z.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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),d(x?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,z.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,z.jsx)(g,{className:`h-3.5 w-3.5`}),d(x?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function Ce({label:e,value:t,good:n}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:T(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function we({issue:e}){let{t}=o(`integrations`),n=`plugins.headroom.issues.${e.code}`,r=t(`${n}.title`,{defaultValue:e.title}),i=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,z.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium`,children:r}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:i}),(0,z.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function Te({state:e}){let{t,i18n:n}=o(`integrations`),r=e.metrics,i=r.outputSavingsAvailable,a=[`codex`,`claude`].map(e=>({provider:e,metric:r.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=a.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=a.some(({metric:e})=>e.inputTokensSaved>0),u=a.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,z.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(j,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,z.jsx)(`span`,{className:T(`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,z.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsx)(Ee,{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,z.jsx)(Ee,{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,z.jsx)(`div`,{className:`grid gap-2`,children:a.map(({provider:e,metric:t})=>(0,z.jsx)(De,{metric:t,outputAvailable:r.outputSavingsAvailable},e))}),(0,z.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 Ee({label:e,processed:t,saved:n,detail:r,align:i=`left`}){let{t:a}=o(`integrations`);return(0,z.jsxs)(`div`,{className:T(`min-w-0`,i===`right`&&`text-right`),children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,z.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a(`plugins.headroom.savings.processed`)}),(0,z.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:a(`plugins.headroom.savings.saved`)}),(0,z.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),r&&(0,z.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:r})]})}function De({metric:e,outputAvailable:t}){let{t:n,i18n:r}=o(`integrations`),i=!e.available,a=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:he(e.requests,r.language)}):i?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,z.jsxs)(`div`,{className:T(`rounded-md border border-border bg-card/45 px-2.5 py-2`,a&&`opacity-70`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,z.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,z.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,z.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,z.jsx)(Ee,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,z.jsx)(Ee,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function Oe({provider:e,active:t,available:n,detectedRoute:r,busy:i,onClick:a}){let{t:s}=o(`integrations`),c=s(n?t?`plugins.headroom.provider.routedThroughHeadroom`:r?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,z.jsxs)(`button`,{type:`button`,onClick:a,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,z.jsx)(`div`,{className:T(`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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,z.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:c})]}),(0,z.jsx)(`span`,{className:T(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,z.jsx)(`span`,{className:T(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ke({plugin:e,projects:t,onClose:n}){let{t:r}=o(`integrations`),[i,a]=(0,R.useState)(``);(0,R.useEffect)(()=>a(``),[e]);let s=t.find(e=>e.id===i)??null;return(0,z.jsx)(w,{open:!!e,onOpenChange:e=>{e||n()},children:(0,z.jsxs)(C,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(x,{children:r(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,z.jsx)(b,{children:r(`plugins.projectWizard.description`)})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:r(`plugins.projectWizard.chooseProject`)}),(0,z.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!c(t).some(e=>de.has(e));return(0,z.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>a(t.id),className:T(`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,z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,z.jsx)(`div`,{className:`truncate text-[10px]`,children:n?r(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude or Codex`}):t.path})]},t.id)})})]}),(0,z.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,z.jsx)(Ae,{project:s,onDone:n}):(0,z.jsx)(je,{project:s,onDone:n}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function Ae({project:e,onDone:t}){let{t:n}=o(`integrations`),r=Q(e.id),[i,a]=(0,R.useState)(null),[s,c]=(0,R.useState)(!0),[l,u]=(0,R.useState)(null),d=(0,R.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch(`${r}/jira/connection`).then(e=>Z(e));a(e)}catch(e){a({connected:!1}),u(e.message)}finally{c(!1)}},[r]);return(0,R.useEffect)(()=>{d()},[d]),s?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,z.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):i?.connected&&i.connection?(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,z.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,z.jsx)(J,{state:i,apiBase:r,onChanged:()=>{d()}})]}):(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,z.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,z.jsx)(V,{apiBase:r,onConnected:()=>{d()},onSkip:t})]})}function je({project:e,onDone:t}){let{t:n}=o(`integrations`),r=(0,R.useMemo)(()=>c(e).filter(e=>de.has(e)),[e]),i=r.includes(e.provider)?e.provider:r[0]??e.provider,[a,s]=(0,R.useState)(i),[l,u]=(0,R.useState)(null),[p,h]=(0,R.useState)(null),[g,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null),x=(0,R.useRef)(0);(0,R.useEffect)(()=>{s(i),u(null),h(null)},[e.id,i]);let S=(0,R.useCallback)(async()=>{let t=++x.current;b(null);try{let n=`?provider=${encodeURIComponent(a)}`,r=await fetch(`${Q(e.id)}/plugins${n}`).then(e=>Z(e));if(t!==x.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(u(i),h(null),i?.status===`not-installed`){let r=await fetch(`${Q(e.id)}/plugins/serena/preview-install${n}`).then(e=>Z(e));t===x.current&&h(r)}}catch(e){t===x.current&&b(e.message)}},[e.id,a]);(0,R.useEffect)(()=>{S()},[S]);async function C(){v(!0),b(null);try{await fetch(`${Q(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:a})}).then(e=>Z(e)),await S(),t()}catch(e){b(e.message)}finally{v(!1)}}let w=(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&&!y?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,z.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,z.jsxs)(`label`,{className:`block space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,z.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:a,disabled:g,onChange:e=>{u(null),h(null),s(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,z.jsx)(`option`,{value:e,children:d(e)},e))})]}),l&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:T})}),E&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:E})]}),p&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,z.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:p.files.map(e=>(0,z.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,z.jsx)(`ul`,{className:`space-y-1 text-xs`,children:p.requirements.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,z.jsx)(O,{className:`h-3 w-3 text-accent-success`}):(0,z.jsx)(_,{className:`h-3 w-3 text-accent-warning`}),(0,z.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),y&&(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:y}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.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,z.jsxs)(`button`,{type:`button`,disabled:g||l?.status!==`not-installed`||!w,onClick:C,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,z.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function Me({open:e,onClose:t}){let{t:n}=o(`integrations`),[i,a]=(0,R.useState)(null);return(0,R.useEffect)(()=>{e&&fetch(`${r}/api/global-plugins/headroom/diagnostics`).then(e=>Z(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,z.jsx)(w,{open:e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(C,{className:`max-w-3xl`,children:[(0,z.jsxs)(S,{children:[(0,z.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,z.jsx)(D,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,z.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,z.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{ge as default};
|
package/client/dist/assets/{ProjectSettingsDialog-Ce8DSG6H.js → ProjectSettingsDialog-BUNj0tvN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r,t as i}from"./createLucideIcon-DtODIU64.js";import{r as a}from"./useDesktop-BjLT0_EE.js";import{t as o}from"./git-branch-yf6LE1Bw.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./utils-BC4DHlz2.js";import{St as p,_ as m,a as h,bt as g,en as _,g as v,gt as y,h as b,i as x,jt as S,n as C,o as w,r as T,rn as E,s as D,yt as O}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r,t as i}from"./createLucideIcon-DtODIU64.js";import{r as a}from"./useDesktop-BjLT0_EE.js";import{t as o}from"./git-branch-yf6LE1Bw.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./utils-BC4DHlz2.js";import{St as p,_ as m,a as h,bt as g,en as _,g as v,gt as y,h as b,i as x,jt as S,n as C,o as w,r as T,rn as E,s as D,yt as O}from"./index-Ce4yZtKf.js";var k={name:`key-round`,size:24,node:[[`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`}]]};k.node;var A=i(k),j=e(t(),1),M=n(),N=[{id:`general`,icon:g,labelKey:`projectDialog.nav.general`},{id:`agentRuntime`,icon:_,labelKey:`projectDialog.nav.agentRuntime`},{id:`subagents`,icon:S,labelKey:`projectDialog.nav.subagents`},{id:`branch`,icon:o,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:A,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:y,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:E,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:O,labelKey:`projectDialog.nav.terminal`}];function P({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:o}=a(),g=o.find(e=>e.id===i),[_,y]=(0,j.useState)(`general`),S=e=>f(`space-y-5`,_===e?``:`hidden`);return(0,M.jsx)(d,{open:e,onOpenChange:e=>{e||t()},children:(0,M.jsxs)(u,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,M.jsxs)(l,{children:[(0,M.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,M.jsx)(p,{className:`w-4 h-4`}),g?n(`projectDialog.title`,{name:g.name}):n(`page.title`)]}),(0,M.jsx)(s,{children:n(`projectDialog.description`)})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,M.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:N.map(e=>{let t=e.icon;return(0,M.jsxs)(`button`,{type:`button`,onClick:()=>y(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`,_===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,M.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,M.jsxs)(`div`,{className:S(`general`),children:[(0,M.jsx)(b,{}),(0,M.jsx)(x,{})]}),(0,M.jsx)(`div`,{className:S(`agentRuntime`),children:(0,M.jsx)(D,{})}),(0,M.jsx)(`div`,{className:S(`subagents`),children:(0,M.jsx)(m,{})}),(0,M.jsx)(`div`,{className:S(`branch`),children:(0,M.jsx)(T,{})}),(0,M.jsx)(`div`,{className:S(`environment`),children:(0,M.jsx)(w,{})}),(0,M.jsx)(`div`,{className:S(`budget`),children:(0,M.jsx)(C,{})}),(0,M.jsx)(`div`,{className:S(`telemetry`),children:(0,M.jsx)(h,{})}),(0,M.jsx)(`div`,{className:S(`terminal`),children:(0,M.jsx)(v,{mode:`project`})})]})]})]})})}export{P 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-BbYvbtY8.js";import{d as r,f as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as ee,t as o}from"./createLucideIcon-DtODIU64.js";import{a as s,r as te}from"./useDesktop-BjLT0_EE.js";import{H as ne,K as re,n as ie}from"./TicketDetailModalContext-Dkwo2cDs.js";import{C as ae,E as oe,b as se,r as ce,t as le,w as ue}from"./RepositoryDeliveries-B4ybHOyB.js";import{n as de}from"./save-LmPSfsvZ.js";import{t as fe}from"./ban-wqfdzoXt.js";import{n as pe}from"./chevron-up-6EFqEHBj.js";import{n as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./sparkles-CCfUdFGY.js";import{t as me}from"./triangle-alert-Cxpn8bqr.js";import{t as he}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{Tt as ge,Xt as p,xt as m,y as _e}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,f as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as ee,t as o}from"./createLucideIcon-DtODIU64.js";import{a as s,r as te}from"./useDesktop-BjLT0_EE.js";import{H as ne,K as re,n as ie}from"./TicketDetailModalContext-Dkwo2cDs.js";import{C as ae,E as oe,b as se,r as ce,t as le,w as ue}from"./RepositoryDeliveries-B4ybHOyB.js";import{n as de}from"./save-LmPSfsvZ.js";import{t as fe}from"./ban-wqfdzoXt.js";import{n as pe}from"./chevron-up-6EFqEHBj.js";import{n as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./sparkles-CCfUdFGY.js";import{t as me}from"./triangle-alert-Cxpn8bqr.js";import{t as he}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{Tt as ge,Xt as p,xt as m,y as _e}from"./index-Ce4yZtKf.js";var h={name:`circle-dollar-sign`,size:24,node:[[`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.node;var ve=o(h),g={name:`file-diff`,size:24,node:[[`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.node;var _=o(g),v=e(t(),1),y=n();function b(e){return e.split(/\n{2,}/).map(e=>{if(e.includes(`
|
|
2
2
|
`))return e;let t=e.match(/(?:^|\s)(\d{1,2})\.\s+(?=\S)/g);return!t||t.length<3?e:e.replace(/\s+(\d{1,2})\.\s+(?=\S)/g,(e,t,n)=>n===0?e:`\n${t}. `)}).join(`
|
|
3
3
|
|
|
4
4
|
`)}function x({children:e,muted:t=!1,className:n}){let r=(0,v.useMemo)(()=>({a:({href:e,children:t})=>(0,y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-accent-primary underline decoration-accent-primary/40 underline-offset-2 hover:decoration-accent-primary`,children:t}),img:()=>null,code:({className:e,children:t})=>e?(0,y.jsx)(`code`,{className:e,children:t}):(0,y.jsx)(`code`,{className:`rounded-md border border-border/50 bg-background-deep/60 px-1.5 py-px font-mono text-[0.85em] text-accent-info`,children:t})}),[]);return(0,y.jsx)(`div`,{"data-testid":`packet-markdown`,className:he(`prose prose-invert prose-sm max-w-none leading-relaxed`,`prose-p:my-1.5 prose-headings:mt-3 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold`,`prose-strong:text-foreground prose-ul:my-1.5 prose-ol:my-1.5 prose-li:my-0.5 prose-li:marker:text-accent-primary/70`,`prose-pre:my-2 prose-pre:rounded-lg prose-pre:border prose-pre:border-border/50 prose-pre:bg-background-deep/60 prose-pre:text-xs`,`prose-blockquote:border-accent-primary/40 prose-blockquote:text-muted-foreground prose-hr:border-border/50`,t?`text-muted-foreground`:`text-foreground/85`,n),children:(0,y.jsx)(d,{remarkPlugins:[f],skipHtml:!0,components:r,children:b(e)})})}var S=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ye(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return S({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return S({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return S({fineControlOnly:!0});if(n.noChanges)return S({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return S({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return S(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return S({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return S({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return S({fineControlOnly:!0})}function be(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 xe=[`app-verified`,`ai-reported`,`reviewer-score`],Se={"app-verified":m,"ai-reported":u,"reviewer-score":_},Ce={"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 C({item:e}){let{t}=ee(`packet`);return(0,y.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,y.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,y.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 we(e){return e.implementationOutcome===`failed`?`failed`:e.deliveryOutcome===`no_changes`||e.implementationOutcome===`succeeded`&&e.changed===!1?`noChanges`:e.deliveryOutcome===`not_started`?`notStarted`:e.implementationOutcome===`succeeded`?`succeeded`:`unknown`}var w={resolved:`border-accent-success/40 bg-accent-success/10 text-accent-success`,partial:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,blocked:`border-destructive/40 bg-destructive/10 text-destructive`,unreported:`border-border bg-background-deep/50 text-muted-foreground`},Te={succeeded:`border-accent-success/40 bg-accent-success/10 text-accent-success`,noChanges:`border-accent-info/40 bg-accent-info/10 text-accent-info`,failed:`border-destructive/40 bg-destructive/10 text-destructive`,notStarted:`border-border bg-background-deep/50 text-muted-foreground`,unknown:`border-border bg-background-deep/50 text-muted-foreground`};function T({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,v.useState)(n);return(0,y.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,y.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,y.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,y.jsx)(c,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,y.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,y.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function E(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:o}=ee([`packet`,`common`]),c=a(),[u,he]=i(),d=u.get(`repositoryId`),f=(0,v.useRef)(0),p=e.onClose??(()=>c(`/`)),{activeProjectId:m}=te(),h=ce(m),g=n?h.has(n):!1,{act:_,checkout:b}=_e(),{openTicketDetail:S}=ie(),E=JSON.stringify([m,n,d]),D=(0,v.useRef)({key:E,epoch:0});D.current.key!==E&&(D.current={key:E,epoch:D.current.epoch+1});let O=D.current.epoch,k=(0,v.useRef)(!0);(0,v.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,v.useCallback)(()=>k.current&&D.current.key===E&&D.current.epoch===O,[E,O]),[j,M]=(0,v.useState)(null),N=j?.key===E&&j.epoch===O?j:null,P=N?.data??null,F=N?.loading??!0,I=N?.error??null,[L,R]=(0,v.useState)(null),[Ee,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(!1),[De,K]=(0,v.useState)(null),[Oe,q]=(0,v.useState)(!1),J=(0,v.useCallback)(async()=>{if(!n||!m||!A())return;let e=++f.current,t=()=>A()&&f.current===e;M(e=>({key:E,epoch:O,data:e?.key===E&&e.epoch===O?e.data:null,loading:!0,error:null}));try{let e=d?`?repositoryId=${encodeURIComponent(d)}`:``,r=await fetch(`${s()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){M({key:E,epoch:O,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;M({key:E,epoch:O,data:i,loading:!1,error:null})}catch{if(!t())return;M({key:E,epoch:O,data:null,loading:!1,error:`loadFailed`})}},[n,m,d,E,O,A]);(0,v.useEffect)(()=>(J(),z(!1),q(!1),R(null),V(null),K(null),G(!1),U(``),()=>{f.current++}),[J]);let Y=(0,v.useMemo)(()=>ue(P?.snapshot),[P?.snapshot]),X=P?.packet??null,Z=F||L!==null||W||!!Y?.operation,ke=P?.acceptCapability??null,Q=(0,v.useMemo)(()=>{if(!X)return null;let e=oe({decision:X.decision,ticketIds:X.ticketIds,prState:X.prUrl?`pr-created`:`none`,statusCode:X.statusCode,prUrl:X.prUrl,runIds:X.runIds});return ye({decision:X.decision,presentation:e,prUrl:X.prUrl,canCreatePr:ke?.target===`create-pr`})},[X,ke]),$=(0,v.useCallback)(async e=>{if(!X||!Q||Z||!A())return;let t=be(e,Q);if(t){V(null),R(e);try{let e=await(d&&Y?_(Y.railIndex,t,Y.decision,Y.prDeliveryId,d):_(X.railIndex,t,X.decision,X.prDeliveryId));if(!A())return;e.ok?m&&se(m):V(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await J()}finally{A()&&(R(null),z(!1))}}},[_,m,J,X,Q,Y,d,Z,A]),Ae=(0,v.useCallback)(async()=>{if(!(!X||!H.trim()||!m||Z||!A())){K(null),G(!0);try{let t=await fetch(`${s()}/rails/${X.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({loopId:`factory:sdd-quick-openspec`,revisionOfDeliveryId:Y?.prDeliveryId??X.prDeliveryId,revisionNote:H.trim(),...Y?.executionManifest?{repositoryIds:Y.executionManifest.selectedRepositoryIds}:{}})});if(!A())return;if(!t.ok){let e=await t.json().catch(()=>null);if(!A())return;K(e?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}U(``),q(!1);let r=await t.json().catch(()=>null);if(!A())return;r?.prDeliveryId&&r.prDeliveryId!==n?e.onClose?e.onClose():c(`/review/${encodeURIComponent(r.prDeliveryId)}`):await J()}catch{A()&&K(`revisionFailed`)}finally{A()&&G(!1)}}},[m,J,X,H,Y,Z,A,n,e.onClose,c]);if(F&&!X)return(0,y.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,y.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),o(`common:states.loading`)]});if(I||!X||!Q)return(0,y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,y.jsx)(me,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(I===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,y.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:o(`backToBoard`)})]});let je=xe.map(e=>({tier:e,items:X.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Me=X.cost.totalUsd===null?`—`:`${X.cost.estimated?`~`:``}$${X.cost.totalUsd.toFixed(2)}`;return(0,y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,y.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),o(`backToBoard`)]}),Y?.repositoryDeliveries?.length?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[o(`common:repositories.select`),(0,y.jsxs)(`select`,{value:d??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),he(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,y.jsx)(`option`,{value:``,children:o(`common:repositories.all`)}),Y.repositoryDeliveries.map(e=>(0,y.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,y.jsx)(le,{deliveryId:Y.prDeliveryId,repositories:Y.repositoryDeliveries,busy:Z,onAct:async(e,t)=>{if(!(Z||!A())){R(`accept`);try{let n=await _(Y.railIndex,e,Y.decision,Y.prDeliveryId,t);if(!A())return;n.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}},onCheckout:async e=>{if(!(Z||!A())){R(`accept`);try{let t=await b(Y.railIndex,Y.prDeliveryId,e);if(!A())return;t.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}}})]}):null,(0,y.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,y.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:o(X.headlineCode,{count:X.totalCount,succeeded:X.succeededCount,total:X.totalCount,defaultValue:X.headlineCode})}),(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[X.confidence?.overall!==null&&X.confidence?.overall!==void 0?(0,y.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:o(`confidence.tooltip`),children:o(`confidence.pill`,{overall:X.confidence.overall})}):(0,y.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:o(`confidence.unavailable`)}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,y.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),o(`cost.thisBuild`,{amount:Me})]}),X.prUrl?(0,y.jsxs)(`a`,{href:X.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,y.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),o(`openPr`,{number:X.prNumber??``})]}):null]}),Q.fineControlOnly?(0,y.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:o(`fineControlOnly`)}):Q.inFlight?(0,y.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}),o(`stillWorking`)]}):Q.terminal?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:o(`alreadyResolved`)}):(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!Y?.repositoryDeliveries?.length||d)?Ee?(0,y.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,y.jsx)(`p`,{className:`text-xs text-foreground`,children:o(`accept.irreversibleWarning`)}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:Z,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:o(`accept.irreversibleConfirm`)}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:o(`common:actions.cancel`)})]})]}):(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?z(!0):$(`accept`)},disabled:Z,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:[L===`accept`?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),o(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),disabled:Z||W,"aria-expanded":Oe,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,y.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:Z,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:[L===`discard`?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),o(`discard.label`)]}):null]}),g&&Q.verbs.includes(`discard`)?(0,y.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:o(`discard.stackedNote`)}):null,B?(0,y.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:o(`error.${B}`)}):null,Oe?(0,y.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,y.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:o(`requestChanges.prompt`)}),(0,y.jsx)(`textarea`,{id:`packet-revision-note`,value:H,onChange:e=>U(e.target.value),rows:2,placeholder:o(`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,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Ae(),disabled:Z||H.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:[W?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.submit`)]}),(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`requestChanges.hint`)})]}),De?(0,y.jsx)(`p`,{className:`text-xs text-accent-warning`,children:o(`error.${De}`)}):null]}):null]}),X.driftNudges.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,y.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:o(`drift.title`)}),(0,y.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:X.driftNudges.map(e=>(0,y.jsx)(`li`,{children:o(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,y.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:o(`drift.advisory`)})]}):null,X.versions.length>1?(0,y.jsxs)(T,{title:o(`versions.title`,{count:X.versions.length}),badge:(0,y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,y.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:X.versions.map(e=>(0,y.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:o(`versions.label`,{version:e.version})}),e.current?(0,y.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:o(`versions.current`)}):null,(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??o(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:o(`cost.allVersions`,{amount:X.chainCostUsd===null?`—`:`${X.chainCostEstimated?`~`:``}$${X.chainCostUsd.toFixed(2)}`})})]}):null,X.watchOut.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,y.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,y.jsx)(me,{className:`size-4`,"aria-hidden":!0}),o(`watchOut.title`)]}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:X.watchOut.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]}):null,(0,y.jsx)(T,{title:o(`sections.whatYouAsked`),defaultOpen:!0,children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>S(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.problem}):null]},e.ticketId))})}),X.followUp&&(0,y.jsxs)(T,{title:o(`followUp.title`,{count:X.followUp.comments.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`followUp.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-3`,"data-testid":`packet-follow-up`,children:X.followUp.comments.map(e=>{let t=X.followUpReport?.find(t=>t.commentId===e.id)??null,n=t?t.verdict:`unreported`;return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded bg-surface/70 px-1 font-mono text-[10px] text-muted-foreground`,children:e.id}),e.path?(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-info`,children:[e.path,e.line?`:${e.line}`:``]}):null,(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${w[n]}`,"data-testid":`packet-follow-up-verdict`,children:o(`followUp.verdict.${n}`)}),(0,y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[o(`followUp.source.${e.source===`github`?`github`:`pasted`}`),e.author?` · ${e.author}`:``]})]}),(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.body}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`followUp.noReport`)})]},e.id)})}),X.followUp.scope.excludedChanges.length>0&&(0,y.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(`span`,{className:`font-medium`,children:[o(`followUp.excluded`),`:`]}),` `,X.followUp.scope.excludedChanges.join(` · `)]})]}),X.specAddenda&&X.specAddenda.length>0&&(0,y.jsxs)(T,{title:o(`addenda.title`,{count:X.specAddenda.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`addenda.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-2`,"data-testid":`packet-addenda`,children:X.specAddenda.map(e=>{let t=X.specAddendaReport?.find(t=>t.addendumId===e.id)??null,n=t?t.verdict:`unreported`,r=n===`applied`?w.resolved:w[n];return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-primary`,children:[`#`,e.ticketId]}),(0,y.jsx)(`span`,{className:`rounded-full border border-border/50 px-1.5 py-px text-[10px] text-muted-foreground`,children:o(`addenda.kind.${e.kind}`)}),(0,y.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${r}`,"data-testid":`packet-addenda-verdict`,children:o(`addenda.verdict.${n}`)})]}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`addenda.noReport`)})]},e.id)})})]}),(0,y.jsx)(T,{title:o(`sections.whatIDid`),children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,"data-testid":`packet-done-${e.ticketId}`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),e.title?(0,y.jsx)(`span`,{className:`text-foreground/80`,children:e.title}):null,(()=>{let t=we(e);return(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${Te[t]}`,"data-testid":`packet-outcome-pill`,children:o(`outcome.${t}`)})})()]}),e.churn?(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[o(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines}),` · `,e.churn.testFilesTouched.length>0?o(`churn.testFiles`,{count:e.churn.testFilesTouched.length}):o(`churn.noTestFiles`)]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`churn.batchNotSplittable`)}),e.solution?(0,y.jsxs)(`details`,{className:`group mt-2 rounded-md border border-border/50 bg-background-deep/30 px-3 py-2`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-muted-foreground group-open:text-foreground/80`,children:o(`planned.title`)}),(0,y.jsx)(`p`,{className:`mt-1 text-[11px] italic text-muted-foreground/80`,children:o(`planned.caveat`)}),(0,y.jsx)(x,{className:`mt-2`,children:e.solutionOverflow??e.solution})]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`noSolutionRecorded`)})]},e.ticketId))})}),(0,y.jsx)(T,{title:o(`sections.howItWasChecked`),badge:X.evidenceUnavailable?(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:o(`proof.evidenceUnavailable`)}):void 0,children:(0,y.jsx)(`div`,{className:`space-y-4`,children:je.map(({tier:e,items:t})=>{let n=Se[e];return(0,y.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${Ce[e]}`,children:[(0,y.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,y.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),o(`tier.${e}.title`)]}),(0,y.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:o(`tier.${e}.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{E as default};
|
package/client/dist/assets/{TemplatePreviewModal-CTBZUXAN.js → TemplatePreviewModal-V7FpMWuw.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-BbYvbtY8.js";import{n as t}from"./createLucideIcon-DtODIU64.js";import{t as n}from"./download-C9wP_42h.js";import{t as r}from"./git-branch-yf6LE1Bw.js";import{n as i,t as a}from"./square-D0JTbRSR.js";import{a as o,i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./button-4FS1ZDTp.js";import{$t as p,_t as m,rt as h}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-BbYvbtY8.js";import{n as t}from"./createLucideIcon-DtODIU64.js";import{t as n}from"./download-C9wP_42h.js";import{t as r}from"./git-branch-yf6LE1Bw.js";import{n as i,t as a}from"./square-D0JTbRSR.js";import{a as o,i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./button-4FS1ZDTp.js";import{$t as p,_t as m,rt as h}from"./index-Ce4yZtKf.js";var g=e(),_={core:p,start:i,"ai-step":p,shell:m,decider:r,condition:r,end:a};function v(e){if(e.type===`core`){let t=e.data?.params;return t?String(t.text??t.prompt??t.goal??t.expr??t.question??t.message??t.ref??t.body??t.outcome??JSON.stringify(t,null,2)):null}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 y({template:e,onClose:r,onUse:i}){let{t:m}=t(`loops`);return(0,g.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,g.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(l,{children:[(0,g.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,g.jsx)(p,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,g.jsx)(s,{children:e.description})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,g.jsx)(`span`,{title:m(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:m(`gallery.needsSpec`)}):(0,g.jsx)(`span`,{title:m(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:m(`gallery.standalone`)}),e.category&&(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:m(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?m(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):m(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=_[e.type]??a,r=v(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,g.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),m(e.type===`core`?`builder.core.pieces.${e.data?.kind}`:`builder.nodes.${e.type}`)]}),r&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,g.jsxs)(o,{children:[(0,g.jsx)(f,{variant:`ghost`,onClick:r,children:m(`common:actions.cancel`)}),(0,g.jsxs)(f,{onClick:()=>i(e.id),children:[(0,g.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),m(`actions.use`)]})]})]})})})}export{y as n,v as r,_ as t};
|